[22365] in Perl-Users-Digest
Perl-Users Digest, Issue: 4586 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 19 18:06:21 2003
Date: Wed, 19 Feb 2003 15:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 19 Feb 2003 Volume: 10 Number: 4586
Today's topics:
A simple problem befuddling my simple head (Liam James)
Re: A simple problem befuddling my simple head <Graham.T.Wood@oracle.com>
Re: A simple problem befuddling my simple head (Tad McClellan)
Also religious: brackets <mr@sandman.net>
Re: Also religious: brackets <shondell@cis.ohio-state.edu>
Re: Also religious: brackets <mr@sandman.net>
Check for occurrence of element in Array <upro@gmx.net>
Re: Check for occurrence of element in Array <wichmann@uni-wuppertal.de>
Re: Check for occurrence of element in Array <mr@sandman.net>
Re: Check for occurrence of element in Array <me@privacy.net>
Re: Check for occurrence of element in Array (Tad McClellan)
Re: Compiling Perl with Intel Linux C++ Compiler (Seth Brundle)
Re: dbd-pg (postgres) on windows <swen@news.com>
Re: DBD::CSV creates tables with column names in upper (john harrold)
How do I get the current date? <justinagraham@hotmail.com>
Re: How do I get the current date? <mr@sandman.net>
Re: How do I get the current date? <justinagraham@hotmail.com>
Re: How do I get the current date? <tony_curtis32@yahoo.com>
Re: How do I get the current date? <uri@stemsystems.com>
Re: How do I get the current date? <mr@sandman.net>
Re: How do I get the current date? <krahnj@acm.org>
Re: How do I get the current date? <uri@stemsystems.com>
Re: How do I get the current date? <me@privacy.net>
how to install bzip2-102-x86-win32 (samphdauto)
Re: how to install bzip2-102-x86-win32 <news@wildgooses.com>
Re: how to join 2 text files sql style in perl <jeff@vpservices.com>
Re: Is "123abc" a number? (Anno Siegel)
Re: Is "123abc" a number? <abigail@abigail.nl>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 19 Feb 2003 11:33:45 -0800
From: liamngs@aol.com (Liam James)
Subject: A simple problem befuddling my simple head
Message-Id: <d85a8322.0302191133.6b8f22e9@posting.google.com>
Hello,
I am just learning PERL, and I am trying to set up a simple validation
script, it checks to set that the content of one edit box is the same
as another. Its similar to 'choose a password - now confirm it'. No
matter what I do I keep getting a 500 error.
So far I have :
==============
#!/bin/perl -w
use CGI;
$cgiobject = new CGI;
$email1=$cgiobject->param("email1");
$email2=$cgiobject->param("email2");
print $cgiobject->header;
test();
sub test
{
If ($email1 eq $email2)
{print "yes they match"}
else
{print "no they dont"}
}
I have been prowling the archives of this group for most of the
afternoon, and have found several approaches, but cannot get any to
work. Can anyone suggest anyhting to help ? I have preinted out
contents of email1/email2 from the htm page so i know they are coming
through ok, and are identical, and that the path to PERL is correct.
Thanks for any help, sorry about the simplistic stupidity of the
question.
Liam
------------------------------
Date: Wed, 19 Feb 2003 20:01:15 +0000
From: Graham Wood <Graham.T.Wood@oracle.com>
Subject: Re: A simple problem befuddling my simple head
Message-Id: <3E53E28B.7DFCF9C8@oracle.com>
Liam James wrote:
> Hello,
>
> I am just learning PERL, and I am trying to set up a simple validation
> script, it checks to set that the content of one edit box is the same
> as another. Its similar to 'choose a password - now confirm it'. No
> matter what I do I keep getting a 500 error.
>
> So far I have :
>
> ==============
>
> #!/bin/perl -w
>
> use CGI;
>
> $cgiobject = new CGI;
>
> $email1=$cgiobject->param("email1");
> $email2=$cgiobject->param("email2");
>
> print $cgiobject->header;
>
> test();
>
> sub test
>
> {
>
> If ($email1 eq $email2)
> {print "yes they match"}
>
> else
> {print "no they dont"}
>
> }
>
> I have been prowling the archives of this group for most of the
> afternoon, and have found several approaches, but cannot get any to
> work. Can anyone suggest anyhting to help ? I have preinted out
> contents of email1/email2 from the htm page so i know they are coming
> through ok, and are identical, and that the path to PERL is correct.
>
> Thanks for any help, sorry about the simplistic stupidity of the
> question.
>
> Liam
Is your 500 error from you web browser? Try running perl -c scriptname on
the command line (-c will check that it compiles without trying to run
it).. I cut'n'pasted this to a script and got a message telling the there
is a syntax error at line 19 near ")
{"
Try writing "if" instead of "If".
Graham
------------------------------
Date: Wed, 19 Feb 2003 15:33:51 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: A simple problem befuddling my simple head
Message-Id: <slrnb57u1v.1vi.tadmc@magna.augustmail.com>
Graham Wood <Graham.T.Wood@oracle.com> wrote:
> Is your 500 error from you web browser?
Web browsers do not generate that error.
Web servers do.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 19 Feb 2003 23:34:56 +0100
From: Sandman <mr@sandman.net>
Subject: Also religious: brackets
Message-Id: <mr-DD6C65.23345619022003@news.fu-berlin.de>
How do you use brackets in your code in loops or if statements? Here are some
versions I can come up with:
# 1
if (statement){
do ..
} else {
do ...
}
# 2
if (statement){ do ... }
else { do ... }
# 3
if (statement)
{
do ...
}
else
{
do ...
}
Any other variations you prefer? I am a #1 guy myself, but use #2 if the do's
are one-liners.
--
Sandman[.net]
------------------------------
Date: 19 Feb 2003 17:46:49 -0500
From: Ryan Shondell <shondell@cis.ohio-state.edu>
Subject: Re: Also religious: brackets
Message-Id: <xcw65rfanxi.fsf@psi.cis.ohio-state.edu>
Sandman <mr@sandman.net> writes:
> How do you use brackets in your code in loops or if statements? Here
> are some versions I can come up with:
>
> # 1
> if (statement){
> do ..
> } else {
> do ...
> }
>
> # 2
> if (statement){ do ... }
> else { do ... }
>
> # 3
> if (statement)
> {
> do ...
> }
> else
> {
> do ...
> }
Or #4:
if (something) {
do ...
}
else {
do ...
}
You should check out perldoc perlstyle, if you haven't already. It has
some info on things like this.
--
Ryan Shondell <shondell@cis.ohio-state.edu>
------------------------------
Date: Wed, 19 Feb 2003 23:53:50 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Also religious: brackets
Message-Id: <mr-7A29A9.23535019022003@news.fu-berlin.de>
In article <xcw65rfanxi.fsf@psi.cis.ohio-state.edu>,
Ryan Shondell <shondell@cis.ohio-state.edu> wrote:
> > # 1
> > if (statement){
> > do ..
> > } else {
> > do ...
> > }
> >
> > # 2
> > if (statement){ do ... }
> > else { do ... }
> >
> > # 3
> > if (statement)
> > {
> > do ...
> > }
> > else
> > {
> > do ...
> > }
>
> Or #4:
>
> if (something) {
> do ...
> }
> else {
> do ...
> }
That's identical to #1 apart from one newline.
You just made that one to be compliant with Larry! :-D
> You should check out perldoc perlstyle, if you haven't already. It has
> some info on things like this.
Well, this is, including perldoc perlstyle, after all a matter of personal
taste rather than right/wrong :)
--
Sandman[.net]
------------------------------
Date: Wed, 19 Feb 2003 21:22:46 +0100
From: upro <upro@gmx.net>
Subject: Check for occurrence of element in Array
Message-Id: <87smukdnqh.fsf@web.de>
Hello,
I'm quite sure this is an easy issue, but please help...:
I want to check for occurrences of a pattern in an array.
E. g. my array contains the valuaes "de", "en", and "fr". I have
anther list with iso codes, and I want to check for their presence.
Well, I guess what I want to do is a kind of pattern matching on an
array...
I have heard that it is better tpo do this with a hash but I don't
know how to do that.
Any help (woith array or hash) is greatly appreciated...
Yours,
Michael
------------------------------
Date: Wed, 19 Feb 2003 21:35:55 +0100
From: Ingo Wichmann <wichmann@uni-wuppertal.de>
Subject: Re: Check for occurrence of element in Array
Message-Id: <b30q48$t9s$03$1@news.t-online.com>
upro schrieb:
> Hello,
>
> I'm quite sure this is an easy issue, but please help...:
>
> I want to check for occurrences of a pattern in an array.
>
> E. g. my array contains the valuaes "de", "en", and "fr". I have
> anther list with iso codes, and I want to check for their presence.
> Well, I guess what I want to do is a kind of pattern matching on an
> array...
>
> I have heard that it is better tpo do this with a hash but I don't
> know how to do that.
>
> Any help (woith array or hash) is greatly appreciated...
perldoc -q array -q element
How can I tell whether a list or array contains a
certain element?
Hearing the word "in" is an indication that you
probably should have used a hash, not a list or
array, to store your data. Hashes are designed to
answer this question quickly and efficiently.
Arrays aren't.
Ingo
------------------------------
Date: Wed, 19 Feb 2003 21:57:56 +0100
From: Sandman <mr@sandman.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <mr-939130.21575619022003@news.fu-berlin.de>
In article <87smukdnqh.fsf@web.de>, upro <upro@gmx.net> wrote:
> Hello,
>
> I'm quite sure this is an easy issue, but please help...:
>
> I want to check for occurrences of a pattern in an array.
>
> E. g. my array contains the valuaes "de", "en", and "fr". I have
> anther list with iso codes, and I want to check for their presence.
> Well, I guess what I want to do is a kind of pattern matching on an
> array...
>
> I have heard that it is better tpo do this with a hash but I don't
> know how to do that.
>
> Any help (woith array or hash) is greatly appreciated...
@countries=("se", "us", "fr", "de", "it", "no", "be");
@scandinavia=("dk", "no", "se", "fi");
foreach $c (@countries){
print "$c is in scandinavia\n" if grep {$c eq $_} @scandinavia;
}
Note that in the grep, $_ equals the object in @scandinavia, not @countries, so
you need to use another variable name for the foreach, or translate it
beforehand.
--
Sandman[.net]
------------------------------
Date: Thu, 20 Feb 2003 08:59:24 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: Check for occurrence of element in Array
Message-Id: <b30uo4$1gto7h$1@ID-172104.news.dfncis.de>
"upro" <upro@gmx.net> wrote in message news:87smukdnqh.fsf@web.de...
> Hello,
>
> I'm quite sure this is an easy issue, but please help...:
>
> I want to check for occurrences of a pattern in an array.
>
> E. g. my array contains the valuaes "de", "en", and "fr". I have
> anther list with iso codes, and I want to check for their presence.
> Well, I guess what I want to do is a kind of pattern matching on an
> array...
>
> I have heard that it is better tpo do this with a hash but I don't
> know how to do that.
>
> Any help (woith array or hash) is greatly appreciated...
my %lang = (
'en' => 'English',
'de' => 'German',
'fr' => 'French'
);
print "French exists\n" if $lang{'fr'};
------------------------------
Date: Wed, 19 Feb 2003 15:38:12 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Check for occurrence of element in Array
Message-Id: <slrnb57ua4.1vi.tadmc@magna.augustmail.com>
upro <upro@gmx.net> wrote:
> E. g. my array contains the valuaes "de", "en", and "fr". I have
> anther list with iso codes, and I want to check for their presence.
> I have heard that it is better tpo do this with a hash but I don't
> know how to do that.
my %tld;
$tld{de} = 1;
$tld{en} = 1;
$tld{fr} = 1;
if ( $tld{$isocode} )
{ print "found $isocode\n" }
else
{ print "$isocode not found\n" }
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 19 Feb 2003 11:29:05 -0800
From: brundlefly76@hotmail.com (Seth Brundle)
Subject: Re: Compiling Perl with Intel Linux C++ Compiler
Message-Id: <53e2ec95.0302191129.750cc0b9@posting.google.com>
I actually I found the free non-commercial version on their website
and tried it myself - the following program ran 15% faster on my Red
Hat 7.2 Pentium III 1GHz laptop then the same version perl compiled
with gcc:
while(<>){
print if /error/;
}
...Where the input was some logfile.
I think thats astoundingly better, epspecially since I designed the
test program for 'what i typically do with perl' and figured it was
just mostly a lot of I/O.
I cant wait to compile kernels and gcc with it!
------------------------------
Date: Wed, 19 Feb 2003 12:26:08 -0800
From: swen <swen@news.com>
Subject: Re: dbd-pg (postgres) on windows
Message-Id: <3E53E860.50979C4A@news.com>
that worked. thanks!
"Andrew Perrin (CLists)" wrote:
> swen <swen@news.com> writes:
>
> > Hi,
> >
> > I'm guessing someone here has probably used postgres with perl on
> > windows. I'm having problems at DBI->connect. for example,
> >
> > $dbh = DBI->connect('dbi:Pg:dbname=test','','');
> >
> > dies with error:
> >
> > "DBI->connect(dbname=test) failed: could not create socket: An address
> > incompatible with the requested protocol was used"
>
> It's been a while since I did this, but my best guess is that the DBI
> is trying to use a unix socket to connect to the database. Since
> Windows doesn't have unix sockets, you'd get a similar error to
> that. Try, perhaps, putting an explicit hostname in the connection
> string (localhost should do):
>
> $dbh = DBI->connect('dbi:Pg:dbname=test;host=localhost','','')
> or die $DBI->errstr;
>
> --
> ----------------------------------------------------------------------
> Andrew J Perrin - http://www.unc.edu/~aperrin
> Assistant Professor of Sociology, U of North Carolina, Chapel Hill
> clists@perrin.socsci.unc.edu * andrew_perrin (at) unc.edu
------------------------------
Date: 19 Feb 2003 14:12:15 -0800
From: jmh17@pitt.edu (john harrold)
Subject: Re: DBD::CSV creates tables with column names in upper case..
Message-Id: <31d0e2b6.0302191412.1a8777d7@posting.google.com>
Jeff Zucker <jeff@vpservices.com> wrote in message
> > so my question is why does it change all of the column names to upper
> > case? is there any way to prevent this?
>
>
> The next version of SQL::Statement (1.006) which will be out within
> about a week will correct this problem.
hey that cool. thanks for the quick reply.
------------------------------
Date: Wed, 19 Feb 2003 20:26:13 GMT
From: "Justin A. Graham" <justinagraham@hotmail.com>
Subject: How do I get the current date?
Message-Id: <3E53E86F.2090803@hotmail.com>
I want to write a script that zip up files, and names the archive
file-month-day-year.zip
How do I get the current date in a perl script?
Thanks
Justin
------------------------------
Date: Wed, 19 Feb 2003 21:34:35 +0100
From: Sandman <mr@sandman.net>
Subject: Re: How do I get the current date?
Message-Id: <mr-1DC82A.21343519022003@news.fu-berlin.de>
In article <3E53E86F.2090803@hotmail.com>,
"Justin A. Graham" <justinagraham@hotmail.com> wrote:
> I want to write a script that zip up files, and names the archive
> file-month-day-year.zip
>
> How do I get the current date in a perl script?
$filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
(localtime)[3], (localtime)[5]+1900);
--
Sandman[.net]
------------------------------
Date: Wed, 19 Feb 2003 20:39:10 GMT
From: "Justin A. Graham" <justinagraham@hotmail.com>
Subject: Re: How do I get the current date?
Message-Id: <3E53EB78.7020002@hotmail.com>
Sandman wrote:
> $filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
> (localtime)[3], (localtime)[5]+1900);
>
Thanks :)
------------------------------
Date: Wed, 19 Feb 2003 14:40:32 -0600
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: How do I get the current date?
Message-Id: <87ptpongvz.fsf@limey.hpcc.uh.edu>
>> On Wed, 19 Feb 2003 21:34:35 +0100,
>> Sandman <mr@sandman.net> said:
> In article <3E53E86F.2090803@hotmail.com>,
> "Justin A. Graham" <justinagraham@hotmail.com> wrote:
>> I want to write a script that zip up files, and names
>> the archive file-month-day-year.zip
>>
>> How do I get the current date in a perl script?
> $filename = sprintf("file-%02d-%02d-%04d.zip",
> (localtime)[4]+1, (localtime)[3], (localtime)[5]+1900);
3 separate calls to localtime() ? Not good,
(a) inefficient,
(b) each one returns a different date/time
use POSIX qw(strftime);
my $filename = strftime('file-%m-%d-%Y.zip', localtime);
hth
t
------------------------------
Date: Wed, 19 Feb 2003 21:03:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How do I get the current date?
Message-Id: <x7wujwq8y0.fsf@mail.sysarch.com>
cc'ed to the OP so he doesn't use this bad code.
>>>>> "S" == Sandman <mr@sandman.net> writes:
S> In article <3E53E86F.2090803@hotmail.com>,
S> "Justin A. Graham" <justinagraham@hotmail.com> wrote:
>> I want to write a script that zip up files, and names the archive
>> file-month-day-year.zip
>>
>> How do I get the current date in a perl script?
S> $filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
S> (localtime)[3], (localtime)[5]+1900);
GACK!!
what if those calls to localtime just happen to straddle the interval
between an hour, day or even month?
there is no guarantee they will all return the same time.
and don't say that it seems to work. it will fail eventually and when
you least expect or want it. murphy lives for bugs like that.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Wed, 19 Feb 2003 22:35:46 +0100
From: Sandman <mr@sandman.net>
Subject: Re: How do I get the current date?
Message-Id: <mr-397960.22354619022003@news.fu-berlin.de>
In article <x7wujwq8y0.fsf@mail.sysarch.com>,
Uri Guttman <uri@stemsystems.com> wrote:
> cc'ed to the OP so he doesn't use this bad code.
>
> >>>>> "S" == Sandman <mr@sandman.net> writes:
>
> S> In article <3E53E86F.2090803@hotmail.com>,
> S> "Justin A. Graham" <justinagraham@hotmail.com> wrote:
>
> >> I want to write a script that zip up files, and names the archive
> >> file-month-day-year.zip
> >>
> >> How do I get the current date in a perl script?
>
> S> $filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
> S> (localtime)[3], (localtime)[5]+1900);
>
> GACK!!
>
> what if those calls to localtime just happen to straddle the interval
> between an hour, day or even month?
And what if a meteor crashes into his house at the same time.
--
Sandman[.net]
------------------------------
Date: Wed, 19 Feb 2003 21:48:56 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: How do I get the current date?
Message-Id: <3E53FB7A.EB02001E@acm.org>
"Justin A. Graham" wrote:
>
> I want to write a script that zip up files, and names the archive
> file-month-day-year.zip
>
> How do I get the current date in a perl script?
use POSIX qw(strftime);
my $file = strftime( 'file-%m-%d-%Y.zip', localtime );
John
--
use Perl;
program
fulfillment
------------------------------
Date: Wed, 19 Feb 2003 21:59:53 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: How do I get the current date?
Message-Id: <x7ptpoq6cm.fsf@mail.sysarch.com>
>>>>> "S" == Sandman <mr@sandman.net> writes:
S> In article <x7wujwq8y0.fsf@mail.sysarch.com>,
S> Uri Guttman <uri@stemsystems.com> wrote:
>> cc'ed to the OP so he doesn't use this bad code.
>>
>> >>>>> "S" == Sandman <mr@sandman.net> writes:
>>
S> In article <3E53E86F.2090803@hotmail.com>,
S> "Justin A. Graham" <justinagraham@hotmail.com> wrote:
>>
>> >> I want to write a script that zip up files, and names the archive
>> >> file-month-day-year.zip
>> >>
>> >> How do I get the current date in a perl script?
>>
S> $filename = sprintf("file-%02d-%02d-%04d.zip", (localtime)[4]+1,
S> (localtime)[3], (localtime)[5]+1900);
>>
>> GACK!!
>>
>> what if those calls to localtime just happen to straddle the interval
>> between an hour, day or even month?
S> And what if a meteor crashes into his house at the same time.
just will be fully dead instead of brain dead.
it still is bad code. justifying low odds on a bug happening means you
don't understand coding.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Thu, 20 Feb 2003 09:01:05 +1100
From: "Tintin" <me@privacy.net>
Subject: Re: How do I get the current date?
Message-Id: <b30ur8$1fh22h$1@ID-172104.news.dfncis.de>
"Justin A. Graham" <justinagraham@hotmail.com> wrote in message
news:3E53E86F.2090803@hotmail.com...
> I want to write a script that zip up files, and names the archive
> file-month-day-year.zip
Please try to use a sensible date format where ever possible. The ISO date
format is unambigious and sorts easily (YYYYMMDD)
------------------------------
Date: 19 Feb 2003 11:05:55 -0800
From: samj@eisa.net.au (samphdauto)
Subject: how to install bzip2-102-x86-win32
Message-Id: <65050d4c.0302191105.538d821e@posting.google.com>
Hello
I downlaoded bzip2-102-x86-win32 and don't know how to install it on
my W2K. I got it inorder to unzip gcc-3.2.2.tar.bz2 and install it
inorder to compile Perl source code. so I am way back there and need
some help...
thanks
Sam
------------------------------
Date: Wed, 19 Feb 2003 20:24:03 GMT
From: "Ed W" <news@wildgooses.com>
Subject: Re: how to install bzip2-102-x86-win32
Message-Id: <DJR4a.415852$1y5.2959731@news.easynews.com>
I have never made this module work...
Does anyone fancy writing a new one which works better and also implements
the stream functions as well? Small fee offered if you are interested...
Ed
"samphdauto" <samj@eisa.net.au> wrote in message
news:65050d4c.0302191105.538d821e@posting.google.com...
> Hello
> I downlaoded bzip2-102-x86-win32 and don't know how to install it on
> my W2K. I got it inorder to unzip gcc-3.2.2.tar.bz2 and install it
> inorder to compile Perl source code. so I am way back there and need
> some help...
>
> thanks
> Sam
------------------------------
Date: Wed, 19 Feb 2003 13:14:01 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: how to join 2 text files sql style in perl
Message-Id: <3E53F399.4000906@vpservices.com>
Domenico Discepola wrote:
> I appreciate everyone's honest opinion. The reason that I didn't want
> to use any external packages is that I was having problems getting
> them to work (I don't wish to discuss this further, as this isn't the
> purpose of this post).
Perhaps your problems with getting the modules to work are not relevant
to you. But they are relevant to me (author of DBD::AnyData and
maintainer of DBD::CSV) and to other users of the modules. If you have
time to drop me a note off list about the problems you encountered, it
may benefit others.
--
Jeff
------------------------------
Date: 19 Feb 2003 19:32:58 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Is "123abc" a number?
Message-Id: <b30m5a$hp7$3@mamenchi.zrz.TU-Berlin.DE>
John Brock <jbrock@panix.com> wrote in comp.lang.perl.misc:
> In Perl 5.004 I find that the statement
>
> $x = "123abc" / 2;
>
> sets $x to 61.5. Is this a feature?
That depends on your point of view.
> Testing with other values
> the rule seems to be treat a string as a number up until you hit
> a character which cannot be interpreted as part of a number, and
> then ignore everything from there on (note that with the -w flag
> I do get a warning message). This would be useful to me if I knew
> I could count on it, but I did a quick search of Programming Perl
> (3rd Edition) and I couldn't find this behavior described. Is this
> an official part of the language?
I think it's described somewhere, though I can't find it in a hurry.
It is best not to use the feature (if that's what it is), simply
because it's not warning-safe. Try your code with switched-on
warnings and see. So it's no good for general consumption.
If you really think you must use it, put the operation in a small
block, and disable only this warning with "no warnings 'numeric'".
Anno
------------------------------
Date: 19 Feb 2003 19:59:48 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: Is "123abc" a number?
Message-Id: <slrnb57ohj.1ea.abigail@alexandra.abigail.nl>
Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMMCDLIX
September MCMXCIII in <URL:news:b30m5a$hp7$3@mamenchi.zrz.TU-Berlin.DE>:
"" John Brock <jbrock@panix.com> wrote in comp.lang.perl.misc:
"" > In Perl 5.004 I find that the statement
"" >
"" > $x = "123abc" / 2;
"" >
"" > sets $x to 61.5. Is this a feature?
""
"" That depends on your point of view.
""
"" > Testing with other values
"" > the rule seems to be treat a string as a number up until you hit
"" > a character which cannot be interpreted as part of a number, and
"" > then ignore everything from there on (note that with the -w flag
"" > I do get a warning message). This would be useful to me if I knew
"" > I could count on it, but I did a quick search of Programming Perl
"" > (3rd Edition) and I couldn't find this behavior described. Is this
"" > an official part of the language?
""
"" I think it's described somewhere, though I can't find it in a hurry.
"" It is best not to use the feature (if that's what it is), simply
"" because it's not warning-safe. Try your code with switched-on
"" warnings and see. So it's no good for general consumption.
*boggle*
Sir, you don't understand warnings. Warnings aren't there so you
have to code your way around them. A warning is nothing more than
Perl saying "are you sure?". A good coder, one who understands the
power of Perl would exploit the feature if (s)he knows the data
to be of that form. That's why you can turn the warnings off.
Novice programmers turn warnings on, and just focus on not generating
warnings.
"" If you really think you must use it, put the operation in a small
"" block, and disable only this warning with "no warnings 'numeric'".
I certainly would do so. Most likely, your program would get faster,
I'd expect C's atoi() to be faster than Perl's regex engine (and
afterwhich C's atoi() needs to be called anyway).
Abigail
--
perl -we '$_ = q ;4a75737420616e6f74686572205065726c204861636b65720as;;
for (s;s;s;s;s;s;s;s;s;s;s;s)
{s;(..)s?;qq qprint chr 0x$1 and \161 ssq;excess;}'
------------------------------
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 4586
***************************************