LS,
I should have this under 'paste' by now, seeing this apparently needs repeating every
so often.
DO NOT READ ENTIRE FILES INTO ARRAYS UNLESS THERE IS NO OTHER OPTION.
are you realising you are slurping an entire file into memory? ever tried that with an
apache log file?
In this case, slur
Go buy Randal Schwartz's excellent book : Learning Perl (The llama book).
It is the best learning text I've ever used.
Regards,
Jim
-Original Message-
From: Walnut [mailto:[EMAIL PROTECTED]]
Sent: Friday, August 17, 2001 11:09 AM
To: [EMAIL PROTECTED]
Subject: Re: I am a real b
#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 expr
Casey West wrote ..
>On Wed, May 02, 2001 at 11:44:20PM -0700, David Monarres wrote:
>: I am alos fairly new with perl and completely new with perl one
>: liners. I see how you can use regex's on the cmd line to edit a file
>: (sort of sed ish). I tried this
>:
>: $ perl -pe 's/hello/reverse($1)
On Wed, May 02, 2001 at 11:44:20PM -0700, David Monarres wrote:
: I am alos fairly new with perl and completely new with perl one liners. I
: see how you can use regex's on the cmd line to edit a file (sort of sed
: ish). I tried this
:
: $ perl -pe 's/hello/reverse($1)/' -i test
:
: all it prin
David Monarres writes ..
>I am alos fairly new with perl and completely new with perl one liners.
>I see how you can use regex's on the cmd line to edit a file (sort of
>sed ish). I tried this
>
>$ perl -pe 's/hello/reverse($1)/' -i test
>
>all it print's is reverse. I was wondering if you knew
I am alos fairly new with perl and completely new with perl one liners. I
see how you can use regex's on the cmd line to edit a file (sort of sed
ish). I tried this
$ perl -pe 's/hello/reverse($1)/' -i test
all it print's is reverse. I was wondering if you knew of a way to read in
a word and rev
> "how do I tell perl to open a file for reading, do various
> commands, and then output those changes to a new file"???
Perl has some great one-liner shortcuts for writing filters.
First, -e lets you put perl on the command line:
perl -e ' print "foo\n" '
Prints
foo
Second, -p conve
> beginner ... recommended books other than the camel ...
Apparently, the original Camel had two chapters that
beginners would love -- "Common Tasks in Perl" and
"Real Perl Programs".
Later Camels removed this sort of material.
The essence of this material, greatly expanded and
wonderfully edit
: I am also a beginner and wondering if there are any other recommended
: books other than the camel book from O'Reilly. I have been asked to
: display information from the Oracle Database on the web using Perl and
: CGI. So far, I mostly know how to check for patterns. Gulp!!
O'Reilly has al
are lots I left out.
Hell, just perldoc perl for a list!
> Thanks for any input.
>
> Olivier
>
> >-Original Message-
> >From:Paul [SMTP:[EMAIL PROTECTED]]
> >Sent:Wednesday, May 02, 2001 2:05 PM
> >To: n6tadam; [EMAIL PROTECTE
ROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2001 8:04 PM
Subject: RE: I am a real begginer to perl..
> I am also a beginner and wondering if there are any other recommended
> books other than the camel book from O'Reilly. I have been asked to
> display infor
input.
Olivier
>-Original Message-
>From: Paul [SMTP:[EMAIL PROTECTED]]
>Sent: Wednesday, May 02, 2001 2:05 PM
>To:n6tadam; [EMAIL PROTECTED]
>Subject: Re: I am a real begginer to perl..
>
>
>--- n6tadam <[EMAIL PROTECTED]> wrote:
>> Dear A
--- n6tadam <[EMAIL PROTECTED]> 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 outp
Read the documentation in IO::Handle and FileHandle
- Original Message -
From: n6tadam <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, May 02, 2001 1:27 PM
Subject: I am a real begginer to perl..
> Dear All,
>
> I wonder if someone could help me. I have been programming
#open file for reading
open (READ, "file2.txt");
# you'll then have to loop through
# the READ file with a foreach loop
# or a while loop to perform
# "various commands"
while () {
#perform command
# Then write to the file
print WRITE "$value\n";
}
close(READ);
close(WRITE);
Greg
16 matches
Mail list logo