tunafish has asked for the wisdom of the Perl Monks concerning the following question:
Wasn't sure what to put in the title of the queston. I'm a little confused by the following behavior. I'm trying to strip the HTML tags from a variable and save that value to another variable. I have the following code:
$item->{'notag_title'}=&strip_tags($item->{'title'}); sub strip_tags { $_[0]=~s/<[^>]+>//gs; return $_[0]; }
As expected $item->{'notag_title'} becomes a tag-less version of $item->{'title'}. But $item->{'title'} loses its tags too! I don't understand it at all. Is $_[0] a reference to the original variable, not a variable local to the subroutine?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Subroutine performing operation on variable submitted to it...
by davido (Cardinal) on Nov 24, 2011 at 07:41 UTC | |
|
Re: Subroutine performing operation on variable submitted to it...
by Eliya (Vicar) on Nov 24, 2011 at 07:38 UTC |