[16229] in Perl-Users-Digest
Perl-Users Digest, Issue: 3641 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jul 12 18:11:08 2000
Date: Wed, 12 Jul 2000 15:10:34 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963439833-v9-i3641@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Wed, 12 Jul 2000 Volume: 9 Number: 3641
Today's topics:
Re: Beginner Question <bart.lateur@skynet.be>
Re: Beginner Question (Will England)
Re: Beginner Question <lr@hpl.hp.com>
Re: Beyond perl? Need advice... garthl@crosslink.net
Re: Beyond perl? Need advice... <emschwar@rmi.net>
Re: Beyond perl? Need advice... dejajason@my-deja.com
Re: Beyond perl? Need advice... dejajason@my-deja.com
Re: Bit shifting...should be exponentiation <bart.lateur@skynet.be>
Re: Bit shifting <bart.lateur@skynet.be>
Bug in Cookbook: default @_ argument list? <jboes@eoexchange.com>
Comparing Two Files Problem <kuzmin@hotmail.com>
Re: Creating an ordered HoH <mjcarman@home.com>
Re: Creating users using www CGI <kasper@hauge.com>
Re: Embedding Logo (images) in Email generated by Perl <bart.lateur@skynet.be>
Error from unsupported lookbehind <pensch@dal.asp.ti.com>
Re: Error from unsupported lookbehind <care227@attglobal.net>
Getting a list of keys.. <admin@overdoos.dhs.org>
Re: Getting a list of keys.. <care227@attglobal.net>
Re: Getting a list of keys.. <panderse@us.ibm.com>
good free guestbook scripts needed... <londoncrewNOloSPAM@e.raver.net.invalid>
Help - I can not figure out how to pass params to a scr <gary.fuller@mindspring.com>
Re: Help - I can not figure out how to pass params to a <tony_curtis32@yahoo.com>
Re: hohoh:how create & do I really need? <mjcarman@home.com>
Re: interacting perl w/ nt/dos <bart.lateur@skynet.be>
Re: Is there a way to make a perl script into an execut <nospam@nospam.com>
Looping(loop operator?) <JohnCasey_member@newsguy.com>
Re: Looping(loop operator?) <care227@attglobal.net>
Re: metrics <lauren_smith13@hotmail.com>
msgsnd/msgrcv problem timhood@bigfoot.com
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 12 Jul 2000 20:55:42 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Beginner Question
Message-Id: <defpmsc954d27au62aj0381bf8teb96amd@4ax.com>
Duncan Drury wrote:
>Am I right in thinking that $fred{$key} is completely different to $fred? I
>think it refers to the scalar variable referenced by $key in the hash %fred.
>Argh, but I can't tell if I am right or wrong!
Yes. $fred{$key} is the scalar entry in the hash %fred for $key,
@fred{$key1, $key2} is the list of two hash items, for $key1 and $key2
respectively. %fred is the whole hash.
Similarily, $fred[$number] is the scalar entry in the array for index
$number, and @fred[$number1, $number2] is the list of two scalar entrie,
for indices $number1 and $number2 respectively. @fred is the whole
array.
Somebody wrote: "$" is like an "S", for scalar, and "@" is like an "a",
for "array" (and, if you insist, "%" is a bit like an "H"). He could be
right. It indicates what kind of access you're trying to make, not
really what variable it is. That is what "{...}" and "[...]" are for.
--
Bart.
------------------------------
Date: Wed, 12 Jul 2000 19:38:10 GMT
From: will@mylanders.com (Will England)
Subject: Re: Beginner Question
Message-Id: <slrn8mpice.s8.will@mylanders.com>
On Wed, 12 Jul 2000 11:03:07 -0500, Tom Briles
<sariq@texas.net> wrote:
>Will England wrote:
>> perldoc perlvar will explain all of this as well.
>
>perlvar documents Perl's predefined variables.
>
>Make that:
>
>perldoc perldata
Whups. You are right. Teach me to post without checking.
Will
--
"If Al Gore invented the Internet, then I invented spellcheck!"
Dan Quayle, quoted at the National Press Club, 8/3/1999
pgpkey at http://will.mylanders.com/pub_pgp.asc
Recovery page: http://will.mylanders.com/ will@mylanders.com
------------------------------
Date: Wed, 12 Jul 2000 13:08:34 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Beginner Question
Message-Id: <MPG.13d6701f27c5d03098abc1@nntp.hpl.hp.com>
In article <396C9774.E819617A@attglobal.net> on Wed, 12 Jul 2000
12:06:12 -0400, Drew Simonis <care227@attglobal.net> says...
...
> So, to get at the value associated with the $key (a scalar variable),
> you use the notation $fred{key}. This returns you the value associated
> with $key. ...
Errr, no. This returns you the value associated with 'key'.
$fred{$key} returns you the value associated with $key.
Your brain knew that, but your fingers didn't.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: 12 Jul 2000 14:48:41 -0400
From: garthl@crosslink.net
Subject: Re: Beyond perl? Need advice...
Message-Id: <8kieia$t2c$1@poseidon.crosslink.net>
In article <8ki0ie$j8q$1@nnrp1.deja.com>, <dejajason@my-deja.com> wrote:
>Just code a quick bubble sort in both languages, and you'll see speed
>difference of 30 or more. It DOES NOT MATTER that a sort could be
>done more efficiently, since the only purpose was to compare basic
>engine speed and not the speed of library functions. You can use the
>same libraries in either case.
Given that a bubble sort implementation is:
(a) epsilon slower in Perl than C,
and
(b) is order of N**2,
then depending on the size of N, Perl really is 30 times slower than C
(for values of 30 between zero and infinity).
Wow, I think I'll go and stick 30 on my universal constant list, right
after e and pi.
garth
------------------------------
Date: 12 Jul 2000 13:18:52 -0600
From: Eric The Read <emschwar@rmi.net>
Subject: Re: Beyond perl? Need advice...
Message-Id: <xkflmz7jgwz.fsf@valdemar.cos.agilent.com>
dejajason@my-deja.com writes:
> Just code a quick bubble sort in both languages, and you'll see speed
> difference of 30 or more.
I just did that very thing. I used the exact same algorithm in both
programs; the only difference was C vs. Perl. Both programs loaded an
array with 10,000 random elements, and then bubblesorted that array. I
ran both programs once first to make sure they were in the disk cache,
then ran them with 'time'. The results:
$ time /tmp/bbsort
real 27.1
user 25.8
sys 0.1
$ time /tmp/bbsort.pl
real 10.5
user 8.7
sys 0.5
So the difference was not 30; it was more like a factor of 3, and in
favour of the Perl implementation. I should note for the benefit of the
peanut gallery, that this is a very old version of perl (5.004), on a
fairly old HP-UX box (712/100MHz, running 10.20). Presumably modern
Perls could optimize better.
Wow, I think my sigmonster's psychic. Good sigmonster! Have a biccie!
-=Eric
--
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
# US govt says this is a munition. See http://www.dcs.ex.ac.uk/~aba/rsa
------------------------------
Date: Wed, 12 Jul 2000 21:18:15 GMT
From: dejajason@my-deja.com
Subject: Re: Beyond perl? Need advice...
Message-Id: <8kinab$5ff$1@nnrp1.deja.com>
In article <xkflmz7jgwz.fsf@valdemar.cos.agilent.com>,
Eric The Read <emschwar@rmi.net> wrote:
> dejajason@my-deja.com writes:
> > Just code a quick bubble sort in both languages, and you'll see
speed
> > difference of 30 or more.
>
> I just did that very thing. I used the exact same algorithm in both
> programs; the only difference was C vs. Perl. Both programs loaded an
> array with 10,000 random elements, and then bubblesorted that array.
I
> ran both programs once first to make sure they were in the disk cache,
> then ran them with 'time'. The results:
>
> $ time /tmp/bbsort
>
> real 27.1
> user 25.8
> sys 0.1
>
> $ time /tmp/bbsort.pl
>
> real 10.5
> user 8.7
> sys 0.5
>
> So the difference was not 30; it was more like a factor of 3, and in
> favour of the Perl implementation. I should note for the benefit of
the
> peanut gallery, that this is a very old version of perl (5.004), on a
> fairly old HP-UX box (712/100MHz, running 10.20). Presumably modern
> Perls could optimize better.
>
> Wow, I think my sigmonster's psychic. Good sigmonster! Have a
biccie!
Well the results from the C program look right, but I think something
isn't right with the perl. Here's my results on a Sun S20 which is a bit
slower than that HP. Perl 5.005_03 and gcc 2.29.2.
/usr/bin/time ./csort
real 37.5
user 35.2
sys 0.0
/usr/bin/time ./perlsort.pl
real 19:03.1
user 18:39.5
sys 0.0
Oddly enough, the differance is larger with 1000 elements but that could
be due to startup penalty. I didn't have enough patients to try more
than 10,000.
And the code:
#!/usr/local/bin/perl -w
$arraysize=10000;
for ($i=0;$i<$arraysize;$i++) {
$array[$i]=rand(100);
}
for( $i=0 ; $i < $arraysize-1 ; $i++) {
for( $j= $i+1 ; $j<$arraysize ; $j++ ) {
if ($array[$i]>$array[$j]) {
$k=$array[$i];
$array[$i]=$array[$j];
$array[$j]=$k;
}
}
}
exit(0);
#include <stdio.h>
#include <stdlib.h>
#define ARRAYSIZE 10000
int main(int argc, char *argv[]) {
int i,j;
double k, array[ARRAYSIZE];
for(i=0;i<ARRAYSIZE;i++)
array[i]=drand48()*100;
for(i=0;i<ARRAYSIZE-1;i++)
for(j=i+1; j<ARRAYSIZE; j++)
if (array[i]>array[j]) {
k=array[i];
array[i]=array[j];
array[j]=k;
}
exit(0);
}
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 12 Jul 2000 21:19:50 GMT
From: dejajason@my-deja.com
Subject: Re: Beyond perl? Need advice...
Message-Id: <8kinda$5fu$1@nnrp1.deja.com>
In article <8kieia$t2c$1@poseidon.crosslink.net>,
garthl@crosslink.net wrote:
> In article <8ki0ie$j8q$1@nnrp1.deja.com>, <dejajason@my-deja.com>
wrote:
> >Just code a quick bubble sort in both languages, and you'll see speed
> >difference of 30 or more. It DOES NOT MATTER that a sort could be
> >done more efficiently, since the only purpose was to compare basic
> >engine speed and not the speed of library functions. You can use the
> >same libraries in either case.
>
> Given that a bubble sort implementation is:
>
> (a) epsilon slower in Perl than C,
> and
> (b) is order of N**2,
>
> then depending on the size of N, Perl really is 30 times slower than C
> (for values of 30 between zero and infinity).
>
> Wow, I think I'll go and stick 30 on my universal constant list, right
> after e and pi.
Practical average. Didn't think programmers like pure math. :)
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Wed, 12 Jul 2000 21:21:44 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bit shifting...should be exponentiation
Message-Id: <u7hpms4pedoqcnug4v68jfhd4vqb86j9oq@4ax.com>
Steffen Beyer wrote:
> (a mod p) * (b mod p) == (a * b) mod p
Wrong. Take a=b=16, and p=256, for example.
--
Bart.
------------------------------
Date: Wed, 12 Jul 2000 20:50:38 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Bit shifting
Message-Id: <ancpms8qdnfghjjofakcpnog0plbiftitr@4ax.com>
Simon Armstrong wrote:
> $bytevalue = $i & 256; #constrain to byte?
No, it's ($i & 255). Or use ($i % 256), if you like.
But I agree with Steffen Beyer: this number as a floating point number
is much too big to have any significant lower bits, because all bits
can't possibly fit into any kind of integer.
If this is the direct translation of the code in C/C++, I have doubts
about it's validity there, too.
>Any ideas how I can perform this shifting and just get the low-order byte?
You'd have to calculate the powers all by yourself, and throw away any
bits higher than bit 7 on the intermediate result, because ($n*256)**$k
is a multiple of 256, for any integer $n and $k; i.e. lower 8 bits all
zero.
This is some rough code that works this way:
my $c = 83;
my $k = 96;
my @factors = factors($k); # (2, 2, 2, 2, 2, 3)
foreach(@factors) {
$c **= $_;
$c &= 255;
}
print $c;
sub factors {
my $n = shift;
my @factors;
my $i = 2;
while($n > 1) {
while(($n % $i)==0) {
push @factors, $i;
$n /= $i;
}
if($i==2) {
$i = 3;
} else {
$i += 2;
}
}
return @factors;
}
This prints 129. I'm not sure if this is indeed the correct answer.
There's only one way to find out.
use Math::BigInt;
my $c = new Math::BigInt(83);
print +($c**96)%256;
-->
+129
Yup. The same.
My guess: you must have misunderstood the algorithm from the original
code.
--
Bart.
------------------------------
Date: Wed, 12 Jul 2000 16:43:24 -0400
From: Jeff Boes <jboes@eoexchange.com>
Subject: Bug in Cookbook: default @_ argument list?
Message-Id: <396cd9f8$0$1507$44a10c7e@news.net-link.net>
I'm using a Perl snippet from the Perl Cookbook that is supposed to
return a truth value about whether an argument is numeric. This is under
perl 5.005_03. The snippet takes advantage of @_ being passed from one
routine to another implicitly.
# The following are from the Perl Cookbook, p. 45:
sub getnum {
use POSIX qw(strtod);
my $str = shift;
$str =~ s/^\s+//;
$str =~ s/\s+$//;
$! = 0;
my($num, $unparsed) = strtod($str);
if (($str eq '') || ($unparsed != 0) || $!) {
return undef;
} else {
return $num;
}
}
sub is_numeric { defined scalar &getnum }
When I invoke this as
... unless(is_numeric($foo)) {...} ...
it behaves as though getnum is never called. If I change the second
routine to
sub is_numeric { defined(scalar(&getnum(@_))) }
then all is well. What gives?
--
Jeff Boes |Computer science is no more about
|jboes@eoexchange.com
Sr. S/W Engineer |computers than astronomy is about |616-381-9889 ext
18
Change Technology|telescopes. --E. W. Dijkstra |616-381-4823 fax
EoExchange, Inc. |
|www.eoexchange.com
------------------------------
Date: Wed, 12 Jul 2000 12:45:03 -0800
From: "Oleg Kuzmin" <kuzmin@hotmail.com>
Subject: Comparing Two Files Problem
Message-Id: <smpm12b7nd6126@corp.supernews.com>
Greetings!
I'm trying to write my pretty much first Perl script, and it doesn't work
the way I want it to.
Here is a beginning - very simple, opening "old" file to be compared with
the "new" one. The results of comparison will go to the "result" file.
"New" and "old" files are huge ASCII files, ranging from 146M to 1.7G in
size.
----------------------------------------
use Getopt::Long;
# Set up the command line to accept a filename.
my $ret = GetOptions ("o|input:s", "n|output:s", "r|result:s");
my $old = $opt_o || die "Usage: $0 -o Old filename -n New filename -r
Results filename\n";
my $new = $opt_n || die "Usage: $0 -o Old filename -n New filename -r
Results filename\n";
my $result = $opt_r || die "Usage: $0 -o Old filename -n New filename -r
Results filename\n";
# Open the new file.
open (NEW, "$new") || die "Could not open file $new : $!\n";
# Open the output file.
open (OLD, "$old") || die "Could not open file $output : $!\n";
# Open the results file.
open (RESULT, ">$result") || die "Could not open file $result : $!\n";
----------------------------------------
What needs to be done is the following:
1. Read a line from the "old" file.
2. See if this line exists in the "new" file.
3. If it does, then go to the next line in the "old" file. If it doesn't,
write the line into the "result" file, then go to the next line in the "old"
file.
In other words, if we have "old" file with the words 'one', 'two', 'three'
on separate lines and "new" file with the words 'one', 'two', then "result"
file should contain 'three' after the script is done working.
Would it be wise to assign the contents of "new" to one variable considering
enormous file size? The statement [my @temp = <NEW>;] will result in a 1.7G
variable; can Perl handle it?
Thanks,
Oleg
------------------------------
Date: Wed, 12 Jul 2000 14:07:47 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: Creating an ordered HoH
Message-Id: <396CC203.72CE8E5E@home.com>
Lauren Smith wrote:
>
> Hashes are used for storage and naturally unordered. What does it
> buy you to know the internal representation of your data?
Normally nothing, but I have a situation where the order of keys is
important. I create a HoHoL and later on I need to process it in the
same order that it was created in.
Update: tie %{$hash}{key}}, "Tie::IxHash"
does appear to preserve order. I had been experimenting in the debugger
and it did NOT do so there (using 'x %hash' to view). Printing via
Data::Dumper didn't seem to work either, but when I manually step
through things it does seem to behave properly. Any reason why the
debugger and Data::Dumper should behave this way?
-mjc
------------------------------
Date: Wed, 12 Jul 2000 21:20:38 +0200
From: Kasper Hauge <kasper@hauge.com>
Subject: Re: Creating users using www CGI
Message-Id: <396CC506.FFADF846@hauge.com>
Hi
I would like to now that to !!
kasper@hauge.com
Landim wrote:
> Hi all...
>
> I want to know how to create popusers on my linux server
> using a perl CGI.
>
> What is the command?
>
> Like in hotmail, when you enter with the username and
> password...
>
> landim2@brhs.com.br
>
> Thanks...
>
> * Sent from AltaVista http://www.altavista.com Where you can also find related Web Pages, Images, Audios, Videos, News, and Shopping. Smart is Beautiful
------------------------------
Date: Wed, 12 Jul 2000 20:50:43 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Embedding Logo (images) in Email generated by Perl Script
Message-Id: <fvepmsko905rapdqr2c6ii9g66s18d3qtg@4ax.com>
t0873 wrote:
>I have email system written in Perl which generates text messages using
>Text Template and sends out email. If I want to embed a logo or any gif
>in these message , how do I do that. I do not want to attach the GIF
>file.
>When the user/customer recieves email, it should have logo/gif images
>in the body of the email message.
Er... sorry. Attachments, sometimes of the "inline" variety, are the
ONLY way to include images in an e-mail.
And no, I don't like to receive that kind of e-mail, either.
--
Bart.
------------------------------
Date: Wed, 12 Jul 2000 16:13:49 -0500
From: Peter Ensch <pensch@dal.asp.ti.com>
Subject: Error from unsupported lookbehind
Message-Id: <396CDF8D.9279990F@dal.asp.ti.com>
I want to use the positive lookbehind construct
(?<=PATTERN) as in:
@array = split /(?<=>)\s+/, $_;
(split on one+ white spaces preceded by a '>')
Unfortunately this doesn't appear to be supported
in my version of perl - 5.005.
What I don't understand is that when I compile a
script with this code I get this error:
Sequence (?<...) not recognized at parse_switches.pl line 30
but when I run it, I get no errors.
My problem is that I want to put the routine containing
this code into a CGI script - which is not so
forgiving. Anyone know how I can hide this error
from the CGI environment?
Peter
--
***********************************************
Peter Ensch,
pensch@dal.asp.ti.com A-1140 (214) 480 2333
***********************************************
------------------------------
Date: Wed, 12 Jul 2000 17:21:33 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Error from unsupported lookbehind
Message-Id: <396CE15D.AB1DDF9B@attglobal.net>
Peter Ensch wrote:
>
> I want to use the positive lookbehind construct
> (?<=PATTERN) as in:
The what?!?!?
Is this new in 5.6?
------------------------------
Date: Wed, 12 Jul 2000 18:49:04 GMT
From: "Gmo" <admin@overdoos.dhs.org>
Subject: Getting a list of keys..
Message-Id: <A43b5.129119$xe3.939294@nlnews00.chello.com>
Hi
Im trying to get a list of keys from the $FORM in this piece of pretty
stardard code..
i know the @FIELDNAMES = keys %$FORM command but that didnt seem to work ..
here is the code for memory refreshment reasons.. Can someone help me??
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
foreach $pair (@pairs)
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/\n/ /g; # added to strip line breaks
$FORM{$name} = $value;
}
------------------------------
Date: Wed, 12 Jul 2000 15:08:29 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Getting a list of keys..
Message-Id: <396CC22D.D10B6066@attglobal.net>
Gmo wrote:
>
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> foreach $pair (@pairs)
>
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/\n/ /g; # added to strip line breaks
> $FORM{$name} = $value;
> }
Throw out this cargo cult crap and use one of the CGI modules.
You be glad you did.
------------------------------
Date: Wed, 12 Jul 2000 14:48:21 -0500
From: "Paul R. Andersen" <panderse@us.ibm.com>
Subject: Re: Getting a list of keys..
Message-Id: <396CCB85.42140305@us.ibm.com>
Gmo wrote:
>
> Hi
>
> Im trying to get a list of keys from the $FORM in this piece of pretty
> stardard code..
> i know the @FIELDNAMES = keys %$FORM command but that didnt seem to work ..
> here is the code for memory refreshment reasons.. Can someone help me??
>
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> foreach $pair (@pairs)
>
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/\n/ /g; # added to strip line breaks
> $FORM{$name} = $value;
> }
Have you tried:
@FIELDNAMES = keys %FORM;
Eliminate the dollar sign?
--
Paul Andersen
+++++++++++++
The difference between theory and practice is that in theory there is no
difference between theory and practice; but in practice there is.
------------------------------
Date: Wed, 12 Jul 2000 13:40:35 -0700
From: kie <londoncrewNOloSPAM@e.raver.net.invalid>
Subject: good free guestbook scripts needed...
Message-Id: <2084d650.d30dba88@usw-ex0103-086.remarq.com>
i need good but simple to install guestbook and form to email
scripts. both must look like they have not been given for free
(no banner ads, company names) and must be available for
modification (fonts, images, etc)
any ideas???
-----------------------------------------------------------
Got questions? Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.com
------------------------------
Date: Wed, 12 Jul 2000 13:07:09 -0700
From: "Gary Fuller" <gary.fuller@mindspring.com>
Subject: Help - I can not figure out how to pass params to a script
Message-Id: <8kij2o$qmr$1@slb7.atl.mindspring.net>
Ok, I'm stuck - please forgive this idiot who just can't get it...
I want to pass to a perl script the name of a file set, the current page
number and the last page number to generate html code for a navigation
panel.
Example:
Page 3 of 5
<- Prev Next ->
1 2 3 4 5
The current page is bolded, the other pages a hyperlink. If it is the first
page, it drops the <- Prev, last Next ->
I, for the life of me, can not seem to get how you pass information to the
perl script. I assumed it was just a ? with your options (ex test.pl?ca.3.5
would be ca_ file set, page 3 of 5) and just use the $ENV('QUERY_STRING')
but I get either an Option Not Found or 500 Server error.
Please, could someone show me the error of my ways?
Thank you,
Gary Fuller
editor@ocbtracker.com
(code follows)
#!/usr/bin/perl
$current_page = 3;
$last_page = 5;
$file_set = "ca";
$counter = 1;
$temp = 1;
$delta = "_";
$alpha = ".html";
print("Content-type: text/html\n\n");
print "Page $current_page of $last_page <br>\n";
if ($current_page >= 2) {
$prev_page = $current_page - 1;
print "<a href=\"$file_set$delta$prev_page$alpha\"><- PREV</a> ";
};
if ($current_page < $last_page) {
$next_page = $current_page + 1;
print "<a href=\"$file_set$delta$next_page$alpha\">NEXT -></a>";
};
print "<br>\n";
while ($counter <= $last_page) { if ($counter == $current_page ) { print
" <b>$current_page</b> "; $counter =
$counter + 1;} else {
print "<a
href=\"$file_set$delta$counter$alpha\">$counter</a> "; $counter =
$counter + 1;};
};
------------------------------
Date: 12 Jul 2000 15:10:05 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Help - I can not figure out how to pass params to a script
Message-Id: <87d7kjaz4y.fsf@limey.hpcc.uh.edu>
>> On Wed, 12 Jul 2000 13:07:09 -0700,
>> "Gary Fuller" <gary.fuller@mindspring.com> said:
> Ok, I'm stuck - please forgive this idiot who just can't
> get it... I want to pass to a perl script the name of a
> file set, the current page number and the last page
> number to generate html code for a navigation panel.
> Example:
> Page 3 of 5 <- Prev Next -> 1 2 3 4 5
> The current page is bolded, the other pages a hyperlink.
> If it is the first page, it drops the <- Prev, last Next
> ->
> I, for the life of me, can not seem to get how you pass
> information to the perl script. I assumed it was just a
> ? with your options (ex test.pl?ca.3.5 would be ca_ file
> set, page 3 of 5) and just use the $ENV('QUERY_STRING')
> but I get either an Option Not Found or 500 Server
> error.
Use the CGI module:
With a query_string like
script?page=4&lastpage=10&set=ca
you'd then just parse like:
use CGI ':standard';
my $page = param('page'); # 4
my $set = param('set'); # "ca"
etc.
"perldoc CGI" for enlightenment.
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Wed, 12 Jul 2000 12:29:18 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: hohoh:how create & do I really need?
Message-Id: <396CAAEE.59E316B0@home.com>
ollie_spencer@my-deja.com wrote:
>
> I have data that I am trying to read into an hohoh,
> [...]
>
> I earlier assumed the line:
> $TestData{$Wafer}{$ChipCoord}{$TestName=>$TestValue}
> actually created the hohoh,
Not quite, try this instead:
$TestData{$Wafer}{$ChipCoord}{$TestName} = $TestValue;
> Please post to this forum or e-mail me: ollie.spencer@lmco.com
Do people often do otherwise? Call you at home? Snail mail?
(Sorry, couldn't resist.)
You seem to be having some problems with references. => is the 'comma
arrow' while -> is a dereference... completely different creatures.
Reading 'perldoc perldsc' will help you out here. You may also want to
take a look at 'perldoc perlref' and 'perldoc perlreftut' as well.
-mjc
------------------------------
Date: Wed, 12 Jul 2000 20:50:40 +0200
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: interacting perl w/ nt/dos
Message-Id: <v3epms88iok413v1ihit5js508ij6ripdk@4ax.com>
Young H Lee wrote:
>system ("some_command > something.txt");
>
>
>how could I access something.txt without using the open command in perl?
Try
$output = `some_command`;
--
Bart.
------------------------------
Date: 12 Jul 2000 20:33:59 GMT
From: The WebDragon <nospam@nospam.com>
Subject: Re: Is there a way to make a perl script into an executable?
Message-Id: <8kiknn$6b7$c@216.155.32.201>
In article <FE4313E01B8C1248.4F6007A9C244F90E.0FAEED0AF65F2359@lp.airnews.net>,
nnickee@nnickee.com wrote:
| On Tue, 11 Jul 2000 21:44:23 -0400, someone claiming to be Drew
| Simonis <care227@attglobal.net> said:
|
| >> He probably just knew that you have way more time on your hands than he
| >> does :)
|
| >I get paid to read Usenet. I can't help it. =)
|
| Ok Drew, you suck. <g>
| I only get paid to irc.
Gah! you both suck! :D
--
send mail to mactech (at) webdragon (dot) net instead of the above address.
this is to prevent spamming. e-mail reply-to's have been altered
to prevent scan software from extracting my address for the purpose
of spamming me, which I hate with a passion bordering on obsession.
------------------------------
Date: 12 Jul 2000 12:36:59 -0700
From: JohnCasey <JohnCasey_member@newsguy.com>
Subject: Looping(loop operator?)
Message-Id: <8kihcr$1phn@drn.newsguy.com>
Problem is in the below program , how do i get back to the While loop
from the innermost if loop (based on its result) ??
*****
While (<FILEHANDLE>)
{
if (/ABCD/)
{
if ( ! /ZABCD/ )
{
$value = xyz (based on regex on the above pattern);
if ( $value == somecondition)
{
*** exit and go back to the While loop ***?????? how???
}
}
statements;
statements;
}
}
*********************
I tried two options and both seem to be working fine:
1) I stuck in a "loop" command after the if ($value == somecondition)
and it seems to work fine!! . But, is there anything like
a "loop" command in perl at all!!!? the manuals point to next,
last commands..
2) I tried the perl variant of 'goto" , basically by
attaching a label before the "while" eg: WLOOP while ...
and giving a next WLOOP in the if statement. This too seems
to work fine. (gives the same result as 1).
I am just trying to make sure whether the above options are correct or not.
If there is a better way to do it, please share.
Thanks
John
------------------------------
Date: Wed, 12 Jul 2000 16:39:10 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Looping(loop operator?)
Message-Id: <396CD76E.66100D7B@attglobal.net>
JohnCasey wrote:
>
> Problem is in the below program , how do i get back to the While loop
> from the innermost if loop (based on its result) ??
> *****
> While (<FILEHANDLE>)
> {
> if (/ABCD/)
> {
> if ( ! /ZABCD/ )
> {
> $value = xyz (based on regex on the above pattern);
> if ( $value == somecondition)
> {
> *** exit and go back to the While loop ***?????? how???
> }
> }
>
> statements;
> statements;
> }
> }
Check out the last function. Like: last if $value == somecondition;
Note that this will break you out of that nested if(). If you want to
break all the way back, I'd suggest labeling the block, and specifying
the label in the last condition.
http://www.perl.com/pub/doc/manual/html/pod/perlfunc/last.html
Also check out Perlfaq7 at:
http://www.perl.com/pub/doc/manual/html/pod/perlfaq7.html
under the heading:
"How do I create a switch or case statement?"
HTH
------------------------------
Date: Wed, 12 Jul 2000 13:23:30 -0700
From: "Lauren Smith" <lauren_smith13@hotmail.com>
Subject: Re: metrics
Message-Id: <8kik5d$26g$1@brokaw.wa.com>
Nadim Khemir <nkh@cpen.com> wrote in message
news:396cadaa.0@d2o68.telia.com...
> Can someone point me to some metric scripts ?
Sorry dude, here in America we use the English system, not the metric
system. Try an international search engine.
www.google.com
www.yahoo.com
www.altavista.com
Lauren
------------------------------
Date: Wed, 12 Jul 2000 19:01:28 GMT
From: timhood@bigfoot.com
Subject: msgsnd/msgrcv problem
Message-Id: <8kif9s$veu$1@nnrp1.deja.com>
I am trying to pass messages between processes using msgsnd and msgrcv.
In one particular case, I wish to use the type value to designate a
unique type so that only one particular client will listen for and
respond to the message. The problem seems to be that msgrcv blocks
indefinitely whenever type is not zero. Anyone have any ideas? Is this a
bug?
Details: perl 5.6.0 on Digital Unix 4.0
code snippet:
our $msg_id = msgget(200, 0666);
if (defined $msg_id)
{
msgrcv($msg_id, $msg_text, $msg_size, $PID, 0);
}
Here I'm using the client's PID at the message type to receive. This is
being sent using either:
if (msgsnd($id, pack("L a*", $type, $sent), 0)) # or
if (msgsnd($id, $sent, 0))
{
print "Cool, the message was sent to queue $id.\n";
}
The message is sent to the queue and the queue shows there are bytes
waiting to be received, yet msgrcv won't pick up the message unless I
use type 0 (which is to listen for all message types).
Hopefully, someone can point me in the right direction here.
Tim
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 3641
**************************************