[16735] in Perl-Users-Digest
Perl-Users Digest, Issue: 4147 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Aug 27 21:05:21 2000
Date: Sun, 27 Aug 2000 18: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)
Message-Id: <967424708-v9-i4147@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 27 Aug 2000 Volume: 9 Number: 4147
Today's topics:
Bulk add to a hash.. Any ideas? alphazerozero@my-deja.com
Re: Bulk add to a hash.. Any ideas? (Jakob Schmidt)
Re: Bulk add to a hash.. Any ideas? (Jakob Schmidt)
Re: Bulk add to a hash.. Any ideas? (brian d foy)
Re: Bulk add to a hash.. Any ideas? (Jakob Schmidt)
Re: Bulk add to a hash.. Any ideas? (brian d foy)
Compiling Perl with on Win32 (Borland) <eyalb@aks.com>
Re: get temporary file name? <tim@ipac.caltech.edu>
Re: Global symbol "$dbh" requires explicit package name <elephant@squirrelgroup.com>
Golf: Date of Easter <tony@pyxis.blackstar.co.uk>
Re: How can I find an images size?? (Martien Verbruggen)
Re: How to Unzip a .tar.gz file <whataman@home.com>
Re: How to Unzip a .tar.gz file (brian d foy)
Re: Kill Me! (Martien Verbruggen)
Module to Download HTML Pages <grichards@flashcom.net>
pattern matching question (David Gay)
Re: pattern matching question (Jakob Schmidt)
Re: pattern matching question (Jakob Schmidt)
Re: pattern matching question (David Gay)
Re: pattern matching question (Douglas Wilson)
Re: pattern matching question <godzilla@stomp.stomp.tokyo>
Perl binary file download using octet-stream rusty_mason@my-deja.com
Re: problem with the system() function <tim@ipac.caltech.edu>
Re: stupid question probably <flavell@mail.cern.ch>
Re: Unix Perl to OpenVMS Perl <dan@tuatha.sidhe.org>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 27 Aug 2000 22:01:18 GMT
From: alphazerozero@my-deja.com
Subject: Bulk add to a hash.. Any ideas?
Message-Id: <8oc336$8um$1@nnrp1.deja.com>
I am curious if anyone knows a shortcut to adding to a hash.
I know how to create a new hash anonamously but I dont know how to add
several key/value pairs to an already existing hash at the same time.
I was hoping this woudl work, but to no avail (as was obvious when I
thought about it)
#first set up the hash
$hash={'key1'=>"value1",
'key2'=>"value2"};
#then later add to it in bulk
$hash->{'key3'=>"value3",
'key4'=>"value4"}; #but it doesnt work
$hash->{'key3'}="value3"; #however this
$hash->{'key4'}="value4"; #does... But surely its more verbose than
nec?
I suppose its not that important, but I just thought there must be some
way to do this.... TMTOWTDI?
thanx,
alphazerozero
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 28 Aug 2000 00:29:58 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Bulk add to a hash.. Any ideas?
Message-Id: <1eg1t40.1ayipiw13wturkN@[192.168.88.117]>
<alphazerozero@my-deja.com> wrote:
> I am curious if anyone knows a shortcut to adding to a hash.
> I know how to create a new hash anonamously but I dont know how to add
> several key/value pairs to an already existing hash at the same time.
>
> I was hoping this woudl work, but to no avail (as was obvious when I
> thought about it)
> #first set up the hash
> $hash={'key1'=>"value1",
> 'key2'=>"value2"};
>
> #then later add to it in bulk
> $hash->{'key3'=>"value3",
> 'key4'=>"value4"}; #but it doesnt work
>
> $hash->{'key3'}="value3"; #however this
> $hash->{'key4'}="value4"; #does... But surely its more verbose than
> nec?
Use a hash slice. They're slick and popular with the gurus - and you can
use them even for adding to an anonymous hash as the one in your
example:
# first set up the hash
$hash_reference = { key1 => 'value1',
key2 => 'value2'
};
# then add
@$hash_reference{ ( 'key3', 'key4' ) } = ( 'value3', 'value4' );
--
Jakob
------------------------------
Date: Mon, 28 Aug 2000 00:36:07 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Bulk add to a hash.. Any ideas?
Message-Id: <1eg1thr.1ktfiv2gcb6mgN@[192.168.88.117]>
Jakob Schmidt <sumus@aut.dk> wrote:
> # then add
> @$hash_reference{ ( 'key3', 'key4' ) } = ( 'value3', 'value4' );
Hey - I should've been more stylish there:
@$hash_reference{ 'key3',
'key4'
}
=
( 'value3',
'value4'
);
or something. Note - the parens in my original key list aren't
necessary. Also should have told you taht this is the one place where
the high precedence of @ as dereferencin operator comes in really handy.
HTH
--
Jakob
------------------------------
Date: Sun, 27 Aug 2000 18:47:18 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Bulk add to a hash.. Any ideas?
Message-Id: <brian-ya02408000R2708001847180001@news.panix.com>
In article <1eg1thr.1ktfiv2gcb6mgN@[192.168.88.117]>, sumus@aut.dk (Jakob Schmidt) posted:
> Jakob Schmidt <sumus@aut.dk> wrote:
>
> > # then add
> > @$hash_reference{ ( 'key3', 'key4' ) } = ( 'value3', 'value4' );
> Hey - I should've been more stylish there:
why?
> @$hash_reference{ 'key3',
> 'key4'
> }
> =
> ( 'value3',
> 'value4'
> );
the second way does not seem to enhance anything.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Mon, 28 Aug 2000 00:51:40 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: Bulk add to a hash.. Any ideas?
Message-Id: <1eg1u47.6g9crzkfgz7bN@[192.168.88.117]>
brian d foy <brian@smithrenaud.com> wrote:
> In article <1eg1thr.1ktfiv2gcb6mgN@[192.168.88.117]>, sumus@aut.dk
> (Jakob Schmidt) posted:
>
> > Jakob Schmidt <sumus@aut.dk> wrote:
> > Hey - I should've been more stylish there:
>
> why?
>
> [...]
>
> the second way does not seem to enhance anything.
Well if you're going to add a 'bulk' (sounds like at least a dozen k-v
pairs to me) it'll enhance readability hugely IMHO.
If you don't agree that's OK with me.
--
Jakob
------------------------------
Date: Sun, 27 Aug 2000 20:22:36 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Bulk add to a hash.. Any ideas?
Message-Id: <brian-ya02408000R2708002022360001@news.panix.com>
In article <1eg1u47.6g9crzkfgz7bN@[192.168.88.117]>, sumus@aut.dk (Jakob Schmidt) posted:
> brian d foy <brian@smithrenaud.com> wrote:
[ you snipped the good parts! ]
> Well if you're going to add a 'bulk' (sounds like at least a dozen k-v
> pairs to me) it'll enhance readability hugely IMHO.
then, i would suggest that a slice is not a good way to do it
(from a readability perspective).
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: 28 Aug 2000 02:09:53 +0300
From: Eyal Ben-David <eyalb@aks.com>
Subject: Compiling Perl with on Win32 (Borland)
Message-Id: <m2zolyl2ri.fsf@eyalb_home.localdomain>
Hello,
First, I have a working perl (5.6.0) compiled with C++Builder 4.
I use it successfully in an application that embed Perl in a C++Builder GUI.
The backend compiler is BC++ 5.4 (from BCB 4)
I compiled successfully many CPAN modules (libwww, libnet, libw32 and more)
The same sources fail to build correctly with BC++ 5.5(.1). This compiler is
available for free download. It is the backend compiler for C++Builder 5 too.
I could build the distribtion but many tests failed (90% okay. In BC++ 5.4
It is 100% okay)
(Since the distribution support BC++, I think the latest compiler should
always be supported, especially a free compiler. I'm no Perl guru but I can
help ifm needed)
Did anyone succeeded with the BC++ 5.5?
Does anybody know if this compiler will be supported in future distribtions?
Thanks
Eyal
------------------------------
Date: Sun, 27 Aug 2000 15:54:45 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: get temporary file name?
Message-Id: <39A99C35.218F3E8A@ipac.caltech.edu>
"s. keeling" wrote:
>
> On Tue, 08 Aug 2000 16:35:17 -0700, Tim Conrow <tim@ipac.caltech.edu> wrote:
> > % perldoc -q temporary
> >
> > =head1 Found in /usr/local/lib/perl5/5.6.0/pod/perlfaq5.pod
> >
> > =head2 How do I make a temporary file name?
> >
> > Like magic, isn't it? Documentation is a wonderful thing.
>
> This is perl, version 5.004_04 built for i386-linux
> [snip]
>
> (255) /home/keeling/_ perldoc -q temporary
> Unknown option: q
>
> Usually. Or am I (yet again) hopelessly out of date from the current
> (bleading edge) configuration?
I don't know the history of the FAQs, so I don't know if this question/answer
was around with 5.004_04. As for 'perldoc -q ...' not working: The answer is
available in the FAQs (I included the explicit reference to perlfaq5) so one can
look it up by whatever method is available.
(The "Like magic ..." comment was meant to be somewhat tongue and cheek, since
'perldoc -q' isn't always so magical in providing exactly what one wants.)
--
-- Tim Conrow tim@ipac.caltech.edu
------------------------------
Date: Mon, 28 Aug 2000 00:56:51 GMT
From: jason <elephant@squirrelgroup.com>
Subject: Re: Global symbol "$dbh" requires explicit package name at d:\...\Behzad.pl line 17.
Message-Id: <MPG.1414564434fe71a698970d@localhost>
Jeff Zucker <jeff@vpservices.com> wrote ..
>jason wrote:
>>
>> Jeff Zucker <jeff@vpservices.com> wrote ..
>> >>
>> >> jason wrote:
>> >> >
>> >> > change the above to
>> >>
>> >> > my $dbh; # separate declaration
>> >>
>> >> > $dbh = DBI->connect($data_source, $username, $password)
>> >> > or die "cant connect to $data_source : $dbh->errstr\n";
>> >>
>> >
>> >Well, personally, I don't think putting the declaration separate does
>> >anything.
>>
>> thanks for your opinion .. perl - however - agrees with me .. of course
>> - if you were testing without the $dbh in the die clause then you would
>> not have seen the error
>
>Yes, perl agrees with you if one uses $dbh->errstr and you're entirely
>correct that it needs to be separate in that case. My posting was
>ambiguous about that, thanks for clarifying. But, OTOH, perl agrees
>with me if you use $DBI->errstr and this is still the one I'd recommend:
I was leaving that for the originator to discover for themselves from
the documentation (where they would have discovered that it is
$DBI::errstr and not $DBI->errstr - and yes - I know you had it correct
in your example .. but those little errors are part of the reason why I
point people to documentation rather than type it out myself)
the other point I was making was that if you're going to use a variable
in an 'or die' construct then you must have already declared it (and
ideally initialised it as well) because if the thing that you're testing
fails then the word will not be declared and you will get errors from
strict
--
jason -- elephant@squirrelgroup.com --
------------------------------
Date: Sun, 27 Aug 2000 22:41:36 GMT
From: Tony Bowden <tony@pyxis.blackstar.co.uk>
Subject: Golf: Date of Easter
Message-Id: <AOgq5.3468$EB2.81070@news2-win.server.ntlworld.com>
We had a golf contest in work last week, to find the date of Easter Sunday.
The best I've been able to come up with (by tweaking the winning entry)
is 97 chars:
$y=pop;$a=(19*($y%19)+24)%30;$b=22+$a+(2*($y%4)+4*($y%7)+6*$a+5)%7;
print $b<32?"3/$b":"4/",$b-31
But I suspect this isn't the tersest algorithm ...
Any advances?
Tony
--
-----------------------------------------------------------------------------
Tony Bowden | tony@blackstar.co.uk http://www.blackstar.co.uk/
Black Star | The UK's Biggest Video & DVD store * Free Postage Worldwide
-----------------------------------------------------------------------------
------------------------------
Date: Mon, 28 Aug 2000 09:27:58 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: How can I find an images size??
Message-Id: <slrn8qj5fe.3fr.mgjv@martien.heliotrope.home>
[please, for future reference, put your responses after the suitably
shortened quote you reply to. It makes your posts just so much more
readable]
On Sun, 27 Aug 2000 14:56:01 +0100,
Speed Demon <speed.demon9999@virgin.net> wrote:
> "Martien Verbruggen" <mgjv@tradingpost.com.au> wrote in message
> news:slrn8qi3bn.3fr.mgjv@martien.heliotrope.home...
> > On Sun, 27 Aug 2000 12:41:51 +0100,
> > Speed Demon <speed.demon9999@virgin.net> wrote:
> > > Hi, using either Perl or Javascript is it possible to find out the
> > > dimensions of an image.
> >
> > You want the Image::Size module. Available from CPAN:
> > http://www.cpan.org/
>
> I can't open the tar.gz files as im on windows, can someone send the files
> in either a .zip or uncompressed format to me so I can upload to my UNIX
> host?
Get yourself winzip, it read gzipped tar files. Or get some windows
versions of gzip and tar. Otherwise you'll have to ask here every time
you need a module. www.tucows.com should have some stuff for you.
But wouldn't it be easier to just ask your ISP to install the module?
Martien
--
Martien Verbruggen |
Interactive Media Division | In a world without fences, who needs
Commercial Dynamics Pty. Ltd. | Gates?
NSW, Australia |
------------------------------
Date: Sun, 27 Aug 2000 22:20:46 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: How to Unzip a .tar.gz file
Message-Id: <39A9947D.149F02FB@home.com>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<p>BUCK NAKED1 wrote:
<blockquote TYPE=CITE>Can someone please help me out with a perl
script(not command line
<br>input) for unzipping a .tar.gz file from my Unix/Apache webserver.
I've
<br>tried
<p>do gunzip xvf filename.tar.gz -tar
<p>etc., and it gives an internal 500 error and won't run. I tried to use
<br>the module Compress::Zlib which is installed on my server, but all
the
<br>error log says when using that module is that inflate() failed.
<p>Thanks.
<p>--Dennis
<br> </blockquote>
I forgot to add that I have also tried the following codes on my webserver
to no avail:
<p>/usr/um/gnu/bin/gunzip filename.tar.Z
<br> tar -xvf filename.tar
<p>or
<p> /usr/um/gnu/bin/zcat filename.tar.Z | tar -xvf
-
<p>FWIW, I have a perl script that will unzip a .zip (Windows) file, but
not one to unzip .tar.gz (Unix) files. A perl script to extract a .tar.gz
file would really be helpful, as sometimes I'm on a system that has no
available program for unzipping .tar.gz files. Additionally, it might cut
down on some of my perl questions here because much of the perl documentation
is only in .tar.gz format. Would someone PLEEZE post a working perl script
to do this?!?! I'm begging, yes.
<p>Thanks,
<br>Dennis</html>
------------------------------
Date: Sun, 27 Aug 2000 18:42:27 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: How to Unzip a .tar.gz file
Message-Id: <brian-ya02408000R2708001842270001@news.panix.com>
In article <39A9947D.149F02FB@home.com>, "What A Man !" <whataman@home.com> posted:
> FWIW, I have a perl script that will unzip a .zip (Windows) file, but
> not one to unzip .tar.gz (Unix) files. A perl script to extract a .tar.gz
> file would really be helpful, as sometimes I'm on a system that has no
> available program for unzipping .tar.gz files.
use the Archive::Tar and Compress::Zlib modules.
--
brian d foy
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>
------------------------------
Date: Mon, 28 Aug 2000 09:40:38 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Kill Me!
Message-Id: <slrn8qj676.3fr.mgjv@martien.heliotrope.home>
On Sun, 27 Aug 2000 11:35:40 -0400,
Albert Dewey <timewarp@shentel.net> wrote:
>
> Martien Verbruggen wrote:
>
> > On Sat, 26 Aug 2000 18:04:27 -0400,
> > Albert Dewey <timewarp@shentel.net> wrote:
> >
> > I saw a few followups to your stuff, so I temporarily removed the kill.
> > I believe I can help you out here.
>
> even mentioned posting after quoting, but that is not the issue. These
> very people who have jumped down my throat on this issue are equally
> guilty of bad netiquette behavior according to many of these sites.
Usenet is not the best forum to encourage rational well-thought
discussions. It isn't always easy to see the point of view of the other
person and not having the normal visual and aural clues that
face-to-face discussion provides doesn't help either. Apart from that,
many regulars here were on Usenet way before the Web, and some even
before it was part of the Internet. They see their world destroyed by
people who don't know the rules. If someone then professes that he
doesn't want to know the rules, and he won't listen when people point
them out, they get angry. That person in response gets defensive, and
you have your flamewar.
That's what happened here, isn't it?
> The remainder of my list that I had posted specifically deal with
> these things that I personally saw as posting violations that most of
> my abusers are indeed guilty of at least one of them on regular
> occasion. <list follows>
I am glad you have decided to give this some more thought, but your list
still includes one or two things that are not a good thing. The most
important one:
> # I will answer off topic questions if I really believe that I can help
> that person with an answer that is Perl related or even combining Perl
> with other solutions.
Please, don't do this. If you want to help people that post offtopic
questions, do it by email. The groups has more than enough noise as it
is, and there is simply too much for us to read. I have personally
resorted to filtering out certain subjects, simply because experience
has taught me that 90% of the posts with tose subjects are offtopic. It
means I kill about half of the posts, most based on subject, and I still
sometimes feel overwhelmed by the number of posts, especially after I
haven't been able to read news for a few days.
All you do by perpetuating this sort of thing is making the group
unreadable, with the result that the only people left are the ones that
ask questions. Not the ones that answer.
Martien
--
Martien Verbruggen |
Interactive Media Division | The gene pool could use a little
Commercial Dynamics Pty. Ltd. | chlorine.
NSW, Australia |
------------------------------
Date: Sun, 27 Aug 2000 16:13:09 -0700
From: "Gabe" <grichards@flashcom.net>
Subject: Module to Download HTML Pages
Message-Id: <sqj7uj7ot9188@corp.supernews.com>
Does a module exists which will follow all the links on a page and download
those pages?
Gabe
------------------------------
Date: Sun, 27 Aug 2000 22:49:45 GMT
From: david@palmetto.net (David Gay)
Subject: pattern matching question
Message-Id: <39a996b4.4028269@news.duesouth.net>
Greetings-
I'm trying to check a pattern to ensure that it's a 6 digit, hyphen
delimited set of numbers, each no less than 0 nor greater than 4 .
Example:
0-1-2-3-4-4 or 1-2-1-3-4-0 is acceptable.
02-1-2-3-4-4 or 0-1-2-3-4-5 is not acceptable.
I must specify to only match a single occurence of each digit,
therefore using ? for zero or one occurence is no good, nor is * for
zero or more occurences.
So I tried {1} to specify exactly one occurence like this:
if ($spec_pat !~
/[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}/ {
miscellaneous code;
}
This will still match 02-0-1-2-3-4 which is not what I desire.
What've I overlooked here?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Gay
David Gay Development
Worry gives a small thing a big shadow ;-)
- Swedish proverb
------------------------------
Date: Mon, 28 Aug 2000 01:02:18 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: pattern matching question
Message-Id: <1eg1uov.l65bc1vnthlsN@[192.168.88.117]>
David Gay <david@palmetto.net> wrote:
> 0-1-2-3-4-4 or 1-2-1-3-4-0 is acceptable.
> 02-1-2-3-4-4 or 0-1-2-3-4-5 is not acceptable.
[...]
> if ($spec_pat !~
> /[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}/ {
> miscellaneous code;
> }
the problem is that your expression doesn't demand that there's nothing
before (or after) the digits. When you want one char you don't need at
quantifyer at all. Which leads us to
/^[0-4]\-[0-4]\-[0-4]\-[0-4]\-[0-4]\-[0-4]$/
or /^([0-4]\-){5}[0-4]$/
--
Jakob
------------------------------
Date: Mon, 28 Aug 2000 01:04:33 +0200
From: sumus@aut.dk (Jakob Schmidt)
Subject: Re: pattern matching question
Message-Id: <1eg1uxh.1qy04civluwl5N@[192.168.88.117]>
Jakob Schmidt <sumus@aut.dk> wrote:
> /^[0-4]\-[0-4]\-[0-4]\-[0-4]\-[0-4]\-[0-4]$/
>
> or /^([0-4]\-){5}[0-4]$/
make that
/^[0-4]-[0-4]-[0-4]-[0-4]-[0-4]-[0-4]$/
or /^([0-4]-){5}[0-4]$/
- you don't need to escape '-' outside [].
I must be tired.
--
Jakob
------------------------------
Date: Sun, 27 Aug 2000 23:12:49 GMT
From: david@palmetto.net (David Gay)
Subject: Re: pattern matching question
Message-Id: <39a99ff2.6395178@news.duesouth.net>
On Mon, 28 Aug 2000 01:02:18 +0200, sumus@aut.dk (Jakob Schmidt)
wrote:
>the problem is that your expression doesn't demand that there's nothing
>before (or after) the digits. When you want one char you don't need at
>quantifyer at all. Which leads us to
>
>/^[0-4]\-[0-4]\-[0-4]\-[0-4]\-[0-4]\-[0-4]$/
>
>or /^([0-4]\-){5}[0-4]$/
>
>--
>Jakob
Thank you Jakob, that easily solved the problem.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
David Gay
David Gay Development
Worry gives a small thing a big shadow ;-)
- Swedish proverb
------------------------------
Date: Sun, 27 Aug 2000 23:09:15 GMT
From: dwilson@gtemail.net (Douglas Wilson)
Subject: Re: pattern matching question
Message-Id: <39a99ebf.1291122@news>
On Sun, 27 Aug 2000 22:49:45 GMT, david@palmetto.net (David Gay) wrote:
>Greetings-
>
>I'm trying to check a pattern to ensure that it's a 6 digit, hyphen
>delimited set of numbers, each no less than 0 nor greater than 4 .
>
>Example:
>0-1-2-3-4-4 or 1-2-1-3-4-0 is acceptable.
>02-1-2-3-4-4 or 0-1-2-3-4-5 is not acceptable.
>if ($spec_pat !~
>/[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}\-[0-4]{1}/ {
> miscellaneous code;
>}
Why use {1} qualifiers at all? and dashes are not special, so
no need to escape them. So:
/^[0-4]-[0-4]-[0-4]-[0-4]-[0-4]-[0-4]$/
or:
/^[0-4](-[0-4]){5}$/
HTH,
Douglas Wilson
------------------------------
Date: Sun, 27 Aug 2000 17:34:09 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: pattern matching question
Message-Id: <39A9B381.F49D65D6@stomp.stomp.tokyo>
David Gay wrote:
> I'm trying to check a pattern to ensure that it's a 6 digit, hyphen
> delimited set of numbers, each no less than 0 nor greater than 4 .
> Example:
> 0-1-2-3-4-4 or 1-2-1-3-4-0 is acceptable.
> 02-1-2-3-4-4 or 0-1-2-3-4-5 is not acceptable.
(snip)
A few weeks back, a number of experts here proclaimed
" exit; " to be of little value, if any value at all.
This meets your parameters precisely and affords an
alternative to usual Perl 5 Cargo Cult. Do not respond
with changed parameters and "This doesn't work."
TEST SCRIPT:
____________
#!/usr/local/bin/perl
print "Content-Type: text/plain\n\n";
$string = "0-0-0-0-0-0";
if (${\length ($string)} > 11)
{ print "Boss, string is too long.\n $string"; exit; }
if (${\length ($string)} < 11)
{ print "Boss, string is too short.\n $string"; exit; }
@Array = split (/-/, $string);
if (($#Array < 5) || ($#Array > 5))
{ print "Boss, string format is wrong.\n $string"; exit; }
foreach $element (@Array)
{
if ($element > 4)
{ print "Boss, some numbers are too big.\n $string"; exit; }
}
print "Your string passes all tests. Boss, you are a genius!",
"\n String: $string";
print "\n\n\n--\nGodzilla Rocks!\n",
" http://la.znet.com/~callgirl3/inagadda.mid";
exit;
PRINTED RESULTS:
________________
Your string passes all tests. Boss, you are a genius!
String: 0-0-0-0-0-0
--
Godzilla Rocks!
http://la.znet.com/~callgirl3/inagadda.mid
------------------------------
Date: Sun, 27 Aug 2000 22:17:22 GMT
From: rusty_mason@my-deja.com
Subject: Perl binary file download using octet-stream
Message-Id: <8oc415$9ti$1@nnrp1.deja.com>
Hello, Perl wizards, how are you? I hope you can help me, I've got a
script here I can't get working. I'm trying to validate users before
letting them download certain binary files. The script below is the
best thing I could piece together so far, but it doesn't work. Does
anyone know why? This is running on Unix/Apache.
Thanks,
Rusty
#!/usr/bin/perl
$binary = "robert_e_mason.doc";
$size = -s "$binary";
open(INFILE,"<$binary") or die $!;
print "Content-Type:application/octet-stream\n";
print "Content-Disposition:attachment; filename=robert_e_mason.doc\n";
print "Content-Length:$size\n\n";binmode(INFILE);binmode(STDOUT);
while(<INFILE>){
print $_;
}
close(INFILE);
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Sun, 27 Aug 2000 16:13:22 -0700
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: problem with the system() function
Message-Id: <39A9A092.EC9F0070@ipac.caltech.edu>
vincent picard wrote:
> #!/usr/bin/perl
> print "Content-type: text/html\n\n";
> @cmd=("vnewvirtmaps");
> $a=system("@cmd");
> unless ($a==0)
> {
> print "ERREUR DANS @cmd ===> $a";
> exit;
> }
>
> the system function never works. it send back a 65280 error level, even if i
> use thue complete path of the system called function.
> the problem is the same with any system command (echo, ls, ....)
> i 'm working under a freebsd system.
Since your code is acceptable perl, I assume it must be related to your CGI
environment. Perhaps you don't have permission to fork/exec?
--
-- Tim Conrow tim@ipac.caltech.edu 626-395-8435
------------------------------
Date: Mon, 28 Aug 2000 02:25:56 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: stupid question probably
Message-Id: <Pine.GHP.4.21.0008280224240.7184-100000@hpplus03.cern.ch>
On Sun, 27 Aug 2000, BUCK NAKED1 wrote:
> >flavell@mail.cern.ch (Alan J. Flavell) >wrote: Standard HTML has no
> such tag...
>
> Huh? Of course HTML has an embed tag,
If you genuinely believe you have a good answer to the off-topic
question, you should at least have the self-confidence to cross-post
your answer to the appropriate group.
------------------------------
Date: Sun, 27 Aug 2000 22:43:22 GMT
From: Dan Sugalski <dan@tuatha.sidhe.org>
Subject: Re: Unix Perl to OpenVMS Perl
Message-Id: <eQgq5.4830$CW2.45617@news1.rdc1.ct.home.com>
Stephen Bishop <sbishop@mincom.com> wrote:
> Hi everyone,
> I'm totally new to Perl and VMS, and have been given a Perl script in Unix
> and have been asked to convert it, so that it will run on an OpenVMS system.
> Has anyone ever done this before?
Sure, all the time. :)
> I'm wondering what sort of changes I will need to make.
For pure-perl code, generally nothing, though you might need to mess with
embedded paths in filenames and suchlike things.
> Obviously I will need to remove any references to Unix commands (like dd),
> and will also have to change the directory structures, but I would greatly
> appreciate any hints or clues as to exactly what I will need to change.
Perl on VMS takes Unix-style filenames, so for plain file reading and
writing you probably won't need to do much at all. To invoke external
commands, of course, things will be different, and what you need to do
depends on what the replaced command does. There are generally VMS analogs
to pretty much everything Unix, though you may need to think VMS-style to
get things working the way you want.
"perldoc perlvms" is your friend, it explains many of the
platform-specific issues you'll encounter. The VMSPerl mailing list
(vmsperl@perl.org) is also a good spot to go to for VMS-specific perl
info.
Dan
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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 V9 Issue 4147
**************************************