[19485] in Perl-Users-Digest
Perl-Users Digest, Issue: 1680 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Sep 2 18:05:36 2001
Date: Sun, 2 Sep 2001 15:05:11 -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: <999468310-v10-i1680@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Sun, 2 Sep 2001 Volume: 10 Number: 1680
Today's topics:
Re: a mystery to me: EOF (Mark Jason Dominus)
Re: a mystery to me: EOF <nospam-abuse@ilyaz.org>
Re: Advise on a basic perl script <krahnj@acm.org>
Re: Alternations in Parse::RecDescent <weymer@mediawise.de>
ANNOUNCE: Filter::Simple 0.61 (Damian Conway)
ANNOUNCE: NEXT 0.02 (Damian Conway)
ANNOUNCE: Switch 2.05 (Damian Conway)
ANNOUNCE: Text::Balanced 1.86 (Damian Conway)
Re: Black Perl (N01937)
Re: Converting Perl to C <pne-news-20010902@newton.digitalspace.net>
Re: Dangerous Perl Script? <tsee@gmx.net>
Editing a text file? <schrykex2@yahoo.com>
Re: Editing a text file? <info@fruiture.de>
Re: Editing a text file? <schrykex2@yahoo.com>
Godzilla DOS Perl Script Timer <godzilla@stomp.stomp.tokyo>
Inline::Java and mod_perl <tinamue@zedat.fu-berlin.de>
Re: is perl an 'interpretative' language? (Seymour J.)
Is there a better way of righting this... <noone@none.com>
Re: Is there a better way of righting this... <davidhilseenews@yahoo.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 02 Sep 2001 15:11:02 GMT
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: a mystery to me: EOF
Message-Id: <3b924c05.663d$126@news.op.net>
In article <9mpunp$kr0$1@ichaos.ichaos-int>,
Juha Laiho <Juha.Laiho@iki.fi> wrote:
>The return value of read() is the number of bytes actually read from
>the stream. If no additional error condition is set (in a global
>variable errno), and the number of bytes read was smaller than the
>number of bytes desired, then the read() encountered the end of file.
Not quite. read() indicates an end-of-file condition by returning *zero*.
For plain files, read will always return the number of bytes that the
programmer requested, if there are that many, and so if read() returns
a smaller number, the programmer vcan be sure that there is nothing
left to read.
But that is not true for other data sources such as pipes and sockets.
If you ask Unix to read 100 bytes from a socket, and only 50 bytes are
available, Unix will return the 50 bytes immediately, without waiting
for more, and this does *not* indicate end-of-file, because more data
might arrive later over the network.
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f^ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: Sun, 2 Sep 2001 15:58:45 +0000 (UTC)
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: a mystery to me: EOF
Message-Id: <9mtkvl$v1a$1@agate.berkeley.edu>
[A complimentary Cc of this posting was sent to
Mark Jason Dominus
<mjd@plover.com>], who wrote in article <3b924c05.663d$126@news.op.net>:
> Not quite. read() indicates an end-of-file condition by returning *zero*.
>
> For plain files, read will always return the number of bytes that the
> programmer requested,
Nope, this depends on CRTL. E.g., with EMX read() with NL
translation enabled (default on plain files) will return data until
the next NL. (This allows NL translation without extra memory moves.)
Hope this helps,
Ilya
------------------------------
Date: Sun, 02 Sep 2001 20:10:09 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Advise on a basic perl script
Message-Id: <3B929297.3B6B8E04@acm.org>
sammy wrote:
>
> Have unix text file which I tail and look for certain patterns I need to
> certain patterns and in addition if it has the string some where within the
> second
> field then ignore or just print message .
>
> Appreciate if you could just take a look at this syntax and advise if okay
> or not.
>
> Ps I've have not any perl, mainly shell and just need to mod perl script
>
> [snip code]
>
> DATA
>
> message_id="63-3d09801f0000" source_name="daisy-xxx800-44.fred.com" more
> data ....
> message_id="23-3d09801f0000" source_name="tom.700.44.fred.com" more data
> ....
> message_id="73-3d09801f0000" source_name="patrick-xxx800-44.fred.com" more
> data ....
#!/usr/contrib/bin/perl -w
use strict;
while ( <DATA> ) {
if ( /source_name="([^.]*)\./ ) {
my $xxx = (split /-/, $1)[1];
next unless defined $xxx;
$xxx = substr( $xxx, 0, 3 );
if ( $xxx eq 'xxx' ) {
print "THIS IS XXX $xxx OKAY\n";
#ie do nothing
}
else {
# $command = "/usr/bin/mailx -s blah blah
}
}
}
__DATA__
message_id="63-3d09801f0000" source_name="daisy-xxx800-44.fred.com" more
data ....
message_id="23-3d09801f0000" source_name="tom.700.44.fred.com" more data
....
message_id="73-3d09801f0000" source_name="patrick-xxx800-44.fred.com"
more data ....
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sun, 02 Sep 2001 20:49:07 +0200
From: Andreas Weymer <weymer@mediawise.de>
Subject: Re: Alternations in Parse::RecDescent
Message-Id: <3B927F23.9FFB5D36@mediawise.de>
Hi,
Thanks, also to Damian. I especially liked your first ansatz.
> Parse::RecDescent rules!
Yes!!!
> You might also want to join the P::RD mailing list, one of the lists
> hosted at perl.org.
I will.
Andreas
------------------------------
Date: 2 Sep 2001 21:27:13 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Filter::Simple 0.61
Message-Id: <9mu87h$sk8$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release
==============================================================================
Release of version 0.61 of Filter::Simple
==============================================================================
NAME
Filter::Simple - Simplified source filtering
SYNOPSIS
# in MyFilter.pm:
package MyFilter;
use Filter::Simple;
FILTER { ... };
# or just:
#
# use Filter::Simple sub { ... };
# in user's code:
use MyFilter;
# this is filtered
no MyFilter;
# this is not
DESCRIPTION
The Filter::Simple module provides a simplified interface to
Filter::Util::Call; one that is sufficient for most common cases.
AUTHOR
Damian Conway (damian@conway.org)
COPYRIGHT
Copyright (c) 2000-2001, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
==============================================================================
CHANGES IN VERSION 0.61
- Added a real test suite (thanks Jarkko)
- Changed licence to facilitate inclusion in
core distribution
- Added documentation for using F::S and Exporter together
==============================================================================
AVAILABILITY
Filter::Simple has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Filter-Simple.tar.gz
==============================================================================
------------------------------
Date: 2 Sep 2001 20:53:09 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: NEXT 0.02
Message-Id: <9mu67l$rv9$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release
==============================================================================
Release of version 0.02 of NEXT
==============================================================================
NAME
NEXT - Pseudo class for method redispatch
DESCRIPTION
NEXT.pm adds a pseudoclass named C<NEXT> to any program that
uses it. If a method C<m> calls C<$self->NEXT::m()>, the call to
C<m> is redispatched as if the calling method had not originally
been found.
In other words, a call to C<$self->NEXT::m()> resumes the
depth-first, left-to-right search of parent classes that
resulted in the original call to C<m>.
Note that this is not the same thing as C<$self->SUPER::m()>, which
begins a new dispatch that is restricted to searching the ancestors
of the current class. C<$self->NEXT::m()> can backtrack past
the current class -- to look for a suitable method in other
ancestors of C<$self> -- whereas C<$self->SUPER::m()> cannot.
An particularly interesting use of redispatch is in
C<AUTOLOAD>'ed methods. If such a method determines that it is
not able to handle a particular call, it may choose to
redispatch that call, in the hope that some other C<AUTOLOAD>
(above it, or to its left) might do better.
Note that it is a fatal error for any method (including C<AUTOLOAD>)
to attempt to redispatch any method except itself. For example:
sub D::oops { $_[0]->NEXT::other_method() } # BANG!
AUTHOR
Damian Conway (damian@conway.org)
COPYRIGHT
Copyright (c) 2000-2001, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
==============================================================================
CHANGES IN VERSION 0.02
- Fixed setting of $AUTOLOAD in NEXT'd AUTOLOADS (thanks Leonid)
- Changed licence for inclusion in core distribution
==============================================================================
AVAILABILITY
NEXT has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/NEXT.tar.gz
==============================================================================
------------------------------
Date: 2 Sep 2001 21:14:48 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Switch 2.05
Message-Id: <9mu7g8$s9c$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release
==============================================================================
Release of version 2.05 of Switch
==============================================================================
NAME
Switch - A switch statement for Perl
DESCRIPTION
Switch.pm provides the syntax and semantics for an explicit case
mechanism for Perl. The syntax is minimal, introducing only the
keywords C<switch> and C<case> (or C<given> and C<when> in Perl 6 mode)
and conforming to the general pattern of existing Perl control structures.
The semantics are particularly rich, allowing any one (or more) of nearly
30 forms of matching to be used when comparing a switch value with its
various cases.
AUTHOR
Damian Conway (damian@conway.org)
COPYRIGHT
Copyright (c) 1997-2001, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
==============================================================================
CHANGES IN VERSION 2.05
- Changed licence for inclusion in core distribution
- Added new test file for non-fallthrough and nested switches
==============================================================================
AVAILABILITY
Switch has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Switch.tar.gz
==============================================================================
------------------------------
Date: 2 Sep 2001 19:57:53 GMT
From: damian@cs.monash.edu.au (Damian Conway)
Subject: ANNOUNCE: Text::Balanced 1.86
Message-Id: <9mu301$s0j$1@towncrier.cc.monash.edu.au>
Keywords: perl, module, release
==============================================================================
Release of version 1.86 of Text::Balanced
==============================================================================
NAME
Text::Balanced - Extract delimited text sequences from strings.
SUMMARY (see Balanced.pod for full details)
Text::Balanced::extract_delimited
`extract_delimited' extracts the initial substring of a string
which is delimited by a user-specified set of single-character
delimiters, whilst ignoring any backslash-escaped delimiter
characters.
Text::Balanced::extract_bracketed
`extract_bracketed' extracts a balanced-bracket-delimited substring
(using any one (or more) of the user-specified delimiter brackets:
'(..)', '{..}', '[..]', or '<..>').
Text::Balanced::extract_quotelike
`extract_quotelike' attempts to recognize and extract any one of the
various Perl quote and quotelike operators (see "perlop(3)"). Embedded
backslashed delimiters, nested bracket delimiters (for the
quotelike operators), and trailing modifiers are all correctly handled.
Text::Balanced::extract_codeblock
`extract_codeblock' attempts to recognize and extract a
balanced bracket-delimited substring which may also contain
unbalanced brackets inside Perl quotes or quotelike
operations. That is, `extract_codeblock' is like a combination
of `extract_bracketed' and `extract_quotelike'.
Text::Balanced::extract_tagged
`extract_tagged' attempts to recognize and extract a
substring between two arbitrary "tag" patterns (a start tag
and an end tag).
INSTALLATION
It's all pure Perl, so just put the .pm file in its appropriate
local Perl subdirectory.
AUTHOR
Damian Conway (damian@cs.monash.edu.au)
COPYRIGHT
Copyright (c) 1997-2001, Damian Conway. All Rights Reserved.
This module is free software. It may be used, redistributed
and/or modified under the same terms as Perl itself.
==============================================================================
CHANGES IN VERSION 1.86
- Revised licence for inclusion in core distribution
- Consolidated POD in .pm file
- renamed tests to let DOS cope with them
==============================================================================
AVAILABILITY
Text::Balanced has been uploaded to the CPAN
and is also available from:
http://www.csse.monash.edu.au/~damian/CPAN/Text-Balanced.tar.gz
==============================================================================
------------------------------
Date: 2 Sep 2001 10:06:54 -0700
From: N01937@hushmail.com (N01937)
Subject: Re: Black Perl
Message-Id: <622db6be.0109020906.3e9ccfbc@posting.google.com>
In my copy (3rd edition), it attributes the first poem to Sharon, but
not Black Perl. Larry writes, "A person who wishes to remain anonymous
wrote the following example of Black Perl". I was wondering if anyone
has taken credit since.
$incerely =$_='
Kevin
';m;\w+;;$_=$&;y;nK;lD;;$_="The $_";print;
mgjv@tradingpost.com.au (Martien Verbruggen) wrote in message news:<slrn9p42ce.3ga.mgjv@martien.heliotrope.home>...
> On 2 Sep 2001 02:52:34 -0700,
> N01937 <N01937@hushmail.com> wrote:
> > Does anyone know the author of the Black Perl poem found in the Camel Book?
>
> Hmm.. I thought it was by Larry Wall, himself, but it's actually by
> Sharon Hopkins, who's done quite a few poems in Perl.
>
> Martien
------------------------------
Date: Sun, 02 Sep 2001 21:15:04 +0200
From: Philip Newton <pne-news-20010902@newton.digitalspace.net>
Subject: Re: Converting Perl to C
Message-Id: <af05ptc7qrkq8ghldfa0bm9b49q78jf513@4ax.com>
On Sat, 01 Sep 2001 09:43:43 +0200, Tassilo von Parseval
<Tassilo.Parseval@post.rwth-aachen.de> wrote:
> Philip Newton wrote:
>
> > On Thu, 30 Aug 2001 13:57:31 +0400, "Oleg Bogumirsky"
> > <oleg_b@newmail.ru> wrote:
> >
> >>i mean to convert Perl source to C/C++ source, so I could compile
> >>this C source with c compiler.
> >
> > And why do you want to do that?
>
> Oh, there may be reasons for doing that, be it for the sake of writing a
> closed-source program or just being able to run this particular program
> on a similar machine having no Perl interpreter by its hand.
I'm sure there are reasons. I was just wondering what *his* reason was.
(Perhaps I suspected that it was "I want to compile my Perl programs to
C code so that they run more quickly", which will probably not give the
results he expects. I believe mjd has an article on that.)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: Sun, 2 Sep 2001 21:52:06 +0200
From: "Steffen Müller" <tsee@gmx.net>
Subject: Re: Dangerous Perl Script?
Message-Id: <9mu2qd$f7m$01$1@news.t-online.com>
"Malcolm Dew-Jones" <yf110@vtn1.victoria.tc.ca> schrieb im Newsbeitrag
news:3b8f2ef1@news.victoria.tc.ca...
> Yes, but last time I checked, CGI.pm has no *default* limit. so virtually
> all cgi scripts that use CGI.pm are vunerable to the attack.
Which is why we all RTFM of CGI.pm and have a very careful look at the
security considerations "Avoiding Denial of Service Attacks."
Umm, at least some do that... :(
Steffen
------------------------------
Date: Sun, 02 Sep 2001 18:02:31 GMT
From: "Schryke" <schrykex2@yahoo.com>
Subject: Editing a text file?
Message-Id: <Xuuk7.19847$xb.13460283@news1.mntp1.il.home.com>
I'm totally lost. I'm new at programming perl and CGI, and I need to be able
to open a specific text file and edit a list of names on it then save it
again... can anyone help me out here?
-R
Rebel without a clue.
------------------------------
Date: Sun, 2 Sep 2001 21:01:06 +0200
From: "fruiture" <info@fruiture.de>
Subject: Re: Editing a text file?
Message-Id: <9mu04e$aig$01$1@news.t-online.com>
"Schryke" <schrykex2@yahoo.com> wrote:
> I'm totally lost. I'm new at programming perl and CGI, and I need to be
able
> to open a specific text file and edit a list of names on it then save it
> again... can anyone help me out here?
the 'perldoc' can help you
try:
% perldoc perldoc
% perldoc perlop
% perldoc -f open
% perldoc perlopentut
% perldoc -f close
% perldoc -f print
% perldoc perlre
HTH
--
require Time::HiRes;my @m=split(/8/,55.52.56.49.49.55.56.49.49.53);push
@m,map{($_%2)?$_-1:$_+1} map ord($_),split//,'u!`onuids!Qdsm!i`bjds';
unshift @m,43 for(0..@m);for(0..@m){print map chr($_),@m[0..(@m/2-1)];
push @m,shift @m;print "\b"x(@m/2);Time::HiRes::usleep(0246*0xA**3);}
------------------------------
Date: Sun, 02 Sep 2001 19:16:51 GMT
From: "Schryke" <schrykex2@yahoo.com>
Subject: Re: Editing a text file?
Message-Id: <DAvk7.20458$xb.13572804@news1.mntp1.il.home.com>
Thanks for the info. It's helped a bit. I've figured out how to open, close,
and write the file, my main problem right now is doing the actual editing. I
need something like a CGI text editor/notepad sort of thing. I can open the
file, I can display it, I can save it, I just can't edit it without
downloading it, opening it in notepad and uploading it again when I'm done.
-R
"fruiture" <info@fruiture.de> wrote in message
news:9mu04e$aig$01$1@news.t-online.com...
> "Schryke" <schrykex2@yahoo.com> wrote:
> > I'm totally lost. I'm new at programming perl and CGI, and I need to be
> able
> > to open a specific text file and edit a list of names on it then save it
> > again... can anyone help me out here?
>
> the 'perldoc' can help you
> try:
>
> % perldoc perldoc
> % perldoc perlop
> % perldoc -f open
> % perldoc perlopentut
> % perldoc -f close
> % perldoc -f print
> % perldoc perlre
>
> HTH
>
> --
> require Time::HiRes;my @m=split(/8/,55.52.56.49.49.55.56.49.49.53);push
> @m,map{($_%2)?$_-1:$_+1} map ord($_),split//,'u!`onuids!Qdsm!i`bjds';
> unshift @m,43 for(0..@m);for(0..@m){print map chr($_),@m[0..(@m/2-1)];
> push @m,shift @m;print "\b"x(@m/2);Time::HiRes::usleep(0246*0xA**3);}
>
------------------------------
Date: Sun, 02 Sep 2001 12:37:04 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Godzilla DOS Perl Script Timer
Message-Id: <3B928A60.BF26779E@stomp.stomp.tokyo>
This is a low level DOS timer designed to measure
the amount of time a Perl script takes to execute
in milliseconds. It works quite well but there are
some explicit instructions for use.
Back in the nineteen-eighties, this binary executable
was quite popular for timing and optimizing DOS based
programs. It has been written and compiled in dozens
of different ways by an equal number of authors, all
of whom, are actually unknown. Few, if any, cared much
about credits and copyrights back then.
I have rewritten this binary program to adapt it to use
with perl core. My modifications are only two. My first
modification is to add an extra input parameter to allow
perl core to be called followed by a call for a Perl
script to execute, then arguments as needed. My second
modification is an extra utility to allow timing of
perl core compilation and execution timing along with
a Perl script compilation and execution timing.
I have not included any credits nor copyright notices
for myself, within this DOS program. Do as you wish
with it. I really don't care. I support old fashion
true open source traditions. This program has never
been credited and shall remain so.
In a nutshell, here is how to use this DOS executable.
After unzipping my zip file, move gozilla.exe to your
perl directory containing your files to be timed. This
program needs to run from a DOS box _WITH_ Windows 9.x
or Windows.me running in the background. It will not
run in a pure DOS environment. This is obvious, you
need Windows running to execute Perl for Windows. Heh!
To time both perl core and a script, do not use any options,
this is, do not call for more than one execution:
godzilla perl test.pl
This will produce a total time in milliseconds for
perl core to execute and your Perl script to execute.
This is a relative time; it includes some Windows
background noise as well, although minimized. Use
a single run to attain a relative time notion for
comparing scripts. Do not treat this as solely the
time for perl core and a script to execute.
Use this syntax to time only your Perl script:
godzilla -n4 perl test.pl
This -n4 means run it four times and average the times.
You will receive an average event time for your Perl
script only. My godzilla program will ignore (minimize)
the amount of time perl core consumes. Your results are
almost purely for your Perl script.
One run - total of perl core and script.
Two + runs - average of Perl script only.
Syntax usage will be presented by running godzilla only:
godzilla
This produces:
USAGE: godzilla opts perl program args
Options: -n# # = number of executions
-N# # = #+2 execs and min/max are discarded
godzilla - to run godzilla.exe
opts - either -n# or -N# with # being a number
perl - include perl as normal to execute perl core
program - name of your script
args - any extra arguments to be fed into your script
Do note -N will discard the lowest time and the highest
time to narrow your average results. This does seem to
provide a higher degree of accuracy by discarding those
events not truly associated with your script; background
noise generated by Windows.
This simple DOS timer is intended to fill this gap left
by Benchmark of not being able to time only a few events.
Its accuracy is not too bad; fairly decent. Keep in mind
some Windows background noise will inherently be present.
Use this for relative time comparisons. Greater accuracy,
like Benchmark, is attained with high multiple runs.
A final note. Do not include print commands in your Perl
script to be tested. Think on this. You will figure it out.
My DOS timer is available here as a zip file. It is small:
http://la.znet.com/~callgirl/timer.html
Oh yes, almost forget. This DOS timer will work with other
types of programs, beyond perl scripts. Simply leave out
"perl" in your syntax. Experiment and have fun.
* wonders if Perl 5 Cargo Cultists can master this program *
Godzilla! Queen Of Perl Heretics.
------------------------------
Date: 2 Sep 2001 16:14:47 GMT
From: Tina Mueller <tinamue@zedat.fu-berlin.de>
Subject: Inline::Java and mod_perl
Message-Id: <9mtltn$40jfa$1@fu-berlin.de>
hi,
I'm using Inline::Java under mod_perl, and it's
working like a charm, the only thing is,
I'm starting the webserver with a wrapper-skript, like
script start server
script stop server
script restart server
and normally this starts the server and exits. if i'm
using Inline::Java, it doesn't exit. the server is starting,
but the wrapper-script hangs forever (or it's printing debug-messges,
if I switched on the DEBUG-entry.
does anybody of you know of possibility to change that? i guess
if i'm using Inline::Java there is something like a server started.
i can see the process
"...../bin/sparc/native_threads/java InlineJavaServer true <port_number>"
running.
i also found the line in the JVM.pm. it's called with open3():
$pid = open3($in, ">&STDOUT", ">&STDERR", $cmd);
is there a possibility to make this command starting in
the background?
(I'm on SunOS 5.7, perl 5.005_03)
thanks for any hints,
tina
--
http://www.tinita.de \ enter__| |__the___ _ _ ___
tina's moviedatabase \ / _` / _ \/ _ \ '_(_-< of
search & add comments \ \ _,_\ __/\ __/_| /__/ perception
--- Warning: content of homepage hopelessly out-dated ---
------------------------------
Date: Sun, 02 Sep 2001 01:24:05 -0400
From: "Shmuel (Seymour J.) Metz" <spamtrap@library.lspace.org.invalid>
Subject: Re: is perl an 'interpretative' language?
Message-Id: <3b91c275$1$fuzhry$mr2ice@news.patriot.net>
In <93aad7d0.0108230454.74dec340@posting.google.com>, on 08/23/2001
at 05:54 AM, ziegler@algorilla.de (Joachim Ziegler) said:
>what do you think about calling Perl an 'interpretative language'?
The same as for any other language: somebody is confusing a definition
with an implementation. When someone uses the term "interpretive
language" I cease taking him seriously.
--
-----------------------------------------------------------
Shmuel (Seymour J.) Metz, SysProg and JOAT
Atid/2
Team OS/2
Team PL/I
Any unsolicited commercial junk E-mail will be subject to legal
action. I reserve the right to publicly post or ridicule any
abusive E-mail.
I mangled my E-mail address to foil automated spammers; reply to
domain acm dot org user shmuel to contact me. Do not reply to
spamtrap@library.lspace.org
-----------------------------------------------------------
------------------------------
Date: Sun, 02 Sep 2001 16:47:30 +0100
From: kdgjloiureo <noone@none.com>
Subject: Is there a better way of righting this...
Message-Id: <vrk4ptkfaeeeq81f0t1tmf07pmpj405257@4ax.com>
Right im fairly new to perl and im sure there must be a better way of
righting the sub below any one have any ideas as to how to make this a
bit more efficient.
sub print_record {
if ($FORM{'select'} eq "/home/closey/secure/dBs/CD/") {
$dir = "../CD/";
$display = "CD's";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/CDR/") {
$dir = "../CDR/";
$display = "CD RW's";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Phone/") {
$dir = "../Phone/";
$display = "Phones";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/accessories/") {
$dir = "../accessories/";
$display = "Accessories";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/cable/") {
$dir = "../cable/";
$display = "Cables";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/gfx/") {
$dir = "../gfx/";
$display = "Multimedia";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/HD/") {
$dir = "../HD/";
$display = "Hard disk drives";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Mainboard/") {
$dir = "../Mainboard/";
$display = "Mainboards";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Memory/") {
$dir = "../Memory/";
$display = "Memory";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Monitors/") {
$dir = "";
$display = "Monitors";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Cases/") {
$dir = "../Cases/";
$display = "Cases";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Software/") {
$dir = "../Software/";
$display = "Software";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/notebooks/") {
$dir = "../notebooks/";
$display = "Notebooks";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Printers/") {
$dir = "../Printers/";
$display = "Printers";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/CPU/") {
$dir = "../CPU/";
$display = "Processors";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/controllers/") {
$dir = "../controllers/";
$display = "Controllers";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Scanners/") {
$dir = "../Scanners/";
$display = "Scanners";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
else {
$dir = "../all/";
$display = "All";
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
}
}
TIA
------------------------------
Date: Sun, 02 Sep 2001 16:16:52 GMT
From: "David Hilsee" <davidhilseenews@yahoo.com>
Subject: Re: Is there a better way of righting this...
Message-Id: <UXsk7.55194$hT4.13841227@news1.rdc1.md.home.com>
"kdgjloiureo" <noone@none.com> wrote in message
news:vrk4ptkfaeeeq81f0t1tmf07pmpj405257@4ax.com...
> Right im fairly new to perl and im sure there must be a better way of
> righting the sub below any one have any ideas as to how to make this a
> bit more efficient.
>
> sub print_record {
>
>
> if ($FORM{'select'} eq "/home/closey/secure/dBs/CD/") {
> $dir = "../CD/";
> $display = "CD's";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
>
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/CDR/") {
> $dir = "../CDR/";
> $display = "CD RW's";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
>
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Phone/") {
> $dir = "../Phone/";
> $display = "Phones";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
>
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/accessories/") {
> $dir = "../accessories/";
> $display = "Accessories";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/cable/") {
> $dir = "../cable/";
> $display = "Cables";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
>
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/gfx/") {
> $dir = "../gfx/";
> $display = "Multimedia";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/HD/") {
> $dir = "../HD/";
> $display = "Hard disk drives";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Mainboard/") {
> $dir = "../Mainboard/";
> $display = "Mainboards";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Memory/") {
> $dir = "../Memory/";
> $display = "Memory";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Monitors/") {
> $dir = "";
> $display = "Monitors";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Cases/") {
> $dir = "../Cases/";
> $display = "Cases";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Software/") {
> $dir = "../Software/";
> $display = "Software";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/notebooks/") {
> $dir = "../notebooks/";
> $display = "Notebooks";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
>
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Printers/") {
> $dir = "../Printers/";
> $display = "Printers";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
>
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/CPU/") {
> $dir = "../CPU/";
> $display = "Processors";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
>
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/controllers/") {
> $dir = "../controllers/";
> $display = "Controllers";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
>
> &print_resualts_gen;
> }
> elsif ($FORM{'select'} eq "/home/closey/secure/dBs/Scanners/") {
> $dir = "../Scanners/";
> $display = "Scanners";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
>
> else {
> $dir = "../all/";
> $display = "All";
> $price = $third_del / 1.175;
> $price2 = sprintf("%.2f", $price);
> &print_resualts_gen;
> }
>
>
> }
>
>
> TIA
The first thing that jumps out at me is the code involving $price, $price2,
and print_resualts_gen (sp?) is performed no matter which condition is true.
If this is true, then that probably shouldn't be in a conditional block at
all. Hence, at the bottom of the subroutine, after all of the "if, elsif,
else...":
$price = $third_del / 1.175;
$price2 = sprintf("%.2f", $price);
&print_resualts_gen;
The other thing that I noticed is the code involves setting two variables
based on the value of another. This could be done using a hash:
%table = (
'/home/closey/secure/dBs/CD/'
=> {
'dir' => '../CD/',
'display' => 'CD\'s'
},
'/home/closey/secure/dBs/CDR/'
=> {
'dir' => '../CDR/',
'display' => 'CD RW\'s'
},
#....and so on
);
Then the code could say something like:
$selection = $FORM{'select'};
if ( exists $table{$selection} )
{
$dir = $table{$selection}{'dir'};
$display = $table{$selection}{'display'};
}
else
{
$dir = "../all/";
$display = "All";
}
# price/price2/print code here
Hope this helps.
David Hilsee
------------------------------
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 1680
***************************************