[30937] in Perl-Users-Digest
Perl-Users Digest, Issue: 2182 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 4 16:09:47 2009
Date: Wed, 4 Feb 2009 13:09:12 -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 Wed, 4 Feb 2009 Volume: 11 Number: 2182
Today's topics:
& 1 Samuel 25v42 systemofadownsyndrom3@gmail.com
Re: & 1 Samuel 25v42 <msoloff@verizon.net>
package and "global" vars <oldyork90@yahoo.com>
Re: package and "global" vars <noreply@gunnar.cc>
Re: package and "global" vars <zen13097@zen.co.uk>
Re: package and "global" vars <oldyork90@yahoo.com>
Re: package and "global" vars <oldyork90@yahoo.com>
Re: package and "global" vars <noreply@gunnar.cc>
Re: Regular Expression Help? <valid@email.address>
Re: Regular Expression Help? <ben.usenet@bsb.me.uk>
Re: Regular Expression Help? <tadmc@seesig.invalid>
what is the best way to convert a formatted time to a u <rabbits77@my-deja.com>
Re: what is the best way to convert a formatted time to <noreply@gunnar.cc>
Re: what is the best way to convert a formatted time to <rabbits77@my-deja.com>
Re: what is the best way to convert a formatted time to <rabbits77@my-deja.com>
Re: what is the best way to convert a formatted time to <jurgenex@hotmail.com>
Re: what is the best way to convert a formatted time to <rabbits77@my-deja.com>
Re: what is the best way to convert a formatted time to <tadmc@seesig.invalid>
Re: what is the best way to convert a formatted time to <tadmc@seesig.invalid>
Re: what is the best way to convert a formatted time to <1usa@llenroc.ude.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 4 Feb 2009 00:27:58 -0800 (PST)
From: systemofadownsyndrom3@gmail.com
Subject: & 1 Samuel 25v42
Message-Id: <0632048e-0b1b-4943-9cf0-4bc4b38db6f4@v38g2000yqb.googlegroups.com>
And Abigail hasted, http://mmfactor.blogspot.com/ and arose, and rode
upon an ass, with five damsels of hers that went after her; and she
went after the messengers of David, and became his wife. Please TURN!
to page 288 of your king james green covered bible printed with one
page in korea with me and have a look at this particularly interesting
passage. Numbers 33v41 And they departed from mount hor, and pitched
in zalmonah. what you think I am making this stuff up people?
------------------------------
Date: Wed, 04 Feb 2009 12:28:46 GMT
From: Marv Soloff <msoloff@verizon.net>
Subject: Re: & 1 Samuel 25v42
Message-Id: <2Sfil.1221$eK2.857@nwrddc01.gnilink.net>
systemofadownsyndrom3@gmail.com wrote:
> And Abigail hasted, http://mmfactor.blogspot.com/ and arose, and rode
> upon an ass, with five damsels of hers that went after her; and she
> went after the messengers of David, and became his wife. Please TURN!
> to page 288 of your king james green covered bible printed with one
> page in korea with me and have a look at this particularly interesting
> passage. Numbers 33v41 And they departed from mount hor, and pitched
> in zalmonah. what you think I am making this stuff up people?
Yes.
Marv
------------------------------
Date: Wed, 4 Feb 2009 05:21:18 -0800 (PST)
From: okey <oldyork90@yahoo.com>
Subject: package and "global" vars
Message-Id: <d570daae-1a4d-407b-80c6-c068838cc73c@r36g2000prf.googlegroups.com>
I have a package midway in a perl script. I that package there is a
global at the top called varTwo. No matter what I do, I can access
within the package. Why doesn't the below work? Also tried my, our
and no package name at all.
Thanks.
#================================== begin file here
my $varOne = 'This is var 1.';
print qq{This is var one: $varOne\n}; # prints fine
my $p = new MYPACKAGE();
#=== a package
package MYPACKAGE;
$MYPACKAGE::varTwo = 'This is var two';
sub new {
my $class = shift;
my $self = {};
bless($self, $class);
my $t = $FU::varTwo;
print qq{Inside packet, var two is:$MYPACKAGE::varTwo\n}; #
prints, but no value
return $self;
}
------------------------------
Date: Wed, 04 Feb 2009 15:50:47 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: package and "global" vars
Message-Id: <6utoa9FgfpjeU1@mid.individual.net>
okey wrote:
> I have a package midway in a perl script. I that package there is a
> global at the top called varTwo. No matter what I do, I can access
> within the package. Why doesn't the below work? Also tried my, our
> and no package name at all.
> Thanks.
>
>
> #================================== begin file here
> my $varOne = 'This is var 1.';
> print qq{This is var one: $varOne\n}; # prints fine
>
> my $p = new MYPACKAGE();
>
> #=== a package
> package MYPACKAGE;
>
> $MYPACKAGE::varTwo = 'This is var two';
>
> sub new {
> my $class = shift;
> my $self = {};
> bless($self, $class);
> my $t = $FU::varTwo;
> print qq{Inside packet, var two is:$MYPACKAGE::varTwo\n}; #
> prints, but no value
> return $self;
> }
Because assignment happens at runtime, and you create the MYPACKAGE
object before the assignment of $MYPACKAGE::varTwo.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 04 Feb 2009 14:53:56 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: package and "global" vars
Message-Id: <4989ac04$0$16157$db0fefd9@news.zen.co.uk>
On Wed, 4 Feb 2009 05:21:18 -0800 (PST), okey <oldyork90@yahoo.com> wrote:
> I have a package midway in a perl script. I that package there is a
> global at the top called varTwo. No matter what I do, I can access
> within the package. Why doesn't the below work? Also tried my, our
It *does* "work", it just doesn't do what you're expecting.
> and no package name at all.
> Thanks.
perl runs the code in order...
> #================================== begin file here
> my $varOne = 'This is var 1.';
> print qq{This is var one: $varOne\n}; # prints fine
So first it runs this:
> my $p = new MYPACKAGE();
which calls new(), which prints the current value of varTwo (i.e.
undef).
> #=== a package
> package MYPACKAGE;
and *then* it gets to this line where it sets the value of varTwo.
> $MYPACKAGE::varTwo = 'This is var two';
One solution to your problem is to wrap the initialisation in
a BEGIN{} block, i.e:
BEGIN { $MYPACKAGE::varTwo = 'This is var two'; }
------------------------------
Date: Wed, 4 Feb 2009 06:59:52 -0800 (PST)
From: okey <oldyork90@yahoo.com>
Subject: Re: package and "global" vars
Message-Id: <244c083f-b629-4f12-8e12-5e74a16ea694@x16g2000prn.googlegroups.com>
Thank you much.
------------------------------
Date: Wed, 4 Feb 2009 07:32:01 -0800 (PST)
From: okey <oldyork90@yahoo.com>
Subject: Re: package and "global" vars
Message-Id: <755d113a-ad15-4ef5-8648-7119824d5a7a@40g2000prx.googlegroups.com>
> =A0BEGIN { =A0$MYPACKAGE::varTwo =3D 'This is var two'; }
Is there a way to initialize all these types of "globals" in a single
step.
I suspect one way would be to move the package to the top.
------------------------------
Date: Wed, 04 Feb 2009 18:21:36 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: package and "global" vars
Message-Id: <6uu151FhekglU1@mid.individual.net>
okey wrote:
>> BEGIN { $MYPACKAGE::varTwo = 'This is var two'; }
>
> Is there a way to initialize all these types of "globals" in a single
> step.
> I suspect one way would be to move the package to the top.
First you ought to ask yourself if that's really what you want to do. If
you put "package MYPACKAGE" in the module MYPACKAGE.pm, and use or
require it, the assignment takes place before the next step in your main
program.
use MYPACKAGE;
my $p = new MYPACKAGE();
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 4 Feb 2009 18:52:28 +0900
From: "Trespasser" <valid@email.address>
Subject: Re: Regular Expression Help?
Message-Id: <4989655b$0$18772$5a62ac22@per-qv1-newsreader-01.iinet.net.au>
Hi Tim,
Thanks very much for responding to my regular expression query.
^www\..[^.]+\.domain\.com$
Yes, this is the corrected form of the example expression. Sorry about the
mix up.
> What about domain.com? Will you want to be matching
> www.something.example.com, still as well?
I've just discovered that I can create DNS A records from URLs of the
www.something.example.com form. This form of match is interesting as well. I
think the example trigger expression is intended to accommodate this form,
but not the www.domain.com and username.domain.com forms as well.
Yes, triggering on username.domain.com and otherusername.domain.com, but not
on www.domain.com is the single focus my interest here. I can't figure how
to write a regular expression that triggers on the 3-tier URL, but not if
the first word is www.
Any suggestions, Tim?
Regards,
Tressie.
"Tim Greer" <tim@burlyhost.com> wrote in message
news:xA8il.1918$ml6.1098@newsfe09.iad...
> Trespasser wrote:
>
>> Hi,
>>
>> I can appreciate what a wonderfully powerful tool regular expressions
>> are, but I am still learning and seem to need a little help.
>>
>> I have an example of a regular expression for an Apache server
>> mod_rewrite module rewrite trigger condition.
>>
>> ^www.\.[^.]+\.domain\.com$
>
> You probably don't want ^www.\., but ^www\. instead.
>
>> As far as I can gather this is supposed to match
>> www.username.domain.com, where 'username' could be any system user's
>> username or other alphanumeric character sequence.
>>
>> Can anyone please tell me how I can modify this type of regular
>> expression as follows? I want the rule to match for sequences like
>> username.domain.com and otherusername.domain.com, but specifically not
>> to match for www.domain.com.
>
> What about domain.com? Will you want to be matching
> www.something.example.com, still as well?
> --
> Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
> Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
> and Custom Hosting. 24/7 support, 30 day guarantee, secure servers.
> Industry's most experienced staff! -- Web Hosting With Muscle!
------------------------------
Date: Wed, 04 Feb 2009 14:05:06 +0000
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Regular Expression Help?
Message-Id: <87tz7a5mct.fsf@bsb.me.uk>
"Trespasser" <valid@email.address> writes:
> Thanks very much for responding to my regular expression query.
>
> ^www\..[^.]+\.domain\.com$
>
> Yes, this is the corrected form of the example expression. Sorry about the
> mix up.
Tim suggested /^www\.[^.]+\.domain\.com$/. You still have an extra
'.' in there.
>> What about domain.com? Will you want to be matching
>> www.something.example.com, still as well?
>
> I've just discovered that I can create DNS A records from URLs of the
> www.something.example.com form. This form of match is interesting as well. I
> think the example trigger expression is intended to accommodate this form,
> but not the www.domain.com and username.domain.com forms as well.
>
> Yes, triggering on username.domain.com and otherusername.domain.com, but not
> on www.domain.com is the single focus my interest here. I can't figure how
> to write a regular expression that triggers on the 3-tier URL, but not if
> the first word is www.
Perl has a negative look-behind that can be used when the string you
must avoid is fixed length:
/(?<!www)\.domain\.com$/
but this may not be what you want. Note the ^ has gone. This meets
the narrow interpretation of your request but may not do what want
with names like www.other.domain.com (matches) and
other.www.domain.com (it does not match). I think that was the force
of Tim's clarifying question.
--
Ben.
------------------------------
Date: Wed, 4 Feb 2009 06:24:21 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: Regular Expression Help?
Message-Id: <slrngoj27l.d2n.tadmc@tadmc30.sbcglobal.net>
Trespasser <valid@email.address> wrote:
> Hi Tim,
>
> Thanks very much for responding to my regular expression query.
>
> ^www\..[^.]+\.domain\.com$
>
> Yes, this is the corrected form of the example expression.
That will match
www..user.domain.com
...
> Yes, triggering on username.domain.com and otherusername.domain.com, but not
> on www.domain.com is the single focus my interest here. I can't figure how
> to write a regular expression that triggers on the 3-tier URL, but not if
> the first word is www.
>
> Any suggestions, Tim?
I am not Tim, yet I have a suggestion.
Use a negative lookahead assertion:
-----------------------------
#!/usr/bin/perl
use warnings;
use strict;
foreach my $domain ( qw/ www.domain.com www.something.domain.com
username.domain.com otherusername.domain.com
wwwfoobar.domain.com / ) {
print "$domain matched\n"
if $domain =~ /^(?!www\.)[^.]+\.domain\.com$/;
}
-----------------------------
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 04 Feb 2009 12:22:22 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: what is the best way to convert a formatted time to a unix epoch
Message-Id: <65d40$4989ced3$d0365e7a$24855@news.eurofeeds.com>
x-no-archive: yes
What is the best way to convert a formatted time to a
unix "time since epoch"?
So, I have a string like
2009-02-3 21:31:29
and I want that converted to the number of milliseconds since the unix
epoch. What is the best way to do this?
------------------------------
Date: Wed, 04 Feb 2009 18:37:06 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <6uu223Fha597U1@mid.individual.net>
rabbits77 wrote:
> x-no-archive: yes
>
> What is the best way to convert a formatted time to a
> unix "time since epoch"?
> So, I have a string like
> 2009-02-3 21:31:29
> and I want that converted to the number of milliseconds since the unix
> epoch. What is the best way to do this?
To get epoch seconds, Time::Local is your friend. If you don't want to
parse the time string yourself, you may want to use Date::Parse.
I don't see a need for milliseconds here, but if that's really what you
want, Time::HiRes might be helpful.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 04 Feb 2009 12:46:42 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <d971$4989d478$c6509b06$25055@news.eurofeeds.com>
x-no-archive: yes
Gunnar Hjalmarsson wrote:
> rabbits77 wrote:
>> x-no-archive: yes
>>
>> What is the best way to convert a formatted time to a
>> unix "time since epoch"?
>> So, I have a string like
>> 2009-02-3 21:31:29
>> and I want that converted to the number of milliseconds since the unix
>> epoch. What is the best way to do this?
>
> To get epoch seconds, Time::Local is your friend. If you don't want to
> parse the time string yourself, you may want to use Date::Parse.
>
> I don't see a need for milliseconds here, but if that's really what you
> want, Time::HiRes might be helpful.
You may not see a need but I assure you what I am working on needs it. ;)
------------------------------
Date: Wed, 04 Feb 2009 12:47:27 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <821ca$4989d4a5$c6509b06$25055@news.eurofeeds.com>
x-no-archive: yes
Gunnar Hjalmarsson wrote:
> rabbits77 wrote:
>> x-no-archive: yes
>>
>> What is the best way to convert a formatted time to a
>> unix "time since epoch"?
>> So, I have a string like
>> 2009-02-3 21:31:29
>> and I want that converted to the number of milliseconds since the unix
>> epoch. What is the best way to do this?
>
> To get epoch seconds, Time::Local is your friend. If you don't want to
> parse the time string yourself, you may want to use Date::Parse.
>
> I don't see a need for milliseconds here, but if that's really what you
> want, Time::HiRes might be helpful.
Thanks!
------------------------------
Date: Wed, 04 Feb 2009 09:57:59 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <9iljo41c3mc0bfvqnmsjau160mns565fve@4ax.com>
rabbits77 <rabbits77@my-deja.com> wrote:
>What is the best way to convert a formatted time to a
>unix "time since epoch"?
See "perldoc -q epoch":
How can I take a string and turn it into epoch seconds?
>So, I have a string like
>2009-02-3 21:31:29
>and I want that converted to the number of milliseconds since the unix
>epoch. What is the best way to do this?
You don't. Your input data only has a resolution of seconds. There is no
point in computing the output to milliseconds and pretending to have a
resolution that is three orders of magnitude higher than your input
provides.
jue
------------------------------
Date: Wed, 04 Feb 2009 14:24:03 -0500
From: rabbits77 <rabbits77@my-deja.com>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <dfc7$4989eb57$c6509b06$6676@news.eurofeeds.com>
x-no-archive: yes
Jürgen Exner wrote:
> rabbits77 <rabbits77@my-deja.com> wrote:
>> What is the best way to convert a formatted time to a
>> unix "time since epoch"?
>
> See "perldoc -q epoch":
> How can I take a string and turn it into epoch seconds?
>
>> So, I have a string like
>> 2009-02-3 21:31:29
>> and I want that converted to the number of milliseconds since the unix
>> epoch. What is the best way to do this?
>
> You don't. Your input data only has a resolution of seconds. There is no
> point in computing the output to milliseconds and pretending to have a
> resolution that is three orders of magnitude higher than your input
> provides.
I left out part of the data.
I really have a string like this
2009-02-3 21:31:29,777
Anyway, its a shame you wanted to be a cunt instead of just answer the
question...
I already got a helpful answer earlier in the thread. Time::Local does
the trick.
------------------------------
Date: Wed, 4 Feb 2009 13:33:56 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <slrngojrd4.iet.tadmc@tadmc30.sbcglobal.net>
rabbits77 <rabbits77@my-deja.com> wrote:
> Jürgen Exner wrote:
>> rabbits77 <rabbits77@my-deja.com> wrote:
>>> So, I have a string like
>>> 2009-02-3 21:31:29
>>> and I want that converted to the number of milliseconds since the unix
>>> epoch. What is the best way to do this?
>>
>> You don't. Your input data only has a resolution of seconds. There is no
>> point in computing the output to milliseconds and pretending to have a
>> resolution that is three orders of magnitude higher than your input
>> provides.
> I left out part of the data.
> I really have a string like this
> 2009-02-3 21:31:29,777
> Anyway, its a shame you wanted to be a cunt instead of just answer the
> question...
It's a shame you blame others for your own mistakes.
You cannot get milliseconds if you don't have millisecond resolution
to start with.
It was _you_ who said you had resolution to only seconds.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 4 Feb 2009 13:30:56 -0600
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <slrngojr7g.iet.tadmc@tadmc30.sbcglobal.net>
rabbits77 <rabbits77@my-deja.com> wrote:
> x-no-archive: yes
Why did you (attempt to) ask for no archiving of your post?
If it is archived, then others seeking an answer to the same
question would be able to find it.
> Jürgen Exner wrote:
>> rabbits77 <rabbits77@my-deja.com> wrote:
>>> What is the best way to convert a formatted time to a
>>> unix "time since epoch"?
>>
>> See "perldoc -q epoch":
>> How can I take a string and turn it into epoch seconds?
> Anyway, its a shame you wanted to be a cunt instead of just answer the
> question...
He did answer the question.
> I already got a helpful answer earlier in the thread. Time::Local does
> the trick.
The FAQ he pointed you to mentions using Time::Local.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Wed, 04 Feb 2009 20:24:55 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: what is the best way to convert a formatted time to a unix epoch
Message-Id: <Xns9BA89CCCF1E4Aasu1cornelledu@127.0.0.1>
rabbits77 <rabbits77@my-deja.com> wrote in
news:dfc7$4989eb57$c6509b06$6676@news.eurofeeds.com:
> x-no-archive: yes
This must be a joke.
> Jürgen Exner wrote:
>> rabbits77 <rabbits77@my-deja.com> wrote:
...
>>> So, I have a string like
>>> 2009-02-3 21:31:29
>>> and I want that converted to the number of milliseconds since the
>>> unix epoch. What is the best way to do this?
>>
>> You don't. Your input data only has a resolution of seconds. There is
>> no point in computing the output to milliseconds and pretending to
>> have a resolution that is three orders of magnitude higher than your
>> input provides.
> I left out part of the data.
C:\> perl -MESP -e 1
Can't locate ESP.pm in @INC (@INC contains: C:/opt/perl/site/lib
C:/opt/perl/lib .). BEGIN failed--compilation aborted.
> Anyway, its a shame you wanted to be a cunt instead of just answer the
> question...
Abuse report sent.
*PLONK*
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/
------------------------------
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 2182
***************************************