[29648] in Perl-Users-Digest
Perl-Users Digest, Issue: 892 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 30 16:09:43 2007
Date: Sun, 30 Sep 2007 13:09:06 -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 Sun, 30 Sep 2007 Volume: 11 Number: 892
Today's topics:
Re: [NEWBIE] Trivial? <elvis-85363@notatla.org.uk>
in what array do all the $1,$2,... live? jidanni@jidanni.org
Re: in what array do all the $1,$2,... live? <mritty@gmail.com>
Re: in what array do all the $1,$2,... live? <see.sig@rochester.rr.com>
Re: Problem installing IO::Compress::Base <joliver@john-oliver.net>
Re: Problem installing IO::Compress::Base sisyphus1@optusnet.com.au
Re: SOAP timing out <raherh@gmail.com>
Re: SOAP timing out <perl4hire@softouch.on.ca>
Re: string concatentation vs. interpolation: which one <hjp-usenet2@hjp.at>
Re: the camel perl book <1usa@llenroc.ude.invalid>
Re: Using fcntl and |= - "Argument .... isn't numeric i <allergic-to-spam@no-spam-allowed.org>
Re: using IPC::Open3 to write to *and* read from a proc xhoster@gmail.com
Re: using IPC::Open3 to write to *and* read from a proc <elvis-85363@notatla.org.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 30 Sep 2007 00:37:18 GMT
From: all mail refused <elvis-85363@notatla.org.uk>
Subject: Re: [NEWBIE] Trivial?
Message-Id: <slrnfftrsf.f1l.elvis-85363@notatla.org.uk>
On 2007-09-29, El Bandolero <el_bandolero@libero.it> wrote:
> I'm solving an exercise studying on a tutorial
>
> The task is to print the (empty or not) lines of a file numbering only the
> non empty ones.
nl -bt
--
Elvis Notargiacomo master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
------------------------------
Date: Sun, 30 Sep 2007 10:03:10 +0800
From: jidanni@jidanni.org
Subject: in what array do all the $1,$2,... live?
Message-Id: <87odfk29lt.fsf@jidanni.org>
What is the name of the array where all the $1,$2,... live?
Or do I really need to gather them up manually:
@all_the_matches=($1,$2,$3,$4,$5,...);
man perlvar doesn't mention it.
------------------------------
Date: Sat, 29 Sep 2007 19:30:25 -0700
From: Paul Lalli <mritty@gmail.com>
Subject: Re: in what array do all the $1,$2,... live?
Message-Id: <1191119425.818655.321660@g4g2000hsf.googlegroups.com>
On Sep 29, 10:03 pm, jida...@jidanni.org wrote:
> What is the name of the array where all the $1,$2,... live?
There isn't one by default.
> Or do I really need to gather them up manually:
> @all_the_matches=($1,$2,$3,$4,$5,...);
You can. You don't need to.
> man perlvar doesn't mention it.
No, but perlop tells you:
If the "/g" option is not used, "m//" in list
context returns a list consisting of the
subexpressions matched by the parentheses in the
pattern, i.e., ($1, $2, $3...).
So just evaluate your pattern match in list context (ie, assign it to
an array), and you've got your $1, $2, $3, etc variables:
my $str = "foo bar baz";
my @matches = $str =~ /(\w+) (\w+) (\w+)/;
# @matches = ('foo', 'bar', 'baz)
Paul Lalli
------------------------------
Date: Sat, 29 Sep 2007 22:58:18 -0400
From: Bob Walton <see.sig@rochester.rr.com>
Subject: Re: in what array do all the $1,$2,... live?
Message-Id: <46ff1075$0$16490$4c368faf@roadrunner.com>
jidanni@jidanni.org wrote:
> What is the name of the array where all the $1,$2,... live?
> Or do I really need to gather them up manually:
> @all_the_matches=($1,$2,$3,$4,$5,...);
> man perlvar doesn't mention it.
Well, you can easily put them all in whatever array you want:
use strict;
use warnings;
my $string='abc';
my @array=$string=~/(.)(.)(.)/;
print join ':',@array;
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 29 Sep 2007 18:10:10 GMT
From: John Oliver <joliver@john-oliver.net>
Subject: Re: Problem installing IO::Compress::Base
Message-Id: <slrnfft596.8ko.joliver@ns.sdsitehosting.net>
On Fri, 28 Sep 2007 20:22:00 +0100, Ben Morrow wrote:
>
> Quoth John Oliver <joliver@john-oliver.net>:
><snip>
>> # Failed test (t/01misc.t at line 29)
>> # You don't have the XS version of Scalar::Util
>
> Seems fairly self-explanatory to me... you need to (re-)install
> Scalar::Util, so you get the XS version.
For the archives, as inevitably someone will email me about this in two
years... :-)
This was fixed by removing and reinstalling all perl packages (RHEL 5).
There is no Scalar::Util::XS and no way that I can see of determining
whether or not Scalar::Util is "XS" or not. I mention this because
Google was of no help whatsoever with this... a few mentions of others
getting the same error, but no explanations of how
to determine whether or not you're installing an "XS" version of
Scalar::Util This was probably one of the packages installed via RPM,
and it's a complete mystery to me how from one install I do not have XS
but another I do. I know nothing about perl other than to (try to)
install whatever modules a given program needs, and I know i'm not the
only one in that boat :-)
--
* John Oliver http://www.john-oliver.net/ *
------------------------------
Date: Sat, 29 Sep 2007 18:04:44 -0700
From: sisyphus1@optusnet.com.au
Subject: Re: Problem installing IO::Compress::Base
Message-Id: <1191114284.022197.31920@g4g2000hsf.googlegroups.com>
On Sep 30, 4:10 am, John Oliver <joli...@john-oliver.net> wrote:
> but no explanations of how
> to determine whether or not you're installing an "XS" version of
> Scalar::Util
Yes - I didn't spot any such explanation.
At the beginning of the Scalar-List-Utils Makefile.PL you'll find:
my $do_xs = can_cc();
where 'can_cc' is a Module::Install sub. The return of 'can_cc'
determines whether it's an XS build or a pure perl build.
The IO::Compress::Base test file (01misc.t) determines whether you
have the XS or pure perl version of Scalar::Util by calling the
CompTestUtils.pm subroutine 'gotScalarUtilXS' which looks like:
sub gotScalarUtilXS
{
eval ' use Scalar::Util "dualvar" ';
return $@ ? 0 : 1 ;
}
Apparently, 'dualvar' is available only with the xs build.
(CompTestUtils.pm is part of the IO::Compress::Base source.)
Cheers,
Rob
------------------------------
Date: Sat, 29 Sep 2007 20:00:38 +0000
From: rahed <raherh@gmail.com>
Subject: Re: SOAP timing out
Message-Id: <uy7eptf6h.fsf@gmail.com>
Amer Neely <perl4hire@softouch.on.ca> writes:
> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server
> was unable to process request. ---> Object reference not set to an
> instance of an object.</faultstring><detail
> /></soap:Fault></soap:Body></soap:Envelope>
You've got to fiddle with SOAPAction and probably other things as
described in "SOAP::Lite client with a .NET server" section of SOAP::Lite
docs.
--
Radek
------------------------------
Date: Sat, 29 Sep 2007 16:24:11 -0400
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Re: SOAP timing out
Message-Id: <quyLi.774$xa2.24@read2.cgocable.net>
rahed wrote:
> Amer Neely <perl4hire@softouch.on.ca> writes:
>
>> <?xml version="1.0" encoding="utf-8"?><soap:Envelope
>> xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
>> xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>> xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>Server
>> was unable to process request. ---> Object reference not set to an
>> instance of an object.</faultstring><detail
>> /></soap:Fault></soap:Body></soap:Envelope>
>
> You've got to fiddle with SOAPAction and probably other things as
> described in "SOAP::Lite client with a .NET server" section of SOAP::Lite
> docs.
>
It seems fiddling is all I've been doing for the past week or so :) I'll
do some more. For all its hype I'm not impressed with the .NET <-> SOAP
interoperability.
--
Amer Neely
w: www.webmechanic.softouch.on.ca/
Perl | MySQL programming for all data entry forms.
"Others make web sites. We make web sites work!"
------------------------------
Date: Sat, 29 Sep 2007 21:47:50 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: string concatentation vs. interpolation: which one is more optimal?
Message-Id: <slrnfftav6.dpl.hjp-usenet2@zeno.hjp.at>
On 2007-09-29 15:17, rihad <rihad@mail.ru> wrote:
> On Sep 29, 7:04 pm, "Peter J. Holzer" <hjp-usen...@hjp.at> wrote:
>> the time difference between
>>
>> perl -e '$a=$b=303; print "$a $b" for 1..39999999' > /dev/null
>>
>> and
>>
>> perl -e '$a=$b=303; print $a." ".$b for 1..39999999' > /dev/null
>>
>> is real on some machines (it is very noticable on my Core2 in 32 bit
>> mode (19.3 vs. 15.5 seconds) less noticable on a Core2 in 64 bit mode or
>> a P4, and unmeasurable on a PIII - perl 5.8.8 in all cases), so the code
>> can't be the same. Either the output of perl -MO=Concise is wrong or at
>
> Try running each test several times and comparing the average times.
I did that, of course. The timings are stable to about 0.2 seconds -
much less than the difference. (Hardly surprising for a program which is
almost completely CPU bound).
The difference almost vanishes if the builtin variables $a and $b are
replaced by lexical variables:
#!/usr/bin/perl
use warnings;
use strict;
my ($x, $y);
$x=$y=303; print "$x $y" for 1..39999999;
takes 17.70s, 17.70s, 17.80s user time in three successive runs.
#!/usr/bin/perl
use warnings;
use strict;
my ($x, $y);
$x=$y=303; print $x." ".$y for 1..39999999;
takes 17.57s, 17.44s, 17.59s user time in three successive runs.
I was running the scripts alternately to reduce the influence of other
task potentially running at the same time. The concatenation version
still seems a bit faster, but that could be a measurement error.
Note that the timings are now almost exactly between the timings for the
same scripts with $a and $b - one got faster and the other slower.
Using our gives similar results as my, except that it's about 2 seconds
faster and now the interpolating version is consistently a tiny bit
faster.
So it could be some wierd interaction with $a and $b, although I haven't
the slightest idea what it could be.
(Another unexpected result is that all of these scripts get quite a lot
slower if I use the string "303" instead of the number 303).
hp
--
_ | Peter J. Holzer | I know I'd be respectful of a pirate
|_|_) | Sysadmin WSR | with an emu on his shoulder.
| | | hjp@hjp.at |
__/ | http://www.hjp.at/ | -- Sam in "Freefall"
------------------------------
Date: Sun, 30 Sep 2007 16:13:44 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: the camel perl book
Message-Id: <Xns99BB7C6596E3Basu1cornelledu@127.0.0.1>
"Wade Ward" <zaxfuuq@invalid.net> wrote in
news:sc2dncoreJGVlmPbnZ2dnUVZ_gqdnZ2d@comcast.com:
> I have questions from the
> the camel perl book.
>
>
> http://www.zaxfuuq.net/beatdowninabq1.htm
>
All your personalities belong to my killfile.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>
------------------------------
Date: Sun, 30 Sep 2007 09:01:28 +0200 (CEST)
From: Jim Cochrane <allergic-to-spam@no-spam-allowed.org>
Subject: Re: Using fcntl and |= - "Argument .... isn't numeric in bitwise or ..."
Message-Id: <slrnffuie2.rcc.allergic-to-spam@no-spam-allowed.org>
On 2007-09-29, Ben Morrow <ben@morrow.me.uk> wrote:
>
> Quoth Jim Cochrane <allergic-to-spam@no-spam-allowed.org>:
>>
>> I'm stumped - trying to get rid of a warning message with code based on
>> this example snippet from the "Perl Cookbook" book:
>>
>> use Fcntl;
>>
>> $lags = "";
>> fcntl(HANDLE, F_GETFL, $flags) or die "Couldn't get flags: $!\n";
>
> You need to read you systems fcntl(2) as well as the perldocs; at least
> on mine, it says
>
> F_GETFL Get descriptor status flags, as described below (arg is
> ignored).
>
> So, contrary to the example in perldoc -f fcntl, you need
>
> my $flags = fcntl(HANDLE, F_GETFL);
>
This appears to be wrong. It looks like fcntl takes 3 arguments with
F_GETFL, even though the 3rd arg is not passed as a reference. (Trying
it with just 2 args -
$flags = fcntl($handle, F_GETFL) or die "Could not get flags: $!";
produces the error:
Not enough arguments for fcntl at ./exp8.pl line 37, near "F_GETFL) "
)
However, it looks like the answer to my question is that the warning
occurs because the example is based on old code that does not 'use
warnings' and thus does not produce a warning message unless 'use
warnings' is added. I found that instead of doing this, which produced
the warning:
fcntl($file, F_GETFL, $flags) or die "Could not get flags: $!";
$flags |= O_NONBLOCK;
fcntl($file, F_SETFL, $flags) or die "Could not set flags: $!";
doing it this way does not produce a warning:
fcntl($file, F_GETFL, $flags) or die "Could not get flags: $!";
fcntl($file, F_SETFL, $flags | O_NONBLOCK) or die "Could not set flags: $!";
So to answer my own question, the warning is expected and the best way
to get rid of it is to simply use the latter form instead of changing
the value of $flags with |=.
--
------------------------------
Date: 29 Sep 2007 23:06:20 GMT
From: xhoster@gmail.com
Subject: Re: using IPC::Open3 to write to *and* read from a process...
Message-Id: <20070929190622.928$6k@newsreader.com>
Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth RU <ru@vakuum.de>:
> >
> > I'm currently working on some cluster scripts which, among other
> > things, need to start and stop oracle. The typical (/bin/sh) nasty
> > cluster script does something like:
> >
> > #!/bin/sh
> > su -m oracle -c "sqlplus / as sysdba"<<_EOF_
> > startup
> > _EOF_
>
> Firstly, I know very little about Oracle, but my impression is that
> sqlplus just ends up sending SQL to the server? In which case, you can
> likely do the whole thing from Perl with DBI, and not bother trying to
> script an external binary at all.
When used in this way, sqlplus does something special, and is not simply a
client connection. It starts up a database that wasn't previously running.
I'm pretty sure that DBI would be unable to do this.
Having looked at the attempted Perl code (snipped) I'm now trying to figure
out why the above is nasty. It looks remarkably nice to me.
Xho
--
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.
------------------------------
Date: 30 Sep 2007 00:33:19 GMT
From: all mail refused <elvis-85363@notatla.org.uk>
Subject: Re: using IPC::Open3 to write to *and* read from a process...
Message-Id: <slrnfftrl3.f1l.elvis-85363@notatla.org.uk>
On 2007-09-29, RU <ru@vakuum.de> wrote:
> Hi Folks,
>
> I'm currently working on some cluster scripts which, among other things,
> need to start and stop oracle. The typical (/bin/sh) nasty cluster
> script does something like:
>
> #!/bin/sh
> su -m oracle -c "sqlplus / as sysdba"<<_EOF_
> startup
> _EOF_
Nasty is right - that clutters syslog with potentially vast numbers
of useless (discuss this opinion with your security bods if nec)
entries of su from root to oracle.
Do the $( $) $) $> $< thing in Perl instead of calling su.
If you kept the record of open fd's structured in relation
to their process
%my_procs_with_fds={
100 => [ 0, 1, 2 ],
500 => [ 0, 1, 2 ]
);
couldn't you scratch all fd's for a particular process even
if you don't see it close?
--
Elvis Notargiacomo master AT barefaced DOT cheek
http://www.notatla.org.uk/goen/
------------------------------
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 892
**************************************