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
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
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
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
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
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
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
> >
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
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
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)
> {
>
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
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
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
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
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
15 matches
Mail list logo