in reply to Re: Binding operator RAM eater
in thread Binding operator RAM eater

index only helps if the regex is a simple substring, not a regular expression.

Replies are listed 'Best First'.
Re^3: Binding operator RAM eater
by techtruth (Novice) on Apr 19, 2012 at 05:31 UTC

    Hi PerlMonks,

    After some reading and thinking, I came up with this. (see below)

    Thank you RichardK for suggesting a method for piecewise matching. I had to tweak the regex a bit by prefixing it with 'm', which I thought was assumed to be there but I guess not. :)

    Also, thank you johngg for helping me keep even one more small variable in check.

    print "\tProcessing data...\n"; foreach my $link (@links) { # Get data from the internet my $httpReply = $browser->get($link); ####### This is the solution: piecewise matching, as suggested. while($html =~ m/(value)(value2)/g) { ## This is also my (a) solution, it turns out pushing two ## variables joined by a string is _way_ less expensive than ## an array, or anonymous array. ## ##The array has more things to keep track of than a simple scalar. # Correct? ## (I kinda went "doh!" when realized this...) push(@{$data{$2}}, join("::", $1, $link) ); } }
    Also, some fun things I saw on the way: http://perl.find-info.ru/perl/028/perlbp-chp-12-sect-17.html http://perldoc.perl.org/functions/pos.html