[12018] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5618 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 10 12:07:42 1999

Date: Mon, 10 May 99 09:00:20 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 10 May 1999     Volume: 8 Number: 5618

Today's topics:
    Re: About perlre... <fabascal@gredos.cnb.uam.es>
    Re: ActivePerl under W95 latsharj@my-dejanews.com
    Re: Authentication <bill@fccj.org>
    Re: combining data in a text delimited file (Tad McClellan)
    Re: email attachment <david@icon-design.com>
    Re: email attachment <gellyfish@gellyfish.com>
    Re: FAQ "I still don't get locking ..." and use strict <flavell@mail.cern.ch>
    Re: File::Find non-functional when passing arguments to (M.J.T. Guy)
    Re: Free Perl Web Database w/ full source code - commen (Jeff Vannest)
    Re: Free Perl Web Database w/ full source code - commen (Bart Lateur)
    Re: matching resource ID's <ebohlman@netcom.com>
    Re: matching resource ID's (Tad McClellan)
    Re: Need a little looping help <jdf@pobox.com>
    Re: Need a little looping help (Tad McClellan)
        Never mind - I got it (Jared Hecker)
    Re: Oops, here is the script <aqumsieh@matrox.com>
        Oraperl help - inserting perl vars (Jared Hecker)
        readdir sorted by modify date? <tbusche@ncsi-net.com>
    Re: reqiure script (Tad McClellan)
        STDIN/STDOUT to and from a new shell <chad13@bellsouth.net>
    Re: STDIN/STDOUT to and from a new shell (Tad McClellan)
    Re: testing expressions in the IF statement <jwilson@ic.ac.uk>
    Re: testing expressions in the IF statement (Tad McClellan)
    Re: Warnings about uninintialised variables despite use <jdf@pobox.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 10 May 1999 17:07:41 +0200
From: Federico Abascal <fabascal@gredos.cnb.uam.es>
Subject: Re: About perlre...
Message-Id: <3736F63C.F16CC941@gredos.cnb.uam.es>

Tad McClellan wrote:

> ------------------
> #!/usr/bin/perl -w
> use strict;
>
> $_ = 'hello34 5hola 222 que tal3 ar22e you';
>
> while ( /([a-zA-Z]+|\d+)/g ) {
>    print "token: '$1'\n";
> }
> ------------------

That's what I wanted. Thanks you all.
Fede



------------------------------

Date: Mon, 10 May 1999 15:32:21 GMT
From: latsharj@my-dejanews.com
Subject: Re: ActivePerl under W95
Message-Id: <7h6u65$5sl$1@nnrp1.deja.com>

In article <7h6lv6$1h524@norma.bull.net>,
  "Arnaud Limbourg" <haytounet@my-dejanews.com> wrote:
> i am desperately trying to make the activestate version of perl work
under
> my machine (W95, personal web server 4).
>
> Each time i call a perl script i get a 405 method not allowed error.

What happens when you run the script from the command line?
What does it say in the server error log?

--
Regards,
Dick


--== Sent via Deja.com http://www.deja.com/ ==--
---Share what you know. Learn what you don't.---


------------------------------

Date: Mon, 10 May 1999 10:59:53 -0400
From: "Bill Jones" <bill@fccj.org>
Subject: Re: Authentication
Message-Id: <3736f43e.0@usenet.fccj.cc.fl.us>

In article <7h464p$5a7$1@gellyfish.btinternet.com>, Jonathan Stowe 
<gellyfish@gellyfish.com> wrote:


> On Fri, 7 May 1999 22:25:39 -0400 Brett Croman wrote:
>>
>> I have a need to authenticate logins, through an HTML form, using my Linux
>> passwd system.
>>
>
> So there I was, your honour, and the plaintiffs root password found itself
> in plain text on my hard disk - I can hardly be held to blame for my
> network interface being in promiscuous mode ...
>
> /J\


PMFJI:


/J\'s reply not withstanding;

If you must do something like this, please see -

http://www.fccj.org/Webmaster/WebPass.html

for some ideas about how to go about accomplishing your
project.  I would strongly/highly recommend a secure
https server connection, however.

HTH,
-Sneex-  :]
______________________________________________________________________
Windows is a 32-bit extension for a 16-bit patch for a 8-bit operating
system which was originally coded for a 4-Bit microprocessor by a
2-bit company that can't stand 1-bit of competition. :)

         Jacksonville Perl Mongers
         http://jacksonville.pm.org
         jax@jacksonville.pm.org


------------------------------

Date: Mon, 10 May 1999 05:27:34 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: combining data in a text delimited file
Message-Id: <6q86h7.6gc.ln@magna.metronet.com>

Rhett Sutphin (rms1@cec.wustl.edu) wrote:
: I am just learning Perl, too, but I think I can help with this.

: ($product,$quantity,$price) = split(/|/,$line);
                                       ^
                                       ^

: Hope that helps (and that it's a good way to do it -- any opinions?).


   You need to escape regex metacharacters if you want them
   to be taken literally.


   [ you should test code before submitting it to thousands
     of prying eyes  :-)
   ]


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 10 May 1999 14:43:20 +0100
From: "David Craig" <david@icon-design.com>
Subject: Re: email attachment
Message-Id: <5MBZ2.389$T3.1011@newsr2.u-net.net>


>MIME::Lite can handle most people's attachment needs.


Please excuse my ignorance, I am new to this - but how would I implement
MIME::Lite?  Could you point me to and example?

Thanks.
David Craig
david@icon-design.com




------------------------------

Date: 10 May 1999 16:23:05 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: email attachment
Message-Id: <3736f9d9@newsread3.dircon.co.uk>

David Craig <david@icon-design.com> wrote:
> 
>>MIME::Lite can handle most people's attachment needs.
> 
> 
> Please excuse my ignorance, I am new to this - but how would I implement
> MIME::Lite?  Could you point me to and example?

MIME::Lite is available from CPAN the documentation that comes with it has
numerous examples - for instance straight from the manpage:


           # Create a new multipart message:
           $msg = new MIME::Lite
                       From    =>'me@myhost.com',
                       To      =>'you@yourhost.com',
                       Cc      =>'some@other.com, some@more.com',
                       Subject =>'A message with 2 parts...',
                       Type    =>'multipart/mixed';

           # Add parts (each "attach" has same arguments as "new"):
           attach $msg
                       Type     =>'TEXT',
                       Data     =>"Here's the GIF file you wanted";
           attach $msg
                       Type     =>'image/gif',
                       Path     =>'aaa000123.gif',
                       Filename =>'logo.gif';

And then you do a $msg->send;

/J\
-- 
Jonathan Stowe <jns@gellyfish.com>



------------------------------

Date: Mon, 10 May 1999 16:06:48 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: FAQ "I still don't get locking ..." and use strict
Message-Id: <Pine.HPP.3.95a.990510160339.26032K-100000@hpplus01.cern.ch>

On Mon, 10 May 1999, Eric Bohlman wrote:

> :   Bareword "O_RWDR" not allowed while "strict subs" in use
> 
> Are you sure you have it spelled correctly? 

Oh, heavens!  Thanks a lot.

Humble apologies to all.

(Exits red-faced, waving a Supersedes: header).



------------------------------

Date: 10 May 1999 14:04:34 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: File::Find non-functional when passing arguments to &wanted
Message-Id: <7h6p1i$krg$1@pegasus.csx.cam.ac.uk>

Ilya Zakharevich <ilya@math.ohio-state.edu> wrote:
>[A complimentary Cc of this posting was sent to Charles R. Thompson
><design@raincloud-studios.com>],
>who wrote in article <MPG.119fe4c6a1252a08989681@news>:
>
>[ discussing \&findkeywords(@args) ]
>
>> > This is almost certainly not doing what you think it may be doing.
>> > You're not passing a reference to &findkeywords to File::Find::find...
>> > you're calling that subroutine *once* in the context of gathering args
>> > to find(), and then passing a reference to the return value of your
>> > subroutine's invocation.
>> > 
>> > find() wants a coderef.  Not an invocation. :)
>> 
>> Ding!
>> 
>> I decided to not move my eyes from the screen until I read this enough 
>> times for it to click (took six if you were curious). Ilya is correct in 
>> that my lack of understanding common terminology is hurting me here. Now 
>> it makes more sense than ever before! Man... that was kind of a dumb 
>> thing to do now that I understand it. Of course it didn't work. :)
>
>>  perl -wde 0
>  DB<1> sub foo {12 + shift}
>
>  DB<2> x \&foo(3)
>0  SCALAR(0x20dd60)
>   -> 15
>
>I think this should be considered a bug in Perl.  \&foo(3) should at
>least produce a warning.

I consider more generally that \15 not warning is also a bug
(misfeature?) in Perl.

The \ operator ought to be applied only to variables.

But it's a bit late for that now.


Mike Guy


------------------------------

Date: Mon, 10 May 1999 14:50:52 GMT
From: jefflv@usol.com (Jeff Vannest)
Subject: Re: Free Perl Web Database w/ full source code - comments encouraged - db_Perl_Database_100.zip (0/1)
Message-Id: <3737efa2.182309301@news.usol.com>

On Mon, 10 May 1999 01:08:42 GMT, maclell@col.ca (Steve MacLellan)
wrote:
>IMHO this was the right place to post it. Others, here, are often
>quick to tell you your post doesn't belong here. As far as I am
>concerned the "misc" should include scripts. and anything and
>everything else that is miscellaneous Perl.

Thank you for understanding.  I have been encouraged by others to post
just a URL for the scripts: http://www.usol.com/~jefflv  (scripts
packed in .zip format)

I would still appreciate critique on my coding.  Also, I believe these
scripts will be helpful to "perlbies" trying to use flat (text) files
as database sources.

Jeff Vannest


------------------------------

Date: Mon, 10 May 1999 14:57:34 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: Free Perl Web Database w/ full source code - comments encouraged - db_Perl_Database_100.zip (0/1)
Message-Id: <3736f23d.20334717@news.skynet.be>

Jeff Vannest wrote:

>It occurs to me that this newsgroup was not the appropriate place to
>post this message - especially with a file attached.  My apologies in
>advance (but feel free to flame me anyway, for I apparently deserve
>it!)

In concept, it's not the right place to post binaries. Scripts, yes, in
source form.

Looking at the contents of the ZIP file, it was pretty impossible to
post it in source form, because of the large number of files. ALthough I
haven't tested your brainchild (yet), it does seem, huh, interesting.

Be awaren though, that serveices like Dejanews have filters so they
don't archive binaries. Ususally. So it might be that in a few  days
time your post (the attachment) disappears forever. In that case; it may
be a good idea to make the ZIP file available on the web (http/ftp), and
post the URL here (?). In that case, don't make us hunt for it, as many
web sites do ("free scripts available at www.somewhere.com"), and which
I find extremely annoying (I think that's spam, too).

If it turns out to be very worthwile, it might be picked up on other
servers (CPAN?) too. But, as I said, I haven't tested it. Yet.

	Bart.


------------------------------

Date: Mon, 10 May 1999 14:06:45 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: matching resource ID's
Message-Id: <ebohlmanFBIsJ9.26w@netcom.com>

David Stiff <dstiff@symantec.com> wrote:
: I am trying to create a pattern match to separate resource names in a header
: file with their ID number. Unfortunately some of the ID numbers have
: comments after them which is causing a problem. Here is some sample data

: @idList = ( '#define NOTRANS_WFXPGR_REGKEYROOT_NAME          1',
:    '#define IDNAME_ENTRY_NAME             28722',
:    '#define IDNAME_VIEWER_SECTION          0x3035',
:    '#define IDNAME_MSG_RESET        0x0007 // why doesnt this work',
:    '#define IDNAME_MSG_RESET        0x0007 /* comments cause problems
: */'
:     );

: and here is the match:

: if ( $id =~ m/IDNAME.* ([0-9x0-9a-zA-Z]*) .*/ ) {

:     $idName   = $1;

: }

: In the first three cases the match works correctly for either decimal or hex
: values. The last two fail. My understanding was the brackets () would force
: the match to be placed in the $1. But for some reason if the comment exists
: after the ID number, $1 is the entire line.

Reread perlre, paying special attention to the parts about greedy and 
non-greedy matching.  Let's run through the way your pattern matches the 
fourth line:

    '#define IDNAME_MSG_RESET        0x0007 // why doesnt this work',


: if ( $id =~ m/IDNAME.* ([0-9x0-9a-zA-Z]*) .*/ ) {

IDNAME matches IDNAME, of course.
 .* initially matches everything else on the line, but the following test 
for a space fails, so the regex engine starts backtracking and shortening 
the match.  It pulls it all the way back to the space before 'work', 
tries to make the parenthesized pattern match 'work' and fails again when 
it gets to the space after the right paren.  It then pulls the match back 
to the space before 'this' and voila!  It's found a match for the whole 
string!  The first '.*' matches '_MSG_RESET	0x0007 // why doesnt', 
the parenthesized stuff matches 'this' and the last '.*' matches 'work'.


------------------------------

Date: Mon, 10 May 1999 05:47:22 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: matching resource ID's
Message-Id: <av96h7.6gc.ln@magna.metronet.com>

David Stiff (dstiff@symantec.com) wrote:
: I am trying to create a pattern match to separate resource names in a header
: file with their ID number. Unfortunately some of the ID numbers have
: comments after them which is causing a problem. Here is some sample data

[snip]

: and here is the match:

[snip]

   It would have taken about 20 seconds more to convert your code
   fragments into a complete and runnable program.

   You should have spent the 20 seconds, as you word description
   does not seem to match the output...


-------------------
#!/usr/bin/perl -w
use strict;

my @idList = (
   '#define NOTRANS_WFXPGR_REGKEYROOT_NAME          1',
   '#define IDNAME_ENTRY_NAME             28722',
   '#define IDNAME_VIEWER_SECTION          0x3035',
   '#define IDNAME_MSG_RESET        0x0007 // why doesnt this work',
   '#define IDNAME_MSG_RESET        0x0007 /* comments cause problems */'
);

foreach my $id (@idList) {
   if ( $id =~ m/IDNAME.* ([0-9x0-9a-zA-Z]*) .*/ ) {
      print "'$1'\n";
   }
}
-------------------

output:

''
''
'this'
'problems'


:    if ( $id =~ m/IDNAME.* ([0-9x0-9a-zA-Z]*) .*/ ) {
                             ^^^^^^^^^^^^^^^

   That is a character class. It does not work they way you appear
   to think it works.

   A character class matches a *single* character. You cannot specify
   "sequence" in a char class as you are attempting above.

   The char class you have is exactly equivalent to [0-9a-zA-Z].

   Repeating characters in the class has no effect.


   You also allow the parenthesized part to match the empty string.

   I don't think you want that either.


: In the first three cases the match works correctly for either decimal or hex
                                     ^^^^^^^^^^^^^^^

   There is something you are not telling us, unless the output
   above is "correct"...


: values. The last two fail. My understanding was the brackets () would force
: the match to be placed in the $1. But for some reason if the comment exists
: after the ID number, $1 is the entire line.

: Any help?


   Post some code where $1 is the entire line if you want help
   fixing some code that does that.



   Perl programmers tend to reach for regexen right away, without
   considering that they are not always the Right Tool For the Job.

   I think split() would work fine here if you replace the if()
   with:


      my(undef, $name, $value, undef) = split ' ', $id, 4;
      print "name '$name'  value '$value'\n";


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 10 May 1999 10:08:48 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: todd_b_smith@my-dejanews.com
Subject: Re: Need a little looping help
Message-Id: <m3pv496mq7.fsf@joshua.panix.com>

todd_b_smith@my-dejanews.com writes:

> I need to be able to 'eval' the top of a loop, write normal code in the
> middle, and 'eval' the end. Example (doesn't work):

I don't see why.  What are you actually trying to do?

> I'm copying from sight, so please forgive typos:

That's silly.  Does your OS not support copy & paste?

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: Mon, 10 May 1999 06:19:13 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Need a little looping help
Message-Id: <1rb6h7.mkc.ln@magna.metronet.com>

Jonathan Feinberg (jdf@pobox.com) wrote:
: todd_b_smith@my-dejanews.com writes:

: > I'm copying from sight, so please forgive typos:


   I immediately translated that to:

      "You are not looking at the code that I am looking at"


   The action corresponding to such a statement is: 

      stop reading, go to next article


: That's silly.  Does your OS not support copy & paste?


   If you want to be taken seriously, you must contrive some
   method of delivering the code that you need help with to
   the folks that you want help from.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 10 May 1999 15:16:14 GMT
From: jared@pandora.planet.net (Jared Hecker)
Subject: Never mind - I got it
Message-Id: <7h6t7u$ock@jupiter.planet.net>

Thanks to whoever offered help - it was syntax error after all (no commas
between the bind variables - duh).

Regards,
jh
--
Jared Hecker	| HWA Inc. - Oracle architecture and Administration
jared@hwai.com	|  ** serving NYC and New Jersey **


------------------------------

Date: Mon, 10 May 1999 10:42:02 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Oops, here is the script
Message-Id: <x3yzp3d7zr9.fsf@tigre.matrox.com>


"Kevin Howe" <khowe@performance-net.com> writes:

> use strict;
> my ($string,$search);
> my $count = "1";

Do you really want $count to be a string of value "1"? I would change
that to:

	my $count = 1;

Drop the quotes.

> my $count_ref  = \$count;
> 
> $string = "<a>this<b> <c>that<d>";
> 
> $string =~ s/<a>(.*?)<b>|<c>(.*?)<d>/&get_val/egi;
> 
> my $a = "kev";
> 
> sub get_val{
>  my $val = $$$count_ref;

$count_ref is a reference. $$count_ref is dereferencing the reference
to get the value of $count, which is "1". $$$count_ref tries to
dereference "1" to get it's value. But "1" is not a reference and Perl
complains. Check out the perldiag documentation for a brief
explanation of each of Perl's warning/error messages.

>  $count += 1;
>  return $val;
> }
> 
> print $string;

HTH,
Ala



------------------------------

Date: 10 May 1999 14:08:39 GMT
From: jared@pandora.planet.net (Jared Hecker)
Subject: Oraperl help - inserting perl vars
Message-Id: <7h6p97$o5p@jupiter.planet.net>

I have the following oraperl snippet:

eval 'use Oraperl; 1' ||die $@ if $] >= 5;
$ENV{TWO_TASK} = 'EMAN';
$lda = &ora_login('mySID','myusername','mypassword');

$csr2 = &ora_open($lda,'select sysdate from dual');
@sys_date = &ora_fetch($csr2);
&ora_close($csr2);

$csr = &ora_open($lda,'insert into run_times values (:1 :2 :3 :4 :5)');
&ora_bind($csr,'HPR01',$sys_date[0],$logname,$times[0],$times[$counter-1]);

&ora_commit($lda);
&ora_close($csr);
&ora_logoff($lda);


Oraperl is not happy with the ora_bind statement, telling me:

execute: handle  is not a hash reference at testdblog1.pl line 61.

I am able to print all the variables in there to STDOUT (as well as to
flat file), so they are populated.  

Can anyone tell me what Oraperl is not happy about?

If it is convenient, e-mail will reach me faster.

Regards,
jh


------------------------------

Date: Mon, 10 May 1999 11:48:42 -0400
From: "Tim Busche" <tbusche@ncsi-net.com>
Subject: readdir sorted by modify date?
Message-Id: <7h6v4n$8qe$1@autumn.news.rcn.net>

Let me start by saying I'm admittedly a newbie to PERL.

I have a need to read thru a directory and do some processing on each
filename; however, I need to read the files in "modify-date" order.  I'm
running on Windows NT using "Active Perl build 515".  The applicable code as
it is now:

use FileHandle;
my $dir="D:\\FOLDERA";
opendir(WND,"$dir") || die "cannot open directory: $!";
while ($name=readdir(WND)) {
 ...(some file processing here)...
}
closedir(WND);

The program works fine, with the exception of the files not being in the
proper order.

Any ideas how to read the directory in 'date modified' order?

Thanks,
Tim Busche





------------------------------

Date: Mon, 10 May 1999 06:06:00 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: reqiure script
Message-Id: <82b6h7.6gc.ln@magna.metronet.com>

Georg Edelmayer (ged@fortec.tuwien.ac.at) wrote:

: I am trying to import code to a script using require. The script runns
: under use strict.
: Obviously i cannot access global data (as defined with 'my' in the main
: script) by subs i have in the required script.
: (Use of uninitialised value.......)


   my() does not declare global variables (as you can see).

   use vars() declares global variables.


: Here a small example:

: # testscript...i know here should be the shebang thingie, but i use perl
: for win32.....


   It will still look at the shebang line for any switches...


: use strict;

   use vars qw( %hash @array );


: require "import.pl";
:  
: print "making hash\n";
: my %hash = (
  ^^
   s/my//;

:         'a',1,'b',2,'c',3,'d',4,
:          );
:          print $hash{'a'};
:          print $hash{'d'};
:          print "\n";
: print "making array\n";
: my @array = (1,2,3,4);
  ^^

   s/my//;


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: Mon, 10 May 1999 10:55:58 -0400
From: Chad Holliday <chad13@bellsouth.net>
Subject: STDIN/STDOUT to and from a new shell
Message-Id: <3736F37E.A1EA97C8@bellsouth.net>

Hello,
I am trying to write a perl script that does the following:
- run an external command that basically spawns a new shell (cmd on NT
and OS/2, ksh on Unix platforms)
- from the perl script, give commands to the new shell via STDIN
- from the perl script, read the corresponding STDOUT of the shell
commands

Currently, I am using an input file containing the shell commands and
manually redirecting this
input file as STDIN, while also redirecting STDOUT to a file that can be
later accessed by my script, i.e.:
    system("myshellcommand < mycommandfile > myoutputfile 2>&1");

This seems to be somewhat unreliable on non-Unix platforms, as
"mycommandfile", and "myoutputfile"
occasionally are left open by the system() command after it exits.

Is there a better way to accomplish this (perhaps using pipes and/or the
IPC modules?) that can still remain,
for the most part, platform-independent?

Thanks,
Chad Holliday



------------------------------

Date: Mon, 10 May 1999 06:13:49 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: STDIN/STDOUT to and from a new shell
Message-Id: <tgb6h7.mkc.ln@magna.metronet.com>

Chad Holliday (chad13@bellsouth.net) wrote:

: I am trying to write a perl script that does the following:
: - run an external command that basically spawns a new shell (cmd on NT
: and OS/2, ksh on Unix platforms)
: - from the perl script, give commands to the new shell via STDIN
: - from the perl script, read the corresponding STDOUT of the shell
: commands


   Perl FAQ, part 8:

      "How can I open a pipe both to and from a command?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 10 May 1999 13:54:41 GMT
From: "Jeff Wilson" <jwilson@ic.ac.uk>
Subject: Re: testing expressions in the IF statement
Message-Id: <01be9aec$a78c6d30$d53ec69b@leicester>

How do you know that $x represents a numerical value?
-- 

                             Jeff Wilson
                             London UK

Larry Rosler <lr@hpl.hp.com> wrote in article
<MPG.119c9a67792d23849899f3@nntp.hpl.hp.com>...
> In article <3732d489.18399106@news.skynet.be> on Fri, 07 May 1999 
> 11:55:45 GMT, Bart Lateur <bart.lateur@skynet.be> says...
> > Jeff Wilson wrote:
> > 
> > >How about 
> > >
> > >	print "$x is less than 5 and greater than 2\n" if($x =~ /^3|4/);
> > 
> >     foreach $x (3, 4, 32, 43, 12345) {
> > 	print "$x is less than 5 and greater than 2\n" if($x =~ /^3|4/);
> >     }
> 
> On the other hand,
> 
>       foreach $x (qw( +3 0+3 )) {
>   	print "$x is less than 5 and greater than 2\n" if($x =~ /^3|4/);
>       }
> 
> String tests for numerical values are futile.
> 
> -- 
> (Just Another Larry) Rosler
> Hewlett-Packard Company
> http://www.hpl.hp.com/personal/Larry_Rosler/
> lr@hpl.hp.com
> 


------------------------------

Date: Mon, 10 May 1999 06:15:27 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: testing expressions in the IF statement
Message-Id: <vjb6h7.mkc.ln@magna.metronet.com>

Jeff Wilson (jwilson@ic.ac.uk) wrote:

: How do you know that $x represents a numerical value?


   It is inferred from the post that started this thread.


: Larry Rosler <lr@hpl.hp.com> wrote in article

: > String tests for numerical values are futile.


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


------------------------------

Date: 10 May 1999 10:29:49 -0400
From: Jonathan Feinberg <jdf@pobox.com>
To: tertullian@my-dejanews.com
Subject: Re: Warnings about uninintialised variables despite use strict
Message-Id: <m3n1zd6lr6.fsf@joshua.panix.com>

tertullian@my-dejanews.com writes:

> #!/usr/bin/perl  -dw

That's a peculiar combination of switches to see in a shebang line!
You really want to use the perl debugger every time you run the
program?

> I'm trying to tie down my variable declarations with "use strict" but I
> still get warnings such as
> 
> Use of uninitialized value at lib.pl line 36, <IN> chunk 1.
>         main::ReadParse called at sub004.cgi line 34

These have nothing to do with each other.  The warning you quote here
is a result of your (desirable) use of the -w switch.

>       if ( $ENV{'REQUEST_METHOD'} eq "GET" ) {
> 
> So either perl is confused and line 36 isn't the one it's
> complaining about or I'm confused because surely $ENV doesn't need
> declaring.

There is no $ENV.  You mean %ENV, and you're right, it is magical, and
you don't need to declare it.  Read the error message again.  It says
nothing about the hash itself, but rather about that particular
*value*.  In other words, $ENV{REQUEST_METHOD} is not defined.  In
other words, the REQUEST_METHOD environment variable does not exist.

> Actually I'm confused anyway because by saying "use strict;" aren't
> I being forced to declare all variables using "my"?

Nope.  Have you read the documentation for strict?

   perldoc strict

       strict vars
             This generates a compile-time error if you access a
             variable that wasn't declared via use vars,
             localized via my() or wasn't fully qualified.

But, as I said, the warning you're seeing has nothing to do with
scope or namespace.

You ought to be using CGI.pm, anyway.

-- 
Jonathan Feinberg   jdf@pobox.com   Sunny Brooklyn, NY
http://pobox.com/~jdf


------------------------------

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5618
**************************************

home help back first fref pref prev next nref lref last post