Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Storing Substitution Output String

by mrbbking (Hermit)
on Jul 14, 2002 at 17:49 UTC ( [id://181608]=note: print w/replies, xml ) Need Help??


in reply to Storing Substitution Output String

s///; returns the string sent to it if no substitutions actually happened.

You might try something like this:

#!usr/bin/perl -w use strict; my $page2 = ''; while( <DATA> ){ if( s!<title>(.*)</title>!<li>A$1C</li>!gi ){ $page2 .= $_; } } print $page2; __DATA__ <title>first story</title> This story is short. <title>second story</title> This story is longer. But not much longer.
I used a ! instead of the / as the delimiters, so I could leave the literal slashes alone in the regex.

Log In?
Username:
Password:

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

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

    No recent polls found