FW: [RFC] Text::Echelon v0.01

Wilson, Andrew (Belfast) Andrew.Wilson at trw.com
Mon Dec 17 10:07:01 CST 2001



> -----Original Message-----
> From: Wilson, Andrew (Belfast) 
> Sent: 17 December 2001 16:00
> To: 'scott at kungfuftr.com'
> Subject: RE: [RFC] Text::Echelon v0.01
> 
> 
> Hi Scott
> 
> > -----Original Message-----
> > From: Scott McWhirter [mailto:sleepy_uk at hotmail.com]
> > Sent: 17 December 2001 15:19
> > 
> > >@wordlist = <DATA>;
> > my @wordlist = map { chomp; } <DATA>;
> > unless you're gaining <DATA> from somewhere other than a file.
> 
> Definitely not.
> 
> The map returns a list of the result of evaluating the block.  What
> is the return value of chomp?
> 
> Let me give you a hint you will end up either with an empty list or
> with a list of ("\n", "\n") for how ever many of the elements had an
> EOL.
> 
> What you really want is
> 
> my @wordlist = <DATA>;
> chomp @wordlist;
> 
> You could make your version work by doing 
> 
> my @wordlist = map { chomp; $_ } <DATA>;
> 
> But that's pish.  Perl has a built in function for doing it.  
> You should always
> use the built ins.  Lots of very clever people have written 
> teh functions in c
> to make sure they're efficient.
> 
> cheers
> 
> Andrew
> 



More information about the Belfast-pm mailing list