[32663] in Perl-Users-Digest
Perl-Users Digest, Issue: 3939 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat May 4 03:09:26 2013
Date: Sat, 4 May 2013 00:09:08 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 4 May 2013 Volume: 11 Number: 3939
Today's topics:
Turning lines of a file into array? <tuxedo@mailinator.com>
Re: Turning lines of a file into array? <derykus@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 4 May 2013 06:58:37 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Turning lines of a file into array?
Message-Id: <km24hu$e66$1@news.albasani.net>
Sorry for the basic question but how can I best turn each line of a file
into an array?
I have a list filenames (just output of 'ls') in a separate text file, each
on a new line:
DSC07557.JPG
DSC07532.JPG
DSC07563.JPG
etc.
The resulting perl array needed is the above plus a fixed URL string
before, in order to fetch all in a later procedure, such as wget or
likewise.
Thanks for any tips.
Tuxedo
------------------------------
Date: Fri, 03 May 2013 23:42:43 -0700
From: Charles DeRykus <derykus@gmail.com>
Subject: Re: Turning lines of a file into array?
Message-Id: <km2ale$lvq$1@speranza.aioe.org>
On 5/3/2013 9:58 PM, Tuxedo wrote:
> I have a list filenames (just output of 'ls') in a separate text file, each
> on a new line:
> DSC07557.JPG
> DSC07532.JPG
> DSC07563.JPG
> etc.
>
> The resulting perl array needed is the above plus a fixed URL string
> before, in order to fetch all in a later procedure, such as wget or
> likewise.
For a Unix-y quick way:
my @array = qx{cat /path/to/myfile};
die "error: .... : $?" if $?;
unshift @array, "some fixed string...";
see: perlfaq -q "line in a file" or modules Tie::File or File::Slurp for
other ways.
--
Charles DeRykus
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 3939
***************************************