Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
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 avoiding work at the Monastery: (14)
As of 2015-07-02 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (33 votes), past polls