Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^2: How do I combine SPLIT with trimming white space

by codeacrobat (Chaplain)
on Aug 11, 2009 at 20:36 UTC ( [id://787760]=note: print w/replies, xml ) Need Help??


in reply to Re: How do I combine SPLIT with trimming white space
in thread How do I combine SPLIT with trimming white space

Hi, If you want to chain multiple s/// statements, then you can use a comma and get rid of the ugly do and the curlys.
foreach my $entry ( split( /;/, $file_data ) ) { s/^\s+//, s/\s+$// for $entry; push @email_list, $entry; } print join( "\n", sort(@email_list)), "\n";
If you are a Perl::Critic follower then you are not allowed to use the for statement modifier Perl::Critic::Policy::ControlStructures::ProhibitPostfixControls. However consider this using List::MoreUtils apply function.
use List::MoreUtils qw(apply); foreach my $entry ( split( /;/, $file_data ) ) { push @email_list, apply { s/^\s+//; s/\s+$// } $entry; } print join( "\n", sort(@email_list)), "\n";

print+qq(\L@{[ref\&@]}@{['@'x7^'!#2/"!4']});

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (5)
As of 2024-04-24 19:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found