[28416] in Perl-Users-Digest
Perl-Users Digest, Issue: 9780 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 28 18:06:31 2006
Date: Thu, 28 Sep 2006 15:05:07 -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 Thu, 28 Sep 2006 Volume: 10 Number: 9780
Today's topics:
Re: Battlefield Weapon Popularity Trend (Chris Mattern)
can't locate method new IO::Socket::INET <brent.honadel@lawson.com>
Re: cookie problem. (reading news)
Re: cookie problem. <skimba@dambo.di>
Re: cookie problem. <nobull67@gmail.com>
Re: cookie problem. <noreply@gunnar.cc>
Re: CPAN conflict issue - CGI.pm vs ModPerl::Registry <nobull67@gmail.com>
Re: FAQ 2.6 What modules and extensions are available f <jgibson@mail.arc.nasa.gov>
Re: FAQ 3.1 How do I do (anything)? <brian.d.foy@gmail.com>
Re: FTP from Perl script on Windows <veatchla@yahoo.com>
Re: Ftp via Perl cron job <glex_no-spam@qwest-spam-no.invalid>
Re: How to dynamically generate function name and call <nobull67@gmail.com>
Re: How to dynamically generate function name and call <uri@stemsystems.com>
Re: Limit FORM mailer submissions to 5 on website, then <lance.botha@gmail.com>
Re: list vs. array <benmorrow@tiscali.co.uk>
Re: matching date <mritty@gmail.com>
Re: matching date usenet@DavidFilmer.com
Re: matching date <tadmc@augustmail.com>
Re: matching date <simon.chao@fmr.com>
Re: matching date <nobull67@gmail.com>
My first socket question <bik.mido@tiscalinet.it>
Re: My first socket question <jgibson@mail.arc.nasa.gov>
Re: Net::SMTP module error <glex_no-spam@qwest-spam-no.invalid>
Re: Perl Asyn btatnall@gmail.com
Re: problems with Time::HiRes on some SLES systems <Mark.Seger@hp.com>
Re: using http::recorder <glex_no-spam@qwest-spam-no.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 28 Sep 2006 15:17:33 -0000
From: syscjm@sumire.eng.sun.com (Chris Mattern)
Subject: Re: Battlefield Weapon Popularity Trend
Message-Id: <12hnpsdlt89qmd0@corp.supernews.com>
In article <efeko0$bqg$1@mlucom4.urz.uni-halle.de>, Mirco Wahab wrote:
>Thus spoke Chris Mattern (on 2006-09-27 19:09):
>> In article <efd9g0$sn5$1@mlucom4.urz.uni-halle.de>, Mirco Wahab wrote:
>>>
>>>When the Samurai of medieval Japan were confronted
>>>with new 'battlefield language', e.g. early Shotguns,
>>
>> "early Shotguns" :D. Your mastery of the history of
>> firearms overwhelms me.
>
>You want a fight? With a muzzle-loaded gun?
>Three shots for everybody -- 5 minutes time?
>
>BTW: (http://en.wikipedia.org/wiki/Musket)
> The date of the origin of muskets remains
> unknown, but they are mentioned as early as
> the late 15th century, and they were primarily
> designed for use by infantry. Muskets became
> obsolete by the middle of the 19th century,
> as rifles superseded them.
>
Muskets are not shotguns.
--
Christopher Mattern
"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"
------------------------------
Date: 28 Sep 2006 11:55:45 -0700
From: "ten8ciousb" <brent.honadel@lawson.com>
Subject: can't locate method new IO::Socket::INET
Message-Id: <1159469745.778936.53440@b28g2000cwb.googlegroups.com>
Sometimes, not always, an attempt to create a new socket connection
fails with this message:
Socket::INET" (perhaps you forgot to load "IO::Socket::INET"?) at
/usr/local/lib/perl5/5.6.1/IO/Socket/INET.pm line 32
Any ideas why or how INET.pm fails saying it can't find new in INET.pm?
The script runs on many servers many times a day, but only fails on one
and generally about the same time of the day. Okay. Seems kind of
obvious that is something specific to the server and the time of day.
But, within the same script there are multiple calls to create sockets
to different servers and they complete successfully.
I'm kind of out of my element on the internals of perl here, but my
thoughts:
Is it trying to find IO::Socket::INET.pm in @INC in order to identify
the super class, which is IO::Socket?
Does that mean that @INC has somehow become 'corrupted' during runtime?
any other thoughts.
Or has perl's symbol table become corrupted so it doesn't know what
"new" is?
nothing fancy in the script:
use IO::Socket;
use IO::Socket::INET;
$sock = IO::Socket::INET->new(
PeerAddr => $host,
PeerPort => $port,
Proto => 'tcp',
);
for reference : in INET.pm:
@ISA = qw(IO::Socket);
...
sub new {
my $class = shift;
unshift(@_, "PeerAddr") if @_ == 1;
return $class->SUPER::new(@_); ### Here's line 32
}
------------------------------
Date: Thu, 28 Sep 2006 16:11:53 GMT
From: "Mumia W. (reading news)" <paduille.4058.mumia.w@earthlink.net>
Subject: Re: cookie problem.
Message-Id: <dvSSg.2526$Y24.837@newsread4.news.pas.earthlink.net>
On 09/28/2006 05:43 AM, Oobi Van Doobi wrote:
> Could some kind soul advice a little,please.
> I have a C++ client, communicating with a perl script over http.
> I send a cookie from the script to the client, and naturally want to send it
> back to the script to maintain the state.
>
> However, sending the cookie back to the script causes the script to crash.
>
> the script is simple, it accepts parameters from a form in the C++ client,
> and prints them back to the client( this part works).
>
> There is conclusively something wrong with the format of the cookie sent
> back:
> the line of the cookie sent to the script is this:
>
> Cookie:cookiename=cookieval;cookieparam1...cookieparamn.
>
> is this correct way of sending the cookie?(correct format?)
>
> many thank's for any advice
>
<OT>
Here is where cookies are described:
http://www.w3.org/Protocols/rfc2109/rfc2109
E.g.
Cookie: cookie1name="cookie1value"; cookie2name="cookie2value"
Cookie2: $Version=1
FYI:
Download and install the "lynx" web browser; it's very useful for
debugging web pages and scripts. If you enable lynx's "trace" mode, it
outputs into its trace file a verbatim copy of the HTTP request it sends.
--
paduille.4058.mumia.w@earthlink.net
------------------------------
Date: Thu, 28 Sep 2006 20:40:57 +0300
From: Oobi Van Doobi <skimba@dambo.di>
Subject: Re: cookie problem.
Message-Id: <yjTSg.21813$p14.14364@reader1.news.jippii.net>
Mumia W. (reading news) wrote:
> On 09/28/2006 05:43 AM, Oobi Van Doobi wrote:
>> Could some kind soul advice a little,please.
>> I have a C++ client, communicating with a perl script over http.
>> I send a cookie from the script to the client, and naturally want to send
>> it back to the script to maintain the state.
>>
>> However, sending the cookie back to the script causes the script to
>> crash.
>>
>> the script is simple, it accepts parameters from a form in the C++
>> client, and prints them back to the client( this part works).
>>
>> There is conclusively something wrong with the format of the cookie sent
>> back:
>> the line of the cookie sent to the script is this:
>>
>> Cookie:cookiename=cookieval;cookieparam1...cookieparamn.
>>
>> is this correct way of sending the cookie?(correct format?)
>>
>> many thank's for any advice
>>
>
> <OT>
> Here is where cookies are described:
>
> http://www.w3.org/Protocols/rfc2109/rfc2109
>
> E.g.
> Cookie: cookie1name="cookie1value"; cookie2name="cookie2value"
> Cookie2: $Version=1
>
> FYI:
> Download and install the "lynx" web browser; it's very useful for
> debugging web pages and scripts. If you enable lynx's "trace" mode, it
> outputs into its trace file a verbatim copy of the HTTP request it sends.
>
>
>
ah, solved some while ago, but thank's anyway.
------------------------------
Date: 28 Sep 2006 10:24:58 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: cookie problem.
Message-Id: <1159464298.642041.195960@b28g2000cwb.googlegroups.com>
Oobi Van Doobi wrote:
[ A question about the HTTP request Cookie header syntax ]
> Cookie:cookiename=cookieval;cookieparam1...cookieparamn.
>
> is this correct way of sending the cookie?(correct format?)
Dunno. I've go my Perl hat on here.
> many thank's for any advice
http://www.google.com/search?q=http+request+cookie+header
------------------------------
Date: Thu, 28 Sep 2006 19:31:29 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: cookie problem.
Message-Id: <4o2f7jFco9akU1@individual.net>
Brian McCauley wrote:
> Oobi Van Doobi wrote:
>
> [ A question about the HTTP request Cookie header syntax ]
>
> http://www.google.com/search?q=http+request+cookie+header
Yeah, and one of the links that come up, and which I have found very
useful, is: http://www.cookiecentral.com/faq/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 28 Sep 2006 13:52:17 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: CPAN conflict issue - CGI.pm vs ModPerl::Registry
Message-Id: <1159476737.258649.124070@i42g2000cwa.googlegroups.com>
Gabriel wrote:
> Recently, I installed ModPerl::Registry on a Fedora Core Server, as
> regular ModPerl didn't want to install, due to some janky Fedora Core
> reason.
What do you mean by "regular ModPerl"?
What version of Apache and what version of mod_perl are you running?
IIRC ModPerl::Registry is part of mod_perl2 (which runs with Apache 2)
>
> <ERROR_LOG>
> Can't locate Apache.pm in @INC (@INC contains: ...
> </TRUNCATED ERROR_LOG>
Well it would help to know what line was generating that error.
> Now, I have no idea why installing CGI.pm has broken my scripts. Is
> there a way of uninstalling a module,
No. No backups of the overwritten files are kept.
>and, more importantly, would that be likely to fix it?
Uninstalling the CGI.pm you installed and putting back the version that
was there previously probably would fix it.
> My first thought upon looking at the error_log error, was to install
> Apache.pm, but that only results in the following error during 'make
> test'...
>
> <ERROR>
> /httpd -f `pwd`/t/conf/httpd.conf -X -d `pwd`/t &
> /bin/sh: /httpd: No such file or directory
> httpd listening on port 8529
> will write error_log to: t/logs/error_log
> letting apache warm up...\c
> done
> /usr/bin/perl t/TEST 0
> still waiting for server to warm up...............not ok
> server failed to start! (please examine t/logs/error_log) at t/TEST
> line 95.
> make: *** [run_tests] Error 111
> /usr/bin/make test -- NOT OK
> Running make install
> make test had returned bad status, won't install without force
> </ERROR>
>
> Is 'httpd' a utility I need to install in order to install Apache.pm?
Yes, httpd is Apache. You can't install Apache.pm (aka mod_perl)
without Apache installed. However at various stages thoughout the
evolution of mod_perl there where some fairly major renamings of the
Perl modules that comprise mod_perl.
Also CGI.pm interacts rather closely with mod_perl.
You really need to be sure that your versions of Apache, mod_perl and
CGI.pm are all interoperable versions.
> Aside from CPAN, and Apache.pm failing to install (probably due to some
> FC oddity), what I don't understand is how installing CGI.pm managed to
> break my existing install which was using ModPerl::Registry. I mean, I
> didn't change any of my code,
Did your code call CGI.pm ?
------------------------------
Date: Thu, 28 Sep 2006 12:00:06 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: FAQ 2.6 What modules and extensions are available for Perl? What is CPAN? What does CPAN/src/... mean?
Message-Id: <280920061200069993%jgibson@mail.arc.nasa.gov>
In article <6guqu3-omc.ln1@blue.stonehenge.com>, PerlFAQ Server
<brian@stonehenge.com> wrote:
> --------------------------------------------------------------------
>
> 2.6: What modules and extensions are available for Perl? What is CPAN? What
> does CPAN/src/... mean?
>
[snip]
>
> Considering that there are close to two thousand existing modules in the
> archive, one probably exists to do nearly anything you can think of.
I think this number is seriously out-of-date, considering that
<http://www.cpan.org/modules/01modules.index.html>, which doesn't
include current core modules, claims 10600 modules, and I actually
count 10886 modules in that list.
--
Jim Gibson
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Thu, 28 Sep 2006 13:38:57 -0500
From: brian d foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 3.1 How do I do (anything)?
Message-Id: <280920061338572682%brian.d.foy@gmail.com>
In article <hu4nh2p9hqgem5n17um4rpmnboe19tm282@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> On Wed, 27 Sep 2006 18:03:03 -0700, PerlFAQ Server
> <brian@stonehenge.com> wrote:
> >3.1: How do I do (anything)?
>
> How 'bout an ironic answer in terms of the Everything bundle?
Heh, but, no. :)
--
Posted via a free Usenet account from http://www.teranews.com
------------------------------
Date: Thu, 28 Sep 2006 14:13:01 -0500
From: l v <veatchla@yahoo.com>
Subject: Re: FTP from Perl script on Windows
Message-Id: <1159470861_2133@sp6iad.superfeed.net>
Ivan L wrote:
> There is no "%windir%\system32\drivers\etc\protocol" file on my machine.
>
> "Dr.Ruud" <rvtol+news@isolution.nl> wrote in news:efgir2.1f8.1@news.isolution.nl:
>
>> Ivan L schreef:
>>
>>> "Cannot connect to host: Net::FTP: Bad protocol 'tcp' at ftptest1.pl
>>> line 3."
>> Check out the file "%windir%\system32\drivers\etc\protocol".
>>
>
s/protocol/services/
--
Len
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Thu, 28 Sep 2006 13:51:55 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Ftp via Perl cron job
Message-Id: <451c192b$0$25777$815e3792@news.qwest.net>
Bill H wrote:
> Thanks for all the information. After posting this quested I started
> searching and came across the Net::FTP way of doing it. You posting the
> same information makes me feel better about using it. Any idea how to
> use secure ftp?
Whenever you're looking for a module, always start with
CPAN ( http://search.cpan.org/ ) or at least use your
favorite Internet search engine. If you had, you'd have
found your answer without having to post and wait for
a response.
------------------------------
Date: 28 Sep 2006 10:15:13 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <1159463713.875715.263240@m7g2000cwm.googlegroups.com>
Uri Guttman wrote:
> >>>>> "BM" == Brian McCauley <nobull67@gmail.com> writes:
>
> BM> Tad McClellan wrote:
> >> my %actions = ( # a "dispatch table", untested
> >> TRAC => \&CreateTRACTable,
> >> TRCO => \&CreateTRCOTable
> >> );
>
> BM> There are two entries in that hash. A soon as you add another one
> BM> you'll hit the rule-of-3. You'll be manually doing the same thing three
> BM> times in succession. In programming this is generally a sign that you
> BM> are doing it wrong. This is no exception. You probably should be
> BM> going down the symbolic references path. There are a lot of reasons not
> BM> to use symbolic references in a lot of contexts. This leads some
> BM> people, most vocally Tad, to say they are always a bad thing. And
> BM> indeed I'll admit that in some purist sense they are always a bad
> BM> thing. But in this case they are not as bad as breaking the rule-of-3
> BM> (IMNSHO).
>
> i agree with tad about avoiding symrefs. if the command is truly part
> of the function name, then another choice is to use class method calls
> which can be generated without symrefs or breaking strict.
>
> my $meth = "Create${command}able" ;
> MyClass->$meth( ... ) ;
So long as @MyClass::ISA is non-empty and $command doesn't contain '::'
(or similar) that's equivalent to
no strict 'refs';
"MyClass::Create${command}able"->('MyClass', ... ) ;
Uri's solution is still using a symref (i.e.a runtime-lookup of a
string from _data_ in the Perl symbol table) under the hood, but it
doesn't carry the red flag of a "no strict" in front of it.
Now as it happens in this case Uri's solution happens not to open up a
secirty hole in this particular instance because we're augementing
$command. But consider, if you will, the (more common) situation where
you're not.
MyClass->$command( ... ) ;
Now I have to agree that this is looks a whole lot cleaner than my
alternative.
no strict 'refs';
"MyClass::$command"->( ... ) ;
But looks can be deceptive.
> remember:
>
> symrefs are for munging the symbol table, not for flow control or data
> structures.
Remember, symrefs are very dangerous things, and remain dangerous even
if you pretend not to use them. In fact they become more dangerous
because people looking at the code will not see "no strict" and may be
fooled into thinking you aren't using symrefs so not realize the
danger.
Consider what happens in the code below when fed
'main::private_function' on STDIN
#!perl -T
use strict;
use warnings;
sub private_function { die "Bang!" };
sub AllowedOperations::allowed { print "yes, you can do that" }
while (<>) {
chomp;
AllowedOperations->$_();
}
__END__
------------------------------
Date: Thu, 28 Sep 2006 14:25:37 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How to dynamically generate function name and call it?
Message-Id: <x7zmcjonku.fsf@mail.sysarch.com>
>>>>> "BM" == Brian McCauley <nobull67@gmail.com> writes:
BM> MyClass->$command( ... ) ;
BM> Now I have to agree that this is looks a whole lot cleaner than my
BM> alternative.
BM> no strict 'refs';
BM> "MyClass::$command"->( ... ) ;
BM> But looks can be deceptive.
>> remember:
>>
>> symrefs are for munging the symbol table, not for flow control or data
>> structures.
BM> Remember, symrefs are very dangerous things, and remain dangerous even
BM> if you pretend not to use them. In fact they become more dangerous
BM> because people looking at the code will not see "no strict" and may be
BM> fooled into thinking you aren't using symrefs so not realize the
BM> danger.
in general i would use a dispatch table just so i can control which subs
can be called. even if it was uber symmetrical i would have created it
with hard refs. good editors make that easy.
and if i do the dynamic method call i will usually check for existance
with can() or something. you can even have a hash table of allowed
method names and check that first (no hard refs needed as values).
BM> Consider what happens in the code below when fed
BM> 'main::private_function' on STDIN
BM> #!perl -T
BM> use strict;
BM> use warnings;
BM> sub private_function { die "Bang!" };
BM> sub AllowedOperations::allowed { print "yes, you can do that" }
BM> while (<>) {
BM> chomp;
AllowedOperations-> $_();
BM> }
sure you can break a simple version. i was just showing how to do it
without no strict. i reserve no strict for direct symbol table munging
and not basic flow control.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: 28 Sep 2006 13:08:06 -0700
From: "Lance" <lance.botha@gmail.com>
Subject: Re: Limit FORM mailer submissions to 5 on website, then pause until reviewed by webmaster
Message-Id: <1159474086.254386.135940@m73g2000cwd.googlegroups.com>
Thank you Matt.
Your response and suggestions were amazing and well detailed. It's
given me a lot more to think about and definitely helped me to see the
bigger picture and protection problems.
Although i may not get a large number of posts simultaneously, i will
need to think about either counting the current sessions or applying a
lock on a file, as the type of posts could mean that users spend 30
minutes writing the post before clicking submit. It sounds easier to
have a script that creates a temporary row in a sessions table as soon
as the Form Windows is opened. I would need to include a script just
before that to do a count on the session table. If the count is >= 5,
then don't display the input form and instead display the message,
otherwise show the form.
So to avoid being flamed, could I ask if anyone could recommend a good
place to start and the best programming language to go with? I'll be
very grateful for any links and additional pointers.
Many thanks again Matt for your post..
Lance
------------------------------
Date: Thu, 28 Sep 2006 16:51:06 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: list vs. array
Message-Id: <ak7tu3-vh9.ln1@osiris.mauzo.dyndns.org>
Quoth Michele Dondi <bik.mido@tiscalinet.it>:
> On Tue, 26 Sep 2006 21:58:43 +0100, Ben Morrow
> <benmorrow@tiscali.co.uk> wrote:
>
> >> For example, when I work with lists and arrays, I usually focus on
> >> issues such as do I want to be manipulating arrays or arrayrefs...
> >> Which do I want to be using in my APIs, etc.
> >
> >However, it is important to realize that you cannot pass an array to a
> >function, in Perl. You can expand the array into a list of its elements,
> >and pass that, or you can take a ref to the array and pass that: which
> >you choose makes quite a difference.
>
> Hmmm, previous experience with you taught me that often you corrected
> me on something that seemed to be clearly done in a certain way, but
> actually wasn't. So I may well be wrong and I foresee the argument to
> be controversial anyway, but aren't the \@ and \% prototypes (ok,
> recommendations against using prototypes apart) a means to actually
> "pass an array" (or hash) to a function. Indeed you pass a reference,
> but this reference is taken transparently. From the syntactic pov of
> function call it seems to me that the array or hash is actually passed
> in. Again prototypes are limited, e.g. you can't pass in an arbitrary
> number of arrays this way, yet the mechanism seems to provide an
> exception to your claim.
Well, yes, you are correct. I was ignoring prototypes (and functions
like push, which predate general prototypes). From the POV of the called
function, though, it still simply receives a list, some of the members
of which may be arrayrefs.
Ben
--
We do not stop playing because we grow old;
we grow old because we stop playing.
benmorrow@tiscali.co.uk
------------------------------
Date: 28 Sep 2006 11:03:03 -0700
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: matching date
Message-Id: <1159466583.249305.165100@i3g2000cwc.googlegroups.com>
joez...@yahoo.com wrote:
> Can someone help me out with the following pattern match? I want to
> match on the date went its formated like mm/dd/yy. I was trying:
> /[0,1][0-9]/[0-3][0-9]/[0-9[0-9]/
> but my match doesn't seam to work as expected. I think its because of
> the / used to split the feilds.
You have multiple problems.
1) if you use / as the delimiter, you have to escape (that is, precede
with a backslash) any actual / characters that you want to match.
2) commas match themselves in character classes. A character class is
either a list (with nothing separating the elements) or a range (using
the - character) or a combination of both
3) Not all of your character classes are terminated
4) The character class [0-9] is more easily written \d
Putting those together:
m/[01]\d\/[0-3]\d\/\d\d/;
However, this is still not sufficient to match a real date, as it would
allow a date of, for example,
19/38/04;
> Could some one show me the correct way
> to pattern match on this?
The correct way is to not reinvent the wheel:
use Regexp::Common qw/time/;
/$RE{time}{mdy}/;
to allow any month-day-year pattern, or
/$RE{time}{m2d2y2}/
to specify exactly two digits for each field.
Paul Lalli
------------------------------
Date: 28 Sep 2006 11:15:17 -0700
From: usenet@DavidFilmer.com
Subject: Re: matching date
Message-Id: <1159467317.642435.105700@e3g2000cwe.googlegroups.com>
joez...@yahoo.com wrote:
> match on the date went its formated like mm/dd/yy. I was trying:
> /[0,1][0-9]/[0-3][0-9]/[0-9[0-9]/
> but my match doesn't seam to work as expected. I think its because of
> the / used to split the feilds.
Since you use "/" to delimit your pattern, Perl finds the next "/" and
thinks the pattern specification has ended. You can use another
character to delimit the match, but you must actually put "m" in front
of it, such as using bangs:
m!\d\d/[0-3]\d/\d\d!;
Or you can escape the embedded slashes:
/d\d\/[0-3]\d\/\d\d/;
Or you can use Regexp::Common from CPAN...
BTW, you didn't close your second-to-last character class.
--
David Filmer (http://DavidFilmer.com)
------------------------------
Date: Thu, 28 Sep 2006 08:42:49 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: matching date
Message-Id: <slrnehnkap.g60.tadmc@magna.augustmail.com>
joez311@yahoo.com <joez311@yahoo.com> wrote:
> I want to
> match on the date went its formated like mm/dd/yy.
print "$_ looks like a date\n" if m#^\d\d/\d\d/\d\d$#; # untested
> I was trying:
> /[0,1][0-9]/[0-3][0-9]/[0-9[0-9]/
^^^^^ ^^ where is the closing square bracket?
^^^^^ matches any one of *three* characters, it will match a comma...
> but my match doesn't seam to work as expected. I think its because of
> the / used to split the feilds.
Either put a backslash in front of the slashes, or use an alternate
delimiter for the match operator.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 28 Sep 2006 12:26:23 -0700
From: "it_says_BALLS_on_your forehead" <simon.chao@fmr.com>
Subject: Re: matching date
Message-Id: <1159471583.538873.78860@k70g2000cwa.googlegroups.com>
Dr.Ruud wrote:
> joez311@yahoo.com schreef:
>
> > Can someone help me out with the following pattern match? I want to
> > match on the date went its formated like mm/dd/yy. I was trying:
> > /[0,1][0-9]/[0-3][0-9]/[0-9[0-9]/
> > but my match doesn't seam to work as expected. I think its because of
> > the / used to split the feilds. Could some one show me the correct way
> > to pattern match on this?
> > Thanks,
> > Zim
>
>
> I see a comma that probably shouldn't be there, and a missing "]", and
> unescaped slashes, which leads to:
>
> m~[01][0-9]/[0-3][0-9]/[0-9][0-9]~
>
one issue with the OP's regex (even after it's been "corrected") is
that it matches months 13 - 19, and days 32 - 39 (and also day 31 for
months that don't have that particular day).
>
>
> Check out Regexp::Common
> http://search.cpan.org/search?module=Regexp::Common
------------------------------
Date: 28 Sep 2006 14:07:59 -0700
From: "Brian McCauley" <nobull67@gmail.com>
Subject: Re: matching date
Message-Id: <1159477679.307073.323590@k70g2000cwa.googlegroups.com>
joez311@yahoo.com wrote:
> Hi,
> Can someone help me out with the following pattern match? I want to
> match on the date went its formated like mm/dd/yy. I was trying:
> /[0,1][0-9]/[0-3][0-9]/[0-9[0-9]/
> but my match doesn't seam to work as expected. I think its because of
> the / used to split the feilds.
Well yes the unescaped / would be a problem if you are also using it as
your pattern demiliter.
As would the missing ]
And I somehow doubut you really want to allow the first character to be
a comma.
Fix all that and your pattern will still match 19/39/06
So why not simply m{\d\d/\d\d/\d\d}?
Fundamentally though you have an insummountable problem trying to match
a date only when it's fomatted mm/dd/yy since there are strings like
"01/02/03" that look like valid dates in yy/mm/dd or dd/mm/yy format
too.
Perhaps if we knew what you really wanted to do...
------------------------------
Date: 28 Sep 2006 17:21:48 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: My first socket question
Message-Id: <5npnh25e3ck8md6hauvsh0f1din2ddn3cb@4ax.com>
This is my first C/S socket question, so bear with me if the answer is
obvious or simple. I want to write a program that behaves like a
server if called with no arguments and like a client if supplied some,
sending commands based on those arguments to the server and waiting
for a reply. The following minimal example *does* work for me:
#!/usr/bin/perl
use strict;
use warnings;
use IO::Socket;
use constant PORT => 9000;
if (@ARGV) {
my $sock=IO::Socket::INET->new(PeerAddr => 'localhost',
PeerPort => PORT,
Proto => 'tcp') or
die "Cannot connect to server: $!\n";
my $cmd=shift;
print "Client mode, sending command `$cmd'\n";
print $sock "$cmd\r\n";
print scalar <$sock>;
close $sock or die "Cannot disconnect from server: $!\n";
exit;
}
my $server=IO::Socket::INET->new(Listen => 5,
LocalPort => PORT,
Proto => 'tcp') or
die "Cannot start in server mode: $!\n";
print "Server mode\n";
while ( my $client=$server->accept ) {
(my $cmd=<$client>) =~ tr/\r\n//d;
my %answer=(foo => "foo: that's what I wanted!");
print $client
$answer{$cmd} || "Unknown command: `$cmd'", "\r\n";
}
close $server or die "Cannot stop server mode: $!\n";
__END__
Point is, in the *real* application I have in mind, when in server
mode the program will be doing other stuff as well. To be fair, its
main purpose will be doing other stuff. The C/S ipc's purpose will be
exactly of gathering information on how other stuff is being done or
influence how it is. Thus the actual code may be of the form
while (1) {
do_stuff;
???
}
where ??? is the code to handle incoming requests. What should I put
there?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Thu, 28 Sep 2006 11:40:11 -0700
From: Jim Gibson <jgibson@mail.arc.nasa.gov>
Subject: Re: My first socket question
Message-Id: <280920061140118320%jgibson@mail.arc.nasa.gov>
In article <5npnh25e3ck8md6hauvsh0f1din2ddn3cb@4ax.com>, Michele Dondi
<bik.mido@tiscalinet.it> wrote:
> This is my first C/S socket question, so bear with me if the answer is
> obvious or simple. I want to write a program that behaves like a
> server if called with no arguments and like a client if supplied some,
> sending commands based on those arguments to the server and waiting
> for a reply. The following minimal example *does* work for me:
>
>
> #!/usr/bin/perl
>
> use strict;
> use warnings;
> use IO::Socket;
> use constant PORT => 9000;
>
>
> if (@ARGV) {
> my $sock=IO::Socket::INET->new(PeerAddr => 'localhost',
> PeerPort => PORT,
> Proto => 'tcp') or
> die "Cannot connect to server: $!\n";
> my $cmd=shift;
> print "Client mode, sending command `$cmd'\n";
> print $sock "$cmd\r\n";
> print scalar <$sock>;
> close $sock or die "Cannot disconnect from server: $!\n";
> exit;
> }
>
> my $server=IO::Socket::INET->new(Listen => 5,
> LocalPort => PORT,
> Proto => 'tcp') or
> die "Cannot start in server mode: $!\n";
> print "Server mode\n";
>
> while ( my $client=$server->accept ) {
> (my $cmd=<$client>) =~ tr/\r\n//d;
> my %answer=(foo => "foo: that's what I wanted!");
> print $client
> $answer{$cmd} || "Unknown command: `$cmd'", "\r\n";
> }
> close $server or die "Cannot stop server mode: $!\n";
>
> __END__
>
>
> Point is, in the *real* application I have in mind, when in server
> mode the program will be doing other stuff as well. To be fair, its
> main purpose will be doing other stuff. The C/S ipc's purpose will be
> exactly of gathering information on how other stuff is being done or
> influence how it is. Thus the actual code may be of the form
>
> while (1) {
> do_stuff;
> ???
> }
>
> where ??? is the code to handle incoming requests. What should I put
> there?
A call to IO::Select::can_read to see if a client is trying to connect.
Posted Via Usenet.com Premium Usenet Newsgroup Services
----------------------------------------------------------
** SPEED ** RETENTION ** COMPLETION ** ANONYMITY **
----------------------------------------------------------
http://www.usenet.com
------------------------------
Date: Thu, 28 Sep 2006 12:21:10 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: Net::SMTP module error
Message-Id: <451c03e5$0$25773$815e3792@news.qwest.net>
- Bob - wrote:
> Thanks... that's what I suspected. Is there anyway for me to
> install/hack that module within my own area or do I have to have them
> install no matter what ?
perldoc -q "How do I keep my own module/library directory"
------------------------------
Date: 28 Sep 2006 13:52:17 -0700
From: btatnall@gmail.com
Subject: Re: Perl Asyn
Message-Id: <1159476737.874264.208640@m7g2000cwm.googlegroups.com>
Todd English wrote:
> # This doesn't work
> # while ( (my $name, $proc) = each %proc_result)
Did you mean:
while ( my ($name, $proc) = each %proc_result )
notice the location of my
------------------------------
Date: Thu, 28 Sep 2006 08:26:49 -0400
From: Mark Seger <Mark.Seger@hp.com>
To: Mark Seger <Mark.Seger@hp.com>
Subject: Re: problems with Time::HiRes on some SLES systems
Message-Id: <451BBF89.3050400@hp.com>
Mark Seger wrote:
> I've been using this module for doing highly accurate sleeping. I would
> essentially set an alarm for n-seconds and then so a sleep for time time
> greater then n. When the signal is delivered and I act on it (or simply
> just return), my app simply continues after the sleep.
I've been in touch with the developer Jarkko Hietaniemi and he's
confirmed this is indeed a problem and he will have a newer version
coming out some time in the future.
-mark
------------------------------
Date: Thu, 28 Sep 2006 12:52:57 -0500
From: "J. Gleixner" <glex_no-spam@qwest-spam-no.invalid>
Subject: Re: using http::recorder
Message-Id: <451c0b59$0$10299$815e3792@news.qwest.net>
Nospam wrote:
> My apologies for my newbie question, but I am looking at http::recorder, and
> the readme guide says this:
>
> my $proxy = HTTP::Proxy->new;
> # set HTTP::Recorder as the agent
> my $agent = HTTP::Recorder->new( file => "/tmp/tmpfile" );
> $proxy->agent( $agent );
> $proxy->start();
>
> I am wondering if I place the proxy in:
> $proxy->start('proxy:port');
> ?
Just after the example, the documentation for HTTP::Recorder shows, "For
more information about proxy settings and the default port, see ..."
The documentation is where you'll find your answer.
>
> I am also looking at using selenium with javascript to follow a link that is
> a javascript link where the text regex is:
>
> follow_link( text_regex => qr/Articles/i );
Well that's good. Thanks for sharing.
>
> Anyhelp will be greatly appreciated
>
>
------------------------------
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 V10 Issue 9780
***************************************