#open and read
open(FILE, "<$filename");
@alllinesinthefile = <>;
close(FILE);
#open and write. Append uses >>
open(FILE, ">$filename");
print FILE @alllinesinthefile;
close(FILE);
#looping
foreach $line ( @alllinesinthefile ) {
#Do whatever you want
# Go away and study regular expressions
# e.g. $line =~ s/ABC/DEF/g; #substitutes ABC with DEF
}
On Wed, 2 May 2001 12:27:10 +0100, [EMAIL PROTECTED]
(N6tadam) wrote:
>Dear All,
>
>I wonder if someone could help me. I have been programming in bash for years
>now, but I have decided that I would like to use perl.
>
>My question is: "how do I tell perl to open a file for reading, do various
>commands, and then output those changes to a new file"???
>
>Thanks in Anticipation,
>Regards,
>
>Thomas Adam
>
>
>Please note that the content of this message is confidential between the original
>sender and the intended recipient(s) of the message. If you are not an intended
>recipient and/or have received this message in error, kindly disregard the content of
>the message and return it to the original sender.
>
>If you have any complaints about this message please reply to:
> [EMAIL PROTECTED]
>
>The Purbeck School E-Mail server running:
> users.purbeck.dorset.sch.uk
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]