[EMAIL PROTECTED] wrote:
On Jun 28, 12:00 pm, [EMAIL PROTECTED] (Ved) wrote:
Now I have to print a single line at say line number 20 in each of 150
number of kat.s file.
Hey, another chance to show off my favorite Perl module, IO::All.
Situation is bit complex (atleast for a beginer like me).
Actually it is so simple (with IO::All) that you're gonna think I'm
pulling your leg...
#!/usr/bin/perl
use strict;
use warnings;
use IO::All;
my $dir = '/tmp/clpm'; #root directory of data
my $line = 19; #print line 20 (first line is line zero)
my $file = 'kat.s'; #match this filename
map {print "@$_[$line]\n"}
io($dir)->filter(sub{$_->filename eq $file})->all_files(0);
Instead of using map in a void context:
print "@$_[$line]\n" for
io($dir)->filter(sub{$_->filename eq $file})->all_files(0);
Or just call print once with a large list:
print map "@$_[$line]\n",
io($dir)->filter(sub{$_->filename eq $file})->all_files(0);
John
--
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order. -- Larry Wall
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/