[18325] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 493 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 15 14:06:09 2001

Date: Thu, 15 Mar 2001 11:05:24 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <984683124-v10-i493@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 15 Mar 2001     Volume: 10 Number: 493

Today's topics:
    Re: "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? <jazrant@zsc.nrcan.zc.ca>
    Re: "uninitiatlized value" errors? (Tad McClellan)
    Re: "uninitiatlized value" errors? (Tad McClellan)
    Re: 2-dimensional arrays <mjcarman@home.com>
        [OT] Re: HTTP Client Question <joe+usenet@sunstarsys.com>
    Re: [OT] Re: HTTP Client Question <callgirl@la.znet.com>
        [Q] Extracting a 'carriage return' from a string <joedrum414@hotmail.com>
    Re: [Q] Extracting a 'carriage return' from a string <tom@power.net.uk>
    Re: [Q] Extracting a 'carriage return' from a string nobull@mail.com
        [Q] Generating a random number <joedrum414@hotmail.com>
    Re: [Q] Generating a random number <tom@power.net.uk>
    Re: better way for if structure ... <bart.lateur@skynet.be>
        binary files <todd@designsouth.net>
    Re: Data Dumper modules come standard?? merrill@missioncriticallinux.com
    Re: Data Dumper modules come standard?? (Tad McClellan)
        detecting boolean context miko@NO_SPAMidocs.com
    Re: detecting boolean context (Abigail)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 15 Mar 2001 11:08:38 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <98qplm$5ps18@nrn2.NRCan.gc.ca>

"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:e4ssatc2f3n6tdv13uao15sld4kk63rut6@4ax.com...
    [...]
> It is visible to all functions below it in the same module, but it is
> not a global. A global is accessible from anywhere, even from other
> files. A lexical always has limited and static scope. The scope, in your
> particular case, is probably: anywhere in the source file, that is, if
> it's top at the top level. Otherwise, the scope is limited to the
> enclosing block (so a file is a kind of block by itself). Also note that
> you can put subs together in one block:
    [...]

    Thanks for the clarification. Yes, I meant "file scope" instead
    of "global". This all seems similar to C/C++.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here






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

Date: Thu, 15 Mar 2001 11:25:11 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <98qqkn$5ps19@nrn2.NRCan.gc.ca>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9asrp3.vnv.tadmc@tadmc26.august.net...
> John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
> >"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
> >news:873dclys9i.fsf@limey.hpcc.uh.edu...
> >> >> On Sat, 10 Mar 2001 20:54:40 -0500,
> >> >> "John A. Grant" <jazrant@zsc.nrcan.zc.ca> said:
> >    [...]
> >> If you want to pass undef over, you need to change the
> >> test to be
> >>
> >>     if (defined $cc) ...
> >
> >    Ok, I will do that. Is passing "undef" and testing for
> >    "defined" the common/best way to do it?
>
> Yes.

    [...excellent examples...]

    That's very clear. Thanks. I saved the post and pasted it
    into my Perl cookbook. Martien's addendum too.

> >> csh is certainly odd :-)  Try reading this:
> >    Well, I never thought I'd be told to use Bourne instead of
> >    csh in a Perl group.
>          ^^^^^^^^^^^^^^^
>
> Why not?
    [...determined to convince me that csh is bad...]

    I'm not programming the shell, nor do I live & breathe the
    shell.  I really don't care what shell I use to launch Perl while
    developing - the Perl program is only for CGI and the shell
    is simply a way to launch it while testing/compiling/developing.
    Well, for me anyway.  I figured csh/bourne comments were
    more appropriate for a shell.advocacy group rather than
    here in a Perl group. It's more likely that being a non-guru,
    I don't appreciate the Perl-shell symbiosis.

    I was surprised however, that I could not redirect the warning
    messages using csh, whether I tried stderr or stdout:
        $ perl -w xxx.cgi > err
        $ perl -w xxx.cgi 1>err
        $ perl -w xxx.cgi 2>err

    None of these 3 work on csh. The latter (2) works fine on NT.

    From that I would surmise that Perl is a tool was designed to work
    only with Bourne (Korn?) and not with csh. I don't believe that.
    A more likely possibility is that I just don't know how to use csh
    well enough to redirect the warnings. Switching shells just so I
    could have a hard copy of the warning messages seems a little
    extreme. Then again, what do I know - I'm not a Unix shell guru
    nor do I want to be - I just have too many other things to do.
    However, I should be free to choose my preferred shell (wrongly
    or rightly) and use my preferred tool(s). For the record, I didn't
    actually "choose" csh - it's the default shell for the system to
    which I have access.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here




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

Date: Thu, 15 Mar 2001 11:26:35 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <98qqnb$5tm24@nrn2.NRCan.gc.ca>

    Thanks to all who helped me. I found the problems.  There
    were indeed some uninitialized values.  Along the way, I
    picked up several clues about eq/==, calling sequences,
    @_ versus $_, undef/defined etc. Thanks to all.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





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

Date: Thu, 15 Mar 2001 11:30:20 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <98qquc$5s425@nrn2.NRCan.gc.ca>

"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrn9asr9r.vnv.tadmc@tadmc26.august.net...
> John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
> >"Garry Williams" <garry@zvolve.com> wrote in message
> >news:vrLq6.92$by1.9212@eagle.america.net...
> >> On Sat, 10 Mar 2001 23:43:48 -0500, Tad McClellan
<tadmc@augustmail.com>
> >wrote:
> >> >John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
> >> >>"Tad McClellan" <tadmc@augustmail.com> wrote in message
> >    [...]
> >> >>    if($cc) ...
> >> >
> >> >   if( defined $cc ) ...
> >>
> >> There's something else going on here.  `if ($var)' is exempt from that
> >> warning.  Actually, using a variable in boolian context exempts it:
> >>
> >> perlsyn:
> >>
> >>      Declarations
> >>      ...
> >>      If you enable warnings, you'll be notified of an
> >>      uninitialized value whenever you treat `undef' as a string
> >>      or a number.  Well, usually.  Boolean ("don't-care")
> >>      contexts and operators such as `++', `--', `+=', `-=', and
> >>      `.=' are always exempt from such warnings.
> >>
> >>   $
> >    Well, after I agreed with Tad's "if(defined $cc)" suggestion,
> >    I see you are disagreeing with with him and saying it is ok.
> >    Both stances seem reasonable to me, but I don't know
> >    enough about it.  Who is right?
>
>
> I am right if you have an old perl.
    Ok, that was "if(defined $cc)"

> Garry is right if you have a new perl.
    and that was "if ($cc)"

    I'm using Perl 5.6, so I'll leave the test as if($cc). But
    'defined' would still work, right? It's just that "new perl"
    is more forgiving/clever?

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





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

Date: Thu, 15 Mar 2001 11:33:50 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: "uninitiatlized value" errors?
Message-Id: <98qr4u$5ps20@nrn2.NRCan.gc.ca>

"Michael Carman" <mjcarman@home.com> wrote in message
news:3AAEA583.756F0AEA@home.com...
> First, a quick summary of this branch of the thread:
>
> John>  if($cc) ...
>
> Tad>   if( defined $cc ) ...
>
> Garry> There's something else going on here.
>
> John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
> >
> > [A]fter I agreed with Tad's "if(defined $cc)" suggestion,
> > I see you [Garry] are disagreeing with with him and saying it
> > is ok. Both stances seem reasonable to me, but I don't know
> > enough about it.  Who is right?
>
> Obi-wan might say that they both are, depending on your point of view.
>
> In this case, I'd vote with Garry. That's not to say that Tad was wrong,
> just maybe a little overzealous. A simple boolean test will suffice
> because it looks like $cc shouldn't ever have a defined but false value.
> (i.e. 0, '0', or '') It's really a matter of preference, and Tad's
> advice is simply indicitive of his.
>
> In general, though, that's not always the case. Sometimes you need to
> test definedness. Sometimes (with hash keys) you need to check for
> existance. Perl draws subtle distinctions between truth, definedness,
> and existance, and you would do well to learn them. If you can get your
> hands on a copy of  the Cookbook, look at recipe 5.2. It does a good job
> of explaining this.

    Thanks for the info. I'll have a look. Your comments on truth,
    definedness & existence make the language sound very
    zen-like!  I guess it is...

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here






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

Date: Thu, 15 Mar 2001 11:06:30 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: "uninitiatlized value" errors?
Message-Id: <slrn9b1q46.6ai.tadmc@tadmc26.august.net>

John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:

>    I'm using Perl 5.6, so I'll leave the test as if($cc). 


There are four possible values that make that condition false.

That is, all of the FALSE values in Perl:

   numerically zero (there are, of course, a whole bunch of these values)
   empty string
   one-character string where the one character is a zero digit
   undef


>    But
>    'defined' would still work, right? 
                           ^^^^

Right. Maybe.

   if ( defined $cc )

There is only one possible value to make that condition false (undef).

So which "works" depends on what you want to do for the 3 "other"
types of FALSE. It depends on what semantics you want for your
application.

I don't remember what was supposed to be going on in the if block anymore...


>    It's just that "new perl"
>    is more forgiving/clever?


New perl just doesn't warn about that anymore.

I wouldn't call new perl more forgiving or clever though.

They (p5p) just realized that the warning was not (close to)
universally "suspect", and so no longer deserved a warning.

You are still free to code up the wrong semantics though :-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 15 Mar 2001 11:40:20 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: "uninitiatlized value" errors?
Message-Id: <slrn9b1s3k.6ai.tadmc@tadmc26.august.net>

John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
>"Tad McClellan" <tadmc@augustmail.com> wrote in message
>news:slrn9asrp3.vnv.tadmc@tadmc26.august.net...
>> John A. Grant <jazrant@zsc.nrcan.zc.ca> wrote:
>> >"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
>> >news:873dclys9i.fsf@limey.hpcc.uh.edu...
>> >> >> On Sat, 10 Mar 2001 20:54:40 -0500,
>> >> >> "John A. Grant" <jazrant@zsc.nrcan.zc.ca> said:
>> >    [...]

>> >> csh is certainly odd :-)  Try reading this:
>> >    Well, I never thought I'd be told to use Bourne instead of
>> >    csh in a Perl group.
>>          ^^^^^^^^^^^^^^^
>>
>> Why not?
>    [...determined to convince me that csh is bad...]


No, determined to convince you that redirecting STDERR in csh
is a pain in the ass. _You_ get to decide how much it will hurt 
to sit down.  :-)

As I said before, there isn't much difference if you don't need
to put stderr to its own place.


>    I'm not programming the shell, 


If you want to redirect standard error from the command line,
then you *are* programming the shell!


>    nor do I live & breathe the
>    shell.  


Then just go ahead and live with how hard it is to redirect stderr
with the shell you have chosen. Just do it the silly way required
(involves invoking sub-shells, too off-topic to be discussed here).


>    I really don't care what shell I use to launch Perl while
>    developing - the Perl program is only for CGI and the shell
>    is simply a way to launch it while testing/compiling/developing.


I think you wanted to redirect stderr. That is easy in sh,
hard in csh. You are free to choose which to use. I am free
to choose which ones I'll take the time to show you :-)

I don't think I even remember how to actually do it in csh anymore.
I used csh for my first several years on Unix, but haven't used
it at all for 4 years or so.

The Korn shell (ksh) has all of the features of sh, and some of
the features of csh. It is easy to migrate to.


>    Well, for me anyway.  I figured csh/bourne comments were
>    more appropriate for a shell.advocacy group rather than
>    here in a Perl group. 


Yes. That is right.

Redirecting stderr is a shell question. I'm not the one
who asked it here <grin>.


>    It's more likely that being a non-guru,
>    I don't appreciate the Perl-shell symbiosis.


There is nothing Perl-related to my arguments about the shell.

They only have to do with redirecting stderr, whether it is coming
from perl or from any other program.


>    I was surprised however, that I could not redirect the warning
>    messages using csh, whether I tried stderr or stdout:
>        $ perl -w xxx.cgi > err
>        $ perl -w xxx.cgi 1>err
>        $ perl -w xxx.cgi 2>err
>
>    None of these 3 work on csh. 


Because that is not the csh syntax for redirecting stderr.

csh doesn't _have_ a syntax for redirecting stderr, you have
to trick it.

This is the main motivator that got _me_ to abandon csh.


>    The latter (2) works fine on NT.


Even Bill can make a smart choice occasionally :-)


>    From that I would surmise that Perl is a tool was designed to work
>    only with Bourne (Korn?) and not with csh. I don't believe that.


Good, because it is not true. I don't follow how you have
surmised that.


>    A more likely possibility is that I just don't know how to use csh
>    well enough to redirect the warnings. 


Right!


>    Switching shells just so I
>    could have a hard copy of the warning messages seems a little
>    extreme. 


It would be just as extreme if you were wanting stderr from
any other program. Nothing to do with Perl.


>    Then again, what do I know - I'm not a Unix shell guru
>    nor do I want to be - 


Switching shells, redirecting stderr, and switching back will
be less effort than figuring out how to do it in csh.


>    I just have too many other things to do.


So switch shells when you want to redirect stderr then, heh heh.


>    However, I should be free to choose my preferred shell (wrongly
>    or rightly) and use my preferred tool(s). 


Yes, but you said yourself you have time pressure. sh is faster
and easier than csh when it comes to redirecting stderr.


>    For the record, I didn't
>    actually "choose" csh - it's the default shell for the system to
>    which I have access.


You can switch shells as soon as you log it. That's what I did
when I had an unresponsive system administrator.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Thu, 15 Mar 2001 09:01:59 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: 2-dimensional arrays
Message-Id: <3AB0D967.7EB5BD58@home.com>

[In the future, please place your comments *after* the suitably trimmed
text of what you're responding to. It's much easier to follow that way.]

Milliwave wrote:
> 
> I would ideally like to make use of the variables already in the 
> while loop

My example wasn't really intended to solve your problem directly, just 
to show you one way to create a LoL (list of lists, aka 2-D array).
 
>         $table_call_no  = $1;
>         $table_type     = $2;
>         $table_cell_name= $3;
>         $table_xmin     = $4;
>         $table_ymin     = $5;
>         $table_xmax     = $6;
>         $table_ymax     = $7;

Well, okay, but how to you know that $5 contains the ymin? And what is 
"$table_cell_name" supposed to be? You haven't shown any data so I can
only guess. I'll assume that your input data is nicely formatted such 
that (for example) the fifth column is always the ymin. If you want a 
pnemonic for accessing it, why not do this?

$call_no   = 1;
$type      = 2;
$cell_name = 3;
$xmin      = 4;
$ymin      = 5;
$xmax      = 6;
$ymax      = 7;

Then you can access $table[$i][$ymin].

But if this is what you're after, you should probably use a LoH (list
of hashes) as others have suggested. It's the more "Perlish" way.

If you still have questions, show us some sample data and we can 
provide better help.

-mjc


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

Date: 15 Mar 2001 12:12:06 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: [OT] Re: HTTP Client Question
Message-Id: <m3ofv3ufbt.fsf_-_@mumonkan.sunstarsys.com>


--PATTERN--
(?-xism:\bI\b)                    10   (-20)
(?-xism:\bIMN?S?H?O\b)             0   (-20)
(?-xism:\bP(?i:erl)\b)             1   (-20)
(?-xism:\bperl(?:doc)\b)           0   (+20)
-----------
SCORE:                          -220


---LINES---
quoted                             5   (- %)
written                           27   (+ %)
code/indented                      0   (+10)
html-ish                           0   (-10)
-----------
SCORE:                            78


---TOTAL---
SCORE:                          -142


avast@hortonsbay.com (Bob Dilworth) writes:

> On 15 Mar 2001 15:38:51 GMT, anno4000@lublin.zrz.tu-berlin.de (Anno
> Siegel) wrote:
> 
> >Indeed.  Moreover, the immense popularity of Perl as a "web language"
> >takes care that a large part of those postings that are (marginally)
> >on topic are put forward by people with little programming experience,
> >little interest in Perl as a language an no motivation to learn much
> >about both.  It does make folks grumpy, yours truly included.
> 
> There's an interesting assumption in the above snippet.  First - just
> because someone comes to clpm to ask what you may consider an
> inappropriate question does not imply that they have little or no
> motivation to learn Perl.  It may be true for some but not for all.
> Publicly "plonking" them for "jeopardy" posting serves no purpose
> other than, in my view, arrogance.  It is also seems quite mean and
> intolerant.  Why waste all that energy on public humiliation when you
> can simply ignore the posting?
> 
> I frequent a number of other newsgroups, mostly lurking for
> information, and of all of them this one has a surprisingly large and
> vocal  group of folks who seem to enjoy flaming posters for
> infractions of rules.  I understand that their are posting guidelines
> out there and that I also understand that it can be difficult (altho
> not THAT difficult) to wend one's way though the morass of postings to
> find the tasty morsels that are of interest.  I do it (the wending)
> with little difficulty.  I also read the heretical "jeopardy" postings
> also with very little difficulty.  I've never, ever found it to get in
> the way of reading the postings and the responses.
> 
> I guess I just don't understand why the public "plonking", the angry
> RTFM responses, etc., etc., are necessary.  Doesn't it take time away
> from reading the things you want to read?  How hard is it to click the
> left mouse button a couple of times to move on to the next posting?
> I'm actually very interested in answers to these questions because I
> just don't understand where all the anger comes from.
> 
> Bob D.

-- 
Joe Schaefer           "Never tell the truth to those unworthy of it."
                                               --Mark Twain


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

Date: Thu, 15 Mar 2001 09:19:27 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: [OT] Re: HTTP Client Question
Message-Id: <3AB0F99F.1E4C6C5A@la.znet.com>

Joe Schaefer wrote:


>  "Never tell the truth to those unworthy of it."
>    --Mark Twain


"Never give a sucker an even break."
  -- W. C. Fields


Godzilla!


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

Date: Thu, 15 Mar 2001 17:24:22 GMT
From: "giuseppe" <joedrum414@hotmail.com>
Subject: [Q] Extracting a 'carriage return' from a string
Message-Id: <aV6s6.274$wQ3.18175@bgtnsc04-news.ops.worldnet.att.net>

I'm updating a flat-file database from a web based form.
While parsing my data, certain strings can contain many
carriage returns in them.  I need to get rid of these, but chop
won't get all of them.
I tried:      $x  = ~ s/\n/" "/eg;
                           &
                $x =~ s/x0a/" "/eg;    #I think this is the correct hex
value (UNIX)

What am I doing wrong?

Thanks again in advance!..





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

Date: Thu, 15 Mar 2001 17:46:10 +0000
From: Tom Scheper <tom@power.net.uk>
Subject: Re: [Q] Extracting a 'carriage return' from a string
Message-Id: <frv1bt0cd96brnc3pvdrkl33mdvaoetp0g@4ax.com>

On Thu, 15 Mar 2001 17:24:22 GMT, "giuseppe" <joedrum414@hotmail.com>
shed a beam of light on us:

>I'm updating a flat-file database from a web based form.
>While parsing my data, certain strings can contain many
>carriage returns in them.  I need to get rid of these, but chop
>won't get all of them.
>I tried:      $x  = ~ s/\n/" "/eg;
>                           &
>                $x =~ s/x0a/" "/eg;    #I think this is the correct hex
>value (UNIX)
>
>What am I doing wrong?

Use multiline regexps or use chomp instead. Chop will just take out
the last character, beit a carriage return or linefeed or any
character. Chomp will take out any eol characters but nothing else and
should do what you want it to do.

Or you could $x=~s/[\n\r]/" "/gs;

You need an s for multiline, and you don't need the e as you're not
executing any code. The g is only there if there's more than one eol
in there, like a textarea box.

-=Cornelis


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

Date: 15 Mar 2001 18:09:43 +0000
From: nobull@mail.com
Subject: Re: [Q] Extracting a 'carriage return' from a string
Message-Id: <u9g0gegazc.fsf@wcl-l.bham.ac.uk>

"giuseppe" <joedrum414@hotmail.com> writes:

> I tried:      $x  = ~ s/\n/" "/eg;
>                            &
>                 $x =~ s/x0a/" "/eg;    #I think this is the correct hex

The =~ operator does something completely different from the =
operator followed by the ~ operatoe.

There's a \ missing from \x0a

BTW: that susbtitution is more conventionally written without the /e
qualifier and without the double-qoutes.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 15 Mar 2001 17:13:43 GMT
From: "giuseppe" <joedrum414@hotmail.com>
Subject: [Q] Generating a random number
Message-Id: <bL6s6.264$wQ3.17597@bgtnsc04-news.ops.worldnet.att.net>

I've got a script that takes input from a form (web based) and updates a
file.
Each time the form is submitted, I  need a "unique" number assigned to that
transaction.
Does anyone have a nifty way of doing this. --  I'm on a UNIX machine.

Thanks in advance..




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

Date: Thu, 15 Mar 2001 17:15:19 +0000
From: Tom Scheper <tom@power.net.uk>
Subject: Re: [Q] Generating a random number
Message-Id: <b3u1btomfobnqmvc2mj4a7h0eslhirjhcu@4ax.com>

On Thu, 15 Mar 2001 17:13:43 GMT, "giuseppe" <joedrum414@hotmail.com>
shed a beam of light on us:

>I've got a script that takes input from a form (web based) and updates a
>file.
>Each time the form is submitted, I  need a "unique" number assigned to that
>transaction.
>Does anyone have a nifty way of doing this. --  I'm on a UNIX machine.
>
>Thanks in advance..
>

If it doesn't have to be a number persé you could use Apache's
UNIQUE_ID, or even glue PROCESSID+EPOCH together.

-=Cornelis


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

Date: Thu, 15 Mar 2001 14:22:08 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: better way for if structure ...
Message-Id: <0ej1btgm0lfrme54qlilkm8824ettv7jp3@4ax.com>

Jens Luedicke wrote:

>Is there a better way to do that? It works but I'm not happy
>with the if-structure ..
>
>$filter_success = &filter_action($i->{action}, $i->{folder}, @$data)
>	if $i->{type} eq "From" and $head[$_][0] =~ /$i->{pattern}/
>	or $i->{type} eq "Subject" and $head[$_][1] =~ /$i->{pattern}/
>	or $i->{type} eq "To" and $head[$_][2] =~ /$i->{pattern}/
>	or $i->{type} eq "Cc" and $head[$_][4] =~ /$i->{pattern}/
>	or $i->{type} eq "Header" and $headings[$_] =~ /$i->{pattern}/
>	or $i->{type} eq "Body" and $messages[$_] =~ /$i->{pattern}/;

Perhaps you're just doing this the wrong way. You seem to have an array
of "records", but each record is spread over 3 variables: @head, each
item an anonymous array of 4 (5?) headers; @headings, the rest; and
@messages, the bodies.

Why don't you turn this around, and create ONE array of anonymous hashes
instead? Each item could be

	for (0 .. $#message) {
	  $records[$_] = { "From" => $head[$_][0], "To" => $head[$_][1],
	    "Subject" => $head[$_][2], "Cc" => $head[$_][4],
	    "Header" => $headings[$_], "Body" => $messages[$_] };
	}

and your test:

	$records[$_]{$i->{type}} =~ /$i->{pattern}/


Yes, sometimes it's extremely nice that a "record" in Perl is just an
associative array. JavaScript shares this idea. BTW, a lot of JavaScript
appears to be at least inspired by Perl. (an Object in Javascript is a
hash, and an Array is one-dimensional, and can grow on demand. Does that
seem familiar?)

-- 
	Bart.


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

Date: Thu, 15 Mar 2001 18:29:13 GMT
From: "Todd Smith" <todd@designsouth.net>
Subject: binary files
Message-Id: <ZR7s6.6979$Q47.1869553@news1.rdc1.tn.home.com>

Is there a way to convert any file (picture, mp3, text, or anything) to a
binary file that I can read (with a bunch of 1's and 0's) and convert it
back to the original file from the binary? A Perl module maybe?




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

Date: 15 Mar 2001 13:44:51 GMT
From: merrill@missioncriticallinux.com
Subject: Re: Data Dumper modules come standard??
Message-Id: <98qh0j$k0c$1@news.netmar.com>

I' using Perl 5.005_03 on Redhat Linux 6.1, and I can do

  perldoc Data::Dumper

and get the documentation on the Data Dumper module.  That means that
Data::Dumper *is* included with the standard distribution, and so you 
don't have to compile it separately - you should be able to just use it.

HTH.

Hardy Merrill
Mission Critical Linux, Inc.
http://www.missioncriticallinux.com

In article <tb0hkqi3oq3g5e@corp.supernews.com>, kellyboy
<kellyboy@nospanner>
writes:
>Since I've not fully achieved the status of "Perl Guru" yet, I
have this
>question...
>
>I was reading the README about DataDumper.pm for any compile notes. It
says
>"Data-Dumper comes standard with perl from version 5.004_71."
>
>I'm using Perl 5.6.0.
>
>So that mean I dont have to compile the Data-Dumper module??
>
>kellyboy
>
>--
>
>
>




 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: Thu, 15 Mar 2001 15:01:09 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Data Dumper modules come standard??
Message-Id: <slrn9b1gd2.5uc.tadmc@tadmc26.august.net>

Kiel Stirling  <taboo@comcen.com.au> wrote:
>
>"kellyboy" <kellyboy@nospanner> wrote:
>>
>>I was reading the README about DataDumper.pm for any compile notes. It says
>>"Data-Dumper comes standard with perl from version 5.004_71."
>>

>Looks like it try a test like 

>#!/usr/bin/perl
>use DataDumper;
>
>now run it. if no error it's install.


Or just run it from the command line:

   perl -MData::Dumper -e1


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: 15 Mar 2001 17:23:33 GMT
From: miko@NO_SPAMidocs.com
Subject: detecting boolean context
Message-Id: <98qtql$alp$1@news.netmar.com>

The handy-dandy wantarray() subroutine indicates if the subroutine is being
called in a list or scalar context.  Is there a function or technique that
will indicate if the subroutine is being called in a boolean context?  

-Miko



 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

Date: 15 Mar 2001 17:34:16 GMT
From: abigail@foad.org (Abigail)
Subject: Re: detecting boolean context
Message-Id: <slrn9b1v8o.hnj.abigail@tsathoggua.rlyeh.net>

miko@NO_SPAMidocs.com (miko@NO_SPAMidocs.com) wrote on MMDCCLIII
September MCMXCIII in <URL:news:98qtql$alp$1@news.netmar.com>:
,, The handy-dandy wantarray() subroutine indicates if the subroutine is being
,, called in a list or scalar context.  Is there a function or technique that
,, will indicate if the subroutine is being called in a boolean context?  


Not for subroutines, no. Only for overloaded objects.



Abigail


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

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 V10 Issue 493
**************************************


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