Problems? Is your data what you think it is? | |
PerlMonks |
Re: substr problemby TStanley (Canon) |
on Jul 13, 2002 at 18:06 UTC ( [id://181506]=note: print w/replies, xml ) | Need Help?? |
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
In Section
Seekers of Perl Wisdom
|
|