[32041] in Perl-Users-Digest
Perl-Users Digest, Issue: 3305 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 3 06:09:26 2011
Date: Thu, 3 Mar 2011 03:09:08 -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 Thu, 3 Mar 2011 Volume: 11 Number: 3305
Today's topics:
Can't locate Expect.pm <rodbass63@gmail.com>
Re: Can't locate Expect.pm <RedGrittyBrick@spamweary.invalid>
Re: going from CPAN to RPM <justin.1102@purestblue.com>
hash key <nospam.gravitalsun@hotmail.com.nospam>
Re: hash key <ronaldf@eml.cc>
Re: How can you do different things on certain lines in <nospam.gravitalsun@hotmail.com.nospam>
Re: How can you do different things on certain lines in <glex_no-spam@qwest-spam-no.invalid>
Re: How can you do different things on certain lines in <glex_no-spam@qwest-spam-no.invalid>
Re: How can you do different things on certain lines in <tadmc@seesig.invalid>
Re: matching '?' in a string ending with digits sln@netherlands.com
Re: Regular Expressions: Greedy Matching <jimsgibson@gmail.com>
Re: Regular Expressions: Greedy Matching <derykus@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 2 Mar 2011 13:21:13 -0800 (PST)
From: Nene <rodbass63@gmail.com>
Subject: Can't locate Expect.pm
Message-Id: <38338a5b-48e0-4def-b87f-3580ac53d180@r19g2000prm.googlegroups.com>
I'm trying to see if use Net::SSH::Expect; works.
rod001001 rodperl # ./test.pl
Can't locate Expect.pm in @INC (@INC contains: /home/xxxxxx/rodperl /
etc/perl /usr/lib/perl5/site_perl/5.8.5/x86_64-linux /usr/lib/perl5/
site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/
5.8.5/x86_64-linux /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/
vendor_perl /usr/lib/perl5/5.8.5/x86_64-linux /usr/lib/perl5/5.8.5 /
usr/local/lib/site_perl .) at /home/xxxxxx/rodperl/Net/SSH/Expect.pm
line 10.
BEGIN failed--compilation aborted at /home/xxxxxx/rodperl/Net/SSH/
Expect.pm line 10.
Compilation failed in require at ./test.pl line 4.
BEGIN failed--compilation aborted at ./test.pl line 4.
####
This is what test.pl looks like:
#!/usr/bin/perl -w
use lib "/home/xxxxxx/rodperl";
use Net::SSH::Expect;
####
My Expect.pm line 10 is:
1 package Net::SSH::Expect;
2 use 5.008000;
3 use warnings;
4 use strict;
5 use fields qw(
6 host user password port no_terminal escape_char
ssh_option
7 raw_pty exp_internal exp_debug log_file log_stdout
restart_timeout_upon_receive
8 timeout terminator expect debug next_line before match
after binary
9 );
10 use Expect;
####
Things I should tell you.
I compiled all the required modules on a different box and copied over
to another box that does not have a compiler. All the modules were
built with 'perl Makefile.PL PREFIX=/home/xxxxxx/rodperl
On the box I copied all the files to, has identical file directory
structure: /home/xxxxxx/rodperl
Help please.
------------------------------
Date: Thu, 03 Mar 2011 10:07:17 +0000
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Can't locate Expect.pm
Message-Id: <4d6f6854$0$12168$fa0fcedb@news.zen.co.uk>
On 02/03/2011 21:21, Nene wrote:
>
> I'm trying to see if use Net::SSH::Expect; works.
>
> rod001001 rodperl # ./test.pl
> Can't locate Expect.pm in @INC (@INC contains: /home/xxxxxx/rodperl /
> etc/perl /usr/lib/perl5/site_perl/5.8.5/x86_64-linux /usr/lib/perl5/
> site_perl/5.8.5 /usr/lib/perl5/site_perl /usr/lib/perl5/vendor_perl/
> 5.8.5/x86_64-linux /usr/lib/perl5/vendor_perl/5.8.5 /usr/lib/perl5/
> vendor_perl /usr/lib/perl5/5.8.5/x86_64-linux /usr/lib/perl5/5.8.5 /
> usr/local/lib/site_perl .) at /home/xxxxxx/rodperl/Net/SSH/Expect.pm
Note this list of locations.
> line 10.
> BEGIN failed--compilation aborted at /home/xxxxxx/rodperl/Net/SSH/
> Expect.pm line 10.
> Compilation failed in require at ./test.pl line 4.
> BEGIN failed--compilation aborted at ./test.pl line 4.
>
> ####
> This is what test.pl looks like:
> #!/usr/bin/perl -w
>
> use lib "/home/xxxxxx/rodperl";
> use Net::SSH::Expect;
> ####
>
> My Expect.pm line 10 is:
> 1 package Net::SSH::Expect;
> 2 use 5.008000;
> 3 use warnings;
> 4 use strict;
> 5 use fields qw(
> 6 host user password port no_terminal escape_char
> ssh_option
> 7 raw_pty exp_internal exp_debug log_file log_stdout
> restart_timeout_upon_receive
> 8 timeout terminator expect debug next_line before match
> after binary
> 9 );
> 10 use Expect;
^^^^^^^^^^^
This other Expect.pm can't be found in the standard library locations
(nor in /home/xxxxxx/rodperl).
>
> ####
> Things I should tell you.
> I compiled all the required modules on a different box and copied over
> to another box that does not have a compiler. All the modules were
> built with 'perl Makefile.PL PREFIX=/home/xxxxxx/rodperl
>
> On the box I copied all the files to, has identical file directory
> structure: /home/xxxxxx/rodperl
>
You haven't installed Expect (I don't mean Net::SSH::Expect) in one of
the listed locations. If you install Expect this problem will go away.
--
RGB
------------------------------
Date: Wed, 2 Mar 2011 10:56:31 +0000
From: Justin C <justin.1102@purestblue.com>
Subject: Re: going from CPAN to RPM
Message-Id: <vbk148-5ql.ln1@zem.masonsmusic.co.uk>
On 2011-02-28, Art Werschulz <agw@dsm.fordham.edu> wrote:
> Hi all.
>
> Although we have used the CPAN shell to install Perl modules on our
> Linux systems, we would like to use the RPM versions of same instead.
> This means that we need to find out which Perl modules were installed
> via the CPAN shell, nuke same, and then install the RPM versions (say,
> via yum).
>
> How can we find out which Perl modules were installed via the CPAN
> shell?
perldoc -q "which modules are installed"
Justin.
--
Justin C, by the sea.
------------------------------
Date: Wed, 2 Mar 2011 12:07:17 +0200
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: hash key
Message-Id: <ikl4re$11bi$1@ulysses.noc.ntua.gr>
Can anyone explain why 'my' is slower than 'our' ?
# Fast key rettieve
our %hash;
for (1 .. 5_000_000) {$hash{$_}=1}
print "filled\n";
print $hash{153};
# Slow key rettieve
my %hash;
for (1 .. 5_000_000) {$hash{$_}=1}
print "filled\n";
print $hash{153};
------------------------------
Date: Wed, 02 Mar 2011 15:11:12 +0100
From: Ronald Fischer <ronaldf@eml.cc>
Subject: Re: hash key
Message-Id: <1299075072.14@user.newsoffice.de>
George Mpouras wrote as nospam.gravitalsun@hotmail.com.nospam on 02. Mar
2011:
> Can anyone explain why 'my' is slower than 'our' ?
It's not necessarily slower. I modified your program a bit (yours is
giving a warning):
use strict;
use warnings;
our %ohash;
my $t=time;
for (1 .. 5_000_000) {$ohash{$_}=1}
my $d=time-$t;
print "$d\n";
my %mhash;
$t=time;
for (1 .. 5_000_000) {$mhash{$_}=1}
$d=time-$t;
print "$d\n";
$t=time;
for (1 .. 5_000_000) {$ohash{$_}=1}
$d=time-$t;
print "$d\n";
$t=time;
for (1 .. 5_000_000) {$mhash{$_}=1}
$d=time-$t;
print "$d\n";
$t=time;
for (1 .. 5_000_000) {$ohash{$_}=1}
$d=time-$t;
print "$d\n";
So we have the sequence 'our','my','our','my','our'. The execution times
on my platform are:
22
17
8
8
9
Usually I would attribute such differences to the garbage collector,
although I don't see much opportunity for GC here...
Ronald
--
Ronald Fischer <ronaldf@eml.cc>
Posted via http://www.newsoffice.de/
------------------------------
Date: Wed, 2 Mar 2011 12:12:35 +0200
From: "George Mpouras" <nospam.gravitalsun@hotmail.com.nospam>
Subject: Re: How can you do different things on certain lines in a text file divided by separators?
Message-Id: <ikl55c$12a5$1@ulysses.noc.ntua.gr>
"hans" <schatzer.johann@gmail.com> wrote in message
news:b30ae1a2-09be-4e37-96e1-121108ca3880@n18g2000vbq.googlegroups.com...
> How can you do different things on lines in a file divided in rages,
> for example:
>
> aaa
> .
> .
> . insert "aaa" on every line between aaa and bbb
> .
> bbb
> .
> .
> . insert "bbb" on every line between bbb and ccc
> .
> .
> ccc
> .
> . etc.
> .
while(<DATA>)
{
if ( /aaa/ .. /bbb/ ) {
print "line between aaa and bbb : $_" }
if ( /bbb/ .. /ccc/ ) {
print "line between bbb and ccc : $_" }
}
__DATA__
aaa
hello1
hello2
hello3
bbb
world1
world2
world3
ccc
------------------------------
Date: Tue, 01 Mar 2011 16:59:37 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: How can you do different things on certain lines in a text file divided by separators?
Message-Id: <4d6d7a5a$0$73603$815e3792@news.qwest.net>
hans wrote:
> How can you do different things on lines in a file divided in rages,
> for example:
What do you have so far?
perldoc -f open
perldoc perldocfaq6
------------------------------
Date: Tue, 01 Mar 2011 17:02:07 -0600
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: How can you do different things on certain lines in a text file divided by separators?
Message-Id: <4d6d7aef$0$73603$815e3792@news.qwest.net>
J. Gleixner wrote:
> hans wrote:
>> How can you do different things on lines in a file divided in rages,
>> for example:
>
> What do you have so far?
>
> perldoc -f open
> perldoc perldocfaq6
Make that perldoc perlfaq6
------------------------------
Date: Tue, 01 Mar 2011 23:02:06 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: How can you do different things on certain lines in a text file divided by separators?
Message-Id: <slrnimrjgn.v8q.tadmc@tadbox.sbcglobal.net>
hans <schatzer.johann@gmail.com> wrote:
> How can you do different things on lines in a file divided in rages,
---------------------
#!/usr/bin/perl
use warnings;
use strict;
my $prefix;
while (<DATA>) {
if (/^([a-z]{3})$/) {
$prefix = $1;
}
else {
print $prefix;
}
print;
}
__DATA__
aaa
.
.
. insert "aaa" on every line between aaa and bbb
.
bbb
.
.
. insert "bbb" on every line between bbb and ccc
.
.
ccc
.
. etc.
.
---------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Wed, 02 Mar 2011 13:28:52 -0800
From: sln@netherlands.com
Subject: Re: matching '?' in a string ending with digits
Message-Id: <l8btm65s2fv2nv8a85to377epeteecvr43@4ax.com>
On Tue, 1 Mar 2011 04:05:24 +0000 (UTC), "ReMo..." <rameme@gmail.com> wrote:
>On 2011-02-26, C.DeRykus <derykus@gmail.com> wrote:
>> On Feb 26, 12:42?am, "ReMo..." <ram...@gmail.com> wrote:
[snip]
>> As it turns out though, the debug looks to me as
>> if the compilation fails for another reason when
>> the optimizer determines "1000" will occurs at
>> offset 4 or 5 in the pattern which won't match its
>> position at offset 6 in the string being matched.
>
>Using debugging would have definitely pointed me in the right
>direction.
>
>It starts giving an exception one character previous to the
>metacharacter... I think it's checking "d". Then 4..5 may refer
>to the boundary between "d" and "?".
There are ways to physically visualize regular expressions such
that it is a lot easier to read. The easier it is to read, the better.
Think of a regular expression as a 2 dimentional object,
with literals being one dimension X and metacharacters being the other
dimension Y.
--------
This third?1000
is really this:
third 1000
?
where a space is left as a placeholder where ? goes.
Quantifier metachars like +*? affect the thing to its immediate left.
Here, ? affects only the character 'd' it says match 'd'
once or not at all.
So, third1000 or thir1000 will match
-----
This third\?1000
is really this:
third?1000
where ? is now literally a ? not a metacharacter.
It will only match third?1000.
------
This thi(rd)?1000
is really this:
thi rd 1000
( )?
where the quantifier ? has the same meaning but affects
the group of characters enclosed by the parenths ( ).
In this case the parenthesis are grouping metachars.
------
After you get the hang of it, you can structure a
regular expression into a pseudo dimensioned object so
that the quantifiers and other metachars are distinguishable
from the literal text.
/ # regex delimeter
^ # metachar, begining of string
( # metachar, start of grouping 1
third # literal text 'third'
){2} # metachar, end of grouping 1, {range}, match group 1 exactly 2 times
( # beginning of grouping 2
1000 # literal text '1000'
){3} # metachar, end of grouping 2, match group 2 exactly 3 times
$ # metachar, end of string
/x # regex delimeter and x modifier (ignore literal whitespace in expression)
This will only match 'thirdthird100010001000.
When you look at it this way, regular expressions are not confusing at all.
Some herky jerky's jam it all together in a single line to feel superior, just
ignore them.
The first thing you do when trying to decipher one is to convert it into a structure
like above. When its broken down like this its easier.
good luck.
-sln
------------------------------
Date: Tue, 01 Mar 2011 13:10:00 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Regular Expressions: Greedy Matching
Message-Id: <010320111310000901%jimsgibson@gmail.com>
In article
<1f7de2a9-fd67-4db1-b6d3-1da850c956c2@glegroupsg2000goo.googlegroups.com>
, Jose Luis <jose.luis.fdez.diaz@gmail.com> wrote:
> Perl regular expressions normally match the longest string possible, but this
> example prints "a|a". Why does it match?
>
>
> <<snip>>
>
> "aax" =~ m/(^a*)([^x])/;
> print "$1|$2\n" ;
Perl will _start_ with the longest possible match for 'a*' in your
regular expression (because a non-qualified '*' is "greedy"), but if it
fails to match because of what follows, then it will shorten the
sub-match by one character and try again. Since the next character
after the first-matched 'aa' is 'x', and you have specified that the
next character be anything but 'x' ([^x]), the match with 'aa' fails.
Perl tries again with 'a', and since the next 'a' matches [^x], the
match succeeds and "a|a" is printed.
--
Jim Gibson
------------------------------
Date: Tue, 1 Mar 2011 21:01:31 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: Regular Expressions: Greedy Matching
Message-Id: <03b89ff5-5f22-4781-a33f-a04dcde73326@v11g2000prb.googlegroups.com>
On Mar 1, 11:13=A0am, Jose Luis <jose.luis.fdez.d...@gmail.com> wrote:
> Perl regular expressions normally match the longest string possible, but =
this example prints "a|a". Why does it match?
>
> <<snip>>
>
> "aax" =3D~ m/(^a*)([^x])/;
> print "$1|$2\n" ;
>
Maybe you're after one of the below:
m/(^a*)([^x]*)/ # * is 0 or more
m/(^a*)([^x]?)/ # ? is 0 or one
This'll enable a max match of "a" for $1 since
* or ? quantifiers will cause $2 to match even
with zero [^x] characters.
--
Charles DeRykus
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 3305
***************************************