> In BASIC there are commands for
> leftstring, midstring, and rightstring.
> I am looking for the perl equiv for these.
> Lets say i have a string 80 charecters long and i
> want to insert at string position 20 for 10 charecters.
substr($EightyCharsLong, 19, 10) = 'morestring';
Yes, you can have (some) functions on the *left*
side of assignments. Neat, huh?
To get up to speed on substr(), use perl at a shell
prompt to experiment. I think this should work at a
bash prompt:
perl -e '$_="barbar"; substr($_, 2, 4) = "qux"; print'
Play with the 2 and 4 and see what happens. Cool, huh?
Try setting the 2 to a negative number, say -2.