[10613] in Perl-Users-Digest
Perl-Users Digest, Issue: 4205 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Nov 12 13:07:14 1998
Date: Thu, 12 Nov 98 10:00:19 -0800
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, 12 Nov 1998 Volume: 8 Number: 4205
Today's topics:
Re: Comparing Arrays -- infinite loop? <stevenjm@olywa.net>
environment variables <zab@mail.vt.edu>
expect with perl <michaelr@lndn.tensor.pgs.com>
External call to sh with a Pipe (EXCHANGE:MTL:6Z04)
Re: External call to sh with a Pipe <dean_darlison@dial.pipex.com>
Re: External call to sh with a Pipe (Sam Holden)
HELP! Concat'ing multiple variables into one <dlincoln@ultrainteractive.com>
Re: HELP! Concat'ing multiple variables into one (brian d foy)
Re: Hiding source code from priving eyes <tchrist@mox.perl.com>
Re: Hiding source code from priving eyes <sgordon@kenan.com>
Re: How do I sort this list by "port" number? (Greg Bacon)
Re: How do I sort this list by "port" number? (Greg Bacon)
Install Errors: 5.005_02 on Solaris 2.6 system jimrsmith@unn.unisys.com
Re: Modification of a read-only?? <r28629@email.sps.mot.com>
Re: Modification of a read-only?? <r28629@email.sps.mot.com>
Re: percentages <dixonmat@pouch.com>
Re: percentages (Bart Lateur)
Perl ODBC control <geoff@newinteractive.com>
Re: Perl question: Arrays in Hash??? <r28629@email.sps.mot.com>
Re: Perl question: Arrays in Hash??? dave@mag-sol.com
perl script -> msdos/win31 executable? (Michael Maxim)
Re: Q: are symbolic refs really needed (was Re: Modific <uri@sysarch.com>
Re: Q: are symbolic refs really needed (was Re: Modific <merlyn@stonehenge.com>
retrieving and archiving mail <bob.donovan@sdrc.com>
Searching and Parsing text from HTML file <coop1x33@nortel.com>
The Perl Institute? dave@mag-sol.com
Using Win32::Registry.pm keydet89@yahoo.com
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 12 Nov 1998 08:59:26 -0800
From: Steven May <stevenjm@olywa.net>
Subject: Re: Comparing Arrays -- infinite loop?
Message-Id: <364B13EE.AC4BDCB@olywa.net>
Oliver
while(@list){} should ALWAYS be approached with a bit of caution.
Ask yourself "when will @list no longer return true?". In the loop you
have below, it's always 'true' and so the loop will spin endlessly....
The while(@list) block needs to do something to reduce list to 0 in
order for the while to terminate automatically.
Usually, a foreach loop is a better choice for iterating through a list,
but if you must use while, you might consider setting a counter to force
an exit if things go wrong.
while(@list){
do_work;
$ct++;
$ct > 100000 and print "While loop max count exceeded\n" and last;
}
HTH,
Steve
Oliver Moffat wrote:
>
> I'm trying to write a Perl script to automate the updating of a flat text
> file database. I'm trying to compare the new database of titles to the old
> databse of titles and get a list of "Brand New Titles."
>
> Everything goes fine up untill the following chunk of code where the
> actual comparison is supposed to happen. When the script gets to this
> point it gets stuck and just spins its wheels. Is there an infinite loop
> here? Is there a more efficient way to do this?
>
> while (@new_titles)
> {
> $i = shift (@new_titles); # grab the title on the top
>
> $j = 0;
>
> foreach $k (@old_titles) # compare the new title to each
> of the old titles
> {
> if ($i eq $k) # untill we find a match
> {
> splice (@old_titles, $j, 1); # remove the matched title from
> the old titles list
> last; # so we don't check
> it again and stop looking
> }
> elsif ($#old_titles < 1) # but if we're at the end of
> the list of old titles
> { # then we found a
> brand new title
> push (@brand_new_titles, $i); # so we push it onto brand_new_titles
> }
> else # if we don't find a
> match
> {
> $j++; # increment the
> counter and keap looking
> }
> }
> }
------------------------------
Date: Thu, 12 Nov 1998 10:36:27 -0400
From: Bill <zab@mail.vt.edu>
Subject: environment variables
Message-Id: <364AF1FF.4B5FC2EF@mail.vt.edu>
Does anyone have a little snippet of code that returns the address of
the referring page?
ie www.domain.com/directory/folder/default.html
to return
www.domain.com/directory/folder/
??
I realize that one could use the HTTP_REFERER, but I have no idea how to
disect the string returned....
Bill
------------------------------
Date: Thu, 12 Nov 1998 15:43:16 +0000
From: Michael Renshaw <michaelr@lndn.tensor.pgs.com>
Subject: expect with perl
Message-Id: <364B0214.4223@lndn.tensor.pgs.com>
does anyone know the pitfalls of doing a telnet followd by an ftp
in perls expect module. I can do them both interactively but
my script times out after submitting the ftp and never gets
the "Name (host:myname): " prompt. I wondered if it was something
to do with the output not going back to my screen like we
normally solve in UNIX with setenv DISPLAY type syntax.
anybody got any ideas ??
Mike
------------------------------
Date: Thu, 12 Nov 1998 09:54:15 -0500
From: "Mikus, Francois (EXCHANGE:MTL:6Z04)" <fmikus@americasm01.nt.com>
Subject: External call to sh with a Pipe
Message-Id: <364AF697.55691014@americasm01.nt.com>
<perl..>
$array[0] = "cuthere_bla";
$cutvar = `echo $array[0] | cut -c1-7`; # The quotes are back quotes :-)
<perl ..>
The error message is:
sh[2]: Syntax error at line 2 : `|' is not expected.
Is there a way to keep only the first n caracters of a variable using
perl. (To replace the " cut -c1-7 ") Any help would be appreciated.
And also, why does the shell not like my pipe?
Thanks
Kilian
fmikus@ nortel.ca
I
------------------------------
Date: Thu, 12 Nov 1998 15:23:25 +0000
From: Dean Darlison <dean_darlison@dial.pipex.com>
Subject: Re: External call to sh with a Pipe
Message-Id: <364AFD6C.735E7A54@dial.pipex.com>
"Mikus, Francois (EXCHANGE:MTL:6Z04)" wrote:Is there a way to keep only the
first n caracters of a variable using
> perl. (To replace the " cut -c1-7 ") Any help would be appreciated.
> And also, why does the shell not like my pipe?
>
I believe what you want is 'substr'.
I think you should read the manuals and then faqs before posting again.
Cheers,
Dean.
--
Dean.A.Darlison
Dasco Ltd.
------------------------------
Date: 12 Nov 1998 15:23:06 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: External call to sh with a Pipe
Message-Id: <slrn74lvaq.du7.sholden@pgrad.cs.usyd.edu.au>
On Thu, 12 Nov 1998 09:54:15 -0500, Mikus, Francois
<fmikus@americasm01.nt.com> wrote:
><perl..>
>
>$array[0] = "cuthere_bla";
>$cutvar = `echo $array[0] | cut -c1-7`; # The quotes are back quotes :-)
>
><perl ..>
>
>The error message is:
>sh[2]: Syntax error at line 2 : `|' is not expected.
Works fine for me.
>
>Is there a way to keep only the first n caracters of a variable using
>perl. (To replace the " cut -c1-7 ") Any help would be appreciated.
>And also, why does the shell not like my pipe?
There are many wyas (this is perl after all).
substr
/^(.......)/
etc,etc...
--
Sam
Simple rule: include files should never include include files.
--Rob Pike
------------------------------
Date: Thu, 12 Nov 1998 12:31:18 -0500
From: "D. Davis" <dlincoln@ultrainteractive.com>
Subject: HELP! Concat'ing multiple variables into one
Message-Id: <364B1B66.1DCDE8BA@ultrainteractive.com>
Help! I'm working on a menu driven search engine with fixed parameters held
in menus. The menus (3 of them) are fine and pass variables individually, but
I can't figure out how to compound all 3 variables into one single variable
(for keywords). I'm sure I'm missing something simple... will one of these work?
The things I've tried:
# Put variables into an array... then make array row = single variable
# Then make array text = to single variable.
#
$searchterm[0] = ($input{'level'});
$searchterm[1] = ($input{'topic'});
$searchterm[2] = ($input{'subject'});
$search_terms = "@searchterm";
$search_terms = $searchterm[0].$searchterm[1].$searchterm[2];
# Make seperate variables... then insert variables into an array...
# Then make array text = to single variable.
#
$level = ($input{'level'});
$topic = ($input{'topic'});
$subject = ($input{'subject'});
@search_keys = ("$level", "$topic", "$subject");
$search_terms = "@search_keys";
# Make seperate variables... then try to concatentate variables w/ .=
# as in:
# $new_row .= "$day\|$month\|$year\|$session_username\|";
$level = ($input{'level'});
$topic = ($input{'topic'});
$subject = ($input{'subject'});
$search_terms .= "$level\ $topic\ $subject";
------------------------------
Date: Thu, 12 Nov 1998 13:05:11 -0500
From: comdog@computerdog.com (brian d foy)
Subject: Re: HELP! Concat'ing multiple variables into one
Message-Id: <comdog-ya02408000R1211981305110001@news.panix.com>
In article <364B1B66.1DCDE8BA@ultrainteractive.com>, dlincoln@ultrainteractive.com posted:
> The things I've tried:
>
> # Put variables into an array... then make array row = single variable
> # Then make array text = to single variable.
> #
> $searchterm[0] = ($input{'level'});
> $searchterm[1] = ($input{'topic'});
> $searchterm[2] = ($input{'subject'});
>
> $search_terms = "@searchterm";
> $search_terms = $searchterm[0].$searchterm[1].$searchterm[2];
how about skipping the array?
$search_terms = "$input{'level'}$input{'topic'}$input{'subject'}";
if you need something between them, just put it between them:
$search_terms = "$input{'level'} $input{'topic'} $input{'subject'}";
or
$search_terms = "$input{'level'},$input{'topic'},$input{'subject'}";
and so on.
--
brian d foy <comdog@computerdog.com>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: 12 Nov 1998 13:30:09 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Hiding source code from priving eyes
Message-Id: <72ent1$qjc$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, Jan Bessels <j.bessels@wolverine.demon.nl> writes:
:A real advantage of
:interpreted languages like Perl is that the program being executed is
:available in source code and one and can change it if one wants. When
:releasing a commercial product however this is a nightmare, the
:cron-jewels (algoririthms etc) are there for the taking.
You haven't been paying much attention to the open source movement,
have you? Wanting to hide source is considered rather outdated
and silly, you know.
--tom
--
There's going to be no serious problem after this. --Ken Thompson
------------------------------
Date: Thu, 12 Nov 1998 11:49:08 -0500
From: Seth Gordon <sgordon@kenan.com>
Subject: Re: Hiding source code from priving eyes
Message-Id: <364B1183.ACFE96E6@kenan.com>
Jan Bessels wrote:
> A real advantage of
> interpreted languages like Perl is that the program being executed is
> available in source code and one and can change it if one wants. When
> releasing a commercial product however this is a nightmare, the
> cron-jewels (algoririthms etc) are there for the taking.
Shrouding your code with misleading variable names, or compiling your
program, will make analyzing it more difficult, but not impossible.
In order for any application program (in Perl or any other language) to run,
the operating system must be able to read it and link to it.
If the operating system can read it and link to it, then another program --
e.g., a disassembler -- can do the same thing. A curious and knowledgeable
person can analyze the disassembler's output (perhaps with the help of other
tools) and deduce what the program's algorithms are. If one such person
figures it out and circulates it to his or her friends, there goes your deep
corporate secret.
Who are you planning to sell your code to?
--
perl -le'$m="r 0rJaa.u0cksthe";$c=967150;s/$/substr$m,($i\
+=$c%2?4:1)%=16,1or$i-2?"no":"Perl h"/e while$c>>=1;print'
== seth gordon == sgordon@kenan.com == standard disclaimer ==
== documentation group, kenan systems corp., cambridge, ma ==
------------------------------
Date: 12 Nov 1998 17:56:42 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How do I sort this list by "port" number?
Message-Id: <72f7gq$1g4$2@info.uah.edu>
In article <72f77k$1g4$1@info.uah.edu>,
gbacon@itsc.uah.edu (Greg Bacon) writes:
: In article <8c67cmx7ei.fsf@gadget.cscaper.com>,
: Randal Schwartz <merlyn@stonehenge.com> writes:
: : No. I disagree. -w is to keep beginners from making beginner
: : mistakes. It's not enabled by default so that experts can make only
: : expert mistakes. :)
:
: You also disagree with the other Larry who wrote
:
: The -w switch is not mandatory.
:
: in the perl manpage.
Oops, I forgot to mention that the excerpt is from the BUGS section
of the perl manpage. Gosh, all these years of writing in English,
and I still make the same mistakes beginners do, just not as frequently.
What beautiful irony. :-)
Greg
--
I want to die peacefully in my sleep like my grandfather, not screaming in
terror like his passengers.
------------------------------
Date: 12 Nov 1998 17:51:48 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: How do I sort this list by "port" number?
Message-Id: <72f77k$1g4$1@info.uah.edu>
In article <8c67cmx7ei.fsf@gadget.cscaper.com>,
Randal Schwartz <merlyn@stonehenge.com> writes:
: >>>>> "Larry" == Larry Rosler <lr@hpl.hp.com> writes:
: Larry> I think it works very poorly, because it is not '-w' clean, and all
: Larry> programs should run with '-w' enabled at all times!
:
: No. I disagree. -w is to keep beginners from making beginner
: mistakes. It's not enabled by default so that experts can make only
: expert mistakes. :)
You also disagree with the other Larry who wrote
The -w switch is not mandatory.
in the perl manpage. -w warns (among others) on the use of an
uninitialized value, and you'll have a hard time convincing me that
this behavior isn't useful to both beginners and experts.
: There are many of my one-off programs that are not -w clean. Some are
: not even "use strict" clean.
The root poster wanted code to use in a log file analyzer. I wouldn't
place log file analysis in the class of one-offable problems.
: Perl is a tool to get the job done. Some
: parts of Perl prevent some kinds of debugging, and are therefore
: redundant with some parts of my 29+ years of programming experience.
: I don't need to put training wheels on my motorcycle, thank you.
Cavaliers don't carry shields either.
Greg
--
Boon: Now, she should be decent looking, but we're willing to trade looks for
a certain kind of morally casual attitude.
------------------------------
Date: Thu, 12 Nov 1998 16:43:27 GMT
From: jimrsmith@unn.unisys.com
Subject: Install Errors: 5.005_02 on Solaris 2.6 system
Message-Id: <72f37f$4f3$1@nnrp1.dejanews.com>
I have a new server to build. e-3000 running Solaris 2.6.
I installed the optional C compiler (4.2).
I run Configure using defaults except for target directories. Whan I run
make, I get the following Results: Does anyone have a suggestion ?
****************************** Run make depend now? [y] sh ./makedepend
MAKE=make make: Warning: Both `makefile' and `Makefile' exist Current working
directory /system/perl5.005_02 sh writemain lib/auto/DynaLoader/DynaLoader.a
> tmp sh mv-if-diff tmp perlmain.c File perlmain.c not changed. echo malloc.c
av.c scope.c op.c doop.c doio.c dump.c hv.c mg.c byterun.c perl.c perly.c
pp.c pp_hot.c pp_ctl.c pp_sys.c regcomp.c regexec.c gv.c sv.c taint.c toke.c
util.c deb.c run.c universal.c globals.c perlio.c miniperlmain.c perlmain.c |
tr ' ' '\n' >.clist Finding dependencies for malloc.o. Finding dependencies
for av.o. Finding dependencies for scope.o. Finding dependencies for op.o.
Finding dependencies for doop.o. Finding dependencies for doio.o.
"/usr/include/sys/unistd.h", line 197: macro _PC_LAST redefines previous
macro at "/usr/ucbinclude/unistd.h", line 89 Finding dependencies for dump.o.
Finding dependencies for hv.o. Finding dependencies for mg.o. Finding
dependencies for byterun.o. Finding dependencies for perl.o. Finding
dependencies for perly.o. Finding dependencies for pp.o. Finding dependencies
for pp_hot.o. Finding dependencies for pp_ctl.o. Finding dependencies for
pp_sys.o. Finding dependencies for regcomp.o. Finding dependencies for
regexec.o. Finding dependencies for gv.o. Finding dependencies for sv.o.
Finding dependencies for taint.o. Finding dependencies for toke.o. Finding
dependencies for util.o. Finding dependencies for deb.o. Finding dependencies
for run.o. Finding dependencies for universal.o. Finding dependencies for
globals.o. Finding dependencies for perlio.o. Finding dependencies for
miniperlmain.o. Finding dependencies for perlmain.o. make: Warning: Both
`makefile' and `Makefile' exist Current working directory
/system/perl5.005_02 echo Makefile.SH cflags.SH config_h.SH makeaperl.SH
makedepend.SH makedir.SH perl_exp.SH writemain.SH | tr ' ' '\n' >.shlist
Updating makefile... test -s perlmain.c && touch perlmain.c cd x2p; make
depend sh ../makedepend MAKE=make make: Warning: Both `makefile' and
`Makefile' exist Current working directory /system/perl5.005_02/x2p echo
hash.c malloc.c str.c util.c walk.c | tr ' ' '\n' >.clist Finding
dependencies for hash.o. Finding dependencies for malloc.o. Finding
dependencies for str.o. Finding dependencies for util.o. Finding dependencies
for walk.o. make: Warning: Both `makefile' and `Makefile' exist Current
working directory /system/perl5.005_02/x2p echo Makefile.SH cflags.SH | tr '
' '\n' >.shlist Updating makefile... Now you must run a make.
If you compile perl5 on a different machine or from a different object
directory, copy the Policy.sh file from this object directory to the
new one before you run Configure -- this will help you with most of
the policy defaults.
# make
make: Warning: Both `makefile' and `Makefile' exist
`sh cflags libperl.a miniperlmain.o` miniperlmain.c
CCCMD = cc -DPERL_CORE -c -DX -O
"./perlvars.h", line 21: invalid token: ##
"./perlvars.h", line 21: undefined or not a type: PL_
"./perlvars.h", line 21: syntax error before or at: Gcurinterp
"./perlvars.h", line 21: warning: old-style declaration or incorrect type for:
Gcurinterp
"./perlvars.h", line 42: invalid token: ##
"./perlvars.h", line 42: undefined or not a type: PL_
"./perlvars.h", line 42: syntax error before or at: Gninterps
"./perlvars.h", line 42: warning: old-style declaration or incorrect type for:
Gninterps
<SNIP>
"./intrpvar.h", line 17: invalid token: ##
"./intrpvar.h", line 17: undefined or not a type: PL_
"./intrpvar.h", line 17: syntax error before or at: Iorigargc
"./intrpvar.h", line 17: warning: old-style declaration or incorrect type for:
Iorigargc
"./intrpvar.h", line 18: invalid token: ##
"./intrpvar.h", line 18: undefined or not a type: PL_
"./intrpvar.h", line 18: syntax error before or at: Iorigargv
"./intrpvar.h", line 18: warning: old-style declaration or incorrect type for:
Iorigargv
<SNIP>
./thrdvar.h", line 20: invalid token: ##
"./thrdvar.h", line 20: undefined or not a type: PL_
"./thrdvar.h", line 20: syntax error before or at: Tstack_sp
"./thrdvar.h", line 20: warning: old-style declaration or incorrect type for:
Tstack_sp
"./thrdvar.h", line 24: invalid token: ##
"./thrdvar.h", line 24: undefined or not a type: PL_
"./thrdvar.h", line 24: syntax error before or at: Top
"./thrdvar.h", line 24: warning: old-style declaration or incorrect type for:
Top
<SNIP>
"miniperlmain.c", line 35: undefined symbol: PL_do_undump
"miniperlmain.c", line 40: undefined symbol: PL_perl_destruct_level
"miniperlmain.c", line 53: warning: using out of scope declaration: exit
*** Error code 2
make: Fatal error: Command failed for target `miniperlmain.o'
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 12 Nov 1998 08:45:46 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Larry Rosler <lr@hpl.hp.com>
Subject: Re: Modification of a read-only??
Message-Id: <364AF49A.9DD128EB@email.sps.mot.com>
= [posted to comp.lang.perl.misc and copy emailed]
Larry Rosler wrote:
>
> [Posted to comp.lang.perl.misc and copy mailed.]
>
> In article <364A36E8.C1BBD936@wco.com> on Wed, 11 Nov 1998 17:16:24 -
> 0800, Steven Smith <steves@wco.com> says...
> > I have a piece of code that is using a file name to store information about
> > the file as a string. The code blows up if the file name starts with a digit.
> >
> > I can demonstrate the problem in the debugger:
> > DB<8> $x = '7a'
> >
> > DB<9> ${$x} = "hello"
> > Modification of a read-only value attempted at (eval 25) line 2, <IN>
> > chunk 12.
> >
> > Can someone explane to me what's happening here? Is there a workaround
> > short of changing the file to be something else if it starts with a
> > digit or just forcing it to start with a non-digit?
>
> Explanation: Not sure. 'perlref' doesn't state explicitly what
> constitutes a valid string to use as a symbolic reference. ('foo bar'
> works OK, but is not an identifier, so it's not clear what the rules
> are.)
My guess is that ${$x} gets evaluated to $7, and the attempt to assign
"hello" would generate such message.
In any case, 'perldata' states that an identifier begins with a letter
or underscore. Guess the digit is breaking the statement here too.
-tk
------------------------------
Date: Thu, 12 Nov 1998 08:53:22 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Ilya Zakharevich <ilya@math.ohio-state.edu>
Subject: Re: Modification of a read-only??
Message-Id: <364AF662.A6EFA164@email.sps.mot.com>
Ilya Zakharevich wrote:
>
> [A complimentary Cc of this posting was sent to Tad McClellan
= [posted to comp.lang.perl.misc and copy emailed]
> <tadmc@flash.net>],
> who wrote in article <j8kd27.jkm.ln@flash.net>:
> > : DB<8> $x = '7a'
> >
> > : DB<9> ${$x} = "hello"
> > : Modification of a read-only value attempted at (eval 25) line 2, <IN>
> > : chunk 12.
> >
> >
> > $7a is not a legal identifier in Perl.
>
> This is irrelevant. Perl has no problem with ${"foo bar"}. The idea
> is that any variable name which starts with a digit is a considered a
> cousin of $7, $71, $716 and so on - they are match-group variables,
> which are (currently) read-only.
>
> I may remember wrong, but I would think that ${'7a'} refers to the 7th
> group (group is calculated by atoi() which discards trailing trash).
looks like you are right.
DB<24> $s = 'acbdefghi'
DB<25> $x = '7a'
DB<26> print ${$x} if $s=~/(.)(.)(.)(.)(.)(.)(.)(.)(.)/
g
DB<27> print $7 if $s=~/(.)(.)(.)(.)(.)(.)(.)(.)(.)/
g
-tk
------------------------------
Date: Thu, 12 Nov 1998 15:29:38 GMT
From: "News" <dixonmat@pouch.com>
Subject: Re: percentages
Message-Id: <C9D22.163$5v3.1363463@news.optonline.net>
this is what I came up with
if ($tot > 5001) { $tot *= -.3; }
elsif ($tot > 2501) { $tot *= -.28; }
elsif ($tot >= 1000) { $tot *= -.25; }
$tot = &Monify ($tot);
print "<Td bgColor=\"#$tdBg1\" Align=left><b><Font Color=black>Discount
Rate</font></b><Td bgColor=\"#$tdBg1\" Align=right><b><Font
Color=black>$currency $tot</Font></b><Tr>\n";
$gtot += $tot;
$gtot = &Monify ($gtot);
print "<Td bgColor=\"#$tdBg1\" Align=left><b><Font Color=red>@string[23]
$deliveryToBeCalculated</Font></b><Td bgColor=\"#$tdBg1\"
Align=right><b><Font Color=red>$currency $gtot</Font></b><Tr>\n";
This works great except for the fact that if the total value is less than
1000 the line
$gtot += $tot;
is added together so if the user purchases $500.00 worth of stuff his grand
total the is $1000.00
this is yet another obstacle I have to overcome any insite would be greatly
appreciated.
------------------------------
Date: Thu, 12 Nov 1998 16:15:36 GMT
From: bart.mediamind@ping.be (Bart Lateur)
Subject: Re: percentages
Message-Id: <364d0959.30969021@news.ping.be>
News wrote:
>This works great except for the fact that if the total value is less than
>1000 the line
> $gtot += $tot;
>is added together so if the user purchases $500.00 worth of stuff his grand
>total the is $1000.00
add an else clause:
if ($tot > 5001) { $tot *= -.3; }
elsif ($tot > 2501) { $tot *= -.28; }
elsif ($tot >= 1000) { $tot *= -.25; }
else { $tot = 0 }; # clear it!
Bart.
------------------------------
Date: Thu, 12 Nov 1998 09:17:12 -0800
From: "Geoff Caylor" <geoff@newinteractive.com>
Subject: Perl ODBC control
Message-Id: <xKE22.231$KL3.1510@news14.ispnews.com>
Hello-
I'm looking for a way to write to a database (either modifying an existing
record, or creating a new one), and haven't found any documentation or
leads...
Any help is greatly appreciated!
Geoff Caylor
------------------------------
Date: Thu, 12 Nov 1998 08:59:12 -0600
From: Tk Soh <r28629@email.sps.mot.com>
To: Jules <julius@clara.net>
Subject: Re: Perl question: Arrays in Hash???
Message-Id: <364AF7C0.BA17D73A@email.sps.mot.com>
= [posted to comp.lang.perl.misc and copy emailed]
Jules wrote:
>
> Dear all Perl experts out there, is it not possible at all to have array in
> a hash? I'm trying to do some backtracking using arrays as hash elements in
> $self:
>
> sub new {
> # get File object to grab its filehandle
> my ($class,$other) = @_;
> return bless { "fh" => $other->fh(), "fill" => $fill, "pfill" => [] },
> $class;
> }
>
> and then when I try to unshift and shift elements onto and from the array
> "pfill" like this:
>
> unshift($self->{pfill},$self->{fill});
$self->{pfill} is a ref, you need to 'cast' it into an array before you
do the unshift:
unshift(@{ $self->{pfill} }, $self->{fill});
See?
-tk
------------------------------
Date: Thu, 12 Nov 1998 17:12:08 GMT
From: dave@mag-sol.com
Subject: Re: Perl question: Arrays in Hash???
Message-Id: <72f4t9$692$1@nnrp1.dejanews.com>
In article <72eop7$sqc$1@eros.clara.net>,
"Jules" <julius@clara.net> wrote:
> Dear all Perl experts out there, is it not possible at all to have array in
> a hash? I'm trying to do some backtracking using arrays as hash elements in
> $self:
>
> sub new {
> # get File object to grab its filehandle
> my ($class,$other) = @_;
> return bless { "fh" => $other->fh(), "fill" => $fill, "pfill" => [] },
> $class;
> }
>
> and then when I try to unshift and shift elements onto and from the array
> "pfill" like this:
>
> unshift($self->{pfill},$self->{fill});
> $self->{fill} = shift($self->{pfill});
>
> I get compilation error:
>
> Type of arg 1 to unshift must be array (not hash elem)
> Type of arg 1 to shift must be array (not hash elem)
>
> Is there a way round it? I really need to use arrays for backtracking.
This is all in the fine documentation that camne with your distribution. You
should look in particular at the data structures cookbook
perldoc perldsc
and the section on references
perldoc perlref
In brief a hash can only contain scalars, not arrays or other hashes.
Fortunately a reference is considered a scalar, so it can be stored in a hash
(or, indeed, an array). If you have an array reference (as you do in this
case) and you want to use it as an array, you need to dereference it using
the appropriate prefix symbol ('@' for arrays).
Therefore your code should look more like:
unshift(@{$self->{pfill}},$self->{fill});
$self->{fill} = shift(@{$self->{pfill}});
hth,
Dave...
(perhaps being a little more helpful than is good for the group)
--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 12 Nov 1998 17:37:07 GMT
From: michael_maxim@nospam.ccm.sc.intel.com (Michael Maxim)
Subject: perl script -> msdos/win31 executable?
Message-Id: <72f7ga$dh5@news.or.intel.com>
Hi all-
Is there any way to make a perl script into a .exe for win31 (actually, to run
in a dos box under win31)? There is such a beastie for win95/NT
(www.perl2exe.com) which works very well, but does NOT support the older OS.
Help. If I can't figure out how to do this, I'll have to rewrite my script in
vbasic, c, or (gasp) as a dos .bat file. :( Can't install perl on the target
pcs....
thanks for any help,
M2.
Michael Maxim
michael_maxim@NO.SPAM.ccm.sc.intel.com
(remove the nospam bit, obviously)
Speaking only for myself, of course.
------------------------------
Date: 12 Nov 1998 11:22:12 -0500
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <x790hg98zv.fsf@sysarch.com>
>>>>> "Z" == Zenin <zenin@bawdycaste.org> writes:
Z> Personally, I consider it a bug that a full "use strict;" isn't
Z> in place by default. Ditto for -w. It likely would have saved us
Z> from huge amounts of code that people like to throw back in Perl's
Z> face as "write once programming".
so maybe in topaz it will be standard. but would that again break the
holy grail of backwards compatibility?
Z> : it's funny, when perl5 came out i thought soft refs were very
Z> cool as i : wished i had them in perl4 instead of typeglobs. but
Z> regular hash refs : are so much better that i never use soft refs.
Z> I hated them. Make a mistake and things just kept on
Z> trucking...often without so much as a warning. I'm so glad I found
Z> use strict before I started doing any major code in 5.x.
i agree. i thought they were a cool feature that i wanted, but i never
used them. i wish i had started using strict earlier but it is standard
with me now except for 1 liners and simple throwaways. i have a large
dir of short junk that i use to play with concepts, regexes, testing
code for/from posts, etc. and i don't use strict there but most people
would think that is ok.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: Thu, 12 Nov 1998 17:50:17 GMT
From: Randal Schwartz <merlyn@stonehenge.com>
Subject: Re: Q: are symbolic refs really needed (was Re: Modification of a read-only??)
Message-Id: <8cn25wu7g0.fsf@gadget.cscaper.com>
>>>>> "Uri" == Uri Guttman <uri@sysarch.com> writes:
Uri> this may be one of the few areas, hacking the symbol table. but most
Uri> users will never need such tricks. so making use strict 'refs' a default
Uri> may be a good idea. you can easily turn it off when doing black magic.
Can't. Breaks perl4 proggies that did this:
$function = "beat_it";
&$function("some args", "go here");
In fact, the whole soft-ref thing is nothing more than an extension
of this one special case in Perl4 of an "indirect function call".
print "Just another Perl documentor,"
--
Name: Randal L. Schwartz / Stonehenge Consulting Services (503)777-0095
Keywords: Perl training, UNIX[tm] consulting, video production, skiing, flying
Email: <merlyn@stonehenge.com> Snail: (Call) PGP-Key: (finger merlyn@teleport.com)
Web: <A HREF="http://www.stonehenge.com/merlyn/">My Home Page!</A>
Quote: "I'm telling you, if I could have five lines in my .sig, I would!" -- me
------------------------------
Date: Thu, 12 Nov 1998 11:15:37 -0500
From: Bob Donovan <bob.donovan@sdrc.com>
Subject: retrieving and archiving mail
Message-Id: <364B09A9.F22DD22D@sdrc.com>
Hi,
I need to write a perl tool that checks for mail messages on a POP
server, retrieves, and archives them for later viewing.
Does anyone know how to do this?
Thank you,
Bob
------------------------------
Date: Thu, 12 Nov 1998 10:54:47 -0500
From: "Vassiliou, Vasos" <coop1x33@nortel.com>
Subject: Searching and Parsing text from HTML file
Message-Id: <364B04C6.BF2B2E20@nortel.com>
I am using a simple text Search routine to search for some
keywords in local HTML files.
At the present I am just returning the Title of the file as
a link using the following code:
...
if ($string =~ /<title>(.*)<\/title>/i) {
$titles{$FILE} = "$1";
}
.
.
.
foreach $key (keys %include) {
if ($include{$key} eq 'yes') {
print "<li><a
href=\"$baseurl$key\">$titles{$key}</a>\n";
}
}
I want to change/add to this code so that I display also the
<META> description of that page (if it has one)
Has anybody done this before? If yes can you point me to
it?
If No, can you help me figure this out?
Any help will be greatly appreciated
Vasos
coop1x33@nortel.com
------------------------------
Date: Thu, 12 Nov 1998 17:23:12 GMT
From: dave@mag-sol.com
Subject: The Perl Institute?
Message-Id: <72f5i0$6pr$1@nnrp1.dejanews.com>
Has anyone been able to connect to the TPI web page <http://www.perl.org>
recently? I've not been able to for a couple of days and I've also recieved
nothing from the daily TPI News Mailing List since Tuesday.
Is something wrong?
Dave...
--
Magnum Solutions Ltd: <http://www.mag-sol.com/>
London Perl M[ou]ngers: <http://london.pm.org/>
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: Thu, 12 Nov 1998 17:19:59 GMT
From: keydet89@yahoo.com
Subject: Using Win32::Registry.pm
Message-Id: <72f5bv$6m3$1@nnrp1.dejanews.com>
I have installed the Win32::Registry.pm module on my
system...NT 4.0 using ActiveState build 506. I have
been working with the examples from LeBerre's site,
and I can't get the OpenEx() function to work. I keep
getting the error:
"Undefined subroutine &Win32::RegOpenKeyEx called at
C:\Perl\site\lib/Win32/Registry.pm line 206."
What is the fix for this?
Carv
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own
------------------------------
Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>
Administrivia:
Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.
If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4205
**************************************