|
Posted by Tad J McClellan on March 18, 2008, 9:45 pm
Please log in for more thread options
> my $key_file="~/.ssh/authorized_keys"; #path the the authorized-keys file
tilde means "home directory" when programming in the shell.
tilde means "tilde character" in a Perl string...
> open(INFO, $file); #opens file systemstats
You should always, yes *always*, check the return value from open():
open(INFO, $file) or die "could not open '$file' $!";
> @lines = <INFO>; #assigns lines to array
> foreach $line (@lines){ #go through each line in file
No point in reading the whole thing into memory if you are only
going to process one line at a time anyway.
while ( my $line = <INFO> ) {
> $num++;
Now you can use the $. variable instead of maintaining the count yourself too.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher0cmdat/"
|