chrism01 has asked for the wisdom of the Perl Monks concerning the following question:
Given the following code:
and file is:#!perl -w use strict; my ( $var1, $var2, @t_arr ); open(SL,"<s.log"); @t_arr=<SL>; close(SL); chomp(@t_arr); $t_arr[0] =~ s/\s+$//; # trailing whitespace ($var1, $var2) = split( /\s*=\s*/, $t_arr[0], 2); if( !defined($var2) ) { print "undefined\n"; } else { print "$var1 X${var2}X\n"; } exit;
Cheers
Chris
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: undef vs empty string '' from split
by ikegami (Patriarch) on Jun 20, 2007 at 23:44 UTC | |
by chrism01 (Friar) on Jun 21, 2007 at 01:15 UTC | |
|
Re: undef vs empty string '' from split
by Joost (Canon) on Jun 20, 2007 at 23:57 UTC | |
by chrism01 (Friar) on Jun 21, 2007 at 01:18 UTC | |
by Joost (Canon) on Jun 21, 2007 at 01:39 UTC | |
by Sidhekin (Priest) on Jun 21, 2007 at 05:32 UTC | |
|
Re: undef vs empty string '' from split
by GrandFather (Saint) on Jun 21, 2007 at 00:08 UTC | |
by chrism01 (Friar) on Jun 21, 2007 at 01:23 UTC |