Beefy Boxes and Bandwidth Generously Provided by pair Networks kudra
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

(ichi) re x 2: Simple file to array

by ichimunki (Priest)
on Jul 08, 2002 at 15:32 UTC ( [id://180287]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Simple file to array
in thread Simple file to array

Sure, this could use some explaining. But not too much. :)

When using a filehandle in list context (such as assigning it to an array), each line is treated as a list element and assigned to the array just like if you were doing my @email_addys = ('x@y.com', 'foo@bar.org', ... ).

One of the problems here is that this doesn't strip the linefeed character from the end of each line, so that what we end up with is an array like ("x@y.com\n", "foo@bar.org\n") when reading this from a file. We probably want to clean up the array, which we can do quickly with for( @email_addys ){ chomp }; at some point after the assignment.

Replies are listed 'Best First'.
Re: (ichi) re x 2: Simple file to array
by fruiture (Curate) on Jul 08, 2002 at 15:42 UTC
    We probably want to clean up the array, which we can do quickly with for( @email_addys ){ chomp }; at some point after the assignment.

    `perldoc -f chomp` tells us an easier way: chomp @email_addys.

      Yes, that is much nicer, isn't it? :)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://180287]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.