in reply to Re^2: system command
in thread system command
But actually I want to find the total number of lines without opening the file
Impossible. Actually, using system or backticks, you are creating a new process and opening more files than you would just using Perl.
Update: But if you insist on forking, how about
sub line_count { my ($fname) = @_; open(my $pipe, '-|', 'cat', $fname) or die("Unable to launch cat: $!\n"); 1 while <$pipe>; return $.; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: system command
by megaurav2002 (Monk) on Oct 31, 2007 at 03:19 UTC | |
by ikegami (Patriarch) on Oct 31, 2007 at 03:21 UTC | |
by NetWallah (Canon) on Oct 31, 2007 at 03:39 UTC | |
by Gangabass (Vicar) on Oct 31, 2007 at 03:49 UTC | |
by Fletch (Bishop) on Oct 31, 2007 at 13:36 UTC |