[18321] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 489 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 14 18:06:01 2001

Date: Wed, 14 Mar 2001 15:05:12 -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: <984611112-v10-i489@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 14 Mar 2001     Volume: 10 Number: 489

Today's topics:
        2-dimensional arrays <milliwave@rfengineering.freeserve.co.uk>
    Re: 2-dimensional arrays <bmb@ginger.libs.uga.edu>
    Re: 2-dimensional arrays <mjcarman@home.com>
        Duplicate entry problem in mysql using DBI <meyrick@NOSPAMhedge-analytics.com>
    Re: file upload problem in 5.6 <SeeReply-To@eaglerock-is.com.invalid>
    Re: Help in understood Perl some slides (Taming of Came (Glyndwr)
    Re: Help in understood Perl some slides (Taming of Came <bmb@ginger.libs.uga.edu>
    Re: Help in understood Perl some slides (Taming of Came (Glyndwr)
    Re: HTTP Client Question (David H. Adler)
    Re: HTTP Client Question <spohn@mayo.edu>
    Re: Is there a shorter way for this? <bart.lateur@skynet.be>
    Re: looking for a script to count downloads <ciaran.mccreesh@useaddressbelow.please>
    Re: Maintaining the number format and not exponential dmeyers+news@panix.com
        Need Form Help!!!!!! <rel@goodergroup.com>
    Re: Need Form Help!!!!!! <dsagnell@junglesoft.com>
    Re: Need Form Help!!!!!! <uri@sysarch.com>
    Re: Need Form Help!!!!!! <dsagnell@junglesoft.com>
    Re: Need Form Help!!!!!! <uri@sysarch.com>
    Re: Need Form Help!!!!!! <jazrant@zsc.nrcan.zc.ca>
    Re: Need Form Help!!!!!! <uri@sysarch.com>
    Re: Need Form Help!!!!!! <jazrant@zsc.nrcan.zc.ca>
    Re: Need Form Help!!!!!! <callgirl@la.znet.com>
    Re: Perl FAQ? <uri@sysarch.com>
    Re: Perl FAQ? <kperrier@kingwoodcable.com>
    Re: perlcc on Win32 failing <jmccaske@pervasive.com>
    Re: Print own "die" message <bmb@ginger.libs.uga.edu>
    Re: RFC: FAQ3 update -- Using less memory (Heiner Marxen)
        Segmentation Fault <worik@telebusiness.co.nz>
        Sophomore Uses List Context; Cops Interrogate <shanem@ll.mit.edu>
    Re: Useless use of addition (+) in a void context... (Tad McClellan)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Mar 2001 20:05:01 -0000
From: "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
Subject: 2-dimensional arrays
Message-Id: <98oir5$blm$1@newsg4.svr.pol.co.uk>

Hello,

I was hoping someone could inform me how to create a 2 dimensional array? I
have
been mostly dealing with 1-dimensional arrays. Basically I have defined a
table

open(TABLE "table.txt")
@table=();
$index=1;  #preffered to start-off with one!

while (<TABLE>)
{
       chomp;

 if (($_ =~
m/\t(\d*)\t\t(\w*)\s*(\w*)\s*\t\S\s*(\S*)\s*(\S*)\s*(\S*)\s*(\S*)\s*\S/) or
($_ =~ m/\t(\d\t\t(\w*)\s*(\w*)\s*/))


        $table_call_no  = $1;
        $table_type     = $2;
        $table_cell_name= $3;
        $table_xmin     = $4;
        $table_ymin     = $5;
        $table_xmax     = $6;
        $table_ymax     = $7;

       $table[$index]=("$table_call_no $table_type $table_cell_name
$table_xmin $table_ymin $table_xmax $table_ymax\n");
          index++;
}

print $table[1];

close TABLE;

****************************************************************************
************************

Now you can see that the table consists of 7 columns. In otherwords an n-row
x 7 column
matrix.   ( n x 7)
Currently the above code represents a 1-dimensional array, I woul like to
have access
to all those individual elements within the matrix for example;

                  1                          2                     3
4                 5                  6                   7
$index $table_call_no $table_type $table_cell_name $table_xmin $table_ymin
$table_xmax $table_ymax

1               1                         2                     3
4                    6                  7                  8
2               4                         5                     5
6                   89               56                65
3              45                       45                  44
33                  33               22                22
                 -
                 -
     and so oN!

I would like to  access say:  $table[$index][$table_ymin]
                         example        $table[2][5] =  89

Can anyone help?
cheers
Kev











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

Date: Wed, 14 Mar 2001 16:55:54 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: 2-dimensional arrays
Message-Id: <Pine.A41.4.21.0103141643460.13928-100000@ginger.libs.uga.edu>

On Wed, 14 Mar 2001, Milliwave wrote:
> I was hoping someone could inform me how to create a 2 dimensional array? I
> have
> been mostly dealing with 1-dimensional arrays. Basically I have defined a
> table

"... I suggest to use a hash."

I also suggest to use warnings and use strict.

> open(TABLE "table.txt")

Even when testing, you should check the return value of your open.

Below is a possible way to do something similar to what you appear to be
trying to do.  I'm sure there's a more succinct answer.  Of course, you
may have a good reason for wanting to use just arrays; you'll probably get
some more suggestions.  :-)

Cheers,

Brad



#!/usr/local/bin/perl
use warnings;
use strict;
use Data::Dumper;
$Data::Dumper::Indent = 1;

my @table = ();

while (<DATA>) {
  chomp;

  my( $call, $type, $cell, $xmin, $ymin, $xmax, $ymax ) =
      (split)[0..2,4..7];

  push @table, {
    call=>$call,
    type=>$type,
    cell=>$cell,
    xmin=>$xmin,
    ymin=>$ymin,
    xmax=>$xmax,
    ymax=>$ymax,
    };

}  # while

print Dumper( \@table );

__DATA__
call1 type1 cell1 dummy xmin1 ymin1 xmax1 ymax1
call2 type2 cell2 dummy xmin2 ymin2 xmax2 ymax2

Output:

$VAR1 = [
  {
    'ymin' => 'ymin1',
    'ymax' => 'ymax1',
    'xmin' => 'xmin1',
    'cell' => 'cell1',
    'xmax' => 'xmax1',
    'type' => 'type1',
    'call' => 'call1'
  },
  {
    'ymin' => 'ymin2',
    'ymax' => 'ymax2',
    'xmin' => 'xmin2',
    'cell' => 'cell2',
    'xmax' => 'xmax2',
    'type' => 'type2',
    'call' => 'call2'
  }
];





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

Date: Wed, 14 Mar 2001 15:52:14 -0600
From: Michael Carman <mjcarman@home.com>
Subject: Re: 2-dimensional arrays
Message-Id: <3AAFE80E.FCE83493@home.com>

Milliwave wrote:
> 
> I was hoping someone could inform me how to create a 2 dimensional 
> array?

Perl does not inherently support multidimensional arrays. All arrays are
1-D lists of scalars. Fortunately, references are scalars, and this
allows us to create arbitrarily complex data structures.

> $index=1;  #preffered to start-off with one!

1) This is the Wrong Way to do what you're trying to do. Use the 
   special variable $[ to control this.
2) You shouldn't do that anyway. Arrays start at zero. Get used to it!

[snip of incomprehensible and badly formatted example]

> I would like to  access say:  $table[$index][$table_ymin]
>                     example        $table[2][5] =  89

Yep, you can. That's the right syntax.

Here's a real simple example -- Go read the perldsc and perlref manpages
for the full story.

#!/usr/local/bin/perl5 -w
use strict;

my @table;
while (<DATA>) {
    chomp;
    my @row = split;
    push(@table, \@row);
}	

print $table[1][4], "\n"; # Prints '89'

__DATA__
 1   2   3   4   6   7   8
 4   5   5   6  89  56  65
45  45  44  33  33  22  22


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

Date: Wed, 14 Mar 2001 23:02:56 +0000
From: Meyrick <meyrick@NOSPAMhedge-analytics.com>
Subject: Duplicate entry problem in mysql using DBI
Message-Id: <3AAFF8A0.66C9A35F@NOSPAMhedge-analytics.com>

Hi,

My perl script generates the following error on accessing mysql:

DBD::mysql::db do failed: Duplicate entry '0000-00-00' for key 1 at
 ./minky.pl line 120
Database handle destroyed without explicit disconnect.

Now, I know from using shell scripts to access this database that mysql
likes to have date format wrapped in single quotes - so that is what I
have done in perl - but it complains!

Here is the code fragment from my script:

		#first create a nice date format
		$my_date=`date -d yesterday -I`; 
		chomp $my_date;

		# then add the single quotes
		$db_date="'".$my_date."'";

		# do the same for another variable added to the database
		$db_expiry="'".$months[$i+1]."'";
		
		# create the database object
		$dbh=DBI->connect("DBI:mysql:database=test;host=localhost",
					"root",undef,{RaiseError=>1});
		$dbh->do("INSERT INTO ED1 VALUES(date,2output,2op_strike,
			1output,1op_strike,atm,atm_strike,1outcall,
			1oc_strike,2outcall,2oc_strike,expiry,underlying)",
			($db_date,$out_put2,$dn_strike2,$out_put1,
			$dn_strike2,$atm_vol,$atm_strike,$out_call1,$up_strike1,
			$out_call2,$up_strike2,$db_expiry,$close)
			) || die $dbh->errstr;
			
		$dbh->disconnect();		
		

Thanks 

Meyrick


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

Date: Wed, 14 Mar 2001 16:23:05 -0600
From: Ray DeGennaro <SeeReply-To@eaglerock-is.com.invalid>
Subject: Re: file upload problem in 5.6
Message-Id: <SeeReply-To-FD755C.16230514032001@newsrump.sjc.telocity.net>

In article <u9ae6p8rrr.fsf@wcl-l.bham.ac.uk>, nobull@mail.com wrote:

> Use CGI.pm's native API rather than it's cgi-lib.pl emulatation and
> your code should work OK.

I just posted a working example in comp.lang.perl.modules

Ray

-- 
 .=================================================================.
| =-=-=-=-=-=-= Eagle Rock Information Systems Corp =-=-=-=-=-=-= |
| -=-=-=-=-=-=- web and database business solutions -=-=-=-=-=-=- |
| <http://www.eaglerock-is.com>    <mailto:info@eaglerock-is.com> |
| Chicago Area Office:  630-955-0365 (voice)  503-905-8153 (eFax) |
 .=================================================================.


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

Date: Wed, 14 Mar 2001 19:22:33 GMT
From: glynFOOdwr@FSCKdeleteEmeD.co.uk (Glyndwr)
Subject: Re: Help in understood Perl some slides (Taming of Camel)
Message-Id: <slrn9avh89.17o.glynFOOdwr@glyndwr.dyndns.org>

On 14 Mar 2001 18:34:07 +0000, nobull@mail.com scribbled:
>glynFOOdwr@FSCKdeleteEmeD.co.uk (Glyndwr) writes:
>
>> Implicit looping: awk scripts are basically a pile of regexps that get
>> tested on each line of the input, hence it implicitly loops over the
>> input.
>
>But I thought this was in a list of features _not_ taken from awk!
>
>awk's implicit looping is available in Perl (as an command line
>switch).

Hmm, perhaps it meant *enforced* implicit looping ;o)

Some of the nawk scripts I wrote back before I discovered Perl had to
jump through some real hoops to do things that were outside the
process-each-line structure awk imposes on scripts.

-- 
                                          -=G=-
Web: http://www.fscked.co.uk                           ICQ: 66545073


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

Date: Wed, 14 Mar 2001 15:08:21 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Help in understood Perl some slides (Taming of Camel)
Message-Id: <Pine.A41.4.21.0103141500490.12928-100000@ginger.libs.uga.edu>

On Wed, 14 Mar 2001, Glyndwr wrote:
> Some of the nawk scripts I wrote back before I discovered Perl had to
> jump through some real hoops to do things that were outside the
> process-each-line structure awk imposes on scripts.

My first useful CGI script was a stats report generator written in awk.
When the source reached about 24170 bytes, it mysteriously broke and I
rewrote it in Perl(4) after learning enough to be dangerous.

Brad



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

Date: Wed, 14 Mar 2001 20:49:10 GMT
From: glynFOOdwr@FSCKdeleteEmeD.co.uk (Glyndwr)
Subject: Re: Help in understood Perl some slides (Taming of Camel)
Message-Id: <slrn9avmam.17o.glynFOOdwr@glyndwr.dyndns.org>

On Wed, 14 Mar 2001 15:08:21 -0500, Brad Baxter scribbled:
>On Wed, 14 Mar 2001, Glyndwr wrote:
>> Some of the nawk scripts I wrote back before I discovered Perl had to
>> jump through some real hoops to do things that were outside the
>> process-each-line structure awk imposes on scripts.
>
>My first useful CGI script was a stats report generator written in awk.
>When the source reached about 24170 bytes, 

Ouchie. I once wrote a program that had to drive several FORTRAN
programs; it consisted of a master csh script that created and wrote
both custom initilisation files for the FORTRAN programs (two different
types), plus two nawk scripts to get results, plus some more csh for
flow control, and there was probably some sed in there too.

I was young and naive at the time. Imagine my face when someone dropped
the camel book on my desk six months later. 

>it mysteriously broke and I rewrote it in Perl(4) after learning enough
>to be dangerous.

I'm slightly ashamed to admit that I wrote the aforementioned
monstrosity whilst Perl 5 was already out. 

-- 
                                          -=G=-
Web: http://www.fscked.co.uk                           ICQ: 66545073


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

Date: 14 Mar 2001 19:39:42 GMT
From: dha@panix2.panix.com (David H. Adler)
Subject: Re: HTTP Client Question
Message-Id: <slrn9avi7u.bch.dha@panix2.panix.com>

On Wed, 14 Mar 2001 16:55:46 GMT, Bob Dilworth <avast@hortonsbay.com> wrote:
>
>Abigail is indicating that you're now part of her kill file which means
>she'll not be reading any of your postings any more.  My advice is to
>welcome such "plonking" since it'll weed out the Taliban and you can
>concentrate on getting help from folks who are less concerned with a
>slavish regard for random rules.

Of course, the fact that abigail is one of the more knowledgeable
posters here, and that many of the other experts may well have followed
suit silently, is unimportant.

</sarcasm>

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
I drink to my coming cirrhosis...	- Charles Aznavour


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

Date: Wed, 14 Mar 2001 16:04:38 -0600
From: "Al Spohn" <spohn@mayo.edu>
Subject: Re: HTTP Client Question
Message-Id: <98opua$9c7$1@tribune.mayo.edu>

Terrifying to consider the possibility that all perl experts might suffer
from the same disorder.  On the bright side, nobody having seen any of my
perl code would ever confuse me for a member of that group :-).

David H. Adler <dha@panix2.panix.com> wrote in message
news:slrn9avi7u.bch.dha@panix2.panix.com...
> On Wed, 14 Mar 2001 16:55:46 GMT, Bob Dilworth <avast@hortonsbay.com>
wrote:
> >
> >Abigail is indicating that you're now part of her kill file which means
> >she'll not be reading any of your postings any more.  My advice is to
> >welcome such "plonking" since it'll weed out the Taliban and you can
> >concentrate on getting help from folks who are less concerned with a
> >slavish regard for random rules.
>
> Of course, the fact that abigail is one of the more knowledgeable
> posters here, and that many of the other experts may well have followed
> suit silently, is unimportant.
>
> </sarcasm>
>
> dha
>
> --
> David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
> I drink to my coming cirrhosis... - Charles Aznavour




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

Date: Wed, 14 Mar 2001 20:52:48 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Is there a shorter way for this?
Message-Id: <pabvatsln9vpr2f3591o2k71q6jb5h1qno@4ax.com>

Zeljko Vrba wrote:

>@data = ($time, $1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14,
>$15, $16, $17, $18, $19, $20, $21, $22, $23, $24, $25, $26, $27, $28, $29, $30,
>$31, $32);
>
>$1 .. $32 result from parsing a regexp.. It can be really tedious to list all
>needed regexp variables.

Randal's suggestion only works if you don't need the /g modiefier.

	@match = /(\w+)=(\S+)/g

stuffs *everything* onto @match, and not in pairs of two.

Anyway, I can see two ways around this:

 * using symbolic references to get at $1 and friends:

	@data = map { $$_ } 1 .. 32;

Nasty, but yet a lot better than eval.

 * Using a variation on that code I posted recently, extracting parts of
the original string using @+ and @-. The disadvantage is that there is
no special variable for referencing the string you just did a match on,
so you have to access the variable under test by name.

	$s =~ /$regex/;
	@data = map { substr $s, $-[$_], $+[$_]-$-[$_] } 1 .. $#+;

Note that thanks to the map() you can't use $_ for the matching string.

-- 
	Bart.


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

Date: Wed, 14 Mar 2001 19:01:40 +0000
From: Ciaran McCreesh <ciaran.mccreesh@useaddressbelow.please>
Subject: Re: looking for a script to count downloads
Message-Id: <5PuUuCAUA8r6IwWl@harlawroad.freeserve.co.uk>

In article <3aafbd84.10316931@news.telocity.com> (whatever that means),
Richard Wilkerson <rw@dreamgate.com> writes
>Original question:   How to get a log file going that counts the use
>of a particular download link on a page of many links? 

Not sure if I understand, but:

If you want to know where downloads come from, use referer() -- if you
have a cgi object, you can get where the person came from with $cgi-
>referer() .

If you're trying to log outgoing links, just link to a redirect script
rather than the thing you're really linking to.

I actually have a script which does what you're asking about -- if
you're interested send me email and I'll add some comments to it for you
:)

Ciaran

-- 
Ciaran McCreesh
mail:        keesh@users.sourceforge.net
web:         http://www.opensourcepan.com/


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

Date: 14 Mar 2001 15:02:54 -0500
From: dmeyers+news@panix.com
Subject: Re: Maintaining the number format and not exponential
Message-Id: <yobofv45dap.fsf@panix3.panix.com>

Heather <hans-n-heather@fish.net> writes:

> (Neither can I find any doubled up words, etc, but that's beside the
> point.) So I'm asking in all honesty, what exactly is it that has been
> claimed to work by the author, and doesn't in your experience?

Here:

Output values always always in canonical form 


But, of course, I just figured that the author of the
man page was simply emphasizing the "always".

That said, it seems a quite straightforward and easy-to-follow
man page, and the module seems to work just fine on my NT box,
barring, of course, the idiotic windoze-quoting issues on the
command line.

In particular, the example with the '-MMath::BigInt=:constant '
was especially interesting to me, as I rarely write one-liners
which use modules and I wasn't aware of that use of the = .

--d (used to write one-liners all the time on unix boxen)

-- 
dmeyers@panix.com


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

Date: Wed, 14 Mar 2001 13:39:54 -0500
From: "rlasker" <rel@goodergroup.com>
Subject: Need Form Help!!!!!!
Message-Id: <98ofbe$2mh6$1@allnight.news.cais.net>

I am using a checkbox_group in my CGI. The problem is is that it is not
sending the paramaters as multivalued, instead it is creating a seperate
parameter name each called the same thing.

For instance:
checkbox1 is named checkbox with a value of 1
checkbox2 is named checkbox with a value of 2
checkbox3 is named checkbox with a value of 3

This should produce a query string like this:
URLAddress?checkbox=1,2,3

But instead I'm getting:
URLAddress?checkbox=1&checkbox=2&checkbox=3

so now if I try to associate an array with the param('checkbox') I only get
the first value instead of all of the values.

Plus there is a hidden field called .cgifields with a value of checkbox.

Does anyone know why it is not creating multivalued parameters and what are
the hidden .cgifields field.

I have done everything I can think of - someone please give me a clue.





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

Date: Wed, 14 Mar 2001 14:45:33 -0500
From: "D. Sagnella" <dsagnell@junglesoft.com>
Subject: Re: Need Form Help!!!!!!
Message-Id: <3AAFCA5D.756074BF@junglesoft.com>

You could parse this yourself easily


for example;

my $querystring = $ENV{'QUERY_STRING'};

then you would split about &.
my @in = split(/\&/,$querystring);

Then each of the results would be split about
=

for $in (@in){
  my @a = split(/=/,$in);

  if (defined $in{$a[0]}){
   $in{$a[0]} .= ",$a[1]";
  }
  else {
   $in{$a[0]} = $a[1];
  }

}




rlasker wrote:

> I am using a checkbox_group in my CGI. The problem is is that it is not
> sending the paramaters as multivalued, instead it is creating a seperate
> parameter name each called the same thing.
>
> For instance:
> checkbox1 is named checkbox with a value of 1
> checkbox2 is named checkbox with a value of 2
> checkbox3 is named checkbox with a value of 3
>
> This should produce a query string like this:
> URLAddress?checkbox=1,2,3
>
> But instead I'm getting:
> URLAddress?checkbox=1&checkbox=2&checkbox=3
>
> so now if I try to associate an array with the param('checkbox') I only get
> the first value instead of all of the values.
>
> Plus there is a hidden field called .cgifields with a value of checkbox.
>
> Does anyone know why it is not creating multivalued parameters and what are
> the hidden .cgifields field.
>
> I have done everything I can think of - someone please give me a clue.



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

Date: Wed, 14 Mar 2001 19:46:56 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Need Form Help!!!!!!
Message-Id: <x7k85s9lqn.fsf@home.sysarch.com>

>>>>> "DS" == D Sagnella <dsagnell@junglesoft.com> writes:

  DS> You could parse this yourself easily
  DS> for example;

<snip of broken code>


and even easier by using CGI.pm. don't post homebrew solutions like that
which have many failure points. yours doesn't handle POST, multiple
params which have , in their values, any form of hex decoding, etc.

on top of which you posted jeopardy style.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 14 Mar 2001 15:02:37 -0500
From: "D. Sagnella" <dsagnell@junglesoft.com>
Subject: Re: Need Form Help!!!!!!
Message-Id: <3AAFCE5D.13C6202A@junglesoft.com>

Excuse me
but this was not a 'HOME brewed' solution
but a section of code found in cgi-lib.

Furthermore, what I wrote was not intended to be
a comprehensive parsing routine
but simply an algorithm to accomplish what the person had requested,
which, if i understood correctly, was to have
key = value1,value2,value3.

I was simply illustrating how the user could accomplish the above.
The appropriate snippet (as decided by the user) may be
modified and inserted into their parser.  It is up to the user to
know where if at all this can be done.

ds



Uri Guttman wrote:

> >>>>> "DS" == D Sagnella <dsagnell@junglesoft.com> writes:
>
>   DS> You could parse this yourself easily
>   DS> for example;
>
> <snip of broken code>
>
> and even easier by using CGI.pm. don't post homebrew solutions like that
> which have many failure points. yours doesn't handle POST, multiple
> params which have , in their values, any form of hex decoding, etc.
>
> on top of which you posted jeopardy style.
>
> uri
>
> --
> Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
> SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
> The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
> The Best Search Engine on the Net  ----------  http://www.northernlight.com



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

Date: Wed, 14 Mar 2001 20:20:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Need Form Help!!!!!!
Message-Id: <x7hf0w9k6f.fsf@home.sysarch.com>

>>>>> "DS" == D Sagnella <dsagnell@junglesoft.com> writes:

  DS> Excuse me

you are not excused.

  DS> but this was not a 'HOME brewed' solution
  DS> but a section of code found in cgi-lib.

which is highly deprecated and known to have flaws.

  DS> Furthermore, what I wrote was not intended to be
  DS> a comprehensive parsing routine
  DS> but simply an algorithm to accomplish what the person had requested,
  DS> which, if i understood correctly, was to have
  DS> key = value1,value2,value3.

which is wrong in any case. so you helped him write buggy code. what if
an input param had a , in it?

  DS> I was simply illustrating how the user could accomplish the above.
  DS> The appropriate snippet (as decided by the user) may be modified
  DS> and inserted into their parser.  It is up to the user to know
  DS> where if at all this can be done.

and what if the use doesn't know enough to do that correctly? you did
them a disservice by posting that broken code.

  >> 
  >> on top of which you posted jeopardy style.

which you did again. if i plonked, you would be plonked.

don't try to defend yourself. what you posted was wrong in many
ways. his problem is more than just a single list of checkboxes. 
telling him to use CGI.pm would solve his cgi parsing problem completely
and correctly.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 14 Mar 2001 15:31:09 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: Need Form Help!!!!!!
Message-Id: <98okk4$5tm19@nrn2.NRCan.gc.ca>

"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7k85s9lqn.fsf@home.sysarch.com...
    [...]
> on top of which you posted jeopardy style.

    "jeopardy style"?

--
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: Wed, 14 Mar 2001 20:45:48 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Need Form Help!!!!!!
Message-Id: <x7d7bk9j0j.fsf@home.sysarch.com>

>>>>> "JAG" == John A Grant <jazrant@zsc.nrcan.zc.ca> writes:

  JAG> "Uri Guttman" <uri@sysarch.com> wrote in message
  JAG> news:x7k85s9lqn.fsf@home.sysarch.com...
  JAG>     [...]
  >> on top of which you posted jeopardy style.

  JAG>     "jeopardy style"?


search dejagooogle in this group for that term. it will all become
apparent to you. but obviously not to the poster i was following up.

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 14 Mar 2001 15:58:26 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: Need Form Help!!!!!!
Message-Id: <98om7b$5tm20@nrn2.NRCan.gc.ca>

"Uri Guttman" <uri@sysarch.com> wrote in message
news:x7d7bk9j0j.fsf@home.sysarch.com...
> >>>>> "JAG" == John A Grant <jazrant@zsc.nrcan.zc.ca> writes:
>
>   JAG> "Uri Guttman" <uri@sysarch.com> wrote in message
>   JAG> news:x7k85s9lqn.fsf@home.sysarch.com...
>   JAG>     [...]
>   >> on top of which you posted jeopardy style.
>
>   JAG>     "jeopardy style"?
>
> search dejagooogle in this group for that term. it will all become
> apparent to you. but obviously not to the poster i was following up.

    Ah yes, I found it. And I thought it was something really
    profound about Perl... :)

--
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: Wed, 14 Mar 2001 13:34:38 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: Need Form Help!!!!!!
Message-Id: <3AAFE3EE.65D64920@la.znet.com>

rlasker wrote:
 
> I am using a checkbox_group in my CGI. 
> The problem is is that it is not sending 
> the paramaters as multivalued, instead it
> is creating a seperate parameter name each
> called the same thing.

You need to research and to learn about both
checkboxes and browser operation. Your assumption
is quite incorrect.


> For instance:
> checkbox1 is named checkbox with a value of 1
> checkbox2 is named checkbox with a value of 2
> checkbox3 is named checkbox with a value of 3

Lacking clear and concise parameters, a presumption
is made you have at least correctly formatted your
checkboxes in this fashion:

<INPUT TYPE="checkbox" NAME="checkbox" VALUE="1">

This is based on your three statements above, paraphrased:

checkbox name value

 
> This should produce a query string like this:
> URLAddress?checkbox=1,2,3

This is untrue. Clearly you do not understand
how checkboxes operate and how browsers operate.

 
> But instead I'm getting:
> URLAddress?checkbox=1&checkbox=2&checkbox=3

This is a correct return format.

 
> so now if I try to associate an array with the param('checkbox')
> I only get the first value instead of all of the values.

You have two choices, with the first being most efficient.
Give each checkbox a unique NAME and create a commonplace
associative array. Second option is to create a misnomer
hash, which is less efficient.

An example of an associative array based on unique NAME
attributes for each checkbox:

@Array = qw (checkbox1=1 checkbox2=2 checkbox3=3);

This eliminates any need to massage a hash construct.
Your read and parse will create an associative array
of unique elements, as needed, if you have written a
decent read and parse or are using CGI.pm correctly.

> Plus there is a hidden field called .cgifields with a
> value of checkbox.

It is a poor programming practice to reuse names like this
and, it is an equally poor programming practice to include
a period in form action fields. Both of these bad habits
often lead to problems within a script.

 
> Does anyone know why it is not creating multivalued parameters
> and what are the hidden .cgifields field.

Your return input data is as it should be. Your problem
is a lack of knowledge. You are not correctly reading
and parsing your input data.

How would anyone know what is your grammatically incorrect
reference to .cgifields field? None are mind readers.

My suggestion is you spend abundant time researching
and learning about whatever it is you are trying to do.
You are sorely displaying a serious lack of knowledge.


Godzilla!
-- 
@ø=(a .. z);@Ø=qw(6 14 3 25 8 11 11 0 17 14 2 10 18);
$§="\n";$ß="\b";undef$©;print$§x($Ø[4]/2);
for($¡=0;$¡<=$Ø[2];$¡++){foreach$¶(@Ø){
$ø[$¶]=~tr/A-Z/a-z/;if(($¡==1)||($¡==$Ø[2]))
{$ø[$¶]=~tr/a-z/A-Z/;}print$ø[$¶];if($¶==0)
{print" ";}if($¶==$Ø[12]){print" !";}&D;}
print$ßx($Ø[4]*2);}print$§x($Ø[10]*2);
sub D{select$©,$©,$©,.25;}exit;


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

Date: Wed, 14 Mar 2001 19:08:40 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Perl FAQ?
Message-Id: <x7n1ao9nig.fsf@home.sysarch.com>

>>>>> "k" == kellyboy  <kellyboy@nospanner> writes:

  k> Is there any Perl FAQ out there on the Net??  Not just "FAQ" but a
  k> really comprehensive FAQ that cover many topics under Perl?

no. nobody ever asks the same simple questions about perl. each time we
get a question or a problem posted here it is always unique and
complex. the perl newbie is nonexistant. they always read the entire doc
set, several books and searched dejagoogle before posting here. that way
they find their answers without ever having to ask a question that has
been posted before. in fact, you are the first person to ever ask if
there is a perl FAQ. congratulations!

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


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

Date: Wed, 14 Mar 2001 13:57:05 -0600
From: Kent Perrier <kperrier@kingwoodcable.com>
Subject: Re: Perl FAQ?
Message-Id: <3AAFCD11.9010603@kingwoodcable.com>

kellyboy wrote:

> Is there any Perl FAQ out there on the Net??
> 
> Not just "FAQ" but a really comprehensive FAQ that cover many topics under
> Perl?

Nonwithstanding Uri's excellant responce, do you mean like the one that
comes with the distribution?

Kent
-- 
Trying to do *anything* industrial-strength on a NT platform is
doomed to failure - it's like the realisation that you've been
allocated a bunk-space below a confirmed bedwetter. The question is
not whether you are going to get pissed on, but when.



-----= Posted via Newsfeeds.Com, Uncensored Usenet News =-----
http://www.newsfeeds.com - The #1 Newsgroup Service in the World!
-----==  Over 80,000 Newsgroups - 16 Different Servers! =-----


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

Date: Wed, 14 Mar 2001 21:50:57 GMT
From: "Jim McCaskey" <jmccaske@pervasive.com>
Subject: Re: perlcc on Win32 failing
Message-Id: <5JRr6.192$Od.34544@dca1-nnrp2.news.digex.net>

OK,

So no one knows why this error happens?  I have searched through FAQ's
(though the Win32 one appears to have dissapeared at
http://language.perl.com/faq/).  I tried searching google (I miss Deja).  I
have found lots o' people with similar questions, but the answer is usually
either, use the compiler in the PDK, or use perl2exe.  Well, I am actually
after making perlcc work.  If I have missed a faq some where, please tell
me.  I'm sure the answer is out there, I just can't find the needle.

Thanks.

-Jim


"Jim McCaskey" <jmccaske@pervasive.com> wrote in message
news:hcxr6.3$Da.2886@dca1-nnrp2.news.digex.net...
> Hello,
>
> I am attempting to use perlcc on Activestates Win32 distro.  I am having a
> very odd problem with it.  I am getting a "The system cannot find the file
> specified." error.  Anyone seen this before?  I think it has something to
do
> with the -u<none> but can't figure out what is goint on.
>
> -Jim
>
>
> E:\work\hello>perlcc hello.pl
>
> --------------------------------------------------------------------------
--
> ----
> Compiling hello.pl:
> --------------------------------------------------------------------------
--
> ----
> Making C(hello.pl.c) for hello.pl!
> D:\Perl\bin\Perl.exe -ID:/Perl/lib -ID:/Perl/site/lib -I. -MB::Stash -c
> hello.pl
>
D:\Perl\bin\Perl.exe -ID:/Perl/lib -ID:/Perl/site/lib -I. -MO=C,-l2000,-umai
> n,-uattributes,-uDB,-u<
> one>,-uWin32 hello.pl
> The system cannot find the file specified.
> ERROR: In generating code for hello.pl!
>
> E:\work\hello>cat hello.pl
> print "Hello world\n";
>
> D:\Perl\site\lib\Win32>perl -v
>
> This is perl, v5.6.0 built for MSWin32-x86-multi-thread
> (with 1 registered patch, see perl -V for more detail)
>
> Copyright 1987-2000, Larry Wall
>
> Binary build 623 provided by ActiveState Tool Corp.
> http://www.ActiveState.com
> Built 16:27:07 Dec 15 2000
>
>
> Perl may be copied only under the terms of either the Artistic License or
> the
> GNU General Public License, which may be found in the Perl 5.0 source kit.
>
> Complete documentation for Perl, including FAQ lists, should be found on
> this system using `man perl' or `perldoc perl'.  If you have access to the
> Internet, point your browser at http://www.perl.com/, the Perl Home Page.
>
>
>
>
>
>




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

Date: Wed, 14 Mar 2001 16:21:35 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Print own "die" message
Message-Id: <Pine.A41.4.21.0103141620360.12928-100000@ginger.libs.uga.edu>

On Wed, 14 Mar 2001, BUCK NAKED1 wrote:
> IOW, I want to check a file open for success. If it fails, I want it to
> print to the browser something like "File Could Not Be Opened" and
> that's all I want it to print.
> 
> I'd also like to prevent my error msg from going to the server's default
> screen for die messages.

I think you want:

         use CGI::Carp qw(fatalsToBrowser);
         die "Fatal error messages are now sent to browser";

See perldoc CGI::Carp

Brad



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

Date: Wed, 14 Mar 2001 17:51:20 GMT
From: Heiner.Marxen@DrB.Insel.DE (Heiner Marxen)
Subject: Re: RFC: FAQ3 update -- Using less memory
Message-Id: <GA789K.9E@DrB.Insel.DE>

In article <3AA56BEC.A7F9F0CD@home.com>,
Michael Carman  <mjcarman@home.com> wrote:
[snip]
>=item * Avoid unnecessary quotes and stringification
>
>Don't quote large strings unless absolutely necessary:
>
>	my $copy = "$large_string";
>
>makes 2 copies of $large_string (one for $copy and another for the 
>quotes), whereas
>
>	my $copy = $large_string;
>
>only makes one copy.

Uh, this comes as a surprise to me.  I had expected perl to optimize
the first form to do the same as the second form.


>=item * Consider using C<eval BLOCK>
>
>If you need to initialize a large variable in your code, you
>might consider doing it with an eval statement like this:
>
>	my $large_string = eval ' "a" x 5_000_000 ';
>
>This allows perl to immediately free the memory allocated to the
>eval statement, but carries a (small) performance penalty.

Sorry, I just don't get it:  which "memory allocated to the eval"?
And also, without the eval there is no such memory allocated in the
first place, since there is no eval, right?  So, what does

	my $large_string = "a" x 5_000_000;

allocate, what the eval version does free?


Otherwise I like the text.
-- 
Heiner Marxen	heiner@drb.insel.de	http://www.drb.insel.de/~heiner/


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

Date: Thu, 15 Mar 2001 10:09:58 +1300
From: "Worik Turei Stanton" <worik@telebusiness.co.nz>
Subject: Segmentation Fault
Message-Id: <98omn7$5kq$1@news.akl.netlink.net.nz>

Friends

I am looking for some general advice here.

I have a programme I am working on  AIX using DBI and db2.  The details are
not important but the process involves reading CSV text files and inserting
data into the db2 tables via DBI.

Periodically the process segfaults.

I found that if I install the latest DBI locally (I changed the prefix= line
of the Makefile after running perl MakefilePL) I could run all the data I
had with no segfaults.  So far so good.  Update the DBI, fix the problem.
But no.  When I install the latest DBI system wide (under /usr/local) and
use it from there the segfaults have returned.

I am perplexed.  Has anybody had a similar problem and any advice on what
may be wrong?

cheers
Worik




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

Date: Wed, 14 Mar 2001 17:33:40 -0500
From: Shane McDaniel <shanem@ll.mit.edu>
Subject: Sophomore Uses List Context; Cops Interrogate
Message-Id: <3AAFF1C4.214496CE@ll.mit.edu>

http://slashdot.org/yro/01/03/13/208259.shtml


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

Date: Wed, 14 Mar 2001 21:54:57 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Useless use of addition (+) in a void context...
Message-Id: <slrn9avn1m.352.tadmc@tadmc26.august.net>

Lou Moran <lmoran@wtsg.com> wrote:

>Useless use of addition (+) in a void context (... lines affected)
>^^^^^^^^^^^^^^
>What does this mean?  I haven't been able to look it up in perldoc.


Put:

   use diagnostics;

near the top of your program, run it once again, and _perl_
will look it up for you!


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


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

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


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