$ cat filter.pl
#!/usr/bin/perl
use strict;
use warnings;
open (F, "<create2.txt" ) || die "unable to open file: $!";
while ( my $file=<F> ) {
chomp($file);
open (FF, "<$file" ) || die "unable to open file: $!";
while ( my $line=<FF> ) {
last if $. == 2;
my @fields=split('\|',$line);
print "$fields[0]\n";
}
close FF;
}
close F;
$
$
$
$
$ ./filter.pl
inb-1
abv-1
nhg-1
$
Bareword found where operator expected at filter.pl line 1, near "$ cat filter"
(Missing operator before filter?)
syntax error at filter.pl line 1, near "$ cat filter"
"use" not allowed in expression at filter.pl line 4, at end of line
BEGIN not safe after errors--compilation aborted at filter.pl line 5.
$ cat filter.pl
#!/usr/bin/perl
use strict;
use warnings;
open (F, "<create2.txt" ) || die "unable to open file: $!";
while ( my $file=<F> ) {
chomp($file);
open (FF, "<$file" ) || die "unable to open file: $!";
while ( my $line=<FF> ) {
last if $. == 2;
my @fields=split('\|',$line);
print "$fields[0]\n";
}
close FF;
}
close F;
$
$
$
$
$ ./filter.pl
inb-1
abv-1
nhg-1
If filter.pl is your script name, then it should contain this:
#!/usr/bin/perl
use strict;
use warnings;
open (F, "<create2.txt" ) || die "unable to open file: $!";
while ( my $file=<F> ) {
chomp($file);
open (FF, "<$file" ) || die "unable to open file: $!";
while ( my $line=<FF> ) {
last if $. == 2;
my @fields=split('\|',$line);
print "$fields[0]\n";
}
close FF;
}
close F;
Also, if your perl path is differ from "/usr/bin/perl" replace it.