[31747] in Perl-Users-Digest
Perl-Users Digest, Issue: 3010 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 30 06:09:20 2010
Date: Wed, 30 Jun 2010 03:09:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 30 Jun 2010 Volume: 11 Number: 3010
Today's topics:
Expect: line endings? <zebeej@gmail.com>
Re: Expect: line endings? <josef.moellers@ts.fujitsu.com>
How to find the end of a word in perl.. <soorajspadmanabhan@gmail.com>
Re: How to find the end of a word in perl.. <jurgenex@hotmail.com>
Re: How to find the end of a word in perl.. <smallpond@juno.com>
Re: How to find the end of a word in perl.. <jurgenex@hotmail.com>
Re: How to find the end of a word in perl.. <justin.0911@purestblue.com>
Re: How to find the end of a word in perl.. <derykus@gmail.com>
Re: How to find the end of a word in perl.. <derykus@gmail.com>
Re: How to generate random number without replacement? <tzz@lifelogs.com>
P5NCI Library for AIX <sachinvpatil26@gmail.com>
Re: P5NCI Library for AIX <ben@morrow.me.uk>
Re: Proposing a new module: Parallel::Loops <tzz@lifelogs.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 30 Jun 2010 01:15:52 +0000 (UTC)
From: Zebee Johnstone <zebeej@gmail.com>
Subject: Expect: line endings?
Message-Id: <slrni2l6m8.bi4.zebeej@gmail.com>
I"m using Expect.pm to log into an HP ILO (management card for HP
Prliant servers) but I'm getting odd results. I'm not sure if it's
because I'm using Expect incorrectly or if the HP is in some odd way
incompatible.
The problem seems to be that the second exp->expect statement either
doesn't run or isn't sent. Or else the /n it ends with isn't sent.
Either way it doesn't seem to produce output. Should I be expecting
to see output? I certainly see the login output.
It says an EOF doesn't show up, what sort of EOF is it looking for, do
I need to tell it to look for something other than the hpiLO prompt
presumably between the 2 exp->expect statements?
Here's the code:
#!/usr/bin/perl
use warnings;
use strict;
use Expect;
my $username = "username";
my $box = "ILOcard";
my $password = "password";
my $timeout=100;
my $exp = new Expect;
$exp->raw_pty(1);
$exp->debug(2);
$exp->log_file("hplog");
$exp->spawn("ssh $box -l $username") or die "Cannot spawn ssh : $!\n";
my $spawn_ok;
$exp->expect($timeout, ['assword:', sub {my $self = shift; $self->send("$password\n");}]);
$exp->expect($timeout, ['hpiLO->', sub {my $self = shift; $self->send("show /map1\n");}]);
$exp->send("\n");
# Destroy the expect object
$exp->soft_close();
Here's what an interactive session looks like:
<localbox>$ ssh ILOcard -l username
username@ILOcard's password:
User:username logged-in to ILOcard.(10.0.1.1)
iLO 2 Advanced 1.80 at 10:12:14 Oct 30 2009
Server Name: ILOcard
Server Power: On
</>hpiLO-> show /map1
status=0
status_tag=COMMAND COMPLETED
/map1
Targets
firmware1
accounts1
[...] #no need to show all output
</>hpiLO-> exit
And here's what the session from the script looks like. Note that the
debug shows the end session called before the show /map1 is given, and
the map1 output never shows up.
Spawned 'ssh ILOcard -l username'
spawn id(3)
Pid: 29291
Tty: /dev/pts/64
Expect::spawn('Expect=GLOB(0x278f1c)', 'ssh ILOcard
-l username') called at o
ldhpmgmt.pl line 22
Starting EXPECT pattern matching...
Expect::expect('Expect=GLOB(0x278f1c)', 100,
'ARRAY(0x29039c)') called at oldhpmgmt.pl line 2
9
username@ILOcard's password: Starting EXPECT pattern
matching...
Expect::expect('Expect=GLOB(0x278f1c)', 100,
'ARRAY(0x224f54)') called at oldhpmgmt.pl line 3
0
User:username logged-in to ILOcard.(10.120.220.122)
iLO 2 Advanced 1.80 at 10:12:14 Oct 30 2009
Server Name: ILOcard
Server Power: On
</>hpiLO-> Closing spawn id(3).
Expect::soft_close('Expect=GLOB(0x278f1c)') called at
oldhpmgmt.pl line 35
show /map1Timed out waiting for an EOF from spawn id(3).
spawn id(3) closed.
Pid 29291 of spawn id(3) exited, Status: 0x01
Closing spawn id(3).
Expect::hard_close('Expect=GLOB(0x278f1c)') called at
/usr/perl5/site_perl/5.8.4/Expect.pm li
ne 1621
Expect::DESTROY('Expect=GLOB(0x278f1c)') called at
oldhpmgmt.pl line 0
eval {...} called at oldhpmgmt.pl line 0
<localbox>$
------------------------------
Date: Wed, 30 Jun 2010 09:04:13 +0200
From: Josef Moellers <josef.moellers@ts.fujitsu.com>
Subject: Re: Expect: line endings?
Message-Id: <i0eq8d$umu$1@nntp.fujitsu-siemens.com>
Am 30.6.2010 schrub Zebee Johnstone:
> I"m using Expect.pm to log into an HP ILO (management card for HP
> Prliant servers) but I'm getting odd results. I'm not sure if it's
> because I'm using Expect incorrectly or if the HP is in some odd way
> incompatible.
At times, Expect can be very confusing and tiresome.
> The problem seems to be that the second exp->expect statement either
> doesn't run or isn't sent. Or else the /n it ends with isn't sent.
You don't send linefeeds ("\n"), you send carriage-returns ("\r")!
The machine will, most likely, respond with a carriage-return/linefeed
combination ("\r\n"), that you should be aware of, although the exact
order may very well not be specified, so I usually expect that as "[\r\n]+".
> Either way it doesn't seem to produce output. Should I be expecting
> to see output? I certainly see the login output.
There is one very useful method:
$exp->exp_internal(0 | 1);
It will tell you what exactly Expect receives and what it is looking for.
Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef Möllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html
------------------------------
Date: Tue, 29 Jun 2010 03:42:21 -0700 (PDT)
From: Sooraj S <soorajspadmanabhan@gmail.com>
Subject: How to find the end of a word in perl..
Message-Id: <931d082a-93cf-4afd-b23a-7ba9fb33fc73@w31g2000yqb.googlegroups.com>
Hi,
My data file :
-------------------
// abc def
//
// abc dser
//
----------------------
i want to remove the lines 2 and 4 from the file.
check criteria : line should start with // and one or more spaces only
as the other characters.
i tried this .. if (/^\/\/(\s)*/ ... but it shows entire lines..
How to do it using regular expressions ? Is there any way to find the
end of a word using regular expressions ?
------------------------------
Date: Tue, 29 Jun 2010 03:56:10 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to find the end of a word in perl..
Message-Id: <4qjj26d3dbvva7d7sfekb0gnprfblqm1lm@4ax.com>
Sooraj S <soorajspadmanabhan@gmail.com> wrote:
>Hi,
>
>My data file :
>-------------------
>// abc def
>//
>// abc dser
>//
>----------------------
>i want to remove the lines 2 and 4 from the file.
>
>check criteria : line should start
^
> with //
//
>and one or more spaces only
+ (that is a space character followed by a plus sign)
>as the other characters.
$
So the whole RE becomes
(^// +$)
>i tried this .. if (/^\/\/(\s)*/ ... but it shows entire lines..
>
>How to do it using regular expressions ?
You are plenking.
>Is there any way to find the
>end of a word using regular expressions ?
Sure, from 'perldoc perlre':
Assertions
Perl defines the following zero-width assertions:
\b Match a word boundary
But what does that question have to do with your earlier problem
statement?
jue
------------------------------
Date: Tue, 29 Jun 2010 09:22:39 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: How to find the end of a word in perl..
Message-Id: <i0cs36$n1r$1@news.eternal-september.org>
Jürgen Exner wrote:
> Sooraj S <soorajspadmanabhan@gmail.com> wrote:
>> How to do it using regular expressions ?
>
> You are plenking.
>
Thanks for the new word.
------------------------------
Date: Tue, 29 Jun 2010 07:30:58 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: How to find the end of a word in perl..
Message-Id: <jq0k26pohamp65g6a4okn22kto6jfvf33a@4ax.com>
Steve C <smallpond@juno.com> wrote:
>Jürgen Exner wrote:
>> Sooraj S <soorajspadmanabhan@gmail.com> wrote:
>>> How to do it using regular expressions ?
>>
>> You are plenking.
>
>Thanks for the new word.
Nothing new about it: http://en.wikipedia.org/wiki/Plenk
jue
------------------------------
Date: Tue, 29 Jun 2010 14:26:16 -0000
From: Justin C <justin.0911@purestblue.com>
Subject: Re: How to find the end of a word in perl..
Message-Id: <cb5.4c2a0288.39155@zem>
On 2010-06-29, Sooraj S <soorajspadmanabhan@gmail.com> wrote:
> Hi,
>
> My data file :
> -------------------
> // abc def
> //
> // abc dser
> //
> ----------------------
> i want to remove the lines 2 and 4 from the file.
>
> check criteria : line should start with // and one or more spaces only
> as the other characters.
>
> i tried this .. if (/^\/\/(\s)*/ ... but it shows entire lines..
>
> How to do it using regular expressions ? Is there any way to find the
> end of a word using regular expressions ?
I think you want a '+' where you have '*'. '*' means 'any number of
times including 0'. '+' means 'at least once'.
However, that will still match the lines that you want to keep. You have
the '^' to match at the beginning of the string. If only there was
something to match the end of the string...
Justin.
PS Regex word boundary = \b
--
Justin C, by the sea.
------------------------------
Date: Tue, 29 Jun 2010 22:07:54 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: How to find the end of a word in perl..
Message-Id: <65df9192-0274-41a9-a81a-d5e94a8e12f0@p22g2000pre.googlegroups.com>
On Jun 29, 3:42=A0am, Sooraj S <soorajspadmanab...@gmail.com> wrote:
> Hi,
>
> My data file :
> -------------------
> // abc def
> //
> // =A0 =A0abc dser
> //
> ----------------------
> i want to remove the lines 2 and 4 from the file.
>
> check criteria : line should start with // and one or more spaces only
> as the other characters.
>
> i tried this .. =A0if (/^\/\/(\s)*/ ... but it shows entire lines..
>
> How to do it using regular expressions ? Is there any way to find the
> end of a word using regular expressions ?
If non-whitespace is the secondary criterion for validity:
print if m{^ // \s+ (?=3D.*?\S) }x; # plenken/klempen frei
--
Charles DeRykus
------------------------------
Date: Tue, 29 Jun 2010 23:20:07 -0700 (PDT)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: How to find the end of a word in perl..
Message-Id: <d37d16be-592b-4c3f-8950-4a879c7f965b@z34g2000pro.googlegroups.com>
On Jun 29, 10:07=A0pm, "C.DeRykus" <dery...@gmail.com> wrote:
> On Jun 29, 3:42=A0am, Sooraj S <soorajspadmanab...@gmail.com> wrote:
>
>
>
> > Hi,
>
> > My data file :
> > -------------------
> > // abc def
> > //
> > // =A0 =A0abc dser
> > //
> > ----------------------
> > i want to remove the lines 2 and 4 from the file.
>
> > check criteria : line should start with // and one or more spaces only
> > as the other characters.
>
> > i tried this .. =A0if (/^\/\/(\s)*/ ... but it shows entire lines..
>
> > How to do it using regular expressions ? Is there any way to find the
> > end of a word using regular expressions ?
>
> If non-whitespace is the secondary criterion for validity:
>
> print if m{^ // \s+ (?=3D.*?\S) }x; =A0# plenken/klempen frei
>
or lookahead free too:
print if m{^ // \s+ \S }x;
--
Charles DeRykus
------------------------------
Date: Tue, 29 Jun 2010 09:37:14 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: How to generate random number without replacement?
Message-Id: <87aaqddhwl.fsf@lifelogs.com>
On Sat, 26 Jun 2010 21:02:19 +0200 "Peter J. Holzer" <hjp-usenet2@hjp.at> wrote:
PJH> On 2010-06-26 18:05, David Combs <dkcombs@panix.com> wrote:
>> In article <87y6exwo6o.fsf@lifelogs.com>,
>> Ted Zlatanov <tzz@lifelogs.com> wrote:
>>> On Tue, 01 Jun 2010 15:37:34 -0400 "Uri Guttman" <uri@StemSystems.com> wrote:
>>>
UG> he said he wanted 1k random numbers out of a large range so a hash would
UG> be fine for that.
>>>
>>> You're right, I wasn't paying enough attention.
>>
>> What, you're saying a div and a mod (let's assume 64 bits, if integet) to
>> find the desired bit, versus dealing each time with a hash bucket to choose
>> an ensuing chain to hunt down through?
>>
>> So you make the bucket-array longer, so the chains are short -- get it
>> long enough so only very, very few chains are longer than one (most
>> being zero) in length, and you're almost emulating the bit-vector
>> scheme, but taking up FAR FAR more space.
PJH> No, for the use case given (1k random numbers out of a large range) a
PJH> hash takes *less* space.
PJH> The bit vector takes (max-min)/8 bytes. So for 0 .. 100_000_000 it takes
PJH> approximately 12.5 MB. 1000 hash entries take (depending on pointer
PJH> size, malloc implementation, etc.) something like 60 to 150 kB. So
PJH> that's about 1/100th of the space. I'd still think a bit vector should
PJH> be faster.
Right. I somehow missed the 1K sample requirement and thought this was
for any set of random numbers. Certainly a bit vector has better O(n)
performance but the requirement is very far from hitting any O(n)
bounds. Also as Peter pointed out memory usage is really high.
Finally, Perl's hashes are very well optimized so I'd rely on them over
Bit::Vector for performance with small sets.
If I expected *clusters* of numbers in a large space, like say Unicode
codepoints, I would use inversion lists
(http://search.cpan.org/~teodor/Algorithm-InversionList-0.03/). If the
domain was 32-bit or smaller ints and I expected at least 10% to be
randomly picked, I would use Bit::Vector. For almost all other
reasonable use cases, though, hashes would work better.
Ted
------------------------------
Date: Tue, 29 Jun 2010 23:14:12 -0700 (PDT)
From: Sachin Patil <sachinvpatil26@gmail.com>
Subject: P5NCI Library for AIX
Message-Id: <b77165f7-0ac2-424c-ba5c-707625bb5705@y21g2000pro.googlegroups.com>
I downloaded P5NCI-0.30 from CPAN and tried to build it.
I am doing this on AIX platform.
After extracting and cd to P5NCI-0.30, I tried
perl Makefile.PL
and it is working fine.
bash-3.00# perl Makefile.PL
# running Build.PL
Creating new 'MYMETA.yml' with configuration results
Creating new 'Build' script for 'P5NCI' version '0.31'
Unknown 'build_class', defaulting to 'Module::Build'
After that i run make but it is giving below error message.
bash-3.00# make
/usr/local/bin/perl Build --makefile_env_macros 1
gcc -maix32 -I/usr/local/lib/perl5/5.10.0/aix/CORE -c -D_ALL_SOURCE -
D_ANSI_C_SOURCE -D_POSIX_SOURCE -DUSE_NATIVE_DLOPEN -fno-strict-
aliasing -pipe -D_LARGE_FILES -O -o src/nci_test.o src/nci_test.c
Use of uninitialized value $baseext in substitution (s///) at /usr/
local/lib/perl5/5.10.0/ExtUtils/CBuilder/Platform/aix.pm line 17.
Use of uninitialized value $args{"dl_file"} in substitution (s///) at /
usr/local/lib/perl5/5.10.0/ExtUtils/CBuilder/Base.pm line 194.
Insufficient information specified to Mksymlists at /usr/local/lib/
perl5/5.10.0/ExtUtils/CBuilder/Base.pm line 197
make: 1254-004 The error code from the last command is 9.
Does any one use this library on AIX platform?
Regards
Sachin
------------------------------
Date: Wed, 30 Jun 2010 08:38:53 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: P5NCI Library for AIX
Message-Id: <dt8rf7-fdf.ln1@osiris.mauzo.dyndns.org>
Quoth Sachin Patil <sachinvpatil26@gmail.com>:
> I downloaded P5NCI-0.30 from CPAN and tried to build it.
> I am doing this on AIX platform.
>
> After extracting and cd to P5NCI-0.30, I tried
> perl Makefile.PL
> and it is working fine.
>
> bash-3.00# perl Makefile.PL
> # running Build.PL
> Creating new 'MYMETA.yml' with configuration results
> Creating new 'Build' script for 'P5NCI' version '0.31'
> Unknown 'build_class', defaulting to 'Module::Build'
>
> After that i run make but it is giving below error message.
> bash-3.00# make
> /usr/local/bin/perl Build --makefile_env_macros 1
> gcc -maix32 -I/usr/local/lib/perl5/5.10.0/aix/CORE -c -D_ALL_SOURCE -
> D_ANSI_C_SOURCE -D_POSIX_SOURCE -DUSE_NATIVE_DLOPEN -fno-strict-
> aliasing -pipe -D_LARGE_FILES -O -o src/nci_test.o src/nci_test.c
> Use of uninitialized value $baseext in substitution (s///) at /usr/
> local/lib/perl5/5.10.0/ExtUtils/CBuilder/Platform/aix.pm line 17.
> Use of uninitialized value $args{"dl_file"} in substitution (s///) at /
> usr/local/lib/perl5/5.10.0/ExtUtils/CBuilder/Base.pm line 194.
> Insufficient information specified to Mksymlists at /usr/local/lib/
> perl5/5.10.0/ExtUtils/CBuilder/Base.pm line 197
> make: 1254-004 The error code from the last command is 9.
>
> Does any one use this library on AIX platform?
I don't, but since P5NCI's Build.PL is unremarkable I suspect this is a
bug in ExtUtils::CBuilder (on AIX). Could you try building something
else straightforward that uses EUCB (DateTime looks like a good
candidate). If it fails in the same way this is an EUCB bug.
Ben
------------------------------
Date: Tue, 29 Jun 2010 09:47:42 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Proposing a new module: Parallel::Loops
Message-Id: <876311dhf5.fsf@lifelogs.com>
On Fri, 25 Jun 2010 23:34:14 +0100 Ben Morrow <ben@morrow.me.uk> wrote:
BM> Personally I find
BM> my %output :shared;
BM> for my $i (@input) {
BM> async {
BM> $output{$i} = do_some_hefty_calculation($i);
BM> }
BM> }
BM> somewhat clearer, but that's just a matter of taste. (With 5.10
BM> presumably a 'my $_' would make $_ work too.)
I personally don't like "inline tagged" code blocks as much as passing
them off to a library subroutine. Inline tagging IMO creates spaghetti
code and is harder to refactor. But I can see the appeal :)
On Tue, 29 Jun 2010 00:06:41 -0700 (PDT) Peter Valdemar Mørch <4ux6as402@sneakemail.com> wrote:
PVM> The problem with a thread pool is that then we need to keep all
PVM> variables synchronized between them. And I'm focusing on forking -
PVM> not threads - here.
Please don't try to make your module do everything for everyone. It's
OK to say "it won't support XYZ." Do a few things well rather than many
things badly.
Ted
------------------------------
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 3010
***************************************