Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
use warnings; use strict; use Data::Dumper; my $file = '1|0||34|0|123'; print "file is $file\n"; my @m_file = map { ($_) ? $_ : 'default' } (split /\|/,$file); # try +w/ defined($_) as well print Dumper(@m_file);
Output I want 1 0 default 34 0 123
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: confused w/ map and trueness
by planetscape (Chancellor) on Jun 16, 2010 at 17:39 UTC | |
|
Re: confused w/ map and trueness
by SuicideJunkie (Vicar) on Jun 16, 2010 at 16:23 UTC | |
|
Re: confused w/ map and trueness
by almut (Canon) on Jun 16, 2010 at 16:23 UTC | |
|
Re: confused w/ map and trueness
by Anonymous Monk on Jun 16, 2010 at 16:29 UTC | |
|
Re: confused w/ map and trueness
by mikeraz (Friar) on Jun 16, 2010 at 16:53 UTC |