leading spaces and Perl.
talexb-SBdzbUvMQDunS0EtXVNi6w at public.gmane.org
talexb-SBdzbUvMQDunS0EtXVNi6w at public.gmane.org
Fri Oct 24 18:07:13 UTC 2003
Hi Lance,
My bad, I should have caught the missing '+' after '\s' .. why are you
calling DB->quote, then trying to get rid of leading and trailing spaces?
If I look at <perldoc DBI>, it suggests that it adds ' to the front and
back of the string. Thus, " foo" will become "' foo'" and the regex
won't strip spaces because none of them are leading || trailing.
How about
$UName =~ s/^\s+//;
$UName =~ s/\s+$//;
$UName = $DB->quote($UName);
instead. Or Sergey's clever regex to do it all in one swell foop.
On Fri, 24 Oct 2003, Lance F. Squire wrote:
> talexb-SBdzbUvMQDunS0EtXVNi6w at public.gmane.org wrote:
> > Hi Lance,
> >
> > When you say that
> >
> > s/^\s//;
> >
> > doesn't work (presumably to remove leading spaces), what do you mean? Are
> > you sure you are operating on the right variable? For example, don't do
> >
> > foreach my $line ( @lines ) {
> > s/^\s//;
> > }
> >
> > because $line will remain untouched.
> >
>
> Test code in question.
>
> $Uname = $DB->quote($Uname);
> print "Uname='$Uname'\n<br>";
> #Kill leading and trailing spaces
> $Uname =~ s/^\s+//;
> print "Remove leading spaces = '$Uname'<br>\n";
> $Uname =~ s/\s+$//;
> print "Remove trailing spaces = '$Uname'<br>\n";
>
> --
> The Toronto Linux Users Group. Meetings: http://tlug.ss.org
> TLUG requests: Linux topics, No HTML, wrap text below 80 columns
> How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
>
>
--
The Toronto Linux Users Group. Meetings: http://tlug.ss.org
TLUG requests: Linux topics, No HTML, wrap text below 80 columns
How to UNSUBSCRIBE: http://tlug.ss.org/subscribe.shtml
More information about the Legacy
mailing list