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

Re: substr problem

by TStanley (Canon)
on Jul 13, 2002 at 18:06 UTC ( [id://181506]=note: print w/replies, xml ) Need Help??


in reply to substr problem

From perldoc:substr:

substr - get or alter a portion of a string 

SYNOPSIS:
=========
substr EXPR,OFFSET,LEN,REPLACEMENT 
substr EXPR,OFFSET,LEN 
substr EXPR,OFFSET 

DESCRIPTION:
============
Extracts a substring out of EXPR and returns it. First
character is at offset 0, or whatever you've set $[ to
(but don't do that). If OFFSET is negative (or more
precisely, less than $[ ), starts that far from the end of
the string. If LEN is omitted, returns everything to the
end of the string. If LEN is negative, leaves that many
characters off the end of the string.
So, your -1 where the OFFSET is at, is starting from the end of the string. And since you
are giving the length, you are getting only the last character of your string.

UPDATE: You might also want to read this

TStanley
--------
Never underestimate the power of very stupid people in large groups -- Anonymous

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2024-03-28 13:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found