Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: cut of first char of a string

by TimToady (Parson)
on Mar 10, 2005 at 08:41 UTC ( [id://438184]=note: print w/replies, xml ) Need Help??


in reply to cut of first char of a string

Well, if you don't count $_ as an extra variable because it's already implicitly there, you can do it like this:
use bytes; if (vec($s,3,2) < 3) { vec($s,$_,8) = vec($s,$_+1,8) for 0..length($s)-2; chop($s); } else { vec($s,$_,8) = vec($s,$_+1,8) for 0..length($s)-2; chop($s); while (vec($s,3,2) == 2) { vec($s,$_,8) = vec($s,$_+1,8) for 0..length($s)-2; chop($s); } }
Update:
Hmm, here's a solution without $_:
use bytes; if (vec($s,3,2) < 3) { () = $s =~ m/.(?=.)(?{ vec($s,pos($s)-1,8) = vec($s,pos($s),8) +})/sg; chop($s); } else { () = $s =~ m/.(?=.)(?{ vec($s,pos($s)-1,8) = vec($s,pos($s),8) +})/sg; chop($s); while (vec($s,3,2) == 2) { () = $s =~ m/.(?=.)(?{ vec($s,pos($s)-1,8) = vec($s,pos($s +),8)})/sg; chop($s); } }

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (6)
As of 2024-03-28 09:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found