iakobski has asked for the wisdom of the Perl Monks concerning the following question:
now this goes on in the same vein for a while, with a whole heap of variable interpolation and $str is in fact a messy looking array dereference.my $str = "a load of constant stuff..."; $str .= "optional bit in the middle " if $option; $str .= "loads more stuff";
In the process of making this more readable, I have written
I don't like the look of that 'undef' in the middle of there, but if I change the bit in parentheses for ( "optional bit in the middle" if $option ) I get a syntax error.my $str = "a load of constant stuff..."; . ($option ? "optional bit in the middle " : undef); . "loads more stuff";
What idiom is there to make this clearer and more readable?
-- iakobski
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: string manipulation question
by how do i know if the string is regular expression (Initiate) on May 18, 2001 at 17:13 UTC | |
|
Re: string manipulation question
by dempa (Friar) on May 18, 2001 at 17:22 UTC | |
by davorg (Chancellor) on May 18, 2001 at 17:36 UTC | |
by Anonymous Monk on May 18, 2001 at 19:06 UTC | |
by Anonymous Monk on May 18, 2001 at 19:10 UTC | |
by dempa (Friar) on May 19, 2001 at 01:36 UTC | |
|
Re: string manipulation question
by grinder (Bishop) on May 18, 2001 at 18:09 UTC | |
by Anonymous Monk on May 18, 2001 at 18:58 UTC |