[28908] in Perl-Users-Digest
Perl-Users Digest, Issue: 152 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 19 16:10:00 2007
Date: Mon, 19 Feb 2007 13:09:15 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 19 Feb 2007 Volume: 11 Number: 152
Today's topics:
Re: array of hashes SrikanthMandava2004@gmail.com
Re: array of hashes xhoster@gmail.com
Re: behavior of my print function call xhoster@gmail.com
Complex calculation of averages <bart@nijlen.com>
fcntl call to check if a file is open - help needed <sysadmin00@gmail.com>
Re: fcntl call to check if a file is open - help needed <sysadmin00@gmail.com>
Re: Perl takes a lot of memory when you just require a <hjp-usenet2@hjp.at>
Re: Regex confusion trashman.horlicks@btinternet.com
Re: Regex confusion trashman.horlicks@btinternet.com
Re: Regex confusion <kenslaterpa@hotmail.com>
Re: Regex confusion sl123@netherlands.area
Re: Regex: Why is overreaching necessary? anno4000@radom.zrz.tu-berlin.de
Re: Regex: Why is overreaching necessary? <nospam-abuse@ilyaz.org>
Re: Regexp for email addresses. <bik.mido@tiscalinet.it>
Re: Sending commands to a secondary prompt <mark.clementsREMOVETHIS@wanadoo.fr>
which is more powerfull ? ehabaziz2001@gmail.com
Re: which is more powerfull ? <source@netcom.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Feb 2007 08:44:11 -0800
From: SrikanthMandava2004@gmail.com
Subject: Re: array of hashes
Message-Id: <1171903451.136332.71570@a75g2000cwd.googlegroups.com>
Gunnar Hjalmarsson
Ignore my previous response as newbie's panic reply.
Thanks for your help, managed to solve that. And I need better
understanding of references, and thats my next task.
thanks,
Sri
------------------------------
Date: 19 Feb 2007 16:58:39 GMT
From: xhoster@gmail.com
Subject: Re: array of hashes
Message-Id: <20070219120000.879$Ox@newsreader.com>
SrikanthMandava2004@gmail.com wrote:
> I have got multiple hashes in an array with same keys. And I want to
> count the total of values with same keys.
>
> hash1
>
> score1 20
> score2 10
> score3 20
>
> hash2
>
> score1 30
> score2 20
> score3 30
>
> Please note that i have multiple hashes not two as above shown. I am
> looking for out put 'Score1 Total = 50; Score2 Total = 30; Score1
> Total = 50; ' Looking for the output on the basis of having same key.
>
> I am a perl newbie, have tried the following loop, ended up with some
> strange numbers..........advice please
>
> my $sum = 0;
> for my $m (0 .. $#notesw){
> for $variable (keys %{$notesw[$m]}) {
> print "$variable = ${notesw[$m]{$variable}}\n";
> $sum += ${notesw[$m]{$variable}};
> print "$sum \n";
> }
> }
my %uberhash;
foreach (@notesw) {
while (my ($k,$v)=each %$_) {
$uberhash{$k}+=$v
};
};
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 19 Feb 2007 17:17:45 GMT
From: xhoster@gmail.com
Subject: Re: behavior of my print function call
Message-Id: <20070219121906.713$wl@newsreader.com>
"Dave Slayton" <evad.notyals@liamg.moc> wrote:
> <xhoster@gmail.com> wrote in message
> news:20070218224100.126$AG@newsreader.com...
> > "Dave Slayton" <evad.notyals@liamg.moc> wrote:
> >> I have a hash full of filehandles and a scalar variable containing a
> >> line of text, and try to do this:
> >>
> >> print $fh_hash{$key} $line;
> >>
> >> which is rejected by the compiler, which says "Scalar found where
> >> operator expected" near "} $line". It wants an operator before $line?
> >
> > Sure. For example, the comma operator would make it happy. perhaps
> > you wouldn't be happy, but the parser would be.
> >
> > ...
> >> Finally, if I surround
> >> the file handle with curly braces like this:
> >>
> >> print {$fh_hash{$key}} $line;
> >>
> >> then it works as desired.
> >>
> >> Would someone please explain what's going on there?
> >
> > perldoc -f print
> >
> > I see no reason to think I could do a better job of explaining that
> > is already done in the documentation. Have you already read it and
> > want more explanation? If so, could you describe in more detail
> > what you want explained?
>
> Well, I see that the documentation states the curly braces must be there.
> It doesn't begin to explain why.
What kind of answer to "why" are you looking for? The design decision?
The reason behind the design decision? A physchoanalysis of the people
who made that decision? The part of the perl source code that implements
that part of the parsing? An interpretation of that code into pseudocode?
> Also, some of the other things it
> offers don't seem to work as it suggests, e.g.:
> "(NOTE: If FILEHANDLE is a variable and the next token is a term, it may
> be misinterpreted as an operator unless you interpose a "+" or put
> parentheses around the arguments.)"
>
> As I said, parentheses around $file make it think I'm invoking a
> subroutine,
The docs do not suggest that putting paranethesis around $line (not
$file) will let you ignore the rest of the documentation!
print $fh_hash{$key} ($line);
Now, is $fh_hash{$key} a simple scalar variable? No. So then we interpret
the print as taking a list, not a filehandle followed by a list. What
would the degenerate list $fh_hash{$key}($line) be interpreted as? A call
to a subroutine via a code-ref, of course.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 19 Feb 2007 08:33:21 -0800
From: "Bart Van der Donck" <bart@nijlen.com>
Subject: Complex calculation of averages
Message-Id: <1171902801.375189.269570@h3g2000cwc.googlegroups.com>
Hello perl gurus,
I have the following problem.
$x{'63'} = "2006-05-17|2006-11-25|2006-12-04";
$x{'67'} = "2005-04-30|2005-09-21|2006-07-17|2007-02-10";
$x{'71'} = "2006-04-23|2006-10-05|2006-12-27|2007-01-21";
etc.
How can I calculate the average number of days between each date for
%x for the last 1,2,3,4,5,6,12 months ?
use Date::Calc(Delta_Days);
print Delta_Days(2006,12,27,2007,1,21); # says '25'
The dates in each value are sorted and in YYYY-MM-DD format.
%x might be thought of as an array, because the hash values are unique
and non-floating numbers.
------------------------
Example 1
------------------------
Today is 2007-02-19. 67 and 71 can be taken to calculate the average
of the last month (=2007-01-19 to 2007-02-19) because 63 holds no data
for it.
Average of 208 (nr of days from 2006-07-17 to 2007-02-10 in $x{'67'})
and 328 (nr of days from 2006-02-27 to 2007-01-21 in $x{'71'}) becomes
268.
Result of example 1 is 268.
------------------------
Example 2
------------------------
Today is 2007-02-19. All three entries can be taken to calculate the
average of last 5 months (=2006-09-19 to 2007-02-19).
For $x{'63'} goes:
192 (2006-05-17 to 2006-11-25) and 9 (2006-11-25 to 2006-04-12), thus
average 100.5.
For $x{'67'} goes:
208 (2006-07-17 to 2007-02-10), thus average 208.
For $x{'71'} goes:
165 (2006-04-23 to 2006-10-05) and 83 (2006-10-05 to 2006-12-27) and
25 (2006-12-27 to 2007-01-21), thus average 91.
The total average is (100.5 + 208 + 91 ) / 3.
Result of example 2 is 103.67.
Thanks a lot,
--
Bart
------------------------------
Date: 19 Feb 2007 12:50:50 -0800
From: "sa" <sysadmin00@gmail.com>
Subject: fcntl call to check if a file is open - help needed
Message-Id: <1171918250.793459.282670@h3g2000cwc.googlegroups.com>
Hi all,
Consider the script below. After reading some man and perldoc on
fcntl, open, etc, I'm obviously doing something wrong - it gives me
the same result regardless whether a file I'm checking is open or
not.
[root@willow tmp]# lsof disk.txt
[root@willow tmp]# ./fcntl_test disk.txt
flags: 4294964736
O_TRUNC
O_APPEND
O_SYNC
O_NOFOLLOW
O_DIRECTORY
O_DIRECT
O_ASYNC
O_LARGEFILE
Now a run when the file is open.
[root@willow tmp]# lsof disk.txt
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
perl 22877 username 4w REG 104,6 18480 508036 disk.txt
[root@willow tmp]# ./fcntl_test disk.txt
flags: 4294964736
O_TRUNC
O_APPEND
O_SYNC
O_NOFOLLOW
O_DIRECTORY
O_DIRECT
O_ASYNC
O_LARGEFILE
Here is the script. Any pointers will be greatly appreciated.
=============================================
#!/usr/bin/perl -w
use Fcntl;
use strict;
use Symbol;
my $fh = gensym;
sysopen $fh, $ARGV[0], O_RDONLY or die "$ARGV[0]: Cannot open ($!)
\n";
my $buf = '';
fcntl($fh, F_GETFL, $buf) or die "Cannot run fcntl\n";
my $flags = unpack 's', $buf;
printf "flags: %u\n", $flags;
for my $f (qw[O_CREAT O_EXCL O_NOCTTY O_TRUNC O_APPEND O_NONBLOCK
O_SYNC O_NOFOLLOW O_DIRECTORY O_DIRECT O_ASYNC
O_LARGEFILE]) {
no strict;
print "$f\n" if ($flags & &$f) == &$f;
}
=============================================
Thanks,
Alex.
------------------------------
Date: 19 Feb 2007 12:53:20 -0800
From: "sa" <sysadmin00@gmail.com>
Subject: Re: fcntl call to check if a file is open - help needed
Message-Id: <1171918400.015428.139920@j27g2000cwj.googlegroups.com>
On Feb 19, 3:50 pm, "sa" <sysadmi...@gmail.com> wrote:
> Hi all,
>
> Consider the script below. After reading some man and perldoc on
> fcntl, open, etc, I'm obviously doing something wrong - it gives me
> the same result regardless whether a file I'm checking is open or
> not.
>
> [root@willow tmp]# lsof disk.txt
> [root@willow tmp]# ./fcntl_test disk.txt
> flags: 4294964736
> O_TRUNC
> O_APPEND
> O_SYNC
> O_NOFOLLOW
> O_DIRECTORY
> O_DIRECT
> O_ASYNC
> O_LARGEFILE
>
> Now a run when the file is open.
>
> [root@willow tmp]# lsof disk.txt
> COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
> perl 22877 username 4w REG 104,6 18480 508036 disk.txt
> [root@willow tmp]# ./fcntl_test disk.txt
> flags: 4294964736
> O_TRUNC
> O_APPEND
> O_SYNC
> O_NOFOLLOW
> O_DIRECTORY
> O_DIRECT
> O_ASYNC
> O_LARGEFILE
>
> Here is the script. Any pointers will be greatly appreciated.
> =============================================
> #!/usr/bin/perl -w
>
> use Fcntl;
> use strict;
> use Symbol;
>
> my $fh = gensym;
> sysopen $fh, $ARGV[0], O_RDONLY or die "$ARGV[0]: Cannot open ($!)
> \n";
> my $buf = '';
> fcntl($fh, F_GETFL, $buf) or die "Cannot run fcntl\n";
> my $flags = unpack 's', $buf;
> printf "flags: %u\n", $flags;
> for my $f (qw[O_CREAT O_EXCL O_NOCTTY O_TRUNC O_APPEND O_NONBLOCK
> O_SYNC O_NOFOLLOW O_DIRECTORY O_DIRECT O_ASYNC
> O_LARGEFILE]) {
> no strict;
> print "$f\n" if ($flags & &$f) == &$f;
> }
> =============================================
>
> Thanks,
> Alex.
Sorry, forgot to tell about my system: RHEL 2.1, kernel 2.4.9-e.
59enterprise, perl v5.6.1
------------------------------
Date: Mon, 19 Feb 2007 20:27:41 +0100
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: Perl takes a lot of memory when you just require a file
Message-Id: <slrnetjuhd.kh9.hjp-usenet2@yoyo.hjp.at>
On 2007-02-19 06:24, RJ <jain.nsit@gmail.com> wrote:
> On Feb 18, 6:34 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> On 2007-02-18 09:12, RJ <jain.n...@gmail.com> wrote:
>> > On Feb 16, 4:38 pm, anno4...@radom.zrz.tu-berlin.de wrote:
>> >> RJ <jain.n...@gmail.com> wrote in comp.lang.perl.misc:
>> >> > First of all, if I just do a `require"<generated_file.pl>" ` it takes
>> >> > a lot of memory (around 4Mb for 2 Mb file even if I do just a return
>> >> > after entering pass_data_from_perl_to_c and populate no Data).
[...]
>> > My main concern here is that even if return from very beggining of
>> > function pass_data_from_perl_to_c , even then perl takes a lot of
>> > memory in just requiring file '<generated_file.pl>' while I am
>> > populating no data structures.
>>
>> I don't understand what you expect to happen when you "just require" the
>> file. When you require a file, it is compiled and the compiled code is
>> stored in memory. Any data embedded in the code is of course compiled
>> (converted to perl data structures) and stored, too.
>>
> I just want to clarify one thing over here. There are only function
> calls in these generated
> perl file. It looks something like follows -
>
><Prototype>
><spyDecompileTagData(index,rName,{"t1" => "1","t2" =>
> ["100","200"],"t3" => "200"});>
>
><Example snippet>
>======================================================================================
> spyDecompileTagData(537,"",{"INCR" => "1","tag1" =>
> ["100","200"],"tag0" => "200"});
> spyDecompileTagData(538,"",{"INCR" => "1","tag2" =>
> "tag2.value2","tag3" => "default"});
> spyDecompileTagData(539,"",{"INCR" => "1","tag4" =>
> ["tag4.value1","tag4.value3"]});
> spyDecompileTagData(540,"",{"INCR" => "1","tag1" => ["200"]});
> spyDecompileTagData(541,"",{"INCR" => "1","tag1" => ["200"]});
> spyDecompileTagData(542,"",{"INCR" => "1","tag4" => ["default"]});
> spyDecompileTagData(543,"",{"INCR" => "1","tag4" => ["tag4.value3"]});
> spyDecompileTagData(544,"",{"INCR" => "1"});
> spyDecompileTagData(545,"",{"INCR" => "1","tag1" => ["200"]});
> spyDecompileTagData(546,"",{"INCR" => "1"});
> spyDecompileTagData(547,"",{"INCR" => "1","tag1" => ["200"]});
> spyDecompileTagData(548,"",{"INCR" => "1"});
> spyDecompileTagData(549,"",{"INCR" => "1"});
> spyDecompileTagData(550,"",{"INCR" => "1","tag4" => ["tag4.value1"]});
> spyDecompileTagData(551,"",{"INCR" => "1","STATUS" => "FIXED"});
> spyDecompileTagData(552,"",{"INCR" => "1","STATUS" => "TOFIX"});
> spyDecompileTagData(553,"",{"INCR" => "1","STATUS" => "ANALYZE"});
> spyDecompileTagData(554,"",{"INCR" => "1","tag9" => "1","tag8" =>
> "3.14","tag7" => "a"});
> spyDecompileTagData(555,"",{"INCR" => "1","tag11" => "2","tag12" =>
> "1","tag9" => "2","tag8" => "9.8","tag0" => "0","tag7" => "c"});
>======================================================================================
> There is no other things in this perl file other than these function
> calls.
Several 10,000's of them, if your files are several megabytes long.
So you have several 10,000 anonymous hashes, each with a few members,
some of which are anonyous arrays. Plus an equal number of strings and
numbers. Plus the code to call spyDecompileTagData with these
arguments, of course. All of this will be stored in memory after the
require.
> Now if I just make a return from inside 'spyDecompileTagData' after
> doing 3 shift stmts (one for each argument passed to this function),
> still perl takes a lot of memory.
Even if you don't even call the code at all, it will take a lot of
memory. You have compiled it, so you now have it in memory.
For example:
------------------------------------------------------------------------
#!/usr/bin/perl
use warnings;
use strict;
my $sub = shift;
my $n = shift;
sub create {
open (my $fh, ">", "foo.pl");
print $fh qq{sub spyDecompileTagData {}\n};
if ($sub) {
print $fh "sub f {\n";
}
for my $i (1 .. $n) {
print $fh qq{spyDecompileTagData($i, '', { "INCR" => "1", "tag4" => ["tag4.value3"]});\n}
}
if ($sub) {
print $fh "}";
}
print $fh "1;";
close($fh);
}
sub vmsize {
open (my $fh, "<", "/proc/$$/status");
while (<$fh>) {
print if (/^VmSize:/);
}
}
create();
vmsize();
require 'foo.pl';
vmsize();
if ($sub) {
f();
vmsize();
}
------------------------------------------------------------------------
This creates a file similar to the files you have (although all the
lines are the same), oprionally encapsulates in a sub. Now if I run
this:
% ./foo 0 100000
VmSize: 5056 kB
VmSize: 108356 kB
the memory consumption will increase by roughly 100 MB when the code is
required. If the created code is encapsulated in a sub:
% ./foo 1 100000
VmSize: 5056 kB
VmSize: 111484 kB
VmSize: 111484 kB
the memory consumption will grow even a little more with the require,
but actually calling the code doesn't make a difference.
Oh, and that's roughly 1 kB per line. If I simply create an array with
100000 elements with the same data, it only takes half as much memory,
so you can probably save quite a lot of memory if you parse the file
instead of requiring it.
> I have used above format just to avoid parsing as I you can see the
> values passed in 3rd argument can be quite complex (a hash whose
> values can be scalar/array refrence or even a hash refrence.
You are trading convenience against memory. You can certainly do that,
your time is probably more expensive than RAM.
However, there are modules for reading and writing such complex data
structures, for example YAML and Storable. I suggest you take a look at
them.
> I don't want perl to store the whole file in code section
> but I want to compile code inline. Is there anyway to do so.
If by "compiling code inline" you mean "compile each line only just
before it is executed", then no, there is no way to do that.
You can only avoid compiling code if you, er, don't compile it. So for
example you could create many small files instead of one big file and
require only the one's you need. Or if you can decide for each line
whether you need it, you could read the file and eval the lines you
need.
hp
--
_ | Peter J. Holzer | Es ist ganz einfach ihn zu verstehen, wenn
|_|_) | Sysadmin WSR | man nur alle wichtigen Worte im Satz durch
| | | hjp@hjp.at | andere ersetzt.
__/ | http://www.hjp.at/ | -- Nils Ketelsen in danr
------------------------------
Date: 19 Feb 2007 08:11:19 -0800
From: trashman.horlicks@btinternet.com
Subject: Re: Regex confusion
Message-Id: <1171901479.341021.110020@v45g2000cwv.googlegroups.com>
On 19 Feb, 16:07, "tfe" <tfeser...@gmail.com> wrote:
> Hi,
>
> You look to put a "," and you do not need.
> Regex looks like that: /regex/ , or !regex! or #regex# , etc...
> If you want to match the word "test", you juste have to put /\btest\b/
> to match it.
>
> The final option "i" comes after the separation :
> /\btest\b/i
>
> --
> tfehttp://tfeserver.be
>
> On 19 f=E9v, 16:55, trashman.horli...@btinternet.com wrote:
>
>
>
> > Hi everyone,
> > I'm just starting to use regex to do some pattern matching but the
> > syntax is a little confusing. I'm using some of
> > the on-line regex checkers, but they all fail the following test:
>
> > regex /\bTest\s*,/i
> > look for Test, (or test, etc.)
> > - result: failure
>
> > I can't see anything wrong. Can anyone suggest whats amiss?
>
> > TIA
>
> > Paul- Hide quoted text -
>
> - Show quoted text -
Thanks mate. I do actually need the "," to be a part of the regex
string.
By the way, looking at some examples of regex, I see constructs like
this:
[_\W]{0,3}
Isn't this just the same as [\w\W]{0,3} ?
------------------------------
Date: 19 Feb 2007 08:25:33 -0800
From: trashman.horlicks@btinternet.com
Subject: Re: Regex confusion
Message-Id: <1171902333.845388.91570@j27g2000cwj.googlegroups.com>
Sorry, got confused. What I meant to say was: I am trying to construct
a regex that will check for
"test," (not the quotes)
"Test,"
"Test ,"
"test ,"
"Test ,"
plus any combination of upper and lower cases, plus whitespace between
"test" and ","
TIA
Paul
------------------------------
Date: 19 Feb 2007 10:01:01 -0800
From: "kens" <kenslaterpa@hotmail.com>
Subject: Re: Regex confusion
Message-Id: <1171908061.376976.315770@p10g2000cwp.googlegroups.com>
On Feb 19, 10:55 am, trashman.horli...@btinternet.com wrote:
> Hi everyone,
> I'm just starting to use regex to do some pattern matching but the
> syntax is a little confusing. I'm using some of
> the on-line regex checkers, but they all fail the following test:
>
> regex /\bTest\s*,/i
> look for Test, (or test, etc.)
> - result: failure
>
> I can't see anything wrong. Can anyone suggest whats amiss?
>
> TIA
>
> Paul
Post actual code & sample input.
Such as:
use strict;
use warnings;
while (<DATA>)
{
chomp();
if ( /\bTest\s*,/i )
{
print "MATCHED: >>$_<<\n";
}
else
{
print "NOT MATCHED: >>$_<<\n";
}
}
__DATA__
test,
Test,
Test ,
test ,
Test ,
Ken
------------------------------
Date: Mon, 19 Feb 2007 12:44:13 -0800
From: sl123@netherlands.area
Subject: Re: Regex confusion
Message-Id: <rk2kt29bitvfslomlvd5o6n1vhr2soi25b@4ax.com>
On 19 Feb 2007 07:55:12 -0800, trashman.horlicks@btinternet.com wrote:
>Hi everyone,
>I'm just starting to use regex to do some pattern matching but the
>syntax is a little confusing. I'm using some of
>the on-line regex checkers, but they all fail the following test:
>
>regex /\bTest\s*,/i
>look for Test, (or test, etc.)
>- result: failure
>
>I can't see anything wrong. Can anyone suggest whats amiss?
>
>TIA
>
>Paul
/\btest\s*,+/i
------------------------------
Date: 19 Feb 2007 18:07:17 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: Regex: Why is overreaching necessary?
Message-Id: <53u7alF1tpe38U1@mid.dfncis.de>
Shannon Jacobs <Shannon.Jacobs.nospam@gmail.com> wrote in comp.lang.perl.misc:
> On Feb 17, 10:58 am, anno4...@radom.zrz.tu-berlin.de wrote:
> > Shannon Jacobs <sha...@cashette.com> wrote in comp.lang.perl.misc:
[...]
> > > I currently have .* in my first version above) so that it only considers 4
> > > digits at a time. Here is some sample data from the file.
> >
> > > The Brethren 20010210282239 Fa
> > > Gorilla, My Love 19810211042240 HF
> > > KeitaiDenwaNoHimitsu 200102110722412242 JaChCS
> > > Harry Potter and the Philosopher's Stone199702111722362243 Fa
> >
> > > In this example the first and fourth lines are proper matches against 2239
> > > and 2243, respectively, but the third line is an undesired match against
> > > 1224. The problem as I see it is that the two things I'm thinking about
> > > inserting should communicate with each other so that they always consume a
> > > total of 8 characters, thereby forcing the target to consider only four
> > > characters at a time.
> >
> > Try this variant:
> >
> > @foo2 = grep substr( $_, 50, 12 ) =~
> > /^(?:\d{4}){0,2}$form_values{'a_SEARCH_VALUE'}/,
> > @foo1;
> >
> > Essentially that ties the pattern to the beginning of the substring,
> > then allows zero to two groups of four digits before a match.
> >
> > Anno
>
> Sorry, but that doesn't work. I think it's because it picks up the
> false matches when it has no groups of four digits before the match.
It doesn't pick up false matches from the sample you supplied.
> Somehow it needs to be limited to considering only four source digits
> at a time, or to think that there is a non-digit boundary between the
> two groups of four digits.
>
> (I don't think it matters, and I tested it both ways, but I think it
> should be
>
> @foo2 = grep substr( $_, 50, 12 ) =~
> /^(?:.{4}){0,2}$form_values{'a_SEARCH_VALUE'}/,
> @foo1;
>
> rather than your version. The data file may have spaces,
Then your sample data should have included such a case.
> and I think
> that \d wouldn't count them at that point.)
You are more permissive than the data requires. If you want to allow
blanks, allow blanks:
/^(?:[\d ]{4}){0,2}$form_values{'a_SEARCH_VALUE'}/
Anno
------------------------------
Date: Mon, 19 Feb 2007 21:03:32 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: Regex: Why is overreaching necessary?
Message-Id: <erd3b4$23tr$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
<anno4000@radom.zrz.tu-berlin.de>], who wrote in article <53n5qdF1t3p29U1@mid.dfncis.de>:
> Try this variant:
>
> @foo2 = grep substr( $_, 50, 12 ) =~
> /^(?:\d{4}){0,2}$form_values{'a_SEARCH_VALUE'}/,
> @foo1;
May be better, may be worse than the "obvious":
@foo2 = grep /^(.50) # Start at pos=50
(?:\d{4}){0,2}$form_values{'a_SEARCH_VALUE'}
(?!.{63}) # Do not allow pos>62
/sx, @foo1;
Hope this helps,
Ilya
------------------------------
Date: Mon, 19 Feb 2007 18:24:42 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Regexp for email addresses.
Message-Id: <d2njt2pg2kuu395dba97nnvjq3blr9kvr9@4ax.com>
On 19 Feb 2007 04:51:38 -0800, "cmic" <cmic@caramail.com> wrote:
>THX Michele
>BTW, your signature worth it, too !
Well, I've been only an occasional obfu player. If you need an
explanation, it's available at <http://perlmonks.org/?node_id=410408>.
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Mon, 19 Feb 2007 20:52:55 +0100
From: Mark Clements <mark.clementsREMOVETHIS@wanadoo.fr>
Subject: Re: Sending commands to a secondary prompt
Message-Id: <45da0017$0$25954$ba4acef3@news.orange.fr>
sanjeeb wrote:
> Hello,
> Is there any way to send parameters to a secondary command prompt
> through perl script.
> Suppose there is a command XYZ , which when invoked gives another
> secondary prompt. I want to send command to the secondary prompt and
> will do the rest of the task after that.
>
> e.g
> c:\XYZ <ENTER>
> Spec-
> OS: Win Xp
> Build : 5.8
I'm not entirely sure what you're after, but try
Expect
http://search.cpan.org/~rgiersig/Expect-1.20/Expect.pod
Mark
------------------------------
Date: 19 Feb 2007 12:01:16 -0800
From: ehabaziz2001@gmail.com
Subject: which is more powerfull ?
Message-Id: <1171915276.013101.268570@a75g2000cwd.googlegroups.com>
I need to process some files to create new one with OMR marks . which
is more powerfull in processing files ? awk/sed or perl or others ?
Thanks
------------------------------
Date: Mon, 19 Feb 2007 20:38:01 GMT
From: David Harmon <source@netcom.com>
Subject: Re: which is more powerfull ?
Message-Id: <460b0a62.152745890@news.west.earthlink.net>
On 19 Feb 2007 12:01:16 -0800 in comp.lang.perl.misc,
ehabaziz2001@gmail.com wrote,
>I need to process some files to create new one with OMR marks . which
>is more powerfull in processing files ? awk/sed or perl or others ?
>Thanks
BEFORE POSTING read the welcome message posted twice per week in
comp.lang.c++ under the subject "Welcome to comp.lang.c++! Read this
first." or available at http://www.slack.net/~shiva/welcome.txt
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>
Administrivia:
#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc. For subscription or unsubscription requests, send
#the single line:
#
# subscribe perl-users
#or:
# unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.
#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V11 Issue 152
**************************************