in reply to What operator prepends?
Usually, when I want to prepend, I just change the order of operations into an append. Instead of:
I'll do:$script = 'foo.pl'; # or $script = <STDIN>; chomp $script; $path = '/some/path/'; $script = $path . $script;
Often, I find that this actually makes more sense in my head because I'm building my string from left to right, which is how I think of the string.$script = '/some/path'; $script .= 'foo.pl'; # or $script .= <STDIN>; chomp $script;
Alternatives is to build the string from pieces using sprintf or join. And, in my particular example, an option would be to use the join-like File::Spec.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: What operator prepends?
by swampyankee (Parson) on Jan 25, 2006 at 21:56 UTC | |
by Tanktalus (Canon) on Jan 25, 2006 at 22:21 UTC | |
by swampyankee (Parson) on Jan 26, 2006 at 03:46 UTC |