Beefy Boxes and Bandwidth Generously Provided by pair Networks chromatic writing perl on a camel
We don't bite newbies here... much
 
PerlMonks  

Re: Storing Substitution Output String

by mrbbking (Hermit)
on Jul 14, 2002 at 17:49 UTC ( #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.


Comment on Re: Storing Substitution Output String
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (16)
As of 2014-04-17 16:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (453 votes), past polls