Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Adding element to Array?

by NetWallah (Canon)
on Oct 13, 2009 at 05:30 UTC ( #800848=note: print w/replies, xml ) Need Help??


in reply to Adding element to Array?

chomp is your friend.

If the $list is EMPTY, it will only contain a linefeed character(linux), which will be removed by chomp, so the following code should work:

chomp $list; push @array,$list if length($list) > 0;
More experienced programmers would probably use a regular expression, looking for a "word" character before collecting it.

     Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://800848]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2023-12-04 12:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What's your preferred 'use VERSION' for new CPAN modules in 2023?











    Results (25 votes). Check out past polls.

    Notices?