[16866] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4278 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 10 18:05:34 2000

Date: Sun, 10 Sep 2000 15:05:13 -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: <968623512-v9-i4278@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Sun, 10 Sep 2000     Volume: 9 Number: 4278

Today's topics:
        Any itches to scratch for perl6? <gnat@frii.com>
    Re: Can I reach my modem through Perl? mtmonacelli@my-deja.com
        Can PERL detect a web-browser's PORT??? genio1980@my-deja.com
    Re: Can PERL detect a web-browser's PORT??? <godzilla@stomp.stomp.tokyo>
    Re: CGI.pm & transaction management (Steve Leibel)
    Re: Count of items is EXCEPTION not RULE (was Re: Littl <tina@streetmail.com>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl (Randal L. Schwartz)
    Re: Count of items is EXCEPTION not RULE (was Re: Littl <kj0@mailcity.com>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl <gnat@frii.com>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl (brian d foy)
    Re: Count of items is EXCEPTION not RULE (was Re: Littl <tina@streetmail.com>
    Re: Count of items is EXCEPTION not RULE (was Re: Littl (Tim Hammerquist)
    Re: Count of items is EXCEPTION not RULE (was Re: Littl (brian d foy)
    Re: Entering data from an HTML into a hash of hashes <g.soper@soundhouse.co.uk>
    Re: Entering data from an HTML into a hash of hashes (Randal L. Schwartz)
    Re: Entering data from an HTML into a hash of hashes (Eric Bohlman)
    Re: Entering data from an HTML into a hash of hashes (brian d foy)
    Re: Entering data from an HTML into a hash of hashes <flavell@mail.cern.ch>
    Re: Entering data from an HTML into a hash of hashes <tina@streetmail.com>
    Re: Help with number formatting needed... <jeffjohnson@earthlink.net>
    Re: Help with number formatting needed... <randy_734@my-deja.com>
    Re: Help with number formatting needed... (Maurice E. Jarrell)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Sun, 10 Sep 2000 20:00:23 GMT
From: Nathan Torkington <gnat@frii.com>
Subject: Any itches to scratch for perl6?
Message-Id: <rLRu5.70$W3.188794880@news.frii.net>

As most of you will probably have heard, plans are afoot for a
major rewrite of Perl.  This is the perfect time to scratch any
itches you've had with perl5.

I don't want to start a massive thread on this here, because we've
already gone into a lot of these discussions on the perl6-* mailing
lists.  However, I do want you to mail me with the things you'd like
to see dropped or changed in Perl.  I'll compile a list of things not
already addressed, and make sure they're considered in the design of
perl6.

To repeat: please send your mail to:
  gnat@frii.com
and do not followup to this message.  If you want to discuss the
proposed changes to Perl, join the mailing lists:
  http://dev.perl.org/lists

Thanks,

Nat


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

Date: Sun, 10 Sep 2000 19:46:01 GMT
From: mtmonacelli@my-deja.com
Subject: Re: Can I reach my modem through Perl?
Message-Id: <8pgodk$46g$1@nnrp1.deja.com>

In article <nCRr5.194$i%1.156627@news.uswest.net>,
  "Dave Ressler" <news@nettenna.com> wrote:
> I'm anxious to be able to ask my modem to dial a number for me using
Perl.
> Can someone point me in the right direction if this is possible? I'm
using
> Windows 2000 and the Phone Dialer that comes with it is terrible!
>
> Thanks,
> Dave
>
>

Information on how to get Perl to use your modem

I spent some time trying to find out how to get perl to
dial a number using my modem.  I ened up subscribing to
the The Perl Journal (http://www.itknowledge.com/tpj/)
and eventually ended up on this article
(published in Journal:
http://www.itknowledge.com/tpj/issues/vol4_1/tpj0401-0020.html.  You
cannot get to this url unless you've paid the $18 membership fee).  The
title of the article is:

Controlling Modems with Win32::SerialPort
 .
 .
 .
[snip]
print "\nStarting Dial\n";
# Use a different number!
$ob->write("ATDT5551234\r");
printf "%s\n", waitfor(20);

print "\n5 seconds to failure..\n";
waitfor(5) || print "Timed Out\n";
 .
 .
 .


I've only printed a fraction of that which is necessary
to get perl to dial because I didn't want to infringe
on copyright material.

I suggest you either purchace the yearly subscription
to the online perl journal or you simply buy edition #13.
It is very insightful.



Taylor.


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 10 Sep 2000 20:43:48 GMT
From: genio1980@my-deja.com
Subject: Can PERL detect a web-browser's PORT???
Message-Id: <8pgrpv$83c$1@nnrp1.deja.com>

A client/server program running, and to stop abusive users from using
the program, We ban their IP address, however, with the use of proxies,
this method becomes pointless... so, is there anyway to detect the port
they are using (80, 8080, etc) so we can tell if they are using a proxy
 or not to ban them?


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Sun, 10 Sep 2000 14:23:33 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Can PERL detect a web-browser's PORT???
Message-Id: <39BBFBD5.122E90A5@stomp.stomp.tokyo>

genio1980@my-deja.com wrote:
 
> A client/server program running, and to stop abusive users from using
> the program, We ban their IP address, however, with the use of proxies,
> this method becomes pointless... so, is there anyway to detect the port
> they are using (80, 8080, etc) so we can tell if they are using a proxy
>  or not to ban them?


Use of a proxy by a client is not determined by a port number.
This is not related. A port number could be anything although
80, 8080 and 3128 are common for proxies. A client's port number
is easy to obtain but tells you nothing about a proxy in use.

Scanning for a port as you ask, may lead to getting you into
a lot of trouble. This activity is not well accepted. It is
considered inappropriate snooping if not black hat hacking.
This is an activity few support nor condone.

Detecting a proxy with Perl, takes no more than twenty-four
lines of casual code to detect ninety-nine point nine percent
of all proxies available, both publically and privately. Doing
so requires no invasion of privacy nor questionable programming.
It is accomplished with common cgi environmental variables.

If you are correctly banning an IP address, this is correctly,
you will not have any return visits from a banned IP address,
even if it is a dynamic IP address.

Perhaps you need to rethink what you are doing. Your approach,
based on what you have stated, is quite illogical.


Godzilla!
-- 
Androids And More.
  http://la.znet.com/~callgirl/android.html


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

Date: Sun, 10 Sep 2000 13:33:58 -0700
From: stevel@bluetuna.com (Steve Leibel)
Subject: Re: CGI.pm & transaction management
Message-Id: <stevel-1009001334260001@192.168.100.2>

In article <8pg92f$kkl$1@panix3.panix.com>, kj0 <kj0@mailcity.com> wrote:

> The state-less model of cookie-free CGI-based interaction makes it a
> bit difficult to prevent accidental duplicate transactions.  For
> example, if a user submits a request to perform a financial
> transaction or to write new data to a database, and sees that his/her
> browser hangs, s/he has no good way of knowning whether the
> transaction went through or should be re-submitted.  Or, seeing the
> browser hang, the user may get impatient and hit the Reload button,
> unaware of the possibility of sending a duplicate submission of the
> original transaction.  One can come up with more scenarios in which
> the user, while seemingly only navigating the site, may inadvertently
> cause duplicate transactions to take place.
> 
> Since this problem is so common, I imagine that already there are
> several standard solutions to it, maybe including some that can be
> implemented as part of CGI.pm-based scripts.
> 
> Where can I read about these solutions?


One idea is session id's.  When the user first submits the HTML form, the
"action" url is www.whatever.com/cgi-bin/myprog for example.

This url has no query string.  When your CGI sees the absence of a query
string, you know it's their first time in.  Randomly assign a number (say,
12345), record their state in your database, and send them back a redirect
to www.whatever.com/cgi-bin/myprog?12345.  Now you know who they are as
long as they stay in that browser window and keep talking to your cgi, and
you can keep track of their state in your database.

Steve L


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

Date: 10 Sep 2000 18:54:50 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <8pgldq$csnku$5@ID-24002.news.cis.dfn.de>

hi,
In comp.lang.perl.misc kj0 <kj0@mailcity.com> wrote:
> In <m1zolh10wt.fsf@halfdome.holdit.com> merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>>> "kj0" == kj0  <kj0@mailcity.com> writes:

>>kj0> I was hoping to get the number of files having a particular format by
>>kj0> using:

>>kj0>   my $n = glob("${prefix}*");

>>kj0> but NOOO!  Instead, in this case Perl puts the first element of the
>>kj0> array in $n, instead of the size of the array.

>>Why would you have thought this?

> My misguided Perl "intuition", I guess, which went something like
> this: glob returns a list, a list is (sort of like?) an array,
> evaluating an array in a scalar context gives the size of the array,
> etc.  This might be ignorant but not entirely unreasonable.

if there is an array returned from a function, then
$n = func(); will give you always the size. but
in a function you can use wantarray() for checking,
if the sub was called in void, scalar or array context.
perldoc -f wantarray

think about 
$line = <STDIN>;
and
@lines = <STDIN>;

glob() works like this.

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: 10 Sep 2000 12:07:30 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <m1n1hgxdzh.fsf@halfdome.holdit.com>

>>>>> "Tina" == Tina Mueller <tina@streetmail.com> writes:

Tina> if there is an array returned from a function,

See, it's sloppy talk like that that gets us all in trouble.
You cannot return an array from a function.  The action of:

        return @foo;

returns a list-copy of @foo if wantarray is true, or the number of
elements of @foo if wantarray is false.  You *cannot* return an array,
only a list or a scalar.

Maybe this is why the newbies get confused.  We have sloppy talk, and
then that gets quoted as real, and then the bad book authors start
using that, and then the newbies get very confused.

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 10 Sep 2000 15:57:25 -0400
From: kj0 <kj0@mailcity.com>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <8pgp35$3v9$1@panix3.panix.com>

In <m1n1hgxdzh.fsf@halfdome.holdit.com> merlyn@stonehenge.com (Randal L. Schwartz) writes:

>>>>>> "Tina" == Tina Mueller <tina@streetmail.com> writes:

>Tina> if there is an array returned from a function,

>See, it's sloppy talk like that that gets us all in trouble.
>You cannot return an array from a function.  The action of:

>        return @foo;

>returns a list-copy of @foo if wantarray is true, or the number of
>elements of @foo if wantarray is false.  You *cannot* return an array,
>only a list or a scalar.

I haven't yet seen a good (i.e. sufficiently memorable) account of the
difference between arrays and lists in Perl.  In the 2nd edition of
Programming Perl there is a section called "List Values and Arrays"
(pp. 47-49) where the authors *hint* at the fact that lists and arrays
are not equivalent, but they never explain what exactly is the
difference.

Ultimately, this is the source of the annoyance: it's too easy to trip
over such a fuzzy distinction.  (In my case, matters are further
screwed by having learned Perl using the first edition of PP, where
the authors use the term "array context" for what now is called "list
context").

I had a similar problem when learning C, because the first book I used
did a very poor job clarifying the difference between pointers and
arrays.  So for the first months as a C programmer I was always
tripping, and then I read Harbison & Steele and all was clear.  But
the Harbison & Steele of Perl is yet to be written, alas.

Come to think of it, maybe the 3rd edition of PP clarifies the
array/list distinction... The thought of plowing through yet a third
edition of PP (I've done it twice already) is an unpleasant one at my
age, though...

pops



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

Date: Sun, 10 Sep 2000 20:32:31 GMT
From: Nathan Torkington <gnat@frii.com>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <zdSu5.72$W3.170615296@news.frii.net>

kj0 <kj0@mailcity.com> wrote:
: I haven't yet seen a good (i.e. sufficiently memorable) account of the
: difference between arrays and lists in Perl. 

A list is a temporary sequence of values.  Functions returns lists.
Functions are passed lists.  You can't change the length of a list.
Lists are very very transient things.

An array is a particular data structure in memory.  You can change the
length of an array.  Arrays have lifetimes measured in blocks (for my
@array) or the lifetime of the program (for global @arrays).

Most of the time in Perl we use arrays because they act as containers
for lists.  We can store a list of values in an array, then fetch the
list of values when we call a function:

  @folks = ("larry", "tom", "guido");	# one of these is not like the others
  @new   = snakeless(@values);		# pass values from @folks to snakeless

The trick is to remember that most things in Perl that act on multiple
values expect lists, not arrays.  The only exceptions are the functions
specifically for arrays: push, pop, shift, unshift, splice.  (There
might be more but they don't come to mind right now, he says hedging
his bets).

A rough analogy for C people is that lists are temporary things
allocated on the stack around function calls, while arrays are
malloc()ed things in the heap.

Cheers;

Nat


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

Date: Sun, 10 Sep 2000 17:02:34 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <brian-ya02408000R1009001702340001@news.panix.com>

In article <8pgldq$csnku$5@ID-24002.news.cis.dfn.de>, news@tinita.de posted:

> if there is an array returned from a function, then
> $n = func(); 
>will give you always the size. but

that is not true.  that is not even being close to true.  indeed,
previous posts and the documentation say otherwise.

> in a function you can use wantarray() for checking,

certainly.  and, because that function exists, i can write

   sub foo
      {
      if( wantarray ) 
         { 
         return ('This value', 'That value', 'Most used value') 
         }
      else            
         { 
         return 'Most used value' 
         }
      }

which clearly contradicts what you claimed.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: 10 Sep 2000 21:35:37 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <8pgur9$csnku$10@ID-24002.news.cis.dfn.de>

hi,
In comp.lang.perl.misc brian d foy <brian@smithrenaud.com> wrote:
> In article <8pgldq$csnku$5@ID-24002.news.cis.dfn.de>, news@tinita.de posted:

>> if there is an array returned from a function, then
>> $n = func(); 
>>will give you always the size. but

> that is not true.  that is not even being close to true.  indeed,
> previous posts and the documentation say otherwise.

>> in a function you can use wantarray() for checking,

> certainly.  and, because that function exists, i can write

>    sub foo
>       {
>       if( wantarray ) 
>          { 
>          return ('This value', 'That value', 'Most used value') 
>          }
>       else            
>          { 
>          return 'Most used value' 
>          }
>       }

> which clearly contradicts what you claimed.

hm, maybe i didn't make this clear enough. i said:
>> if there is an array returned from a function, then
>> $n = func(); 
>>will give you always the size. but

so that meant *if* the function returns *always* an array (or better,
as randal said, a list), *then* 
$result = func();
will *always* give you the size.
your function does not always return a list, so there
is no contradiction.

or more logical, I said:
(sub returns always list) =>
             (call in scalar context will give you the size)

you assumed I said:
(sub returns a list or scalar) =>
             (call in scalar context will give you the size)
which is of course wrong.

if i know the wantarray function you could
assume i know what i can do with it =)

regards,
tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Sun, 10 Sep 2000 21:34:57 GMT
From: tim@degree.ath.cx (Tim Hammerquist)
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <slrn8ro0bi.k2.tim@degree.ath.cx>

kj0 <kj0@mailcity.com> wrote:
> I haven't yet seen a good (i.e. sufficiently memorable) account of the
> difference between arrays and lists in Perl.  In the 2nd edition of
> Programming Perl there is a section called "List Values and Arrays"
> (pp. 47-49) where the authors *hint* at the fact that lists and arrays
> are not equivalent, but they never explain what exactly is the
> difference.

The difference between a Perl list and a Perl array are at times
apparently just nominal.  For instance, you can index a Perl list as if
it were an array, eliminating the need for many temporary vars:

	print (qw/Sun Mon Tue Wed Thu Fri Sat/)[(localtime)[6]];
	print join(':', reverse( (localtime)[0..2] ) );

And of course, you can use an array almost anywhere you can use a list;
it's just not an array anymore.  However, you cannot use lists anywhere
you can use arrays; eg, push(), pop().

Any intricacies of the differences I better leave up to Larry, Randy,
or Tom (if they still follow this NG).  Beyond this I can't help you
much.  What I can say is that this blurred distinction between the
two is more a blessing than anything (to me, anyway).

> I had a similar problem when learning C, because the first book I used
> did a very poor job clarifying the difference between pointers and
> arrays.  So for the first months as a C programmer I was always
> tripping, and then I read Harbison & Steele and all was clear.  But
> the Harbison & Steele of Perl is yet to be written, alas.

Trying to imagine a book that could fail to distinguish clearly between
C arrays and C pointers... 

Alright, an unindexed C array simply returns a pointer to the first
element of the array.  Is this what you're referring to?

[Begin OT section]

Consider:

: #include <stdio.h>
: 
: void main() {
: 	char* str = "arbitrary";
: 	printf("%c\n", str[1]);
: }

After running this little program, I was reminded of how interchangeable
C char arrays and char pointers are.  However, AFAIK this only applies
to char[] and char*.  I've found that indexing a dereferenced int*:

	int* x = new int(5);
	x[0];

 ...does not cause any errors.  But any attempt to _use_ the indexed pointer
caused a segmentation fault.

OTOH, the college professor who taught my C++ class was unaware of this
interchangeability. (Either that, or he didn't want to confuse
anyone...yet.)  =)

[End OT section]

-- 
-Tim Hammerquist <timmy@cpan.org>
I do not, for one, think that the problem was that the band was down.
I think that the problem may have been...that there was a Stonehenge
monument on the stage that was in danger of being crushed by a dwarf.
	-- David St. Hubbins, "This is Spinal Tap"


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

Date: Sun, 10 Sep 2000 17:47:39 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Count of items is EXCEPTION not RULE (was Re: Little perl annoyance #371: glob)
Message-Id: <brian-ya02408000R1009001747390001@news.panix.com>

In article <8pgur9$csnku$10@ID-24002.news.cis.dfn.de>, news@tinita.de posted:

> so that meant *if* the function returns *always* an array (or better,
> as randal said, a list), *then* 

see Nat's post on the difference between arrays and lists.

> $result = func();
> will *always* give you the size.

> your function does not always return a list, so there
> is no contradiction.

what the function returns depends on context.  a function
gets data through a list and returns data through a list
(perhaps one item). 

> or more logical, I said:
> (sub returns always list) =>
>              (call in scalar context will give you the size)

persisting in this sort of explanation will only cause confusion.
try this code:

   sub foo { return ( 1, 2, 4 ) }
   my $value = foo();
   print $value;

now, try to explain that result in terms of what you just said.

> if i know the wantarray function you could
> assume i know what i can do with it =)

what you are saying is wrong.  i don't assume that you know
what you are doing when you are wrong.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Sun, 10 Sep 2000 20:24:41 +0100
From: Geoff Soper <g.soper@soundhouse.co.uk>
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <49fbfce798g.soper@soundhouse.co.uk>

In article <49fbf076c1g.soper@soundhouse.co.uk>, Geoff Soper
<g.soper@soundhouse.co.uk> wrote:
> I'm thinking if I name all the fields in the format data-user-field e.g.
> data-john.doe-email I could go through all the fields returned by the
> param() function, ignoring any that don't begin with data and inserting
> the others into the hash of hashes %allusers using the data and field
> data i.e. $allusers{"john.doe"}{"email"} = param(data-john.doe-email)

How do I get all of the data pairs from the param() function in order that
I may work through them all looking for the data-... 
Is there a way to tranfer it into a hash? I'm assuming there is as it's
mentioned in the CGI programming MetaFAQ but I don't understand it as it
appears to be explained in the object-orientated mode.

Many thanks

Thanks

-- 
Geoff Soper
g.soper@soundhouse.co.uk
Take a look at the Soundhouse page http://www.soundhouse.co.uk/


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

Date: 10 Sep 2000 12:26:13 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <m18zt0xd4a.fsf@halfdome.holdit.com>

>>>>> "Geoff" == Geoff Soper <g.soper@soundhouse.co.uk> writes:

Geoff> How do I get all of the data pairs from the param() function in order that
Geoff> I may work through them all looking for the data-... 
Geoff> Is there a way to tranfer it into a hash? I'm assuming there is as it's
Geoff> mentioned in the CGI programming MetaFAQ but I don't understand it as it
Geoff> appears to be explained in the object-orientated mode.

If you can be sure that you will NEVER NEVER NEVER have a "select multiple"
option in your text, you can use this:

    use CGI qw(param);
    my %data;
    $data{$_} = param($_) for param();

If you have a "select multiple", then that code returns the *first*
selected item, not all of them.  A more general capture will be to make
a multiple-hits-safe structure, as:

    use CGI qw(param);
    my %data;
    $data{$_} = [param($_)] for param();

Now $data{"bigfield"}[0] is the first (possibly only) value for "bigfield".

print "Just another Perl hacker,";

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: 10 Sep 2000 19:40:00 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <8pgo2g$r89$2@nntp9.atl.mindspring.net>

Randal L. Schwartz (merlyn@stonehenge.com) wrote:
: If you can be sure that you will NEVER NEVER NEVER have a "select multiple"
: option in your text,

Or more than one checkbox with the same name.

: you can use this:


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

Date: Sun, 10 Sep 2000 16:58:38 -0400
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <brian-ya02408000R1009001658380001@news.panix.com>

In article <8pgo2g$r89$2@nntp9.atl.mindspring.net>, ebohlman@netcom.com (Eric Bohlman) posted:

> Randal L. Schwartz (merlyn@stonehenge.com) wrote:
> : If you can be sure that you will NEVER NEVER NEVER have a "select multiple"
> : option in your text,
> 
> Or more than one checkbox with the same name.

actually, any widgets with the same name regardless of type, as
long as there is more than one.

-- 
brian d foy                    
CGI Meta FAQ <URL:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>
Perl Mongers <URL:http://www.perl.org/>


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

Date: Sun, 10 Sep 2000 23:12:21 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <Pine.GHP.4.21.0009102307290.17608-100000@hpplus03.cern.ch>

On Sun, 10 Sep 2000, brian d foy wrote:

> > Or more than one checkbox with the same name.
> 
> actually, any widgets with the same name regardless of type, as
> long as there is more than one.

Indeed.

For example, there's nothing actually prohibiting having a list of
prepared entries as checkboxes, and a write-in text field, and giving
them all the same name, if it makes sense in the context of your form
and you're prepared to deal with that at the server.

It's only with radio buttons that having, or not having, the same name
is of any importance to the _client_ behaviour.



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

Date: 10 Sep 2000 21:55:14 GMT
From: Tina Mueller <tina@streetmail.com>
Subject: Re: Entering data from an HTML into a hash of hashes
Message-Id: <8ph002$csnku$11@ID-24002.news.cis.dfn.de>

hi,
In comp.lang.perl.misc Alan J. Flavell <flavell@mail.cern.ch> wrote:
> On Sun, 10 Sep 2000, brian d foy wrote:

>> > Or more than one checkbox with the same name.
>> 
>> actually, any widgets with the same name regardless of type, as
>> long as there is more than one.

> Indeed.

> For example, there's nothing actually prohibiting having a list of
> prepared entries as checkboxes, and a write-in text field, and giving
> them all the same name, if it makes sense in the context of your form
> and you're prepared to deal with that at the server.

> It's only with radio buttons that having, or not having, the same name
> is of any importance to the _client_ behaviour.

right.
and in the end, be aware that the parameters passed
to the script don't reflect anything like checkboxes
or textareas, but only parameters which
can have one or more values. if you think
of the fact that you can call a script by
creating your own query string then checkboxes and co.
are not important any more.

tina

-- 
http://tinita.de    \  enter__| |__the___ _ _ ___
tina's moviedatabase \     / _` / _ \/ _ \ '_(_-< of
search & add comments \    \__,_\___/\___/_| /__/ perception
please don't email unless offtopic or followup is set. thanx


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

Date: Sun, 10 Sep 2000 18:19:56 GMT
From: "Jeff Johnson" <jeffjohnson@earthlink.net>
Subject: Re: Help with number formatting needed...
Message-Id: <ghQu5.1422$%p2.63595@newsread03.prod.itd.earthlink.net>

Thanks for the tip but I must ask for specifics. Since I don't know much
about PERL I don't understand how to use the "sprintf" function you
suggested and the "perldoc -f sprintf" display gives no actual examples.
Could you please supply an example of how to use this function to format
numbers for screen output? Below is a sample of code that I am working with:

  $Price=9.95;
  $Ordered=1;
  $Shipping=5.95;
  $Shipvia='United States Post Office 2 to 3 Day Air'
  $SubTotal=($Ordered * $Price);
  $Total=($SubTotal + $Shipping);

   print "Your order for $Ordered CD(s) at \$$Price per CD comes to ";
   print "\$$SubTotal plus \$$Shipping shipping and handling via $Shipvia ";
   print "for a total of \$$Total.\n";

In this example the $Total variable is diplayed as 15.9 instead of  15.90.
How do I format it properly? It seems that "formline" could help but I can't
seem to use it properly either. The docs on PERL assume too much. They seem
to explain the limits of a function but give no actual examples of how to
use it.

Thanks for any suggestions,
Jeff Johnson


Clinton Pierce <clintp@geeksalad.org> wrote in message
news:lqxu5.36173$QW4.445001@news1.rdc1.mi.home.com...
> [Posted and mailed]
>
> In article <ajxu5.32753$K4.1388147@newsread1.prod.itd.earthlink.net>,
> "Jeff Johnson" <jeffjohnson@earthlink.net> writes:
> > I have managed to re-write the basic formmail.pl, found on many sites
and at
> > Matt's Script Archive, to include a "confirmation page" that shows users
the
> > data they have input on a form, totals their order, and asks them to
> > finalize the order by selecting a "Purchase" button. Since I know a bit
> > about database but nothing about PERL it took me a while to write. I am
left
> > with two final problems to solve.
>
> Ouch.  You're scaring me.  You did all that, and you missed these?  :)
>
> > 1.) How do I format numbers to always appear with two figures after the
> > decimal point?
> >                 Example: 15.90 appears as 15.9
>
> perldoc -f sprintf
>
> > 2.) How do I "clear" memory arrays and variables before exiting a PERL
> > script?
> >                  Example: Once my script "prints" parts of an array to
HTML
> > I want to
> >                  then "clear" that array to be used again later.
>
> In 1 word: unnecessary.  If you exit the script, the memory is freed.
> If you don't exit the script, then just let the variables fall out of
scope or
> initialize them to an empty value (like @a=();).
>
> --
>     Clinton A. Pierce              Teach Yourself Perl in 24 Hours!
>   clintp@geeksalad.org         for details see http://www.geeksalad.org
> "If you rush a Miracle Man,
> you get rotten Miracles." --Miracle Max, The Princess Bride
>




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

Date: Sun, 10 Sep 2000 19:38:57 GMT
From: Randy <randy_734@my-deja.com>
Subject: Re: Help with number formatting needed...
Message-Id: <39bbe0d0.14628437@207.126.101.100>

Jeff,

Like everything in Perl, there's a million ways to do it. You might
try this:

change:
$Total=($SubTotal + $Shipping);
to:
$Total = sprintf ("%.2f", $Shipping + $SubTotal) ;

The "%.2f" is the format string.  Each field begins with a %. The .2
means 2 decimal places and the f means a fixed point number.

HTH
Randy Harris

"Jeff Johnson" <jeffjohnson@earthlink.net> wrote:

>Thanks for the tip but I must ask for specifics. Since I don't know much
>about PERL I don't understand how to use the "sprintf" function you
>suggested and the "perldoc -f sprintf" display gives no actual examples.
>Could you please supply an example of how to use this function to format
>numbers for screen output? Below is a sample of code that I am working with:
>
>  $Price=9.95;
>  $Ordered=1;
>  $Shipping=5.95;
>  $Shipvia='United States Post Office 2 to 3 Day Air'
>  $SubTotal=($Ordered * $Price);
>  $Total=($SubTotal + $Shipping);
>
>   print "Your order for $Ordered CD(s) at \$$Price per CD comes to ";
>   print "\$$SubTotal plus \$$Shipping shipping and handling via $Shipvia ";
>   print "for a total of \$$Total.\n";
>
>In this example the $Total variable is diplayed as 15.9 instead of  15.90.
>How do I format it properly? It seems that "formline" could help but I can't
>seem to use it properly either. The docs on PERL assume too much. They seem
>to explain the limits of a function but give no actual examples of how to
>use it.
>
>Thanks for any suggestions,
>Jeff Johnson
>
>
>Clinton Pierce <clintp@geeksalad.org> wrote in message
>news:lqxu5.36173$QW4.445001@news1.rdc1.mi.home.com...
>> [Posted and mailed]
>>
>> In article <ajxu5.32753$K4.1388147@newsread1.prod.itd.earthlink.net>,
>> "Jeff Johnson" <jeffjohnson@earthlink.net> writes:
>> > I have managed to re-write the basic formmail.pl, found on many sites
>and at
>> > Matt's Script Archive, to include a "confirmation page" that shows users
>the
>> > data they have input on a form, totals their order, and asks them to
>> > finalize the order by selecting a "Purchase" button. Since I know a bit
>> > about database but nothing about PERL it took me a while to write. I am
>left
>> > with two final problems to solve.
>>
>> Ouch.  You're scaring me.  You did all that, and you missed these?  :)
>>
>> > 1.) How do I format numbers to always appear with two figures after the
>> > decimal point?
>> >                 Example: 15.90 appears as 15.9
>>
>> perldoc -f sprintf
>>
>> > 2.) How do I "clear" memory arrays and variables before exiting a PERL
>> > script?
>> >                  Example: Once my script "prints" parts of an array to
>HTML
>> > I want to
>> >                  then "clear" that array to be used again later.
>>
>> In 1 word: unnecessary.  If you exit the script, the memory is freed.
>> If you don't exit the script, then just let the variables fall out of
>scope or
>> initialize them to an empty value (like @a=();).
>>
>> --
>>     Clinton A. Pierce              Teach Yourself Perl in 24 Hours!
>>   clintp@geeksalad.org         for details see http://www.geeksalad.org
>> "If you rush a Miracle Man,
>> you get rotten Miracles." --Miracle Max, The Princess Bride
>>
>
>



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

Date: Sun, 10 Sep 2000 20:27:09 GMT
From: mejarrell@worldnet.att.net (Maurice E. Jarrell)
Subject: Re: Help with number formatting needed...
Message-Id: <m37l8knwg4.fsf@localhost.localdomain>

"Jeff Johnson" <jeffjohnson@earthlink.net> writes:

> Thanks for the tip but I must ask for specifics. Since I don't know much
[...]
> In this example the $Total variable is diplayed as 15.9 instead of  15.90.

Not an expert, but this code works for me.
my( $cost ) = 19.9;
printf("The cost is: \$%.2f\n", $cost);

Outputs:
The cost is: $19.90

HTH,
Mo


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

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 4278
**************************************


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