Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: reversing substr

by chipmunk (Parson)
on Mar 11, 2002 at 04:43 UTC ( #150812=note: print w/ replies, xml ) Need Help??


in reply to reversing substr

It's not quite clear what you're trying to do, especially since substr does accept a negative offset. What do you mean when you say "that doesn't work"?

If you want the first two characters of the string, try this:

my $str = "12345"; my $ss = substr($str, 0, 2); print $ss;
Or, if you want all but the last two characters, try this:
my $str = "12345"; my $ss = substr($str, 0, -2); print $ss;


Comment on Re: reversing substr
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (4)
As of 2014-12-28 06:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (178 votes), past polls