Connecting Tech Pros Worldwide Help | Site Map

Need help with perl and programing !!!!1

Newbie
 
Join Date: Nov 2006
Posts: 6
#1: Nov 28 '06
[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\ch1\ 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 $_;
}]
miller's Avatar
Moderator
 
Join Date: Oct 2006
Location: San Francisco, CA
Posts: 830
#2: Nov 28 '06

re: Need help with perl and programing !!!!1


gooop.

Being completely ignorant is not going to encourage us to help you.
Adding bangs to your subject is not going to encourage us to help you.
Resposting your question in a new thread is not going to encourage us to help you.

GunnerH has already tried to show you an example of how to write a script and run the example. Did you actually try this? You have not acknowledged his efforts in any way.

I will not be providing you any help in this new thread. Ask your questions in your old one, or go figure out your problem on your own.
Reply