Octavian Rasnita wrote:
> 
> Thank you very much for your suggestion. It works, but unfortunately very
> very slow.
> 
> If I put the data after __DATA__ and read <DATA>, it works very fast, but if
> I create a $text var that holds the same data then open(DATA, "<", \$text),
> it works more than 100 times slower.
> 
> Here is what I have done:
> 
> open(IN, "<", \$text) or die - $!;
> 
> while(<IN>) {
> if (/$ARGV[0]/) {
> my ($word, $word2) = split '##', $_, 2;
> print "$word = $word2\n";
> last;
> }
> }
> 
> print times();
> 
> Am I doing something wrong, or can I do something to improve the speed?

my $pattern = qr/$ARGV[0]/;

while ( $text =~ /(?=.*$pattern)(.+?)##(.+)/g ) {
    print "$1 = $2\n";
    }




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to