[23108] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5329 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 7 14:06:11 2003

Date: Thu, 7 Aug 2003 11:05:10 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 7 Aug 2003     Volume: 10 Number: 5329

Today's topics:
    Re: Can't use "open my" with pipe <asu1@c-o-r-n-e-l-l.edu>
    Re: CGI.pm and foreach (Tad McClellan)
    Re: CGI.pm and foreach <tzz@lifelogs.com>
        Checkbox into an Array ? (Sylvie Stone)
    Re: Checkbox into an Array ? ctcgag@hotmail.com
    Re: Checkbox into an Array ? <usenet@dwall.fastmail.fm>
    Re: Checkbox into an Array ? (Tad McClellan)
    Re: Checking number of instances running <tzz@lifelogs.com>
    Re: Getting hostnames from remote servers.... <mothra@mothra.com>
        How do you simulate "." or "source" in a perl script ? (Chris Marshall)
    Re: How do you simulate "." or "source" in a perl scrip <john.thetenant-s@moving-picture.com>
    Re: logging <perseus_medusa@hotmail.com>
    Re: logging <tzz@lifelogs.com>
    Re: nested HTML parsing <tzz@lifelogs.com>
    Re: Net-Whois-IP-0.35 returning incorrect responses? (Peter Scott)
    Re: Out of memory when reading big file (more question) <blackhole@userstudy.com>
        Output to (X)HTML <ellem52@mac.com>
    Re: Output to (X)HTML <cpryce@pryce.nospam.net>
    Re: Renaming Files inside a GZ Zip File (hymie!)
    Re: Replace a word if its not in an html tag (Tad McClellan)
    Re: Replace a word if its not in an html tag <jaspax@u.washington.edu>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Aug 2003 13:41:47 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Can't use "open my" with pipe
Message-Id: <Xns93D062A3BA5C4asu1cornelledu@132.236.56.8>

jain@gmx.net (Eric) wrote in news:835c2e5d.0308070457.76803137
@posting.google.com:

> This works:
> 
>   open SOURCE 'gunzip -c test.rdf.gz|' or die $!;
>   my $source = \*SOURCE;
> 
> This doesn't ("No such file or directory"):

It does work. Tells you that the file you specified does not exist.
 
>   open my $source, '<', 'gunzip -c test.rdf.gz|' or die $!;
> 
> Can latter syntax be made to work, if modified?
> 
> (Rationale: Fits into one line...)

open(my $source, '-|', 'gunzip -c test.rdf.gz') or die $!;
while(<$source>) {
	print;
}

or

open(my $source, 'gunzip -c test.rdf.gz|') or die $!;
while(<$source>) {
	print;
}

perldoc -f open

Sinan.
-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Thu, 7 Aug 2003 09:10:38 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: CGI.pm and foreach
Message-Id: <slrnbj4neu.3qk.tadmc@magna.augustmail.com>

W K <hyagillot@tesco.net> wrote:

> Also, we used to have a manager type 


How did he wear his hair?


> who used to ask how many lines of code
> we had written today.


But that isn't all bad...

 ... it allowed Scott Adams to become rich and famous.  :-)



Here, set yourself up for a promotion (so you can eventually
change hairstyles too):

   # code here
   ;
   ;
   ;
   ;
   ;
   ;
   ;
   ;
   ;
   # more code here


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


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

Date: Thu, 07 Aug 2003 12:42:43 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: CGI.pm and foreach
Message-Id: <4nr83xzaf0.fsf@lockgroove.bwh.harvard.edu>

On Thu, 7 Aug 2003, tadmc@augustmail.com wrote:
> Here, set yourself up for a promotion (so you can eventually
> change hairstyles too):
> 
>    # code here
>    ;
>    ;
>    ;
>    ;
>    ;
>    ;
>    ;
>    ;
>    ;
>    # more code here

Then run it through Acme::Buffy :)

Ted


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

Date: 7 Aug 2003 06:16:44 -0700
From: sylviestone@canada.com (Sylvie Stone)
Subject: Checkbox into an Array ?
Message-Id: <181a24a8.0308070516.6e12bc8d@posting.google.com>

Hi group - I have an html form where users can query the database
based on a bunch of criteria but I'm having trouble capturing all the
checked checkboxes to build the select statement. In php I would just
use implode.

I've been trying to use 'join' but to no avail. 
The checkbox options are generated dynamically:

$dbh->prepare("select id,name from statuslookup where inactive is NULL
order by id");
$sth->execute();
my $ref_allrows = $sth->fetchall_arrayref;
my $i;
for $i (0 .. $#{$ref_allrows}) {
 print "<input type=checkbox name=\"statuscodearray[]\"
value=\"$ref_allrows->[$i][0]\">$ref_allrows->[$i][0]
$ref_allrows->[$i][1]";
}

Then to process the form onsubmit:

<snip>

 my @statuscodearray;
 my $statuscode = join(" ", @statuscodearray);

<snip>

  if (length($statuscode) > 0) {
    $build_query = "$build_query and statuslink = '$statuscode'";
  }


The array will hold integers like this:
select blah from blahblah where statuslink in ('1', '44', '55', '77')
 .... ;

THANK YOU ! This is driving me crazy!

Sylvie.


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

Date: 07 Aug 2003 14:51:16 GMT
From: ctcgag@hotmail.com
Subject: Re: Checkbox into an Array ?
Message-Id: <20030807105116.423$Vv@newsreader.com>

sylviestone@canada.com (Sylvie Stone) wrote:
> Hi group - I have an html form where users can query the database
> based on a bunch of criteria but I'm having trouble capturing all the
> checked checkboxes to build the select statement. In php I would just
> use implode.
>
> I've been trying to use 'join' but to no avail.
> The checkbox options are generated dynamically:
>
> $dbh->prepare("select id,name from statuslookup where inactive is NULL
> order by id");
> $sth->execute();
> my $ref_allrows = $sth->fetchall_arrayref;
> my $i;
> for $i (0 .. $#{$ref_allrows}) {
>  print "<input type=checkbox name=\"statuscodearray[]\"
> value=\"$ref_allrows->[$i][0]\">$ref_allrows->[$i][0]
> $ref_allrows->[$i][1]";
> }

Is it legal to have [] in the name of a form element?


>
> Then to process the form onsubmit:

Yes, you need to process the form on submit!


> <snip>
>
>  my @statuscodearray;
>  my $statuscode = join(" ", @statuscodearray);

Shouldn't you try to fill @statuscodearray with the form
results before you use it?  Something like
@statuscodearray=$q->params('statuscodearray[]');
>
> <snip>
>
>   if (length($statuscode) > 0) {
>     $build_query = "$build_query and statuslink = '$statuscode'";
>   }
>
> The array will hold integers like this:
> select blah from blahblah where statuslink in ('1', '44', '55', '77')
> .... ;
>
> THANK YOU ! This is driving me crazy!

$build_query.= "and statuslink in (" .
      join (',', map "'$_'", @statuscodearray) . ")";


Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: Thu, 07 Aug 2003 15:17:46 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: Checkbox into an Array ?
Message-Id: <Xns93D072E94FDBEdkwwashere@216.168.3.30>

 <ctcgag@hotmail.com> wrote:

> sylviestone@canada.com (Sylvie Stone) wrote:
>> The checkbox options are generated dynamically:
>>
>> $dbh->prepare("select id,name from statuslookup where inactive is
>> NULL order by id");
>> $sth->execute();
>> my $ref_allrows = $sth->fetchall_arrayref;
>> my $i;
>> for $i (0 .. $#{$ref_allrows}) {
>>  print "<input type=checkbox name=\"statuscodearray[]\"
>> value=\"$ref_allrows->[$i][0]\">$ref_allrows->[$i][0]
>> $ref_allrows->[$i][1]";
>> }
> 
> Is it legal to have [] in the name of a form element?

No. See http://www.w3.org/TR/html4/types.html#type-cdata -- which of 
course has nothing to do with Perl.

In any case, the loop could be written more Perlishly:

[untested code]

    for my $row (@$ref_allrows) {
        print qq{<input type=checkbox 
            name="statuscode" 
            value="$row->[0]">$row->[0]$row->[1]};
    }

Using some of the CGI.pm shortcuts might be better, depending on 
taste. <shrug>

-- 
David Wall


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

Date: Thu, 7 Aug 2003 10:20:14 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Checkbox into an Array ?
Message-Id: <slrnbj4rhe.3qk.tadmc@magna.augustmail.com>

Sylvie Stone <sylviestone@canada.com> wrote:

> my $i;


$i is now a global variable, it does not need to be global since
you use it only inside of the loop.


> for $i (0 .. $#{$ref_allrows}) {
>  print "<input type=checkbox name=\"statuscodearray[]\"
> value=\"$ref_allrows->[$i][0]\">$ref_allrows->[$i][0]
> $ref_allrows->[$i][1]";
> }


You could declare $i in the foreach statement.

   for my $i (0 .. $#{$ref_allrows}) {

You do not need explicit indexing at all, so you don't even need $i.

You can use alternate delimiters to avoid the backslashing.

   # untested
   foreach my $row ( @$ref_allrows ) {
      print '<input type=checkbox name="statuscodearray[]"',
          qq(value="$row->[0]">$row->[0]$row->[1]);
   }


>  my @statuscodearray;
>  my $statuscode = join(" ", @statuscodearray);


@statuscodearray *must* contain the empty list at this point...


>   if (length($statuscode) > 0) {


 ... so that condition will never be true.

Don't you want to put something into the array before join()ing it?


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


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

Date: Thu, 07 Aug 2003 12:37:42 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: Checking number of instances running
Message-Id: <4nvft9zand.fsf@lockgroove.bwh.harvard.edu>

On Thu, 7 Aug 2003, Rene.Scheibe@Stud.TU-Ilmenau.de wrote:
> ...what do you think about checking the number
> of scripts (with a specific name) running by:
> 
> my $processname = 'script.pl';
> my @log = split /\n+/, `ps ax`;
> my $count = 0;
> foreach (@log)
> {
>   chomp;
>   if (/$processname/)
>   {
>     $count++;
>   }
> }
> 
> Or is there a better solution?

I prefer Proc::ProcessTable for process analysis.  It's simpler,
less error-prone, and much more platform-independent.  Your example
above, for instance, does not work on a Solaris system.

Ted


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

Date: Thu, 07 Aug 2003 13:07:12 GMT
From: Mothra <mothra@mothra.com>
Subject: Re: Getting hostnames from remote servers....
Message-Id: <pan.2003.08.07.13.07.09.375774@mothra.com>

On Thu, 07 Aug 2003 13:43:53 +0000, Garry Short wrote:

> Mothra wrote:
> 
> <SNIP>
> 
>> I can't remember whether I eventually used IO::Pipe, IO::File, the dreaded
>> backticks or stuck with system(), but I've tried all of these recently and
>> every time, instead of the value of hostname, all I get is the exit status
>> of the command (i.e. '0') in my hash table where the hostname should be.
>> 
>> Can anyone help?
> 
> You *may* need to assign the output of the backticks to an array, since
> you're running multiple commands (don't know if any of them will return any
> codes to the calling script).
> <SNIP> 
> then $returns[-1] should have the hostname you're after.
> 
Thanks - will give it a go.


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

Date: 7 Aug 2003 08:21:27 -0700
From: c_j_marshall@hotmail.com (Chris Marshall)
Subject: How do you simulate "." or "source" in a perl script ?
Message-Id: <cb9c7b76.0308070721.2f4cd3f5@posting.google.com>

Is there a good way of simulating the bourne shell's "." command - or
csh's "source" command inside a perl script ?

Specifically I would like to set environment variables inside a perl
script which are stored inside a separate config file (used by many
other programs)

At the moment I have a separate ksh script wrapper around my perl
script which simply does something like

 #!/bin/ksh

 . /dir/config.sh

 /dir/perlscript.pl

but there's got to be a better way than that.

Unfortunately neither "." nor "source" are particularly easy things to
search for and I've not spotted anything in either perldoc nor
googling this newsgroup.

I guess I could have the perl script read the config file explicitly
and act upon what it finds there - but someone must have tackled this
already.

Thanks
Chris


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

Date: Thu, 7 Aug 2003 16:47:30 +0100
From: John Strauss <john.thetenant-s@moving-picture.com>
Subject: Re: How do you simulate "." or "source" in a perl script ?
Message-Id: <20030807164730.1db960ca.john.thetenant-s@moving-picture.com>

On 7 Aug 2003 08:21:27 -0700
c_j_marshall@hotmail.com (Chris Marshall) wrote:
>
> Is there a good way of simulating the bourne shell's "." command - or
> csh's "source" command inside a perl script ?
> 
> Specifically I would like to set environment variables inside a perl
> script which are stored inside a separate config file (used by many
> other programs)
> 
> At the moment I have a separate ksh script wrapper around my perl
> script which simply does something like
> 
>  #!/bin/ksh
> 
>  . /dir/config.sh
> 
>  /dir/perlscript.pl
> 
> but there's got to be a better way than that.
> 
> Unfortunately neither "." nor "source" are particularly easy things to
> search for and I've not spotted anything in either perldoc nor
> googling this newsgroup.
> 
> I guess I could have the perl script read the config file explicitly
> and act upon what it finds there - but someone must have tackled this
> already.
> 
> Thanks
> Chris

Shell::Source
perhaps this CPAN module will do it for you.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drop the .thetenant to get me via mail


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

Date: Thu, 7 Aug 2003 21:23:06 +0800
From: "j" <perseus_medusa@hotmail.com>
Subject: Re: logging
Message-Id: <3f32512f$1@newsgate.hknet.com>

Some of the features that I can think of is :

1) easily support multithreading or concurrent client usage.
2) different level of logging and can be configured via a config file that
should not have significant impact on performance.
3) Logfile management.

Thanks.




"Mothra" <mothra@mothra.com> wrote in message
news:pan.2003.08.07.12.22.15.143780@mothra.com...
> On Thu, 07 Aug 2003 19:28:58 +0800, j wrote:
>
> > Hi all ,
> >
> >     what's the common module that's used for logging ? i have looked
> >     into
> > log4perl. But seems that not quite mature and doesn't support
> > multithreading. Anyone has some idea ?
> >
> Normally I stick an error-handling subroutine in my code that appends
> warnings and errors to one or more logfiles and then use Logfile::Rotate
> to compress and rotate them.  I take it you want to do something more than
> this - can you be more specific?




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

Date: Thu, 07 Aug 2003 12:32:27 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: logging
Message-Id: <4nznilzaw4.fsf@lockgroove.bwh.harvard.edu>

On Thu, 7 Aug 2003, perseus_medusa@hotmail.com wrote:
> Some of the features that I can think of is :
> 
> 1) easily support multithreading or concurrent client usage.  

> 2) different level of logging and can be configured via a config
> file that should not have significant impact on performance.  

> 3) Logfile management.

Does syslog satisfy your needs?  In addition to the above, you can
also send the output to a remote host.

Ted


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

Date: Thu, 07 Aug 2003 12:48:36 -0400
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: nested HTML parsing
Message-Id: <4nn0elza57.fsf@lockgroove.bwh.harvard.edu>

On Thu, 7 Aug 2003, ixanthi@ixanthi.remove.gr wrote:
> I am using HTML::Parser to parse an html file with my own tags [my
> own templating system actually]. The problem is that I want to be
> able to do the following
> 
> <thtml type="if" condition="<thtml type='cgiparam' name='xxx'
> nextparam='<thtml type="internal" parm1="aaa" parm2="bb">'>"
> name="4th">
> 
> As you can see the condition has in it an other tag with signle
> quotes which in the nextparam has an other tag with double quotes
> and I would like to have that as much as I want. If I write
> 
> <thtml type="if" condition="<thtml type='cgiparam' name='xxx'
> nextparam='<thtml type=internal parm1=aaa parm2=bb>'>" name="4th">
> 
> where the internal - internal tag has no quotes i managed to parse
> it. The problem should be that it will recognize the first double
> quote of the inner most tag as the ending quote of the condition
> parameter.
> 
> Any idea how I can overcome this ?

You could use Parse::RecDescent to parse your own tagging system, then
pass the parsed, processed, and valid HTML to HTML::Parser.  As others
have pointed out, you can't expect a HTML parser to parse
intentionally invalid HTML.

Ted


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

Date: Thu, 07 Aug 2003 14:45:03 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Net-Whois-IP-0.35 returning incorrect responses?
Message-Id: <PBtYa.679048$Vi5.15964706@news1.calgary.shaw.ca>

In article <slrnbj2sal.4o7v.syl@alcor.concordia.ca>,
 Sylvain Robitaille <syl@alcor.concordia.ca> writes:
>I'm trying to write a Perl script which will (among other things) look
>up the Whois information, based on an IP address it encounters, but the
>responses I'm getting from Net-Whois-IP-0.35 are not what I'm expecting,
>(though I suppose they're technically correct).
>
>Please consider the following test case:
[snip program; can be replaced by
perl -MData::Dumper -MNet::Whois::IP=whoisip_query  \
-e 'print Dumper whoisip_query("132.205.7.51")'
]

>Now I run the test program:
>src/whois_test.pl
[snip result for NET-132-0-0-0-0]

>However, if I run whois (whois-4.5.29) at the command line, to look up
>the same IP address, I get the following response (which is what I
>expect to see):
[snip result for  NET-132-205-0-0-1]

First let me thank you for posing a perfectly formed question; all the
information needed (most of which I cut out :-) and a clear question.

I ran this under the debugger and found that the problem is a bug in
Net::Whois::IP.  It thinks that if the result does not include a
TechPhone or an OrgTechPhone attribute then it should try a whois
query for the parent handle.  This is at odds with its documentation
which says it keeps going until it gets an OrgName or CustName.  I
have submitted a bug report.  (The NET-132-0-0-0-0 result doesn't
have a *TechPhone attribute either, but its Parent is blank, so the
module gives up there.)

>Does anyone know how to get Net::Whois::IP to send back the response I'm
>expecting, or should I simply call my command-line whois from the script
>I'm writing?  (it would of course be much cleaner to use a Perl module
>for this ...)

Unless and until the module is improved, you'll need to make a copy of
it to go somewhere earlier in your @INC and modify it.  I suggest you
look for the line

	        }elsif(/Parent:\s+(\S+)/) {

and on the next (long) line, change TechPhone to NetName and change
OrgTechPhone to OrgName.

-- 
Peter Scott
http://www.perldebugged.com


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

Date: Thu, 07 Aug 2003 10:42:29 -0400
From: Shawn O'Donnell <blackhole@userstudy.com>
Subject: Re: Out of memory when reading big file (more question)
Message-Id: <blackhole-77DD7F.10422907082003@news-50.giganews.com>

In article <3f31d7f2$1@nexus.comcen.com.au>,
 "Jason M" <frosty@yoyo.cc.monash.edu.au> wrote:

> Size of file being read: 1,809,891 KB ASCII text file.
> Record length: 1913 chars.

2GB file with ~1 million lines?

> 	while (<DATA>){
>     <snip>
>  }

Do you know how many times you're looping here?  Try adding a print on 
entry and/or exit.  If you're really looping, and you don't want to 
waste too many pixels on the printout, 

print "reassuring message #" . $count/1000 . "\n" if $count % 1000 == 0; 


Do your script and the data file agree on end-of-line delimeters? If 
not, you'd be slurping the whole file at once.  That would use up your 
memory.


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

Date: Thu, 07 Aug 2003 11:33:33 -0400
From: Lou Moran <ellem52@mac.com>
Subject: Output to (X)HTML
Message-Id: <02s4jvsgopt0bv5k4d3th5o8p8p95n6ok3@4ax.com>

Using this code:

#! /usr/local/bin/perl
use diagnostics ;
use warnings ;
use strict ;
use List::Util qw (sum) ;		#not in the standard distro

my $roll = 6 ;

until ($roll == 0) {			#rolls the dice 6 times  
    $roll -- ;
    
    my @d61 = int(rand(5) + 2) ;	#6 sided die with no 1
    my @d62 = int(rand(5) + 2) ;
    my @d63 = int(rand(5) + 2) ;
    my @d64 = int(rand(5) + 2) ;
    
    my @all = sort 				#split line for looks
    { $b <=> $a } @d61, @d62, @d63, @d64 ;	#sorts rolls 
						#to prepare for
    pop @all ;					#pop removing 
    						#the lowest roll
    my $sum = sum(@all) ;				#before adding
    
    print "\n@all - $sum\n" ; 
}

__END__

I would like to have the print output an HTML page.  I assume I will
need to use the (a) CGI module but I am quite fuzzy on which one and
if it would be as easy as calling the Module and referencing @all and
$sum

--
Mac OS X: Because it was easier to make UNIX user friendly than fix Windows.


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

Date: Thu, 07 Aug 2003 11:55:07 -0500
From: cp <cpryce@pryce.nospam.net>
Subject: Re: Output to (X)HTML
Message-Id: <070820031155070611%cpryce@pryce.nospam.net>

In article <02s4jvsgopt0bv5k4d3th5o8p8p95n6ok3@4ax.com>, Lou Moran
<ellem52@mac.com> wrote:

> Using this code:
> 
[ snip code ]
> 
> I would like to have the print output an HTML page.  I assume I will
> need to use the (a) CGI module but I am quite fuzzy on which one and
> if it would be as easy as calling the Module and referencing @all and
> $sum

It is that easy, provided you send the right information first. print
invoked without a filehandle prints to standard optput (STDOUT).
Invoked from a command line, that's the terminal window. Invoked from a
Web server, that's the Web browser window. 

A browser needs a set of headers to tell it what type of content to
send first. See various FAQs on the subject. I'd start with:
http://www.boutell.com/newfaq/creating.html

http://cvs.sourceforge.net/cgi-bin/viewcvs.cgi/*checkout*/brian-d-foy/CG
I_MetaFAQ/CGI_MetaFAQ.html?rev=HEAD&content-type=text/html

( Fix the line wrapping before you try that) 
or the docs for CGI.pm ( perldoc CGI) : 
 http://stein.cshl.org/WWW/software/CGI/cgi_docs.html

To get you started you might try this code: 

#!/usr/bin/perl

use warnings;
use strict; 

use List::Util qw(sum); 
use CGI qw(:standard); 

sub roll_dice { 
    my (  $sides, $mod, $times ) = @_; 
    my @results; 
    
    while ( $times ) { # when $times == 0 this loop stops
        push @results, ( int( rand( $sides ) + $mod ) ); 
        $times --; 
    } 
    return wantarray? @results : \@results; 
} 

# call the dice rolling sub routine with the sides, a mod, and 
# the number of times to roll them. Since roll_dice returns a
# list, we can sort it and store it in an array directly.

my @roll = sort{ $a <=> $b } roll_dice( 5, 2, 6 ); 
pop @roll;

# Functions from the CGI.pm module
print header(), start_html(), 
    p( "Die Rolls: ", join( ", ", @roll) ), 
    p( "Sum: ", sum( @roll ) ), # sums the array and prints it
    start_form(), 
        submit(-name=>'choice', -value=>'roll again'), 
   end_form(),
   end_html(); 
   
exit 0;


There is also a module for dice. search CPAN for Games::Die::Dice 
 
> --
> Mac OS X: Because it was easier to make UNIX user friendly than fix Windows.

Isn't that true :)

-- 
cp


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

Date: Thu, 07 Aug 2003 13:46:14 -0000
From: hymie@lactose.smart.net (hymie!)
Subject: Re: Renaming Files inside a GZ Zip File
Message-Id: <vj4m16g10buo3c@corp.supernews.com>

In our last episode, the evil Dr. Lacto had captured our hero,
  "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de>, who said:

>"hymie!" <hymie@lactose.smart.net> wrote...

>> The only place the filename is stored is in the filename.
>
>Nope! The original filename is stored in the file (unless you use gzip
>-n). You can retrieve the file with the original filename name using the
>-N (or --name) switch.

Thanks for the info.  I hang my head in shame.

hymie!          http://www.smart.net/~hymowitz          hymie@lactose.smart.net
===============================================================================


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

Date: Thu, 7 Aug 2003 09:13:43 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Replace a word if its not in an html tag
Message-Id: <slrnbj4nkn.3qk.tadmc@magna.augustmail.com>

Jürgen Exner <jurgenex@hotmail.com> wrote:
> Tim wrote:
>> What would the regular expression be to replace the word "body" in an
>> html document as long as it's not in between < and > so it doesn't
>> replace the actual body tag or anything else with body?
> 
> Question: in
>     <tag>body</tag>
> is the text "body" between < and > or not?


Even more troubling, are these ones?

   <!-- body -->

   <!-- <body> NOT a body tag! -->


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


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

Date: Thu, 7 Aug 2003 08:17:39 -0700
From: JS Bangs <jaspax@u.washington.edu>
Subject: Re: Replace a word if its not in an html tag
Message-Id: <Pine.A41.4.56.0308070806280.98544@dante18.u.washington.edu>

Tad McClellan sikyal:

> JS Bangs <jaspax@u.washington.edu> wrote:
> > Chesucat sikyal:
> >> On 6 Aug 2003, Tim asked:
> >>
> >> > What would the regular expression be to replace the word "body" in an
> >> > html document as long as it's not in between < and > so it doesn't
> >> > replace the actual body tag or anything else with body?
>
> > Better would be
>
>
> to give up on trying to do it with a pattern match.

Agreed.

> > s/([^<|<\/])\bbody\b/$1/g
>      ^^^^^^^^
>
> This does not do what you think it does, it is exactly equivalent to:
>
>
>     s/([^\/|<])\bbody\b/$1/g
> and
>     s/([^<\/|])\bbody\b/$1/g
> and
>     s/([^|\/<])\bbody\b/$1/g
>
> the order of characters in a character class does not matter,
> neither does repeating a character.

You're correct. How *does* one assert a negative group of multiple
characters?

> > which appears to do what you want.
>
>
> It does not appear that way to me.
>
>    <img src="body">  becomes  <img src="">  with your code
>
> We were supposed to leave it alone when it was inside of a tag.
>
>    <p>See body.doc</p>   becomes   <p>See .doc</p>
>
> It is not clear what we were supposed to do in that case. Poor spec.

Indeed. When the OP said "Don't replace 'body' inside a tag", I DWIMmed
that to mean "Don't replace the <body></body> elements". If he truly does
not want to replace 'body' inside a tag, then a regexp is definitely out
of the question.

> JS Bangs should re-read too, it would appear.  :-)
>
> Along with this Perl FAQ:
>
>    How do I remove HTML from a string?

That certainly does trip me up :).

--
Jesse S. Bangs jaspax@u.washington.edu
http://students.washington.edu/jaspax/
http://students.washington.edu/jaspax/blog

Jesus asked them, "Who do you say that I am?"

And they answered, "You are the eschatological manifestation of the ground
of our being, the kerygma in which we find the ultimate meaning of our
interpersonal relationship."

And Jesus said, "What?"


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.  

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


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