Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Removing empty string elements from an Array

by broquaint (Abbot)
on Nov 13, 2001 at 15:32 UTC ( [id://125028]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my @arr1 = ("foo", "", "bar", "", "baz");
    my @arr2 = grep $_, @arr1;
    ...
        $" = ', ';
        print "@arr1\n@arr2\n";
    }
    
  2. or download this
    my @arr1 = ("foo", "", "bar", "", "baz");
    my @arr2;
    foreach (@arr1) {
        push @arr2, $_ if $_ ne '';
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (4)
As of 2024-04-25 09:17 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found