baxy77bax has asked for the wisdom of the Perl Monks concerning the following question:
well this maybe redundant but i'm curious. is there a way to do this from a command line:
so what i'm aiming for is the result of this :open (IN, "<", $ARGV[0]); my $i =0; while (<IN>){$i++} print $i;
but without open(IN,"<", $ARGV[0]); and while. i would like just to say what want and that iteration is assumed so :perl -e 'open(IN,"<", $ARGV[0]);$i=0;while(<IN>){$i++};print $i' in.fi +le
so the question is how to preserve the $i inperl -ne '$i++; print $i' in.file
and print it when iterator reaches the end of the fileperl -ne '$i++; print $i' in.file
something like in awk but in all mighty Perl way !!!!
thnx
baxy
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: one liner - open file and read
by Corion (Patriarch) on Oct 07, 2010 at 17:28 UTC | |
|
Re: one liner - open file and read
by jwkrahn (Abbot) on Oct 07, 2010 at 17:55 UTC | |
by NetWallah (Canon) on Oct 07, 2010 at 18:07 UTC | |
by FunkyMonk (Bishop) on Oct 07, 2010 at 18:23 UTC | |
by NetWallah (Canon) on Oct 07, 2010 at 19:35 UTC | |
by eyepopslikeamosquito (Archbishop) on Oct 07, 2010 at 20:09 UTC | |
|
Re: one liner - open file and read
by JavaFan (Canon) on Oct 07, 2010 at 18:24 UTC | |
by TomDLux (Vicar) on Oct 07, 2010 at 20:26 UTC | |
by JavaFan (Canon) on Oct 07, 2010 at 20:52 UTC | |
by ChuckularOne (Prior) on Oct 27, 2010 at 17:57 UTC |