On May 29, George Balogi said:
>#!D:perl/bin/ -w
>cut -f3,5 -d"|" try
You appear to be writing shell code in Perl. Perl is not shell, and
vice-versa. Furthermore, cut isn't implemented in DOS (to my knowledge).
You need to basically write this as Perl code. Here are some helpful
hints:
* cut is begging to be a split()
* -f3,5 is a list slice (it's (2,4) in Perl, since lists start at 0)
* the -d"|" is setting the delimiter for cut, so that'll be for split()
* you'll want to join those fields with a | again
Here's a "word-for-word" translation:
#!/usr/bin/perl -w
@ARGV = "try";
while (<>) {
chomp;
my @fields = split /\|/;
my $output = join '|', @fields[2,4];
print "$output\n";
}
That can be written as a one-liner, using several command-line switches:
perl -F"\|" -lane 'print join "|", @F[2,4]' try
Actually, on DOS, that'll have to be:
perl -F"\|" -lane "print join '|', @F[2,4]" try
For more information, please read a Perl tutorial (start at
http://www.perl.com/) and the following docs:
perldoc perlfunc (for functions)
perldoc -f split (for split())
perldoc perlrun (for -a, -e, -F, -l, -n, and more)
perldoc perlvar (for @F)
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
Are you a Monk? http://www.perlmonks.com/ http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc. http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter. Brother #734
** I need a publisher for my book "Learning Perl's Regular Expressions" **