Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: cut of first char of a string

by Anonymous Monk
on Mar 08, 2005 at 08:51 UTC ( [id://437455]=note: print w/replies, xml ) Need Help??


in reply to cut of first char of a string

Not necessary '^' metasym:
my $s = "123456789"; $s =~ s/.//

Replies are listed 'Best First'.
Re^2: cut of first char of a string
by Corion (Patriarch) on Mar 08, 2005 at 08:55 UTC

    This doesn't do 'the right thing' for strings starting with a newline (which admittedly is a border case):

    perl -MData::Dumper -e "$foo=qq(\nHello);$foo =~ s/.//; print Dumper \ +$foo"

    Adding the /s flag makes dot match newline too:

    perl -MData::Dumper -e "$foo=qq(\nHello);$foo =~ s/.//s; print Dumper +\$foo"

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-26 08:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found