Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: correct usage of q, quotemeta, with s///

by termix (Beadle)
on May 30, 2002 at 22:36 UTC ( [id://170536]=note: print w/replies, xml ) Need Help??


in reply to correct usage of q, quotemeta, with s///

You have a single space before and a single space after both the strings. Is that a required effect? Notice:

my $page="nospaceLOTSnospace space LOTS space"; my $old_text = qq ( LOTS ); my $new_text = qq ( LESS ); $page =~ s/$old_text/$new_text/g; print $page;

... will output ...

nospaceLOTSnospace space LESS space

The first "LOTS" does not get replaced because you are replacing " LOTS " (space before and after) with " LESS "

-- termix

Replies are listed 'Best First'.
Re: Re: correct usage of q, quotemeta, with s///
by cidaris (Friar) on May 30, 2002 at 23:52 UTC
    The spacing is irrelevant, (perhaps I should have noted that) I simply used it for illustration purposes.

    "LOTS" simply indicates several lines of HTML that include double-quotes, slashes, you name it. (Note: several lines)

    my $page is also several lines of HTML, the contents of an entire file, actually.
    I'm trying to replace multiple lines of code (compressed into a single string) in one big string (the entire file) with another string (more lines of code).

    I hope this is somewhat clearer.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (8)
As of 2024-03-29 13:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found