[31431] in Perl-Users-Digest
Perl-Users Digest, Issue: 2683 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 20 00:09:43 2009
Date: Thu, 19 Nov 2009 21: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, 19 Nov 2009 Volume: 11 Number: 2683
Today's topics:
Re: FAQ 4.50 How do I select a random element from an a (David Combs)
Handling two signal handler <sanjeeb25@gmail.com>
Re: Handling two signal handler (Jens Thoms Toerring)
Re: How link it takes when line protocol drops and rout <tadmc@seesig.invalid>
How to get at the perl options sharma__r@hotmail.com
Re: How to get at the perl options <ben@morrow.me.uk>
Re: How to get at the perl options <uri@StemSystems.com>
Re: How to get at the perl options <nospam-abuse@ilyaz.org>
Re: How to get at the perl options <uri@StemSystems.com>
How to get cell value excel in perl <cyrusgreats@gmail.com>
Re: How to get cell value excel in perl <cyrusgreats@gmail.com>
Re: Perl to use and create PHP sessions? <sysadmin@example.com>
Re: Perl to use and create PHP sessions? <cartercc@gmail.com>
Re: regexp that seems not to work since 5.10 <derykus@gmail.com>
Re: regexp that seems not to work since 5.10 <scottalorda@libello.com>
sos <robin1@cnsp.com>
Re: sos <xhoster@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 19 Nov 2009 06:06:51 +0000 (UTC)
From: dkcombs@panix.com (David Combs)
Subject: Re: FAQ 4.50 How do I select a random element from an array?
Message-Id: <he2n9r$lrr$5@reader1.panix.com>
In article <061120091303535357%brian.d.foy@gmail.com>,
brian d foy <brian.d.foy@gmail.com> wrote:
>In article
><7f36e87f-d06b-4479-afdb-62e6d92cd5b6@k4g2000yqb.googlegroups.com>,
>m!thun <m0t0rbr3th@gmail.com> wrote:
>
>> On Nov 4, 11:00 am, PerlFAQ Server <br...@theperlreview.com> wrote:
>
>> > my $element = $array[ rand @array ];
>
>> Wouldn't this be safer?
>>
>> $element = $array[ int( rand @array ) ];
>
>Array and slice indices are already converted to integers for you. :)
Now an obvious question, and answer easy enough to find for each who
is interested, but maybe more efficient if answer is added
to the faq:
HOW does the (real) index get converted to integer subscript?
Floor, Ceiling, some .5-rule, or what?
David
------------------------------
Date: Thu, 19 Nov 2009 08:06:54 -0800 (PST)
From: sanjeeb <sanjeeb25@gmail.com>
Subject: Handling two signal handler
Message-Id: <8e7d1f5b-85a1-44c5-b1ef-3262759e6921@x5g2000prf.googlegroups.com>
Hi,
I have a application which multiple modules. Each module do some task.
I have a signal handler defined in the main.pl which is the starting
point to run the application.
I want to define signal handler in each module which will do specific
task and again raised a signal which will be handled by the global
signal handler.
The signal to be caught are same throughout, not specific to any class
or the global handler.
Scenario :
application.pl define a a signal handler &globalhandler
application.pl creates a object out of foo.pm and foo.pm defines
a handle &foo_cleaner
when the execution is under the context of foo.pm object , a
INT signal caught. It will clean up the required things populated
by foo.pm and then raised the same signal from foo_cleaner. After
raising the &globalhandler should be called means the global handler
will be caught.
I tried but didnt succeded.
Do you have guys any idea whether there is some way out???
Can i get two handlers with the same signal???
------------------------------
Date: 19 Nov 2009 17:24:49 GMT
From: jt@toerring.de (Jens Thoms Toerring)
Subject: Re: Handling two signal handler
Message-Id: <7mldb1F3h6iauU1@mid.uni-berlin.de>
sanjeeb <sanjeeb25@gmail.com> wrote:
> I have a application which multiple modules. Each module do some task.
> I have a signal handler defined in the main.pl which is the starting
> point to run the application.
> I want to define signal handler in each module which will do specific
> task and again raised a signal which will be handled by the global
> signal handler.
> The signal to be caught are same throughout, not specific to any class
> or the global handler.
> Scenario :
> application.pl define a a signal handler &globalhandler
> application.pl creates a object out of foo.pm and foo.pm defines
> a handle &foo_cleaner
> when the execution is under the context of foo.pm object , a
What do you mean with "the context of foo.pm object"?
> INT signal caught. It will clean up the required things populated
> by foo.pm and then raised the same signal from foo_cleaner. After
> raising the &globalhandler should be called means the global handler
> will be caught.
> I tried but didnt succeded.
> Do you have guys any idea whether there is some way out???
> Can i get two handlers with the same signal???
You can have only a single signal handler for each signal. So
if the signal has been dealt with by foo_cleaner() then it's
used up. Raising it again would only lead to foo_cleaner() being
called again as long as it's still installed as the handler for
that signal.
What you can do is to simply call global_handler() from
foo_cleaner(). You can figure out its address by inspecting
the value of $SIG{INT} before you install foo_cleaner() as
the new signal handler. I.e. do
my $old_handler = $SIG{ INT };
$SIG{ INT } = \&new_handler;
sub new_handler {
do_something;
&$old_handler( @_ );
}
Regards, Jens
--
\ Jens Thoms Toerring ___ jt@toerring.de
\__________________________ http://toerring.de
------------------------------
Date: Wed, 18 Nov 2009 21:25:08 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: How link it takes when line protocol drops and route to be removed from route table
Message-Id: <slrnhg9ef6.hd8.tadmc@tadbox.sbcglobal.net>
Obama <cyrusgreats@gmail.com> wrote:
> Does anyone know how long it takes for PBR
Pabst Blue Ribbon is brewed in less than a week.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Thu, 19 Nov 2009 10:49:57 -0800 (PST)
From: sharma__r@hotmail.com
Subject: How to get at the perl options
Message-Id: <80523fd7-1527-4320-ba8b-032fbd95af1e@a39g2000pre.googlegroups.com>
Hi,
Is there a way to capture the perl options in a command like this:
perl -w -S script.pl
@ARGV holds the options script.pl & onwards. What I want are the the
perl options (in this case:
-w, -S ) also.
------------------------------
Date: Thu, 19 Nov 2009 22:58:59 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: How to get at the perl options
Message-Id: <j6vgt6-bdk2.ln1@osiris.mauzo.dyndns.org>
Quoth sharma__r@hotmail.com:
>
> Is there a way to capture the perl options in a command like this:
> perl -w -S script.pl
>
> @ARGV holds the options script.pl & onwards. What I want are the the
> perl options (in this case:
> -w, -S ) also.
Some of them (like -w) show up as magic variables: see perldoc perlvar.
I don't believe that applies to -S.
Ben
------------------------------
Date: Thu, 19 Nov 2009 19:21:18 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to get at the perl options
Message-Id: <87iqd682rl.fsf@quad.sysarch.com>
>>>>> "BM" == Ben Morrow <ben@morrow.me.uk> writes:
BM> Quoth sharma__r@hotmail.com:
>>
>> Is there a way to capture the perl options in a command like this:
>> perl -w -S script.pl
>>
>> @ARGV holds the options script.pl & onwards. What I want are the the
>> perl options (in this case:
>> -w, -S ) also.
BM> Some of them (like -w) show up as magic variables: see perldoc perlvar.
BM> I don't believe that applies to -S.
and a better question is why do you want them? i have never seen anyone
ask for these in 16 years of hacking perl. what purpose could you have
to want this info? those are options to make perl do certain things and
there are plenty of them. also perl can use environment variables to set
some things that options can also do. you can't tell where the settings
came from. i smell a major XY problem here where your real problem is X
but you are asking about your solution which is Y.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Fri, 20 Nov 2009 02:49:54 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How to get at the perl options
Message-Id: <slrnhgc0uh.stc.nospam-abuse@powdermilk.math.berkeley.edu>
On 2009-11-20, Uri Guttman <uri@StemSystems.com> wrote:
> BM> Some of them (like -w) show up as magic variables: see perldoc perlvar.
> BM> I don't believe that applies to -S.
>
> and a better question is why do you want them? i have never seen anyone
> ask for these in 16 years of hacking perl.
I need them very much. See the ugly hacks done in perl debugger to
implement even the brain-damaged version of `R' command.
Getting "the @wholeARGV" would be very useful in many situations...
As the minimum, consider remote debugging scenario...
Yours,
Ilya
------------------------------
Date: Thu, 19 Nov 2009 23:23:39 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: How to get at the perl options
Message-Id: <87eint7rjo.fsf@quad.sysarch.com>
>>>>> "IZ" == Ilya Zakharevich <nospam-abuse@ilyaz.org> writes:
IZ> On 2009-11-20, Uri Guttman <uri@StemSystems.com> wrote:
BM> Some of them (like -w) show up as magic variables: see perldoc perlvar.
BM> I don't believe that applies to -S.
>>
>> and a better question is why do you want them? i have never seen anyone
>> ask for these in 16 years of hacking perl.
IZ> I need them very much. See the ugly hacks done in perl debugger to
IZ> implement even the brain-damaged version of `R' command.
IZ> Getting "the @wholeARGV" would be very useful in many situations...
IZ> As the minimum, consider remote debugging scenario...
trivial then. write a c (or other lang wrapper), grab all the argv, then
call perl and pass argv to it. but it makes little sense for needing all
of the options when some apply to perl and some apply to your app. if
you want that control, do the above. i leave it as an exercise to the
reader.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Thu, 19 Nov 2009 17:15:37 -0800 (PST)
From: Obama <cyrusgreats@gmail.com>
Subject: How to get cell value excel in perl
Message-Id: <93974cf9-afd3-4b95-8868-caf048371405@g1g2000pra.googlegroups.com>
Hi good people:
I need to get value of the cell so I can split by : and do some
calculation,the format of numbers is like
12:03:20. Is there any way that I can get the value of the cell in
perl...thanks in advance..
my $workbook = Spreadsheet::WriteExcel->new($out);
my $worksheet = $workbook->add_worksheet("Result");
my $t1 = xl_rowcol_to_cell(2, 4); # E2
my $t2 = xl_rowcol_to_cell(2, 5); # F2
my ($t1_h, $t1_min, $t1_sec) = split (/\:/, $t1);
my ($t2_h, $t2_min, $t2_sec) = split (/\:/, $t1);
my $delta= $worksheet->write('G2', '=$t2_h - t1_h', $unlocked);
But it doesn't work!
------------------------------
Date: Thu, 19 Nov 2009 18:12:58 -0800 (PST)
From: Obama <cyrusgreats@gmail.com>
Subject: Re: How to get cell value excel in perl
Message-Id: <239f04a8-d27f-4cbf-84bf-77ceb824ed20@u16g2000pru.googlegroups.com>
>What was your first indication that it failed?
> Have you tried using a debugger? They are very useful.--Andrew DeFariaSometimes too much drink is not enough.
The value I get is E2....E400, so I can't split it and the
calculation, what I need is to get the value of the cell not columns
number!
------------------------------
Date: Wed, 18 Nov 2009 19:30:09 -0800
From: Wanna-Be Sys Admin <sysadmin@example.com>
Subject: Re: Perl to use and create PHP sessions?
Message-Id: <6Z2Nm.26528$Zu5.19178@newsfe24.iad>
Ben Morrow wrote:
...
>
> One rather crude approach would be to write a minimal PHP script that
> just dumps all the session variables (as plain text, or JSON, or
> something) and then invoke that script using LWP from your perl
> scripts, passing along all the appropriate cookie headers. If you are
> able to it would probably be a good idea to disallow access to that
> URL from outside your site.
>
> Any other approach is going to have to start by giving Perl some sort
> of access to the php sessions file. Whether that means changing its
> permissions, running perl as the appropriate user, or writing some
> sort of daemon running as the right user that will read the file for
> you is up to you. All have their upside and downsides, and all would
> need careful consideration of any possible security implications.
>
> Ben
Unfortunately, anything related to changing the existing PHP code the
other developers wrote, including asking them to open permissions, or
run PHP so it runs as the user as well, are all out of the question.
This is a company system, but I still don't want to open too great of
permissions for any sessions that will house anything related to the
login info, and no non staff should have access, but it's still
something I won't want sitting there (especially readable from any PHP
script running as the web server user). The sessions I've created only
store non sensitive information per user and connection, so I'm not
concerned about that portion, but if PHP needs those credentials, then
all bets are off anyway. I am thinking that I'll just have to tell
them to "use the same login credentials" if they want/need to access
the area of the web interface I'm creating, because nothing else is a
problem and it needn't impose any security concerns (whereas working
with existing PHP sessions probably will by the looks of it).
Perhaps, I can find some method to read the cookies to see if a session
file exists (such as in /tmp) and assume if the session exists and
their cookie has any session login credentials (which will match the
login checks anyway), that the session is valid and just create a new
one for my area, they'll be shot back to the PHP session if they go
back to that area. A little difficult to explain, but I think the
difference in ownership and permissions across the PHP user and CGI
user, just present too much of an issue, unless the PHP developers were
willing to pass a specific argument my script(s) could check to verify
and existing session. Besides, trying to work with one, and knowing
the session should still be valid, isn't something I'd want to only
rely upon and further checks would be required anyway. Maybe I'll just
break down and try and recode it in PHP, but I'll save that for later
if needed. Thanks for the input.
--
Not really a wanna-be, but I don't know everything.
------------------------------
Date: Thu, 19 Nov 2009 11:14:40 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Perl to use and create PHP sessions?
Message-Id: <29d50790-2ff0-4569-815f-dc52e95d64e1@m16g2000yqc.googlegroups.com>
On Nov 18, 7:41=A0pm, Wanna-Be Sys Admin <sysad...@example.com> wrote:
> To put it plainly, it's a centralized login, and once someone logs into
> the main area (PHP driven), they should be able to use my contributed
> scripts without logging in again by just following a link normally, and
> then go back to a PHP driven area once they are done (if they choose
> to). =A0Ideally, if they hit my scripts first and log in there, they
> should be able to not have to log into the PHP area either.
I'm not at all familiar with PHP, but have written a fair amount of
ColdFusion and JSP. My approach to sessions is to use a database for
the current sessions. Any script that can access the database can
authenticate the user and validate the session (or create the new
session).
In my web apps, sessions are application wide, database driven, and
don't depend on cookies. I've never had the problem you've described
(but then, I don't know anything about PHP.)
CC.
------------------------------
Date: Wed, 18 Nov 2009 20:26:45 -0800 (PST)
From: "C.DeRykus" <derykus@gmail.com>
Subject: Re: regexp that seems not to work since 5.10
Message-Id: <90597e94-cc36-415c-8017-240086247587@u36g2000prn.googlegroups.com>
On Nov 18, 8:37=A0am, S=E9bastien Cottalorda <scottalo...@libello.com>
wrote:
> On 18 nov, 15:41, "C.DeRykus" <dery...@gmail.com> wrote:
> ...
>
> I even tried this:
> my $endcar =3D ACK.'|'.NACK.'|'.ETX.'.';
> my $line =3D 'hello World'.ETX.'XHow are you today ?'.ETX.'XWell, not so
> bad.'.ETX.'X';
> while ($line =3D~ s/([[:^cntrl:]]*($endcar))//){
> and it works perfectly but it's a particular case : I suppose that
> split caracters are controls.
>
> but this regexp didn't work with :
> my $endcar =3D ACK.'|'.NACK.'|'.ETX.'.';
> my $line =3D STX.'hello World'.ETX.'X'.ACK.NACK.STX.'How are you
> today ?'.ETX.'X'.ACK.STX.'Well, not so bad.'.ETX.NACK;
> Unfortunately I need to make that last sample to work.
Here's a closer cut I think since you were negating
the character class:
my $endcar =3D STX . '|' . ACK . '|' . NACK . '|' . ETX ;
while ($line =3D~ s/([[:cntrl:]]*($endcar))//){
...
}
print $line;
Case 1:
my $line =3D 'hello World'.ETX.'XHow are you today
?'.ETX.'XWell, not so
output: hello WorldXHow are you today ?XWell, not so
bad.X
Case 2:
my $line =3D STX.'hello World'.ETX.'X'.ACK.NACK.STX.'How are you
today ?'.ETX.'X'.ACK.STX.'Well, not so bad.'.ETX.NACK;
output: hello WorldXHow are you
today ?XWell, not so bad.
--
Charles DeRykus
------------------------------
Date: Wed, 18 Nov 2009 23:28:21 -0800 (PST)
From: =?ISO-8859-1?Q?S=E9bastien_Cottalorda?= <scottalorda@libello.com>
Subject: Re: regexp that seems not to work since 5.10
Message-Id: <88d8dd4c-3ae5-46d5-8e84-0b65dd2dc2e8@m16g2000yqc.googlegroups.com>
Found a solution with the help of Olivier Makinen.
use constant STX => chr( hex('02'));
use constant ETX => chr( hex('03'));
use constant ACK => chr( hex('06'));
use constant NACK => chr( hex('15'));
my $line = STX.'hello World'.ETX.'X'.ACK.NACK.STX.'How are you
today ?'.ETX.'X'.ACK.STX.'Well, not so bad.'.ETX.NACK;
my $noendcar = '[^' . ACK . ETX . NACK . ']';
my $endstring = '(' . ACK . '|' . ETX . '.|' . NACK . ')';
while ($line =~ s/$noendcar*$endstring//) {
print "buf=$&\n";
}
print "lastbuffer = $line\n";
I obtains:
buf={STX}hello World{ETX}X
buf={ACK}
buf={NACK}
buf={STX}How are you today ?{ETX}X
buf={ACK}
buf={STX}Well, not so bad.{ETX}X
buf={NACK}
lastbuffer = .... (empty)
It works perfectly.
Thanks all for your help.
Sebastien
------------------------------
Date: Thu, 19 Nov 2009 18:06:33 -0800 (PST)
From: Robin <robin1@cnsp.com>
Subject: sos
Message-Id: <440b9e2a-77ae-4224-8e02-a2d162b66c94@s15g2000yqs.googlegroups.com>
I was never allowed to do much of anything by our known ethereal world
which is a secret government project or an alien race.
Tey tried to sacraficce me. My name is Robin Bank. It is not
impossible that they got their evil way and sacrificed me if you are
reading this and killed myself.
Please make me into a messiah and a martyr by doing language helpinbg
by asking people "What is the solution to language helping" and then
doing the solution they give you and making things better in the
world.
I also want you to walk all over the place and help people out doing
the same thinng with strangers all over the place.
I also want you to make things better in the world by inventing and
publishing things and publishing things and keeping things clean.
I also want to spread the word to the world about doing these things I
told youy to do to make me into a martyr and a messiah.
The reason why I want you to do them is that it will set a good
example.
------------------------------
Date: Thu, 19 Nov 2009 21:06:12 -0800
From: Xho Jingleheimerschmidt <xhoster@gmail.com>
Subject: Re: sos
Message-Id: <4b0623f2$0$6753$ed362ca5@nr5-q3a.newsreader.com>
Robin wrote:
> I was never allowed to do much of anything by our known ethereal world
> which is a secret government project or an alien race.
Well, have you tried using string eval?
Or at least turning off strict?
Xho
------------------------------
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 2683
***************************************