Mark Anderson wrote: > > > > 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; > > } > > > > Without more comments or sample data, I'm not really sure what your > function is doing, but here are some things to try: > > sub rmgtlt { > $_[0] =~ s/^\<|\>$|\n|\r|\s$//g; > } > > sub rmgtlt { > return $_[0] =~ s/^\<|\>$|\n|\r|\s$//g; > } > > sub rmgtlt { > return ($tmp = $_[0]) =~ s/^\<|\>$|\n|\r|\s$//g; > }
Hi Mark. All of these return the same value: the number of substitutions that the s//g operator made to the string. This is essentially what Dan's problem was. The only difference is your third option, which copies the passed parameter to global variable $tmp before making the modification. Both of the first two options change the variable passed when the subroutine is called. Rob $tmp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]