Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re^4: a farewell to chop

by particle (Vicar)
on Sep 11, 2002 at 18:29 UTC ( [id://197026]=note: print w/replies, xml ) Need Help??


in reply to Re: Re^2: a farewell to chop
in thread a farewell to chop

\X fixes the utf8 problem, but there's still a problem with this regex...

#!/usr/bin/perl -w use strict; use utf8; my($a,$b,$c); $a=$b=$c="123\n456\n"; print chop $a; # prints "\n" print $b =~ s/\X$//; # prints "1" print $a; # prints "123\n456" print $b; # prints "123\n45\n" ## OOPS!!!
i believe s/\X\z// will do what you want, although it still won't return the character removed. instead, use substr EXPR,OFFSET,LEN,REPLACEMENT (i.e. substr $_,-1,1,'').

~Particle *accelerates*

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-23 19:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found