in reply to Problem creating a function
Then you can call it like this: cleaner( $dirty ); and that will change the value of the variable in the way you want. However, I'd point out that that is a pretty uncommon way to use subroutines, althought there's nothing wrong with it. (Do it this way if it's appropriate.) If you want to get a cleaned version of a value, without changing the original, I'd write it like this:sub cleaner { $_[0] =~ s/\n/<br>/g;; $_[0] =~ s/\t/ /g; }
You can call this one like this: $clean = cleaner( $dirty );sub cleaner { local $_ = shift; s/\n/<br>/g;; s/\t/ /g; $_ }
jdporter
...porque es dificil estar guapo y blanco.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Problem creating a function
by tachyon (Chancellor) on Dec 25, 2002 at 09:51 UTC | |
by jdporter (Paladin) on Dec 25, 2002 at 13:44 UTC | |
by tachyon (Chancellor) on Dec 25, 2002 at 15:06 UTC | |
by IlyaM (Parson) on Dec 25, 2002 at 16:06 UTC | |
by tachyon (Chancellor) on Dec 26, 2002 at 02:20 UTC | |
| |
by jdporter (Paladin) on Dec 27, 2002 at 04:55 UTC |