[18322] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 490 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 15 00:05:43 2001

Date: Wed, 14 Mar 2001 21:05:11 -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: <984632710-v10-i490@ruby.oce.orst.edu>
Content-Type: text

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

Today's topics:
    Re: 2-dimensional arrays <milliwave@rfengineering.freeserve.co.uk>
    Re: 2-dimensional arrays (John Joseph Trammell)
    Re: [mod_perl] PerlTaintCheck problem <randy@theory.uwinnipeg.ca>
        Backtick program output question! <acline@okstateREMOVECAPS.edu>
    Re: Backtick program output question! (Steven Smolinski)
    Re: Backtick program output question! <acline@okstateREMOVECAPS.edu>
        Data Dumper modules come standard?? <kellyboy@nospanner>
    Re: Data Dumper modules come standard?? <taboo@comcen.com.au>
    Re: Formatting HTML using Perl <claus.schotten@epost.de>
    Re: Getopt::Std question (Garry Williams)
    Re: How to Print "system" failure ...was <Print own "di <whataman@home.com>
    Re: HTTP Client Question <spohn@bigfoot.com>
    Re: HTTP Client Question (David H. Adler)
        I forgot the script (perl for a guestbook) <lzcom.info@verizon.net>
    Re: I forgot the script (perl for a guestbook) <wyzelli@yahoo.com>
    Re: I forgot the script (perl for a guestbook) <joe+usenet@sunstarsys.com>
    Re: Is there a shorter way for this? <johnlin@chttl.com.tw>
    Re: Maintaining the number format and not exponential <hans-n-heather@fish.net>
    Re: Maintaining the number format and not exponential <callgirl@la.znet.com>
    Re: Maintaining the number format and not exponential <hans-n-heather@fish.net>
        Memory and Perl <collin@crosslink.net>
    Re: Perl FAQ? <kellyboy@nospanner>
    Re: Perl FAQ? (John Joseph Trammell)
    Re: Perl FAQ? <kellyboy@nospanner>
        perl on a guestbook <lzcom.info@verizon.net>
        Perl Version Question <doyleed@sprynet.com>
    Re: Print own "die" message <whataman@home.com>
    Re: Print own "die" message <whataman@home.com>
    Re: Print own "die" message (Iain Chalmers)
        problem passing dir names to glob <kimmfc@mydeja.com>
    Re: Unix trap command in Perl on Win? <peter.sundstrom-eds@eds.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 14 Mar 2001 23:44:33 -0000
From: "Milliwave" <milliwave@rfengineering.freeserve.co.uk>
Subject: Re: 2-dimensional arrays
Message-Id: <98ovmo$sqb$1@news7.svr.pol.co.uk>

I would ideally like to make use of the variables already  in the while loop

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

These are variables constantly being updated as "while (<TABLE>)" sweeps and
detects
certain bits and pieces. I would like to form an n row x 7 column array
based on the
above variables.

>> 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: Thu, 15 Mar 2001 00:17:53 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: 2-dimensional arrays
Message-Id: <slrn9b0084.f67.trammell@bayazid.hypersloth.net>

On Wed, 14 Mar 2001 23:44:33 -0000, Milliwave wrote:

> I would like to form an n row x 7 column array based on the
> above variables.

Not to be contradictory, but wouldn't an array of hashes be
more appropriate?

 my @tables;
 while (<DATA>) # note: @t{...} is a 'hash slice' -- powerful!
 {
     my %t;
     @t{'call_no','type','cell','xmin','ymin','xmax','ymax'} = split;
     push @tables, \%t;
 }

This lets you avoid the messy "xmax == column 6" mapping.  You can
now access the 'ymin' of table #32 via:

 $ymin = $table[32]{ymin};

or all of table #234 via:

 %t234 = %{ $table[234] };



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

Date: Wed, 14 Mar 2001 19:16:46 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: [mod_perl] PerlTaintCheck problem
Message-Id: <98p5is$5m7$1@canopus.cc.umanitoba.ca>

"Trevor Leffler" <tleffler@u.washington.edu> wrote in
   message news:3AAFAC6D.858FC56A@u.washington.edu...
> I've got the following in my httpd.conf:
>
> <Directory "/home/httpd/html">
>     Options ExecCGI FollowSymLinks IncludesNoExec Indexes
>     AddHandler perl-script cgi
>     PerlHandler Apache::Registry
>     PerlSendHeader On
>     PerlTaintCheck On
> </Directory>
>
> But, apache doesn't like the PerlTaintCheck directive:
>
> Starting httpd: Syntax error on line 370 of /etc/httpd/conf/httpd.conf:
> PerlTaintCheck not allowed here

Try moving the PerlTaintCheck directive out of the <Directory> block,
so as to turn it on for the entire mod_perl enabled httpd. If you have
some scripts that won't run under taint mode, the guide
(http://perl.apache.org/guide/) recommends that you place them
on another server with taint mode disabled.

best regards,
randy kobes





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

Date: Wed, 14 Mar 2001 21:07:37 -0500
From: Aaron Cline <acline@okstateREMOVECAPS.edu>
Subject: Backtick program output question!
Message-Id: <ZfWr6.264$Rx.3108@news.onenet.net>

Hi:

I run a binary like this from within a perl script.

$send=`/usr/local/dicom/bin/storescu -v -aet test -aec medweb 192.168.0.97 
104 
/home/ajc/dicom/1.2.840.113680.2.103.30892.971607770.500158/USr.1.2.840.113680.2.103.30892.971608007.192407.1.1`;

The only output from the program happens when the program errors.  From 
what I understand, the output from the program would go into the scalar 
send.  However, the error output is pumped to the console.  How can I get 
this error output into the variable??

Thanks for any help.

Aaron


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

Date: Thu, 15 Mar 2001 03:09:48 GMT
From: sjs@linux.ca (Steven Smolinski)
Subject: Re: Backtick program output question!
Message-Id: <slrn9b0hb1.u0.sjs@ragnar.stevens.gulch>

Aaron Cline <acline@okstateREMOVECAPS.edu> wrote:
> $send=`/usr/local/dicom/bin/storescu -v -aet test -aec medweb 192.168.0.97 
> 104 [... long command line ...]
> 
> The only output from the program happens when the program errors.  From 
> what I understand, the output from the program would go into the scalar 
> send.  However, the error output is pumped to the console.  How can I get 
> this error output into the variable??

Look in the perlop manpage for 'backtick', and you find the entry:

               Because backticks do not affect standard error,
               use shell file descriptor syntax (assuming the
               shell supports this) if you care to address this.
               To capture a command's STDERR and STDOUT together:
 
                   $output = `cmd 2>&1`; 

You ought to get in the habit of checking the docs first.  You'll save
time at the very least.  Better yet, you won't provoke Tad.

Steve
-- 
Steven Smolinski => http://www.steven.cx/


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

Date: Wed, 14 Mar 2001 21:28:12 -0500
From: Aaron Cline <acline@okstateREMOVECAPS.edu>
Subject: Re: Backtick program output question!
Message-Id: <hzWr6.265$Rx.2976@news.onenet.net>

Steven:

Thanks for the reply.  I will check the man pages next time.  They are just 
daugnting when you really don't know what you're looking for.

Thanks again.

Aaron

Steven Smolinski wrote:

> Aaron Cline <acline@okstateREMOVECAPS.edu> wrote:
>> $send=`/usr/local/dicom/bin/storescu -v -aet test -aec medweb
>> 192.168.0.97 104 [... long command line ...]
>> 
>> The only output from the program happens when the program errors.  From
>> what I understand, the output from the program would go into the scalar
>> send.  However, the error output is pumped to the console.  How can I get
>> this error output into the variable??
> 
> Look in the perlop manpage for 'backtick', and you find the entry:
> 
>                Because backticks do not affect standard error,
>                use shell file descriptor syntax (assuming the
>                shell supports this) if you care to address this.
>                To capture a command's STDERR and STDOUT together:
>  
>                    $output = `cmd 2>&1`;
> 
> You ought to get in the habit of checking the docs first.  You'll save
> time at the very least.  Better yet, you won't provoke Tad.
> 
> Steve



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

Date: Wed, 14 Mar 2001 22:38:00 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Data Dumper modules come standard??
Message-Id: <tb0hkqi3oq3g5e@corp.supernews.com>

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

--





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

Date: 15 Mar 2001 15:45:20 +1100
From: "Kiel Stirling " <taboo@comcen.com.au>
Subject: Re: Data Dumper modules come standard??
Message-Id: <3ab048e0@203.23.236.62>


"kellyboy" <kellyboy@nospanner> wrote:
>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??
>
Hi kellyboy

Looks like it try a test like 

#!/usr/bin/perl
use DataDumper;

now run it. if no error it's install.





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

Date: 14 Mar 2001 23:21:45 +0100
From: Claus Schotten <claus.schotten@epost.de>
Subject: Re: Formatting HTML using Perl
Message-Id: <m2elw0j8jq.fsf@olymp.filmstudio.rwth-aachen.de>

Nuet Lareton <phibeta@newsguy.com> writes:

> Hi! I'm somewhat new to perl and I'm a little lost on something I
> wanted to do. I want to format all the HTML documents in a folder the
> same way. 
> 
> In other words I want to strip out all of the text within the document
> so I can see just the tags formatted with a variable spacing like
> $space="  "; or $space="\t"; and that every time it finds a tag that
> doesn't match the one found /<([^>]*)>/ != $prevmatch then it would
> recursively go into a new subroutine and keep going until it matched
> up and so on and so forth till it matched HTML.

My (untested) sugestion:
  use HTML::TreeBuilder;

  my $tree = new HTML::TreeBuilder;
  $tree->ignore_text(1);  # to ommit the text between the tags
  $tree->parse_file(....);
  ...
  print $tree->as_html()

HTML::TreeBuilder and HTML::Element provide many methods to
manipulate and clean up the HTML tree.

If your aren't satisfied with the formating of the final HTML code, 
try HTML::PrettyPrinter

Ciao, Claus                               claus.schotten@epost.de



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

Date: Thu, 15 Mar 2001 02:28:15 GMT
From: garry@zvolve.com (Garry Williams)
Subject: Re: Getopt::Std question
Message-Id: <3NVr6.154$Ff3.6182@eagle.america.net>

On Mon, 12 Mar 2001 19:25:20 -0800, Brian McCann <bmccann@naisp.net> wrote:
>With Getop 
      ^
      ^
I think you mean getop() or getops() or Getopt::Std.  

>why is it that I don't have to explicitly declare $opt_a

If you use strict, and you seem to understand the value of doing so,
then you *do* have to declare $opt_a.  How did you get the idea that
you did not?  

>(is this
>variable built in to Perl?)

No.  

>but I have to declare $tag with my, I tried replacing $opt_a with $tag like
>this
>
>if ( defined( $tag ) ) {

How does that "replace" $opt_a with $tag?  I don't understand what you
mean here.  

>but the compiler complained that $tag needed to be declared,

Yes, if you use strict, *all* variables will need to be declared.[1]  

>it seems a round about way to get a value for $tag from the command line, by
>first assigning it to $opt_a,  then
>to assign $tag the value of $opt_a.

Huh?  

>The way I would like the script to run is, if I want a tagged build I'll
>pass the script getopt.plx the switch -t
>and the tag I want to build e.g. PCS-1-0-0-Build1, and if I don't want a
>tagged build just run the script without
>a switch ( something tells me though that I should have a switch for nightly
>build otherwise the script wont know
>where to start).

Huh?  

[snip] 

Ah, some code...

>use warnings;
>use strict;

Excellent start.  :-)  

>use Getopt::Std
                ^
Something tells me that you didn't copy/paste this code....

>Getopt::Std::getopts( 'a:');
>if ( defined( $opt_a ) ) {
>   print "-a flag set to $opt_a\n";
>   my $tag = $opt_a;
>   print "The value of tag is: $tag\n";
>
>}

This won't compile.  Even when I corrected the typo.  I'm not sure if
that is what you are talking about above.  

The manual page for Getopt::Std explains this: 

     Note that, if your code is running under the recommended
     `use strict 'vars'' pragma, you will need to declare these
     package variables with "our":

         our($opt_foo, $opt_bar);

Simply add `our $opt_a;' at the top of this fragment and correct the
typo and all will be well.  

Good luck.  

[1] Perl's special variables described in the perlvar manual page, $a,
$b (see the sort function in the perlfunc manual page) and barewords
used as file handles don't have to be declared.  

-- 
Garry Williams


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

Date: Thu, 15 Mar 2001 04:36:47 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: How to Print "system" failure ...was <Print own "die" message"
Message-Id: <3AB04750.C5B4788F@home.com>

Iain Chalmers wrote:
> 
> In article <3AB01C54.E1CB14C3@home.com>, "What A Man !"
> <whataman@home.com> wrote:
> 
> >So, I guess my error message is now coming out fine now by just using
> >"print", but then my "system" coding doesn't work. If the "system"
> >command fails, I want it to do everything in the print statement.
> >
> >Here's where I'm at...
> >
> >system("gtar -xzf $tmpfile -C $tmpdir 2>&1")
> >   or print
> >       "<body><!--#echo banner=''-->
> >       <font size=3><BR><BR></font>
> >       <font size=4 face=Verdana,Arial color=990033><BR><BR>
> >       <blockquote><STRONG>Sorry, but there is something wrong
> >       with that TAR file.</STRONG></blockquote></font></body>";
> >       rmdir $tmpdir; unlink $tmpfile; exit();
> >
> >As I stated, the "system("gtar)" line works by itself... but when I add
> >the print message all I get is the print message and it never works.
> >
> >I hope I explained it better this time. Is something wrong with my
> >syntax?
> 
> Whats the return value of system? (perldoc -f system)
Studied this and lipc too. I'm not sure how to find this out. I guess it
would be true, which is 1?
> 
> Whats does gtar return on success? 
Don't know how to find this out either?
> 
> So whats the boolean value of a successful "system("gtar -xzf $tmpfile -C
> $tmpdir 2>&1")"???
Boolean? What does that mean? I've seen that word relating to search
engines?
> 
> Now why are you "or"ing that with your error message?
Because I didn't want to use another conditional statement if I didn't
have to. I already have so many if/else/unless/while's that it's hard to
keep track of. 

Yes, I'm totally lost on this. I take it that changing from system to
backticks wouldn't be any easier, huh?

Thanks,
--Dennis


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

Date: Wed, 14 Mar 2001 19:45:08 -0600
From: "Al Spohn" <spohn@bigfoot.com>
Subject: Re: HTTP Client Question
Message-Id: <tb07l6i6c45o7c@corp.supernews.com>


Bob Dilworth <avast@hortonsbay.com> wrote in message
news:3aafa15d.12498754@news.mco.edu...
 ... stuff snipped...
> The above little worthless commentary from one of the members of the
> clpm Taliban indicates that you've violated on of their favorite
> "rules" - posting the answer to a message before the part of the
> message you're commenting on.  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.
>
> Bob D.

Thanks for the heads up, Bob.  How could I have possibly ever been so
careless?
I guess I should count myself lucky that they don't have capital punishment
in this
state.  But alas, to not have Abigail reading any more of my postings is a
fate worse
than death anyway.  Where can I turn now to get  my dose of unprovoked,
nasty cynicism?
Guess I'll have to settle for a fate of constructive feedback to my
questions, wretchedly
imperfect though they may be.

- Al




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

Date: 15 Mar 2001 04:03:02 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: HTTP Client Question
Message-Id: <slrn9b0fnm.r1e.dha@panix6.panix.com>

[jeapordectamy performed]

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

On Wed, 14 Mar 2001 16:04:38 -0600, Al Spohn <spohn@mayo.edu> wrote:
>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 :-).

Terrifying to consider that so many people think it a perfectly
acceptable thing to come into an established forum of a large group of
people and expect them to follow differnent rules just for him, when he
also expects them to put themselves out for him.

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
"It was failure proof technology"
"What happened?"
"It failed"			- Doctor Who, Frontios


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

Date: Thu, 15 Mar 2001 00:09:00 GMT
From: "lindaz" <lzcom.info@verizon.net>
Subject: I forgot the script (perl for a guestbook)
Message-Id: <wKTr6.2655$5c.242432@paloalto-snr1.gtei.net>

Sorry, I just post a question but forgot including the script, here it goes:

#!/usr/local/bin/perl

require "subparseform.lib";
&Parse_Form;

$name = $formdata{'name'};
$comment=$formdata{'comment'};
print "Content-type: text/html\n\n";
print "Thank you for your entry to my guest book $name";
print "Your comment was: $comment";



if ($ENV{'REQUEST_METHOD'} eq 'GET')

@pairs = split(/&/, $ENV{'QUERY_STRING'});
} elsif ($ENV{'REQUEST_METHOD'} eq 'POST')

read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/, $buffer);
} else

print "Content-type: text/html\n\n";
print "<P>Use Post or Get";
}
foreach $pair (@pairs)

($key, $value) = split (/=/, $pair);
$key =~ tr/+/ /;
$key =~ s/%(..)/pack("c",hex($1))/ge;
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;

$value =~s/<!--(.|\n)*-->//g;

if ($formdata{$key})

$formdata{$key} .= ", $value";
} else

$formdata{$key} = $value;
}


Here is the HTML:

<b>

Enter your name:<INPUT TYPE="text" NAME="name" SIZE="18"><br><br>

Enter your comments:<TEXTAREA NAME="comment" ROWS=6 COLS=40>

</TEXTAREA>

<form action="guestbook.cgi" method="post">

<INPUT TYPE="submit my comments"><INPUT TYPE="reset" value="reset message">











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

Date: Thu, 15 Mar 2001 10:50:17 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: I forgot the script (perl for a guestbook)
Message-Id: <cBUr6.5$Vd.1498@vic.nntp.telstra.net>

"lindaz" <lzcom.info@verizon.net> wrote in message
news:wKTr6.2655$5c.242432@paloalto-snr1.gtei.net...
> Sorry, I just post a question but forgot including the script, here it
goes:
>
> #!/usr/local/bin/perl
>
 require "subparseform.lib";

I suppose you have this lib somewhere...

> &Parse_Form;

Where is this subroutine?

> $name = $formdata{'name'};
> $comment=$formdata{'comment'};
> print "Content-type: text/html\n\n";

What about the rest of the html?

> print "Thank you for your entry to my guest book $name";
> print "Your comment was: $comment";

In the code below you are missing every single opening brace...

> if ($ENV{'REQUEST_METHOD'} eq 'GET')

if ($ENV{'REQUEST_METHOD'} eq 'GET') {

etc etc etc...

> @pairs = split(/&/, $ENV{'QUERY_STRING'});
> } elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
>
> read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/, $buffer);
> } else
>
> print "Content-type: text/html\n\n";
> print "<P>Use Post or Get";
> }
> foreach $pair (@pairs)
>
> ($key, $value) = split (/=/, $pair);
> $key =~ tr/+/ /;
> $key =~ s/%(..)/pack("c",hex($1))/ge;
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
>
> $value =~s/<!--(.|\n)*-->//g;
>
> if ($formdata{$key})
>
> $formdata{$key} .= ", $value";
> } else
>
> $formdata{$key} = $value;
> }
>
>
> Here is the HTML:

Either you didn't supply the full html, or your html is very incomplete.

> <b>
>
> Enter your name:<INPUT TYPE="text" NAME="name" SIZE="18"><br><br>
>
> Enter your comments:<TEXTAREA NAME="comment" ROWS=6 COLS=40>
>
> </TEXTAREA>
>
> <form action="guestbook.cgi" method="post">
>
> <INPUT TYPE="submit my comments"><INPUT TYPE="reset" value="reset
message">


Here is a simple way using CGI.pm which I think you will find not only
works, but is a lot easier.

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

use CGI;

my $query = new CGI;

my $name = $query->param('name');
my $comment=$query->param('comment');

print $query->header;

print $query->start_html('Thank you');
print $query->p("Thank you for your entry to my guest book $name");
print $query->p("Your comment was: $comment");
print $query->end_html;


Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass
it around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";








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

Date: 14 Mar 2001 21:22:36 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: I forgot the script (perl for a guestbook)
Message-Id: <m3k85r7our.fsf@mumonkan.sunstarsys.com>

"lindaz" <lzcom.info@verizon.net> writes:

> Sorry, I just post a question but forgot including the script, 
> here it goes:

Do yourself a favor and learn about CGI.pm- see

  % man CGI
 
Also avoid cgi-lib mode whenever possible; however it's
easiest to fix your program using it.

Your script also has basic syntax errors. See

  % man perlsyn
  % man perldiag

for some useful debugging self-help.

> #!/usr/local/bin/perl
  ^^^^^^^^^^^^^^^^^^^^^
#!/usr/local/bin/perl -wT
  use strict;

=pod 
> require "subparseform.lib";
> &Parse_Form;
=cut

  use CGI qw(:cgi-lib); # better to not use cgi-lib emulation at all

  my %formdata;
  ReadParse(\%formdata);

=pod
> $name = $formdata{'name'};
 ^
 my
> $comment=$formdata{'comment'};
 ^
 my

=head1 use CGI.pm and HERE-docs instead of this:

> print "Content-type: text/html\n\n";
> print "Thank you for your entry to my guest book $name";
> print "Your comment was: $comment";

=cut

  # ill-formed html
  print PrintHeader, <<"HTML";
Thank you for your entry to my guest book $formdata{name}
Your comment was: $formdata{comment}
HTML

  # dummy-down %formdata for some unknown reason
  foreach ( @formdata{keys %formdata} ) {
    next unless ref $_;
    $_ = join ", ", @{$_};
  }

=pod 

=head2 redundant, error-prone CGI parsing below

> if ($ENV{'REQUEST_METHOD'} eq 'GET')
                                        ^
                                        {
> 
> @pairs = split(/&/, $ENV{'QUERY_STRING'});
> } elsif ($ENV{'REQUEST_METHOD'} eq 'POST')
> 
> read (STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
 ^
die "read failed" unless $ENV{CONTENT_LENGTH} ==

> @pairs = split(/&/, $buffer);
> } else
         ^
         {
> 
> print "Content-type: text/html\n\n";
> print "<P>Use Post or Get";
> }
> foreach $pair (@pairs)
                         ^
                         {

=head2 use CGI.pm instead of this

> ($key, $value) = split (/=/, $pair);
> $key =~ tr/+/ /;
> $key =~ s/%(..)/pack("c",hex($1))/ge;
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> 
> $value =~s/<!--(.|\n)*-->//g;
 ^
 #
> 
> if ($formdata{$key})
                       ^
                       {
> 
> $formdata{$key} .= ", $value";
> } else
         ^
         {
> 
> $formdata{$key} = $value;
> }
> 

=for HTML 
> Here is the HTML:
> 
> <b>
> 
> Enter your name:<INPUT TYPE="text" NAME="name" SIZE="18"><br><br>
> 
> Enter your comments:<TEXTAREA NAME="comment" ROWS=6 COLS=40>
> 
> </TEXTAREA>
> 
> <form action="guestbook.cgi" method="post">
> 
> <INPUT TYPE="submit my comments">
              ^     
       "submit" value="

HTH
-- 
Joe Schaefer   All the rest of that day, on those wild screaming beaches, 
                    The Fix-it-Up Chappie kept fixing up Sneetches.
                                               -- Dr. Seuss



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

Date: Thu, 15 Mar 2001 08:36:30 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: Is there a shorter way for this?
Message-Id: <98p2nj$2uh@netnews.hinet.net>

"Bart Lateur" wrote:
> Note that thanks to the map() you can't use $_ for the matching string.

Doesn't matter.  It's "local"ized within map.

$_ = 'abc';
my @x = map {$_} 1..3;
print "$_ @x";

__END__
abc 1 2 3

John Lin





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

Date: Thu, 15 Mar 2001 02:02:50 +0100
From: Heather <hans-n-heather@fish.net>
Subject: Re: Maintaining the number format and not exponential
Message-Id: <150320010202506726%hans-n-heather@fish.net>

In article <yobofv45dap.fsf@panix3.panix.com>, dmeyers+news@panix.com
wrote:

> 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 

Ah! I did overlook that. I was starting to suspect that we were looking
at different versions of the thing. Thanks.

That still leaves the question, though, what particular claim Godzilla!
found to be inaccurate. And if she reads this: No, I'm not trying to be
confrontational, I'm just trying to understand.

Heather


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

Date: Wed, 14 Mar 2001 18:07:26 -0800
From: Kira <callgirl@la.znet.com>
Subject: Re: Maintaining the number format and not exponential
Message-Id: <3AB023DE.860F9C64@la.znet.com>

Heather wrote:
 
> dmeyers+news wrote:
> > Heather wrote:

(snipped)

> ...I'm just trying to understand.


You misspelled "troll."

Godzilla!


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

Date: Thu, 15 Mar 2001 03:40:20 +0100
From: Heather <hans-n-heather@fish.net>
Subject: Re: Maintaining the number format and not exponential
Message-Id: <150320010340208881%hans-n-heather@fish.net>

In article <3AB023DE.860F9C64@la.znet.com>, Kira <callgirl@la.znet.com>
wrote:

> Heather wrote:
> 
> > ...I'm just trying to understand.
> 
> You misspelled "troll."

If by trolling you mean "try to converse in as sober and inoffensive a
way as possible to get her to explain what she meant," then yes, guilty
as charged. I'm not interested in other people's animosities around
here, and I don't know how to be any more plain. 

Just looking for an answer to the simple question about what exactly
you found to be incorrect in the Math::BigInt documentation.

Heather


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

Date: Wed, 14 Mar 2001 21:52:31 -0500
From: "Collin Borrlewyn" <collin@crosslink.net>
Subject: Memory and Perl
Message-Id: <3ab02f49$0$16231@dingus.crosslink.net>

Perl appears to sort of auto-memory-manage, which is a good thing. On the
other hand, this puts me at a sort of a loss as to what to do in certain
instances. For example, what is the recourse I should take when I get "Out
of memory!"? This appears to happen when I have any given script exceed a
certain size. Obviously I am using too much memory (perhaps I am mistaken
here) but since perl handles memory automatically, I find it hard to figure
out where I might be able to be more efficient.

When it comes to that, what about efficiency? Is any particular sort of loop
inherently more efficient than another? There are many places where I could
interchange for and foreach without trouble, for example, but is one
better/more efficient? And, is there a memory-saving way to pass variables
between subroutines without simply creating duplicate local variables? In
short: How can I use less memory when writing my scripts?

All the perl docs that I've looked at have seemed to say about memory is
"use mod_perl", "you can't shrink a hash/array", and some stuff about
substr() and vec().

So, eh. Eh?



--

#Collin E Borrlewyn
##He'll get you through europe on ¢50 a day.
###collin@crosslink.net




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

Date: Wed, 14 Mar 2001 18:51:05 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Re: Perl FAQ?
Message-Id: <tb04b34mpo0885@corp.supernews.com>

Boy... I ve got two book on perl but still dont find what Im looking for...
I 've tried the Net and its hard to find the 'specific' answer because such
"info" im looking for on the Net is not really organized as I hoped...I
tried search engine such as yahoo and thier responds is really way off point
from the search word I used... so thats why I (in frustration) posted this
"faq" question cux I needed a short cut to answer  :-)


at least I tried....

thanks anyway,
kellyboy

--

"Uri Guttman" <uri@sysarch.com> wrote in message
news: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: Thu, 15 Mar 2001 03:39:46 GMT
From: trammell@bayazid.hypersloth.net (John Joseph Trammell)
Subject: Re: Perl FAQ?
Message-Id: <slrn9b0c2k.fg2.trammell@bayazid.hypersloth.net>

On Wed, 14 Mar 2001 18:51:05 -0600, kellyboy <kellyboy@nospanner> wrote:
> I 've tried the Net and its hard to find the 'specific' answer
> because such "info" im looking for on the Net is not really
> organized as I hoped...

If you have a specific Perl question, this is one good place to ask
it (provided you've made a decent effort to answer it yourself).

> I tried search engine such as yahoo and thier responds is really
> way off point from the search word I used

I don't believe you.  I typed in "perl faq" at the search prompt
on the main Yahoo! page, and it pointed me directly to ... the
Perl FAQ.  Google (www.google.com) does the same.

Luck,
J



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

Date: Wed, 14 Mar 2001 22:32:13 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Re: Perl FAQ?
Message-Id: <tb0h9oestqj271@corp.supernews.com>


>
> If you have a specific Perl question, this is one good place to ask
> it (provided you've made a decent effort to answer it yourself).
>
> > I tried search engine such as yahoo and thier responds is really
> > way off point from the search word I used
>
> I don't believe you.  I typed in "perl faq" at the search prompt
> on the main Yahoo! page, and it pointed me directly to ... the
> Perl FAQ.  Google (www.google.com) does the same.

true,,,but these faq that yahoo came up still doesn't have answer to my
question...  :-)

I've decided to build a list of useful links for Perl FAQ that are
potentially useful....

Ummm  ....Im thinking about building a web site  that list all the links to
Perl info on net but catagorized to make it easy for people to find specific
info under specific catagory....oh wait...someone beat me to that... never
mind that...



kellyboy







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

Date: Thu, 15 Mar 2001 00:07:16 GMT
From: "lindaz" <lzcom.info@verizon.net>
Subject: perl on a guestbook
Message-Id: <UITr6.2650$5c.241824@paloalto-snr1.gtei.net>

I wanted to create a guestbook for our website. The following is the script.
The problem is after I entered a name and comment, on cgi page, the name and
comments never popped up. I am frustrated now and don't know why it didn't
work. Can anyone help? Any tips and suggestions would be greatly
appreciated.

Linda




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

Date: Wed, 14 Mar 2001 20:20:20 -0500
From: "Ed Doyle" <doyleed@sprynet.com>
Subject: Perl Version Question
Message-Id: <98p5aq$cqf$1@slb1.atl.mindspring.net>

Hi,
I am the configuration manager on a project that has software developers at
several sites around the world.  Our makefiles are quite complex and utilize
a number of Perl Scripts.  One problem we have is Perl is not installed in
the exact same location at each site.  Each site independently upgrades (or
chooses not to upgrade when an upgrade come out).  Occasionally we get
burned where one site will modify or add a perl script such that it relies
on having a particular version or a particular Use  File::somefile that one
of the other sites does not have.

Let me use an example to illustrate my specific question.

Suppose I add a perl script that has a line

use File::Basename;

Is there something I can put in that script that queries whether the version
of perl being run at that site in fact supports use File::Baseline.

Failing that, is there some way I can find out manually what was the first
version of perl to support use File::Baseline;.

If there was, I could add a line checking if the version of perl was greater
then x where x was the first version to support use File::Baseline;

The above is an example, but if anyone can comment on my example and
problem, I would appreciate it.

Thanks

Ed
Please reply to expo04@email.mot.com and/or doyleed@sprynet.com




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

Date: Wed, 14 Mar 2001 23:25:49 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Print own "die" message
Message-Id: <3AAFFE76.7B20AB01@home.com>

Brad Baxter wrote:
> 
> 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

Thanks, Brad.. but I was hoping not to have to use another module. I'm
using 10 modules in the script already. Is there another way?
--Dennis(aka BuckNaked@webtv.net)


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

Date: Thu, 15 Mar 2001 01:33:17 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Print own "die" message
Message-Id: <3AB01C54.E1CB14C3@home.com>

So, I guess my error message is now coming out fine now by just using
"print", but then my "system" coding doesn't work. If the "system"
command fails, I want it to do everything in the print statement. 

Here's where I'm at...

system("gtar -xzf $tmpfile -C $tmpdir 2>&1")  
   or print 
       "<body><!--#echo banner=''-->
       <font size=3><BR><BR></font>
       <font size=4 face=Verdana,Arial color=990033><BR><BR>
       <blockquote><STRONG>Sorry, but there is something wrong     
       with that TAR file.</STRONG></blockquote></font></body>";
       rmdir $tmpdir; unlink $tmpfile; exit();
 
As I stated, the "system("gtar)" line works by itself... but when I add
the print message all I get is the print message and it never works.

I hope I explained it better this time. Is something wrong with my
syntax?

--Dennis


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

Date: Thu, 15 Mar 2001 13:16:46 +1100
From: bigiain@mightymedia.com.au (Iain Chalmers)
Subject: Re: Print own "die" message
Message-Id: <bigiain-1503011316460001@bigman.mighty.com.au>

In article <3AB01C54.E1CB14C3@home.com>, "What A Man !"
<whataman@home.com> wrote:

>So, I guess my error message is now coming out fine now by just using
>"print", but then my "system" coding doesn't work. If the "system"
>command fails, I want it to do everything in the print statement. 
>
>Here's where I'm at...
>
>system("gtar -xzf $tmpfile -C $tmpdir 2>&1")  
>   or print 
>       "<body><!--#echo banner=''-->
>       <font size=3><BR><BR></font>
>       <font size=4 face=Verdana,Arial color=990033><BR><BR>
>       <blockquote><STRONG>Sorry, but there is something wrong     
>       with that TAR file.</STRONG></blockquote></font></body>";
>       rmdir $tmpdir; unlink $tmpfile; exit();
> 
>As I stated, the "system("gtar)" line works by itself... but when I add
>the print message all I get is the print message and it never works.
>
>I hope I explained it better this time. Is something wrong with my
>syntax?

Whats the return value of system? (perldoc -f system)

Whats does gtar return on success?

So whats the boolean value of a successful "system("gtar -xzf $tmpfile -C
$tmpdir 2>&1")"???

Now why are you "or"ing that with your error message?

HTH

big


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

Date: Wed, 14 Mar 2001 23:48:16 GMT
From: Kim C <kimmfc@mydeja.com>
Subject: problem passing dir names to glob
Message-Id: <e000btsb1nq26lpl6l601v924th37lu5rs@4ax.com>

Hello,

I'm having trouble passing directory names containing spaces to the
'glob()' function using a variable.  For example:

@notes = glob ("$dir/*.log");

works file if '$dir' contains no spaces but returns nothing it
contains a space.

$dir = 'Log_Files';	## ok
$dir = 'Log Files';	## doesn't work

I understand that paramaters to 'glob()' are separated by a space and
the problem is that glob takes everything after the space to be a
parameter, so it returns all that match this paramater (nothing).

The documentation for File::DosGlob suggests double-quoteing or
escaping for strings, but makes no mention of how to do this with a
string contained in a variable.

I'm using Active State 5.6

Thanks in advance.

Kim



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

Date: Thu, 15 Mar 2001 15:19:00 +1300
From: "Peter Sundstrom" <peter.sundstrom-eds@eds.com>
Subject: Re: Unix trap command in Perl on Win?
Message-Id: <98p8r0$v28$1@hermes.nz.eds.com>


"David L. Heim" <dlheim@collins.rockwell.com> wrote in message
news:3AAF794D.BA15DF42@collins.rockwell.com...
> Is there a way to mimic the behavior of the Unix "trap" command in
> Perl on a windows platform?

<nitpick>
There is no Unix trap command, it's a shell builtin
</nitpick>

perldoc -q signal






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

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


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