Re: reading a file

2006-10-20 Thread Anshul Saxena
Hi add this line before your code $/ = "\n"; What this does is breaks your file reading sequence at every new line so that each new line is stored as a separate item in the array you are using. Lemme know if this helps or doesn't. On 10/19/06, Gerald Host <[EMAIL PROTECTED]> wrote: I tried bo

RE: reading a file

2006-10-20 Thread Helliwell, Kim
Another way: foreach $line () { ... } if you don't want to slurp all the lines into an array (to save memory). Kim Helliwell LSI Logic Corporation Work: 408 433 8475 Cell: 408 832 5365 [EMAIL PROTECTED] Please Note: My email address will change to [EMAIL PROTECTED] on Oct 14. The old 'lsil.com

RE: reading a file

2006-10-20 Thread Helliwell, Kim
Try using: my @lines = ; I don't think you need the split, and it's goofing things up. I know the above works, because I use it all the time. Kim Helliwell LSI Logic Corporation Work: 408 433 8475 Cell: 408 832 5365 [EMAIL PROTECTED] Please Note: My email address will change to [EMAIL PROTECTE

Re: reading a file

2006-10-19 Thread xavier mas
A Divendres 20 Octubre 2006 00:34, Gerald Host va escriure: > I'm trying to read a text file line-by-line. > > open IN, shift; > my @lines=split("\n",); > foreach my $line (@lines) { > print OUT "QQQ $line QQQ\n

Re: reading a file

2006-10-19 Thread Jenda Krynicky
From: "Gerald Host" <[EMAIL PROTECTED]> > I'm trying to read a text file line-by-line. > > open IN, shift; > my @lines=split("\n",); Did you ever read the docs??? my @lines=; The <> operator returns the list of lines in the file if called in the

Re: reading a file

2006-10-19 Thread Gerald Host
I tried both, and they typically do work for me, but right now they just aren't... QQQ line1 line2 line3 ... lineX QQQ any ideas? Ryan On 10/19/06, Helliwell, Kim <[EMAIL PROTECTED]> wrote: Another way: foreach $line () { ... } if you don't want to slurp all the lines into an array (to

Re: Reading a file

2003-03-04 Thread John W. Krahn
Nick Drage wrote: > > On Tue, Mar 04, 2003 at 11:24:55AM -, Rob Dixon wrote: > > > > @rgstr=; > > > > This puts the <> operator into list context, so it will read > > all of the file, placing separate records into consecutive > > elements of the array. If this is what you want to do, then > >

Re: Reading a file

2003-03-04 Thread Nick Drage
On Tue, Mar 04, 2003 at 11:24:55AM -, Rob Dixon wrote: > > @rgstr=; > > This puts the <> operator into list context, so it will read > all of the file, placing separate records into consecutive > elements of the array. If this is what you want to do, then > you have finished with the file a

Re: Reading a file

2003-03-04 Thread Rob Dixon
Hi Diego Diego Aguirre wrote: > Hello, > I have just learned opening and reading a file, with > > open (HoyIn,"File.txt"); Filehandles are traditionally all upper case, as: open (HOYIN, "File.txt"); > @rgstr=; This puts the <> operator into list context, so it will read all of the file, p

Re: Reading a file

2003-03-03 Thread John W. Krahn
Diego Aguirre wrote: > > Hello, Hello, > I have just learned opening and reading a file, with > > open (HoyIn,"File.txt"); What would happen if for some reason the file could not be opened? You should ALWAYS verify that the file opened correctly. > @rgstr=; > foreach $linea (@rgstr) > { >

Re: reading a file line by line

2002-03-04 Thread Hernan Freschi
There's a simpler way, if you specify the file from the command line (as in script.pl file) you can do while (<>) { last if /search test/; #do something } in fact, you can make a cat-like script like this: while (<>) { print; } <> is the diamond operator, and it's the filehandle fo

Re: reading a file line by line

2002-02-27 Thread John W. Krahn
Jon Serra wrote: > > Greetings, I am trying to read a text file into a scalar variable line by line > until EOF or a search test if fullfilled. I have been reading files in like > this: > > chomp (@line = `cat filename`); > > I do not want to do this beacuse my file is quite large, and there

RE: reading a file line by line

2002-02-27 Thread Lyon, Justin
Here's something simple: open(FILE, "/export/home/me/filename"); while ($line = ) { # whatever } FILE is a filehandle, and by defualt it will give you back a line at a time. You can also put the whole thing into an array by doing this: @file = ; At least, I think that's it. Somebody corre

Re: reading a file line by line

2002-02-27 Thread Brett W. McCoy
On Wed, 27 Feb 2002, Jon Serra wrote: > Greetings, I am trying to read a text file into a scalar variable line by line > until EOF or a search test if fullfilled. I have been reading files in like > this: > > chomp (@line = `cat filename`); > > I do not want to do this beacuse my file is quite

Re: Reading A File From A Remote Host Using Sockets.

2001-08-29 Thread Brett W. McCoy
On Wed, 29 Aug 2001, Ken Hammer wrote: > I'm attempting to write a perl script, that will > read a file from a remote host. It must be done > through SSL. I was looking into the possibility > of using sockets (IO::Socket::INET), or some > such animal to accomplish this task. > First, is it poss