[QUOTE=gooop]I am new to perl. I am having trouble with this code line I wrote. On thef fourth line I keep getting this message when I go to run this. . Please any advice would help.I am using TextPad, and window xp pro os.This program is suppose to make a modified copy of a text file. In the copy ,every string Fred should be replaced with Larry. I want to have the input filename at the command line. But everytime I go to run this I get the error message below on the 4th line of my code. What is wrong with Usage , am I missing a syntax or something.
Usage:C:\Perl\c h1\ filename at C:\Perl\ch1\ line 4, <> line 1.
Press any key to continue . . .
[#!usr/bin/perl -p
my $in = $ARGV[0];
unless (defined $in) {
die "Usage: $0 filename";
}
print "File: $in\n";
my $out = $in;
$out =~ s/(\.\w+)?$/.out/;
unless (open IN, "<$in") {
die "Can't open '$in': $!";
}
unless (open OUT, ">$out") {
die "Can't write '$out': $!";
}
while (<IN>) {
s/Fred/Larry/gi;
print OUT $_;
}]
Usage:C:\Perl\c h1\ filename at C:\Perl\ch1\ line 4, <> line 1.
Press any key to continue . . .
[#!usr/bin/perl -p
my $in = $ARGV[0];
unless (defined $in) {
die "Usage: $0 filename";
}
print "File: $in\n";
my $out = $in;
$out =~ s/(\.\w+)?$/.out/;
unless (open IN, "<$in") {
die "Can't open '$in': $!";
}
unless (open OUT, ">$out") {
die "Can't write '$out': $!";
}
while (<IN>) {
s/Fred/Larry/gi;
print OUT $_;
}]
Comment