Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Storing Substitution Output String

by little (Curate)
on Jul 14, 2002 at 17:46 UTC ( #181607=note: print w/replies, xml ) Need Help??

in reply to Storing Substitution Output String

So you better use $1 as thats the match you where looking for then a string that you unneccesarily altered, so use a match

$page2 =~ m|<title>(.*)</title>|gi; print $1;
instead. And you might consider not to use dotStar, see Ovid's Death to Dot Star!:-)

Have a nice day
All decision is left to your taste


so alike this?
print '<li>'.$1.'</li>';

Replies are listed 'Best First'.
Re: Re: Storing Substitution Output String
by bob (Novice) on Jul 14, 2002 at 18:53 UTC
    The string is altered on purpose--that's the whole point, in this case, of the expression.
Re: Re: Storing Substitution Output String
by bob (Novice) on Jul 14, 2002 at 19:08 UTC
    Ahhhh.... your update has me thinking... Let me try to fir it like that and see if it'll work. As mentioned above, the sub is really somewhat more complex than drawn in my first post....
      Printing the scalars (and adding the add'l text and tags at that point) allows me to print only the first instance of each match, Little. How would you suggest printing all of the matches made?

        say your text is in a string (or an array of strings) then I would use grep and map :-) to get a list of all matches nicely formatted as list items, but for sure there is an easier way which refuses to come to my mind now :-)

        perhaps this might do :-)

        # the substitution is none in effect, it just digs around $page2 =~ s|<title>(.*)</title>|${my_count(\$1)}|gi; my matches = (); sub my_count { my $occurance = shift; push @matches, ${$occurance} ; return $occurance; } # see what we've got foreach (@matches) { print '<li>'.$_.'</li>'."\n"; # just to format the output :-) }

        Have a nice day
        All decision is left to your taste


        fixed stupid error in the substitutional part where I inserted the '<title>' again.

        You see there might be a dozen matching patterns in each document, Little. And I want to print all of the matches with the additional text added.
        I may be missing replies..... Never used this board before, and now I see replies that aren't showing up in the thread.... Ok, fixed my thread depth.... I'm taking a look at your latest suggestion now, Little.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://181607]
[Your Mother]: A-Team.
[LanX]: never liked it, but a friend of my mother was a big "fan" of Mr T xD
[LanX]: (talking about minority chicks)
[LanX]: Hollywood is built on stereotypes which sell, this includes stereotypes about English, French, russians and ... Americans
[Your Mother]: I think to some degree, maybe a large one, the stereotypes are purely products OF Hollywood and not what would sell best.
[LanX]: well those products which sold best are replicated
[Your Mother]: They get almost everything wrong on every level. I think they create and restrict the market and fundamentally misunderstand audiences.
[Your Mother]: Consider how long, for example, superhero movies were kept at bay because they weren't commercially viable. They always were, just Hollywood couldn't see it or understand how to make one because there is no management talent in the town.
[LanX]: Erich von Strohheim built his career on beeing the most hated guy (The man you love to hate)
[Your Mother]: You see these amazing set, costumes, performances, etc, etc, etc all ruined by production and script decisions from the top down.

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2018-03-19 14:54 GMT
Find Nodes?
    Voting Booth?
    When I think of a mole I think of:

    Results (240 votes). Check out past polls.