Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: Re: substr and strings on the outside

by scott (Chaplain)
on Aug 20, 2001 at 02:45 UTC ( [id://106095]=note: print w/replies, xml ) Need Help??


in reply to Re: substr and strings on the outside
in thread substr and strings on the outside

This works fine for me:

use strict; use warnings; my $f= " Joe Bloggs, 1615 Thislane Street\n"; substr($f, 20, 12345, "This is a new longer address\n"); print $f;

substr has no problems making the string longer. It's inserting new bytes where the first new byte is beyond the end of the original scalar that causes errors. So the following fails with the error message you mention:

substr($f, length($f) + 10, 12345, "This is a new longer address\n");

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others browsing the Monastery: (4)
As of 2024-04-25 16:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found