> Dan Muey wrote:
> > 
> > I have this subroutine and it does what I need ::
> > 
> > print rmgtlt($var);
> > 
> > sub rmgtlt {
> > 
> >         $_[0] =~ s/^\<|\>$|\n|\r|\s$//g;
> >         return $_[0];
> > }
> > 
> > Is there a way to so the substitution and return the result in one 
> > line?
> > 
> > Like ::
> > 
> > sub rmgtlt {
> >         return ??? $_[0] =~ s/^\<|\>$|\n|\r|\s$//g;
> > }
> > 
> > I tried using parenthesis and using list context ::
> > return my($q) = $_[0] =~ s/(^\<|\>$|\n|\r|\s$)//g; }
> > 
> > And you might have figured it returned the number of 
> elements matched 
> > and not the newly fixed up variable contentes.
> > 
> > Is there a way to do this?
> 
> 
> sub rmgtlt { join '', split /^<|>$|\n|\r|\s$/, $_[0] }
Ooohh that works! 

Now that prompts a few other questions :
1) It works with and with out a semi colon behind $_[0], why and which one is better?
2) Is that the same as just leaving out the return line ?
3) Is there any reason why the result may end up being different than the two line 
version?

If any one has any thoughts about the pros and cons of that then I'd love to hear it.

I'll put that line in my test to compare different methods and see which iod faster.

Thanks a lot John!

Dan

> 
> 
> John
> -- 
> use Perl;
> program
> fulfillment
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to