> 
> Dan,
> 
> Maybe you want to do a series of smaller regexes, rather than 
> one large one?

No it was a series of smaller ones. I want to do a one liner **

> 
> For example:
> 
> sub rmgtlt {
>   $_[0] =~ s/^\<|\>$//g;
>   $_[0] =~ s/[\n\r]//$g;
>   $_[0] =~ s/\s$//g;
> 
>   return $_[0];
> }
> 
> Just a thought that might make it more clear where the 
> problem is. Also, what do you mean by "on one line?" do you 

There is no problem with the regex, the regex works like it should.

> mean without \n or \r's anywhere in the string?

** No I mean do the substitution and return the result all in one line of perl code.
You know, a one liner.

Instead of

$_[0] =~ s/whatever//; 
return $_[0];

Do it like :

return ?SYNTAX HERE? s/whatever//;

Thanks

Dan



> 
> --------------------------
> David Olbersen 
> iGuard Engineer
> 11415 West Bernardo Court 
> San Diego, CA 92127 
> 1-858-676-2277 x2152
> 
> 
> > -----Original Message-----
> > From: Dan Muey [mailto:[EMAIL PROTECTED]
> > Sent: Tuesday, March 11, 2003 9:00 AM
> > To: [EMAIL PROTECTED]
> > Subject: return a regex substitution in one line
> > 
> > 
> > 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?
> > I know I must be missing something obvious , thanks for any 
> guidance!
> > 
> > Dan
> > 
> > --
> > 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