[32669] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 3945 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri May 10 09:09:25 2013

Date: Fri, 10 May 2013 06:09:05 -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           Fri, 10 May 2013     Volume: 11 Number: 3945

Today's topics:
        A song with Perl accompaniment <news@lawshouse.org>
    Re: oh perlbal you!!! you got what i need....but you do <visphatesjava@gmail.com>
    Re: Turning lines of a file into array? <tuxedo@mailinator.com>
    Re: Turning lines of a file into array? <mvdwege@mail.com>
    Re: Turning lines of a file into array? <jurgenex@hotmail.com>
    Re: Why do Perl programmers make more money than Python <visphatesjava@gmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Thu, 09 May 2013 19:33:44 +0100
From: Henry Law <news@lawshouse.org>
Subject: A song with Perl accompaniment
Message-Id: <2Iydnd2qVOuUcRbMnZ2dnUVZ8r2dnZ2d@giganews.com>

Phwatttt?   I don't know what to make of this, but I thought it needed 
raising here.

    http://computerengineer.co.il

-- 

Henry Law            Manchester, England


------------------------------

Date: Wed, 8 May 2013 13:00:33 -0700 (PDT)
From: johannes falcone <visphatesjava@gmail.com>
Subject: Re: oh perlbal you!!! you got what i need....but you dotn work with 5 16
Message-Id: <6745defb-e7c3-416f-a82d-c81b4dbb95c3@googlegroups.com>

On Monday, May 6, 2013 11:57:50 PM UTC-7, Peter Makholm wrote:
> johannes falcone <visphatesjava@gmail.com> writes:
> 
> 
> 
> > perlbal does not install when I use 5.16.3 perl and cpanm
> 
> 
> 
> 'Does not install' is a pretty vague probelm description. If you expect
> 
> some useful respons you would probably need to describe the problem a
> 
> bit more. For example by quoting the failing tests.
> 
> 
> 
> Looking at http://www.cpantesters.org/distro/P/Perlbal.html#Perlbal-1.80
> 
> it doesn't seem to be in a fully working state, but the actual failures
> 
> differs quite a bit and none of them seems to be obvious based on my
> 
> generic knowledge of perl.
> 
> 
> 
> //Makholm

installed under perl 5.10 fine
switched to 5.16.3 using perlbrew
did coanm Perlbal said already isntalled
yay
started up and real c00l
go perlbal!!
really slick webserver in perl!!
config is dream compared to apache


------------------------------

Date: Thu, 9 May 2013 09:02:28 +0200
From: Tuxedo <tuxedo@mailinator.com>
Subject: Re: Turning lines of a file into array?
Message-Id: <kmfhm4$l6$1@news.albasani.net>

Ben Morrow wrote:

> 
> Quoth Rainer Weikusat <rweikusat@mssgmbh.com>:
> > Tuxedo <tuxedo@mailinator.com> writes:
> > > 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,
> > 
> > -----------------
> > my ($fh, @data);
> > 
> > open($fh, '<', '/tmp/data') // die($!);
> > @data = map { chomp; "string $_"; } <$fh>;
> 
> I find rather interesting the number of different ways people have
> interpreted 'plus a fixed URL string before' :). Thinking about it I
> suspect this is the interpretation the OP wanted, though I would have
> guessed 'unshift' (or rather, my @ary = $url, <$FH>)...
> 
> Just goes to show, it pays to be as clear as possible when asking for
> help.
> 
> Of course, given 'just output of 'ls'', it's possible that what the OP
> is actually looking for is list-context readdir, but without more
> information it's impossible to tell.
> 
> Ben
> 

Many thanks for all the replies in showing the numerous ways of doing more 
or less the same thing. In the end I just used somothing as follows, as 
taken from one of the replies:

system "ls *.JPG > list.txt"; # from remote

open (my $fh, "<", "list.txt") or die "can't open file: $!";
my @lines = <$fh>;

my $array_entry;

system "wget --delete-after --secure-protocol=auto --http-user=*** 
--http-password=*** \"http://***/img.php?f=$array_entry&x=200\""; 

}

Tuxedo


------------------------------

Date: Thu, 09 May 2013 12:17:02 +0200
From: Mart van de Wege <mvdwege@mail.com>
Subject: Re: Turning lines of a file into array?
Message-Id: <86obckmp9d.fsf@gaheris.avalon.lan>

Tuxedo <tuxedo@mailinator.com> writes:

> Many thanks for all the replies in showing the numerous ways of doing more 
> or less the same thing. In the end I just used somothing as follows, as 
> taken from one of the replies:
>
> system "ls *.JPG > list.txt"; # from remote
>
> open (my $fh, "<", "list.txt") or die "can't open file: $!";
> my @lines = <$fh>;
>
> my $array_entry;
>
> system "wget --delete-after --secure-protocol=auto --http-user=*** 
> --http-password=*** \"http://***/img.php?f=$array_entry&x=200\""; 
>
> }
>
I think some code disappeared there. I assume you are iterating over the
array?

Your code then should look something like: 

for my $array_entry (@lines) {
    system etc...
}

That, however, makes reading the file redundant, as there is an idiom
for that:

while (my $array_entry = <$fh>) {
      system etc...
}

This is standard idiom to read a file line-by-line, the <$fh> line input
operator in scalar context will read the next line until EOF, when it
will return false and terminate the while loop.

But if you're going this route, you don't have to first redirect to a
file. Your code above assumes you're running the script in the directory
the files are in, so instead of using system to use ls to create a file
with all *.JPG files and then iterating over every line in the file, you
can use the glob operator instead (which, confusingly, looks like the
line-input operator):

my @jpgs = <*.JPG>

for my $array_entry (@jpgs) {
    system etc...
}

And even more perly would be to replace the system call with some code
using LWP::UserAgent or WWW::Mechanize.

Mart

-- 
"We will need a longer wall when the revolution comes."
    --- AJS, quoting an uncertain source.


------------------------------

Date: Thu, 09 May 2013 03:28:17 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Turning lines of a file into array?
Message-Id: <3gumo8t1jqk3nih57f895hh5eqsmvq6p16@4ax.com>

Tuxedo <tuxedo@mailinator.com> wrote:
>system "ls *.JPG > list.txt"; # from remote

No need to shell out an external process, please see
	perldoc -f readdir

jue


------------------------------

Date: Wed, 8 May 2013 13:05:31 -0700 (PDT)
From: johannes falcone <visphatesjava@gmail.com>
Subject: Re: Why do Perl programmers make more money than Python programmers
Message-Id: <14745bb1-6da7-4548-9a1f-03ce21a0330a@googlegroups.com>

On Monday, May 6, 2013 5:05:40 PM UTC-7, Ben Morrow wrote:
> Quoth johannes falcone <visphatesjava@gmail.com>:
> 
> > 
> 
> > so few business do well in england due to crushing taxes and VAT
> 
> > 
> 
> > sad 
> 
> > 
> 
> > I couldnt live there
> 
> 
> 
> Thank God for small mercies...
> 
> 
> 
> Ben

yeah kick ass tall ahndsome capitalists would take all your women since you so boring

you have to back up arrogance, usa can, uk cant

make some good products at low prices and get back to me

at least you could be a good commy, and mass produce metal houses or something cool with the government greed


------------------------------

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 3945
***************************************


home help back first fref pref prev next nref lref last post