Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Stripping characters from strings

by moen (Hermit)
on Oct 29, 2000 at 23:15 UTC ( [id://39007]=note: print w/replies, xml ) Need Help??


in reply to Stripping characters from strings

You could do something like
s/.$//g;
This means: substitute(s/) any one character(.) counting from the end ($) with nothing (//) and at all possible matches(g).

Replies are listed 'Best First'.
RE: Re: Stripping characters from strings
by elwarren (Priest) on Oct 30, 2000 at 04:07 UTC
    Is the g needed in this case? Wouldn't this only match the end of line once?
      With an anchor that isn't within an alteration, "g" is pretty useless. I'm not near a perl with Debugging turned on so I can't tell you if it's a no-op, but I do know it isn't a dangerous thing to have on there, just useless. =)

      Update... And what merlyn said below. (yeesh $*)

      --
      $you = new YOU;
      honk() if $you->love(perl)

        Actually, if $* is 1, then $ matches any embedded newline as well as the end of the string, so s/.$//g; actually makes sense!

        I doubt that was the case here, though. {grin}

        -- Randal L. Schwartz, Perl hacker

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://39007]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (8)
As of 2024-04-18 07:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found