That should work. The big problem with it is you are creating an array which
contains the contents of the whole file. Then using only the first element
of that array and ignoring the rest. Depending on the size of your file you
could be wasting huge chunks of memory.

-----Original Message-----
From: Yacketta, Ronald [mailto:[EMAIL PROTECTED]]
Sent: 08 January 2002 16:06
To: [EMAIL PROTECTED]; Yacketta, Ronald
Cc: Beginners (E-mail)
Subject: RE: pull line #1 from a file


so so close...
I had this


OPEN(FILE, "< $g_all_sleepy);
@lines = <FILE>;
CLOSE(FILE);
$lines[0]; # think this is right, its an array.. all arrays start at 0 not
1.. unless
                # perl is funky and dont ;)


> -----Original Message-----
> From: Casey West [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 08, 2002 10:56
> To: Yacketta, Ronald
> Cc: Beginners (E-mail)
> Subject: Re: pull line #1 from a file
> 
> 
> On Tue, Jan 08, 2002 at 10:50:51AM -0500, Yacketta, Ronald wrote:
> :
> :Folks,
> :
> :need some minor help here.. been looking in the Cookbook for 
> an example
> :to pull the first line from a file..
> 
>   open FILE, "filename" or die $!;
>   my $line = <FILE>;
>   close FILE;
> 
> Remember, <FILEHANDLE> is something you can iterate over.  In scalar
> context it returns just one line (for all intents and purposes) at a
> time.
> 
>   Casey West
> 
> -- 
> Usenet is like Tetris for people who still remember how to read. 
>   -- Button from the Computer Museum, Boston, MA
> 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


--------------------------Confidentiality--------------------------.
This E-mail is confidential.  It should not be read, copied, disclosed or
used by any person other than the intended recipient.  Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful.  If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to