[22631] in Perl-Users-Digest
Perl-Users Digest, Issue: 4852 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Apr 16 09:10:54 2003
Date: Wed, 16 Apr 2003 06:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 16 Apr 2003 Volume: 10 Number: 4852
Today's topics:
Re: Accesing machines of a network <kasp@epatra.com>
Re: Accesing machines of a network <bart.lateur@pandora.be>
Re: Accesing machines of a network <kasp@epatra.com>
Re: ActiveState vs. CPAN modules <bart.lateur@pandora.be>
convert emptry string to zero using unpack (qanda)
Re: convert emptry string to zero using unpack (Anno Siegel)
Re: Delete line based on the next. (Anno Siegel)
Re: Delete line based on the next. (supportgeek)
Detached Server Process <cf@<Nooooo spaaammm>phased.co.uk>
Re: grep in array <mr@sandman.net>
Re: How does Perl auto increase hash size? <nospam-abuse@ilyaz.org>
Re: New Perl Beginners Site <bigus AT creationfactor DOT net>
Re: New Perl Beginners Site <bart.lateur@pandora.be>
Re: New Perl Beginners Site <abigail@abigail.nl>
regexp. for a two dates delimited with a minus <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Re: regexp. for a two dates delimited with a minus <laocoon@fastmail.fm>
Re: regexp. for a two dates delimited with a minus (Anno Siegel)
Re: regexp. for a two dates delimited with a minus <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Re: regexp. for a two dates delimited with a minus <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Remote Module Installation (Vijoy Varghese)
Re: Remote Module Installation <ericw@nospam.ku.edu>
Syntax problem <kasp@epatra.com>
Re: Syntax problem <uri@stemsystems.com>
Re: user command with Net::FTP <bernard.el-hagin@DODGE_THISlido-tech.net>
Re: user command with Net::FTP <kkeller-spammmm@wombat.san-francisco.ca.us>
Re: user command with Net::FTP news@roaima.freeserve.co.uk
Re: Validating user input to match certain characters <usenet@NOSPAM.matthewb.org>
Re: WIN32::ODBC problem <bigus AT creationfactor DOT net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 16 Apr 2003 13:58:30 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: Accesing machines of a network
Message-Id: <b7j4ah$vbd$1@newsreader.mailgate.org>
Now I am intimidated...a lot of uncharted area lies up ahead!
I wanted to make this script so that I could get a list of all the MP3 songs
from our local network. Later, I could search on this info to listen to the
desired song, instead of downloading it. I have a Unix system available too.
I will look into both Samba Library and Windows scheduler.
Thanks. Hope to post this script here so that I can get a review for my
coding.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
------------------------------
Date: Wed, 16 Apr 2003 10:05:44 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Accesing machines of a network
Message-Id: <oi9q9vgu3olpcgfkrtv06ddfmnl8r6hotp@4ax.com>
Kasp wrote:
>I wanted to make this script so that I could get a list of all the MP3 songs
>from our local network. Later, I could search on this info to listen to the
>desired song, instead of downloading it. I have a Unix system available too.
Create a M3U file. That is basically nothing but a text file with a list
of URL's in it, one per line. There can be comments, that start with
"#". Browsers generally pass this on to their assigned media player, for
example WinAmp, which downloads the file and starts playing it, while
it's still being downloaded. Likely this is the effect you want.
You need a MIME type, for the content-type... I've seen something along
the line of "mpeg-url"... mp3.com uses "audio/x-mpegurl", so that should
work.
If you want people to be able to seek into the file, you'll need a web
server that supports that. If you have Apache with modperl, the module
Apache::MP3 can help implement that.
<http://search.cpan.org/dist/Apache-MP3/>
And the next page also looks interesting:
"The Linux MP3-HOWTO : Streaming MP3's"
<http://www.mcc.ac.uk/Documentation/linux-doc/HOWTO/MP3-HOWTO-11.html>
--
Bart.
------------------------------
Date: Wed, 16 Apr 2003 17:32:58 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Re: Accesing machines of a network
Message-Id: <b7jhe7$mli$1@newsreader.mailgate.org>
> # The function you should be interested in is
> GetSharedResources(\@Resources,dwType,\%NetResource = NULL)
I am having some trouble with this one Bryan.
Documentation says: "The \%NetResource argument is optional. If it is not
supplied, the root (that is, the topmost container) of the network is
assumed, and all network resources available from the toplevel container
will be enumerated."
Now I don't want to search from the top-level container. In my "Microsoft
Windows Network", amongst many other domains I have a domain called
"myDomain". And I want to search only this domain.
How can I search all the machines on a specific domain?
Thanks.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert
------------------------------
Date: Wed, 16 Apr 2003 08:13:25 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: ActiveState vs. CPAN modules
Message-Id: <ff3q9v0mn2n6cdum726pj39e2en4ebd0pu@4ax.com>
Sam Jesse wrote:
>I am not sure if I understand the module way of choosing and installing. I
>have an ActivePerl installed under my W2K. I feel that CPAN has lots of
>moudles to choose from vs. ActiveState may only have 150 or so. by my using
>ActivePerl and PPM. Am I limited to the PPM version of the moudles and there
>for will not be able to used modules provided on the CPAN site?
You can install them directly from CPAN, provided they're Pure Perl
modules. Most of them are. In that case, all you need is a "make"
utility, for Windows: nmake. Then, the classic mantra would be:
- Fetch the .tar.gz file. Decompress it, for example using Winzip.
- At the command prompt, chdir to the root directory of the
decompressed distribution.
- Type "perl MakeFile.PL". This constructs a "Makefile" from the script
"Makefile.PL". The latter merely contains an overview of what needs to
be done to get an installation, in a simple, high-level Perl script.
- Type "nmake". Watch that the messages look fine. This will build the
final structure of the file trees.
- Next, "nmake test". This runs some tests, temporarily including the
root of your build tree(s) in @INC. Thus, even though it's not installed
yet, you still can use it, this way.
- If all looks OK, you can do the final step: "nmake install".
It's all described as well in this article here:
<http://www.perlmonth.com/perlmonth/issue8/ppm.html>
--
Bart.
------------------------------
Date: 16 Apr 2003 02:35:23 -0700
From: fumail@freeuk.com (qanda)
Subject: convert emptry string to zero using unpack
Message-Id: <62b4710f.0304160135.2b0d5d1c@posting.google.com>
Hi all
I have a problem which the following script demonstrates ...
#!/usr/bin/perl -w
use strict;
comp_times();
sub comp_times {
use Time::Local;
# Format of time fields is YYYYMMDDTHHMMSS.iiiiii
# Hours, mins and seconds are allowed to truncated in the raw data.
my $st = "20021123T2359"; # Normally read from record.
my $et = "20021124T04"; # Normally read from record.
print STDOUT "st:et before[$st:$et]\n";
# Remove microseconds and 'T' separator.
$st =~ s/\.\d+$|T//g;
$et =~ s/\.\d+$|T//g;
print STDOUT "st:et after[$st:$et]\n";
# Unpack the fields.
my @sta = reverse unpack 'a4 a2 a2 a2 a2 a2', $st;
my @eta = reverse unpack 'a4 a2 a2 a2 a2 a2', $et;
print STDOUT "sta:eta before[@sta:@eta]\n";
# Convert to seconds since Epoch (Midnight, Jan 1st 1970).
$sta[5] -= 1900; # Set to number of years since 1970.
$sta[4] -= 1; # Month is 0 to 11.
$eta[5] -= 1900; # Set to number of years since 1970.
$eta[4] -= 1; # Month is 0 to 11.
print STDOUT "sta:eta after[@sta:@eta]\n";
# Convert to seconds since Epoch (Midnight, Jan 1st 1970).
my $sts = timelocal(@sta);
my $ets = timelocal(@eta);
print STDOUT "ets:ets[$sts:ets]\n";
# Carry on processing ...
}
Can anyone tell me how to convert the null (empty string) from the relevant
fields into a zero. Or alternatively, you can see the objective is to convert
the strings in $st and $et into seconds since epoch, is there another way to
achieve this keeping in mind I need to do this to hundreds of thousands of records?
Thanks for reading this far.
------------------------------
Date: 16 Apr 2003 12:24:29 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: convert emptry string to zero using unpack
Message-Id: <b7ji1t$t5t$1@mamenchi.zrz.TU-Berlin.DE>
qanda <fumail@freeuk.com> wrote in comp.lang.perl.misc:
> Hi all
>
> I have a problem which the following script demonstrates ...
>
> #!/usr/bin/perl -w
> use strict;
> comp_times();
> sub comp_times {
> use Time::Local;
>
> # Format of time fields is YYYYMMDDTHHMMSS.iiiiii
> # Hours, mins and seconds are allowed to truncated in the raw data.
>
> my $st = "20021123T2359"; # Normally read from record.
> my $et = "20021124T04"; # Normally read from record.
> print STDOUT "st:et before[$st:$et]\n";
[snip]
Why don't you just zero-pad truncated strings to full length at this
point (or another convenient point)?
Anno
------------------------------
Date: 16 Apr 2003 10:42:41 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Delete line based on the next.
Message-Id: <b7jc31$ob0$1@mamenchi.zrz.TU-Berlin.DE>
Abigail <abigail@abigail.nl> wrote in comp.lang.perl.misc:
> supportgeek (molivier@caregroup.harvard.edu) wrote on MMMDXIV September
> MCMXCIII in <URL:news:da063e5d.0304151241.11dc7459@posting.google.com>:
> || Here's the latest situation I've gotten my self into...
> ||
> || I need to delete a line based on the content on the next. Example of
> || the File:
> ||
> || 125 Jersey Road 104598213 #need to delete
> || 125 Jersey Road 14234523d #need to keep
> || 9832 Auto #need to keep
> || 125 Jersey Road 345234235 #need to delete
> || 125 Jersey Road 434234234 #need to keep
> || 9832 Auto #need to keep
> || 9832 Auto #need to keep
> ||
> || As you can see I need to keep the lines where "9832 Auto" are below
> || "125 Jersey Road" lines. And get rid of the lines that do not have a
> || "9832" auto below them.
> || There are many cases where 9832 Auto is listed twice or thrice and I
> || need to keep all the lines.
> ||
> || The type of file i need to produce is simply:
> ||
> || 125 Jersey Road 14234523d
> || 9832 Auto
> ||
> || 125 Jersey Road 434234234
> || 9832 Auto
> || 9832 Auto
> ||
> || The numbers to the left are account numbers and will always be
> || different. the 125 Jersey Road and 9832 Auto will also remain the
> || same.
>
>
> $ perl -nle '($,,$_)=($_,$,); print if $, =~ /^9832/ || /^9832/;
> END {print $,}' data_file
Wicked!
Note to the original poster: You don't have to understand this. Use
Tad's solution from another reply, which is more practical, though less
entertaining.
Anno
------------------------------
Date: 16 Apr 2003 05:40:35 -0700
From: molivier@caregroup.harvard.edu (supportgeek)
Subject: Re: Delete line based on the next.
Message-Id: <da063e5d.0304160440.71ecee5@posting.google.com>
I'm using Tads. THanks.
BUt if someone had sometime and could explain this that would be really great.
I'd really love to know how it works.
> > || same.
> >
> >
> > $ perl -nle '($,,$_)=($_,$,); print if $, =~ /^9832/ || /^9832/;
> > END {print $,}' data_file
>
> Wicked!
>
> Note to the original poster: You don't have to understand this. Use
> Tad's solution from another reply, which is more practical, though less
> entertaining.
>
> Anno
------------------------------
Date: Wed, 16 Apr 2003 12:10:32 +0100
From: CitFish <cf@<Nooooo spaaammm>phased.co.uk>
Subject: Detached Server Process
Message-Id: <o4eq9vcqdtg51loodfnjvks1f2c9vgo9ts@4ax.com>
Hi
I'm looking for a bit of advice concerning a server process I am
trying to code.
The idea is that a client calls the server on a specific port and
posts a parameter string. The server reads the parameter string and
then disconnects the client. The server then uses the parameter string
to run another process.
On the client side I create the connection with:-
eval {
alarm(10);
my $socket = IO::Socket::INET->new(PeerAddr=>SERVER,
PeerPort=>POSTPORT,
Proto=> 'tcp',
Type=> SOCK_STREAM)
or die "batchPost failed to connect to batch
server";
print $socket "$commandString\n" ;
$reply = <$socket>;
close($socket);
alarm(0); # it worked so disable the alarm
};
On the Server I create the connection with:-
my $server = IO::Socket::INET->new (LocalPort => LISTENPORT,
Type => SOCK_STREAM,
Proto => 'tcp',
Reuse => REUSE,
Listen => LISTEN)
or die ("Could not start server on port ".LISTENPORT." :
".$@."\n");
while(my ($client, $IP) = $server->accept()) {
my $pid = fork();
die("Cannot fork: $!\n") unless defined($pid);
$buffer = <$client>;
....read parameters from $buffer
close $client;
... do other stuff here
}
I expected the client to finish as soon as the close $client statement
was issued, however it appears to wait until the "do other stuff" is
finished. I have also tried $client->shutdown(2) with no success.
I guess that I have not quite got the principles of forking and socket
connections right. Can somebody point me in the right direction.
TIA
CF
------------------------------
Date: Wed, 16 Apr 2003 10:09:24 +0200
From: Sandman <mr@sandman.net>
Subject: Re: grep in array
Message-Id: <mr-4880B8.10092416042003@news.fu-berlin.de>
In article <4nvfxfbwby.fsf@lockgroove.bwh.harvard.edu>,
Ted Zlatanov <tzz@lifelogs.com> wrote:
> > Hello! This is what I have:
> >
> > %people = (
> > "john", "John Andersson",
> > "will", "William Smith"
> > );
> >
> > @names = ("Johnny", "David", "Willy boy", "Richard");
> >
> > foreach $name (@names){
> > if (grep /$name/, keys %people){
> > print "$name is a friend of ours!\n"
> > [...]
> > } else {
> > print "We don't know $name...\n";
> > }
> > }
> >
> > This doesn't work, since its backways. What I want to do with the
> > items in @people is check if "john" or "will" matches -IT- rather
> > than the other way around.
>
> foreach my $short_name (keys %people)
> {
> if (grep /$short_name/i, @names)
> {
> print "$short_name is a friend of ours!\n";
> }
> else
> {
> print "We don't know $short_name...\n";
> }
> }
I am worried about the efficiency of your example. I am doing the matcch inside
a <while> that reads a rather large logfile, and will be doing the match for
every line.
As it is, I have managed to do the match with this:
foreach $name (@names){
if (grep {$nick =~m/$_/i } keys %people){
print "$name is a friend of ours!\n"
}
}
But the problem is that I can't seem to access $& in that scope. What I would
want to do above is:
foreach $name (@names){
if (grep {$nick =~m/$_/i } keys %people){
$fullname = $people{$`$&$´};
print "$fullname is a friend of ours!\n"
}
}
But for some reason, $`$&$´ doesn't contain anything there... Any ideas?
--
Sandman[.net]
------------------------------
Date: Wed, 16 Apr 2003 07:56:03 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: How does Perl auto increase hash size?
Message-Id: <b7j2aj$1ql2$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Abigail
<abigail@abigail.nl>], who wrote in article <slrnb9nuj6.ag6.abigail@alexandra.abigail.nl>:
> Just like almost any sane hash function, Perls hash function includes
> the current size (amount of buckets) in the hash.
> Perl hashes use linear chaining, and no double hashing techique.
> $$ Is there a clever way to get around re-hashing altogether?
> No.
> $$ How does this work?
> The simplest way possible. Just recalculate the hash value (which only
> has a small chance of being the same as the old value).
3 wrongs out of 4.
Hope this helps,
Ilya
------------------------------
Date: Wed, 16 Apr 2003 09:51:23 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: New Perl Beginners Site
Message-Id: <b7j5id$11cm@newton.cc.rl.ac.uk>
Did you realise that the page backgrounds are grey and not white for some
people? In the case of your site, it may be that you intended the background
to be grey, but I mention this because I've seen many sites out there (even
large organisations like - http://www.royalmail.com) where you can see that
the designer clearly intended that the background to be white, yet didn't
specify #FFFFFF a sthe background colour for the page body. Certainly for
me, with IE5.5 on NT4 and IE 6 on XP page backgrounds are rendered as grey
where no background colour is specified.
HTH
Bigus
"Shlomi Fish" <shlomif@vipe.technion.ac.il> wrote in message
news:deca99a9.0304152131.501b66b4@posting.google.com...
> I have set up a new Perl Beginners' portal at:
>
> http://perl-begin.berlios.de/
>
> This site is not intended as a replacement for learn.perl.org, but
> rather as a complement[1]. It covers various net resources more
> closely, has a nicer look and feel (at least, IMO), and the source
> code (in Web Meta Language) is online.
>
> There will be more resources as time goes by. Feel free to contribute.
> I will gladly make anyone a member of the project in BerliOS, and if
> he contributes enough, an admin as well. I wish it to be a true
> community web-site.
>
> Regards,
>
> Shlomi Fish
>
>
> [1] - I don't believe in concentration of effort. In PHP or VB for
> instance, there are many portals with a lot of activity in them, and
> it's not confusing for the users.
------------------------------
Date: Wed, 16 Apr 2003 10:42:43 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: New Perl Beginners Site
Message-Id: <6dcq9vs9uqpj35a68td14prs7ncust3kkd@4ax.com>
Shlomi Fish wrote:
>I have set up a new Perl Beginners' portal at:
>
>http://perl-begin.berlios.de/
Nice. I'm not a beginner, so I'm not sure what a beginner would think of
it, though...
One hole: "Web Forums":
Not Implemented Yet - Info Required
May I point you to PerlMonks? <http://perlmonks.org>, also reachable
under a few other related domains (like <www.perlmonks.org> and
<(www.)perlmonks.com>), likely the most important web forum, and very
newbie friendly. Many of the big names hang out there, or at least, have
an account, like Randal Schwartz (merlyn), Damian Conway (TheDamian),
Mark-Jason Dominus (Dominus), Dan Sugalski (Elian), Abigail
(Abigail-II), and likely a few I forgot, or don't know about because
their username doesn't ring a bell for me.
--
Bart.
------------------------------
Date: 16 Apr 2003 12:56:33 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: New Perl Beginners Site
Message-Id: <slrnb9qko1.qh5.abigail@alexandra.abigail.nl>
Bigus () wrote on MMMDXV September MCMXCIII in
<URL:news:b7j5id$11cm@newton.cc.rl.ac.uk>:
== Did you realise that the page backgrounds are grey and not white for some
== people? In the case of your site, it may be that you intended the background
== to be grey, but I mention this because I've seen many sites out there (even
== large organisations like - http://www.royalmail.com) where you can see that
== the designer clearly intended that the background to be white, yet didn't
== specify #FFFFFF a sthe background colour for the page body. Certainly for
== me, with IE5.5 on NT4 and IE 6 on XP page backgrounds are rendered as grey
== where no background colour is specified.
If no background colour is specified, the background colour used is
the one the reader intended. Which is a *good* thing. If you don't
like the colour, fix the settings of your browser, or get a better
browser.
Abigail
--
perl -wlne '}for($.){print' file # Count the number of lines.
------------------------------
Date: Wed, 16 Apr 2003 12:01:04 +0200
From: "Fizgig" <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Subject: regexp. for a two dates delimited with a minus
Message-Id: <3e9d29e1$0$49106$e4fe514c@news.xs4all.nl>
Hi,
I need a regexp for a string with this format
DD.MM.YYYY-DD.MM.YYYY
I have already a great working expression for a single date;
(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[
0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[
2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00
))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-
9]|[2-9]\d)?\d{2})
How can i get it working for two dates delimited with a minus?
Thanx,
Ward
------------------------------
Date: Wed, 16 Apr 2003 13:08:17 +0200
From: Lao Coon <laocoon@fastmail.fm>
Subject: Re: regexp. for a two dates delimited with a minus
Message-Id: <Xns935F85CFF1545laocoon@62.153.159.134>
"Fizgig" <FizgigNO@SPAMequanimityREMOVETHISTO.nl> wrote in
news:3e9d29e1$0$49106$e4fe514c@news.xs4all.nl:
> Hi,
>
> I need a regexp for a string with this format
>
> DD.MM.YYYY-DD.MM.YYYY
>
> I have already a great working expression for a single date;
>
*snip extremly ugly thing from hell*
>
> How can i get it working for two dates delimited with a minus?
if($string =~ /^(\d\d)\.(\d\d).(\d{4})-(\d\d)\.(\d\d)\.(\d{4})$/) {
my ($d1,$m1,$y1, $d2,$m2,$y2) = ($1,$2,$3, $4,$5,$6);
# insert checks for valid dates here
# ...
}
------------------------------
Date: 16 Apr 2003 12:03:30 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: regexp. for a two dates delimited with a minus
Message-Id: <b7jgqi$s7s$1@mamenchi.zrz.TU-Berlin.DE>
Fizgig <FizgigNO@SPAMequanimityREMOVETHISTO.nl> wrote in comp.lang.perl.misc:
> Hi,
>
> I need a regexp for a string with this format
>
> DD.MM.YYYY-DD.MM.YYYY
>
> I have already a great working expression for a single date;
>
> (?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[
> 0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[
> 2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00
> ))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[6-
> 9]|[2-9]\d)?\d{2})
>
> How can i get it working for two dates delimited with a minus?
Where does that monster come from? Do you understand it? It's obviously
unmanageable, so don't try to manage it.
Working with code you don't understand is what we call "cargo cult coding"
and it's bad practice. Regular expressions are like knots in a work of
knitting -- you need them occasionally and there's nothing wrong with that,
but you try to keep them small and simple. Tying knots can also be an
art form, but that has no place in day-to-day programming.
Start with a simple regex that matches valid dates (or pairs of dates,
as you require). Don't worry if it matches some invalid dates too, you
can do your validity checks later on the individual components. It will
be much clearer, and your problem of matching two dates at once will become
manageable.
Anno
------------------------------
Date: Wed, 16 Apr 2003 14:53:44 +0200
From: "Fizgig" <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Subject: Re: regexp. for a two dates delimited with a minus
Message-Id: <3e9d5259$0$49109$e4fe514c@news.xs4all.nl>
Thank you for your reply Lao. Unfortunatly i need a complete regular
expression because the way i want to use it doesn't allow me to enter other
code but a reg expr.
"Lao Coon" <laocoon@fastmail.fm> wrote in message
news:Xns935F85CFF1545laocoon@62.153.159.134...
> "Fizgig" <FizgigNO@SPAMequanimityREMOVETHISTO.nl> wrote in
> news:3e9d29e1$0$49106$e4fe514c@news.xs4all.nl:
>
> > Hi,
> >
> > I need a regexp for a string with this format
> >
> > DD.MM.YYYY-DD.MM.YYYY
> >
> > I have already a great working expression for a single date;
> >
> *snip extremly ugly thing from hell*
> >
> > How can i get it working for two dates delimited with a minus?
>
>
> if($string =~ /^(\d\d)\.(\d\d).(\d{4})-(\d\d)\.(\d\d)\.(\d{4})$/) {
>
> my ($d1,$m1,$y1, $d2,$m2,$y2) = ($1,$2,$3, $4,$5,$6);
>
> # insert checks for valid dates here
>
> # ...
>
> }
------------------------------
Date: Wed, 16 Apr 2003 15:00:20 +0200
From: "Fizgig" <FizgigNO@SPAMequanimityREMOVETHISTO.nl>
Subject: Re: regexp. for a two dates delimited with a minus
Message-Id: <3e9d53e5$0$49116$e4fe514c@news.xs4all.nl>
Thank you for your reply Anno. I agree with you that this regular expression
is hard to read, but it is very thorough; it even checks for leap
years.
Anyway, if someone can point me out a 'diet' date checker that can verify
this format DD.MM.YYYY-DD.MM.YYYY, i'm also pleased ;-)
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b7jgqi$s7s$1@mamenchi.zrz.TU-Berlin.DE...
> Fizgig <FizgigNO@SPAMequanimityREMOVETHISTO.nl> wrote in
comp.lang.perl.misc:
> > Hi,
> >
> > I need a regexp for a string with this format
> >
> > DD.MM.YYYY-DD.MM.YYYY
> >
> > I have already a great working expression for a single date;
> >
> >
(?:(?:31(\/|-|\.)(?:0?[13578]|1[02]))\1|(?:(?:29|30)(\/|-|\.)(?:0?[1,3-9]|1[
> >
0-2])\2))(?:(?:1[6-9]|[2-9]\d)?\d{2})$|^(?:29(\/|-|\.)0?2\3(?:(?:(?:1[6-9]|[
> >
2-9]\d)?(?:0[48]|[2468][048]|[13579][26])|(?:(?:16|[2468][048]|[3579][26])00
>
> ))))$|^(?:0?[1-9]|1\d|2[0-8])(\/|-|\.)(?:(?:0?[1-9])|(?:1[0-2]))\4(?:(?:1[
6-
> > 9]|[2-9]\d)?\d{2})
> >
> > How can i get it working for two dates delimited with a minus?
>
> Where does that monster come from? Do you understand it? It's obviously
> unmanageable, so don't try to manage it.
>
> Working with code you don't understand is what we call "cargo cult coding"
> and it's bad practice. Regular expressions are like knots in a work of
> knitting -- you need them occasionally and there's nothing wrong with
that,
> but you try to keep them small and simple. Tying knots can also be an
> art form, but that has no place in day-to-day programming.
>
> Start with a simple regex that matches valid dates (or pairs of dates,
> as you require). Don't worry if it matches some invalid dates too, you
> can do your validity checks later on the individual components. It will
> be much clearer, and your problem of matching two dates at once will
become
> manageable.
>
> Anno
------------------------------
Date: 16 Apr 2003 01:45:32 -0700
From: viijv@thedifferenZ.com (Vijoy Varghese)
Subject: Remote Module Installation
Message-Id: <4c08aaff.0304160045.4475bf88@posting.google.com>
Hello group,
I am now working on windows 98 OS with activestate perl on it. I have
a remote server account and the server is Linux. My cgi/perl scripts
are supposed to work properly on this two enviorments and they are
working fine until now. But now i need to use a new perl module
use Digest::HMAC_MD5
which is not in both of my enviorments. So i installed this on the
windows 98 system using ppm and its working fine here. My code is
#!D:\perl\bin\perl.exe
use Digest::HMAC_MD5 qw(hmac_md5 hmac_md5_hex);
print "Content-type: text/html\n\n";
$password="password";
$key="key";
print hmac_md5_hex($password, "key");
And its working perfect.
But when i tried to run this in the remote linux system
#!/usr/bin/perl
use Digest::HMAC_MD5 qw(hmac_md5 hmac_md5_hex);
print "Content-type: text/html\n\n";
$password="password";
$key="key";
print hmac_md5_hex($password, "key");
its giving 500 error!
i think the problem is that this particular module is not installed on
the remote server. And all i have is a FTP access. So how can i use
the function provided by this module on the remote server? Any
pointers will be of great help, this particular module is available
from
http://search.cpan.org/author/GAAS/Digest-HMAC-1.01/
So, how to make use of it on a remote server?
Thanking you in advance,
Regards
Vijoy Varghese.
------------------------------
Date: Wed, 16 Apr 2003 12:34:53 GMT
From: Eric Wilhelm <ericw@nospam.ku.edu>
Subject: Re: Remote Module Installation
Message-Id: <pan.2003.04.16.07.32.19.563956.30426@nospam.ku.edu>
On Wed, 16 Apr 2003 03:45:32 -0500, Vijoy Varghese wrote:
> i think the problem is that this particular module is not installed on
> the remote server. And all i have is a FTP access. So how can i use the
> function provided by this module on the remote server? Any pointers will
> be of great help, this particular module is available from
> http://search.cpan.org/author/GAAS/Digest-HMAC-1.01/ So, how to make use
> of it on a remote server?
Indeed, it is not installed. You will either need to get it into one of your
@INC directories or specify the explicit path to the module (I think it
will work in the same directory as your scripts).
It looks like it is a strictly-perl module, so you don't need to worry
about compiling. Just get the .pm file onto the server and find a way
to use pathtomodule.pm. Try printing your @INC array from a simple
script on a web page. If there is something in it to which you have
access via ftp, put the module there.
--Eric
------------------------------
Date: Wed, 16 Apr 2003 12:58:04 +0530
From: "Kasp" <kasp@epatra.com>
Subject: Syntax problem
Message-Id: <b7j0v1$pgb$1@newsreader.mailgate.org>
The following two statements are equivalent.
if ($x) { print $x; }
print $x if ($x);
Going by the same logic for while loops:
$x=1;
while($x<10) { print $x++; }
is same as....
$x=1;
print $x++ while($x<10);
But while extending this analogy for FOR loops, I got an error.
for($x=0;$x<10;$x++){ print $x;} #compiles
but
print $x for($x=0;$x<10;$x++); ###Error
Can some one please tell me why this is happening?
Initializing $x is not the problem as with the following code also I get the
same error
$x=1;
print $x for($x=0;$x<10;$x++);
Thanks,
Kasp.
--
"Accept that some days you are the pigeon and some days the statue."
"A pat on the back is only a few inches from a kick in the butt." - Dilbert.
------------------------------
Date: Wed, 16 Apr 2003 07:38:48 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Syntax problem
Message-Id: <x7of36lwmv.fsf@mail.sysarch.com>
>>>>> "K" == Kasp <kasp@epatra.com> writes:
K> The following two statements are equivalent.
K> if ($x) { print $x; }
that is actually 2 statements.
K> print $x if ($x);
K> print $x for($x=0;$x<10;$x++); ###Error
the for modifier can only take a list. it doesn't support c style for
loops.
don't confuse statement modifiers with their similar flow control
syntax. they do similar things but in different ways.
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: Wed, 16 Apr 2003 07:15:48 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: user command with Net::FTP
Message-Id: <slrnb9q0or.3cq.bernard.el-hagin@gdndev25.lido-tech>
In article <b7iuvl$fd8$1@mamenchi.zrz.TU-Berlin.DE>, Anno Siegel wrote:
> Dr Trevor Hales <t.hales@unimelb.edu.au> wrote in comp.lang.perl.misc:
>> Dear Perlers
>> Please can advise me how I can do the following interaction using the
>> Net::FTP module within pel ?
>>
>> > Please find attached an ftp session show how you can
>> > login again as a user...
>> > > ftp <name.org.com>
>> > Connected to <name.org.com>
>
> [...]
>
> What have you tried so far?
Getting someone to do it for him.
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'
------------------------------
Date: Wed, 16 Apr 2003 01:32:41 -0700
From: Keith Keller <kkeller-spammmm@wombat.san-francisco.ca.us>
Subject: Re: user command with Net::FTP
Message-Id: <9f4j7b.ejt.ln@goaway.wombat.san-francisco.ca.us>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
In article <3e9cc21c.85626187@news.unimelb.edu.au>, Dr Trevor Hales wrote:
> Please can advise me how I can do the following interaction using the
> Net::FTP module within pel ?
perldoc Net::FTP
- --keith
- --
kkeller-mmmspam@wombat.san-francisco.ca.us
(try just my userid to email me)
alt.os.linux.slackware FAQ: http://wombat.san-francisco.ca.us/cgi-bin/fom
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.0.6 (GNU/Linux)
Comment: For info see http://www.gnupg.org
iEYEARECAAYFAj6dFSgACgkQhVcNCxZ5ID/9IQCfZutAis5pkA9DEmPwepc4L0Gi
sywAnRcfP24h1bLkfeis88Btw3HnnAEC
=ISdD
-----END PGP SIGNATURE-----
------------------------------
Date: Wed, 16 Apr 2003 13:38:20 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: user command with Net::FTP
Message-Id: <srij7b.ni9.ln@moldev.cmagroup.co.uk>
Bernard El-Hagin <bernard.el-hagin@dodge_thislido-tech.net> wrote:
>> What have you tried so far?
> Getting someone to do it for him.
Twice, at least: <3e9baf82.15329703@news.unimelb.edu.au)
Chris
--
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}
------------------------------
Date: Wed, 16 Apr 2003 08:47:54 +0100
From: Matthew Browning <usenet@NOSPAM.matthewb.org>
Subject: Re: Validating user input to match certain characters
Message-Id: <pan.2003.04.16.08.47.52.395825.450@NOSPAM.matthewb.org>
On Tue, 15 Apr 2003 14:10:31 +0100, Anno Siegel wrote:
>> #!/usr/bin/perl -w
>>
>> use strict;
>>
>> my $input = q[abshkjh-h1g4fd3]; #for example
>>
>> my $length = sub { return my @length = split( //, $input, 0 ) }; my
>> $quant = scalar(&$length);
>
> Yikes! That is an incredibly roundabout way of saying "my $quant =
> length $input". Even if you haven't heard of the length() function, why
> would you wrap the code to extract the length in an anonymous sub?
>
My footnote refers ;)
Seriously, I guess this is an example of what happens when you start with
a deliberately contrary construct and attempt to work backwards to
explain how one might get there. Perhaps a valuable Perl lesson,
therefore, is `don't do that'.
>> if( $input !~ /([a-zA-Z0-9_-]{$quant})/ ) {
>
> So the idea is to count the valid characters and see if they make up the
> total length? That can be had cheaper:
>
> $input =~ tr/a-zA-Z0-9_-// == length $input;
>
Not thought of that, very nice.
[MB]
------------------------------
Date: Wed, 16 Apr 2003 09:15:11 +0100
From: "Bigus" <bigus AT creationfactor DOT net>
Subject: Re: WIN32::ODBC problem
Message-Id: <b7j3eg$12pm@newton.cc.rl.ac.uk>
"Jay Tilton" <tiltonj@erols.com> wrote in message
news:3e9c8017.13741618@news.erols.com...
[..]
> It feels like the second Sql() method call is stepping on the first.
> That is, the statement
>
> $db->Sql("SELECT * FROM list_details ... " )
>
> creates a data set of records that need updating, but on the first
> iteration that data set gets clobbered by the statement
>
> $db->Sql("UPDATE list_details ... " )
>
> So on the next pass through the loop, there is nothing for FetchRow()
> to return.
Yes, that would figure ..odd that I've not come across it before, as wanting
to act on a set of retrieved records is something I'm sure I've done before.
Going through my previous scripts now :-)
> : and what's teh bets way of getting round it?
>
> How about simply knocking it all out in one step?
>
> $db->Sql("
> UPDATE list_details
> SET Deleted = '1'
> WHERE
> DateDeleted IS NOT NULL
> AND
> Deleted = 0
> ");
> print $db->RowCount(), " records updated.\n";
<looks embarasssed> An SQL solution again :) That would do the trick nicely.
> Or migrate to DBI where you can conveniently have several statement
> handles on one connection.
The DBI documentation, and shortage of examples therein, is making getting
to grips with that a slow process for me.. but it does look worth persisting
with.
Thanks
Bigus
------------------------------
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.
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 4852
***************************************