Parse a perl string
want to only show hte last four or so char of a perl string .
how do i do that? $myStr = "1234567"; i want to just show 4567. how can i do this? thanks |
substr($myStr, -4, 4);
or generically: substr(string, pos, number); This function returns [number] characters from [string], starting at position [pos]. If [pos] < 0, it starts that many characters from the end, e.g. -4 means start 4 characters from the end of [string]. |
hey thanks, i thought it was that easy.
-djgerbavore |
It may be a little more efficient to use in this case :
substr($myStr, 3); Particulary if used in big loops |
All times are GMT -5. The time now is 03:07 AM. |