in reply to can any reply out with a better code than this??
can any one suggest a better code to this??Yes, for sure:#!/usr/bin/perl -w my $string = "rid"; while (<>) { if (/($string){3}/) { print; } }
and, arguably:#!/usr/bin/perl -w my $string = "rid"; while (<>) { if (/($string){3}/) { print; } }
use strict; my $string = 'ri\d+'; while (my $line = <>) { if ($line =~ m{ (?: \Q$string\E ){3} }xms) { print $line; } }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: can any reply out with a better code than this??
by asdfghjkl (Initiate) on Dec 06, 2007 at 07:50 UTC | |
by fenLisesi (Priest) on Dec 06, 2007 at 07:53 UTC | |
by asdfghjkl (Initiate) on Dec 06, 2007 at 07:57 UTC | |
by fenLisesi (Priest) on Dec 06, 2007 at 08:06 UTC |
In Section
Seekers of Perl Wisdom