[10084] in Perl-Users-Digest
Perl-Users Digest, Issue: 3677 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 10 10:07:26 1998
Date: Thu, 10 Sep 98 07:00:23 -0700
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, 10 Sep 1998 Volume: 8 Number: 3677
Today's topics:
File handling in perl5 <se96ms@english.iielr.dmu.ac.uk>
Re: File handling in perl5 <tchrist@mox.perl.com>
Re: File handling in perl5 <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: getting default browser from registry scott@softbase.com
Re: History of Perl - round 1 <elaine@cts.wustl.edu>
Re: History of Perl - round 1 <eashton@bbnplanet.com>
Re: How can I draw simple chart using perl? (Michael J Gebis)
Re: How can I draw simple chart using perl? <eashton@bbnplanet.com>
Re: Inheritance <tchrist@mox.perl.com>
Re: max function in perl <sam@peritas.com>
Re: Passing file handles <tchrist@mox.perl.com>
PERL newbie needs some help <duncan.b@marchcom.co.uk>
Re: PERL newbie needs some help <CHANGE_THIS@CHANGE_THIS_ALSO.ch>
Re: PERL newbie needs some help (Stefan Berglund)
Re: Perl Search Engine (Robert Bell)
Perl/Html - mixing text and graphics dogboy@doghouse.com
Re: problem with recursion in perl (Lack Mr G M)
Re: problem with recursion in perl <Tony.Curtis+usenet@vcpc.univie.ac.at>
Re: problem with recursion in perl (Mike Wescott)
replacing text in a string <mark@satch.markl.com>
Re: replacing text in a string (Mike Stok)
Re: What version does the CPAN doc document? <tchrist@mox.perl.com>
Re: Where to start? <cj.jones@zetnet.co.uk>
Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 10 Sep 1998 12:10:01 +0100
From: Mark Simonetti <se96ms@english.iielr.dmu.ac.uk>
Subject: File handling in perl5
Message-Id: <Pine.OSF.3.96.980910120611.13550M-100000@english.iielr.dmu.ac.uk>
I'm trying to write a class file which handles a file. Unfortunately,
I've come across a problem which I think may be a perl limitation !
Its a little hard to explain, but basically I wanted to store the file
handle in the object, so I could have several objects all open at once.
But perl won't let you do that !
I cant do: open($file, $filename);
I have to do: open(FILE, $filename);
Unfortunately, this makes each objects file handle not unique which it
needs to be.
Any way around this ?
Mark.
--
o----------------------------------------------o
| Mark Simonetti | Innovation Centre |
| Software Engineer | De Montfort University |
| Musician | Leicester. |
|----------------------------------------------|
| Email : se96ms@dmu.ac.uk |
| WWW : http://www.cms.dmu.ac.uk/~se96ms/ |
o----------------------------------------------o
------------------------------
Date: 10 Sep 1998 11:17:32 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: File handling in perl5
Message-Id: <6t8cgc$gpd$4@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc,
Mark Simonetti <se96ms@english.iielr.dmu.ac.uk> writes:
:I'm trying to write a class file which handles a file. Unfortunately,
:I've come across a problem which I think may be a perl limitation !
:
:Its a little hard to explain, but basically I wanted to store the file
:handle in the object, so I could have several objects all open at once.
:But perl won't let you do that !
:
:I cant do: open($file, $filename);
:I have to do: open(FILE, $filename);
:
:Unfortunately, this makes each objects file handle not unique which it
:needs to be.
use Symbol;
$sym = gensym;
open($sym, "filename");
$_ = <$sym>;
# etc.
--tom
--
echo "ICK, NOTHING WORKED!!! You may have to diddle the includes.";;
--Larry Wall in Configure from the perl distribution
------------------------------
Date: 10 Sep 1998 13:20:35 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: File handling in perl5
Message-Id: <833ea0nri4.fsf@vcpc.univie.ac.at>
Re: File handling in perl5, Mark
<se96ms@english.iielr.dmu.ac.uk> said:
Mark> I'm trying to write a class file which handles a file.
Mark> Unfortunately, I've come across a problem which I
Mark> think may be a perl limitation !
<sounds of flame throwers starting up...>
Mark> Its a little hard to explain, but basically I wanted
Mark> to store the file handle in the object, so I could
Mark> have several objects all open at once. But perl won't
Mark> let you do that !
perldoc IO::File
hth
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: 10 Sep 1998 13:18:09 GMT
From: scott@softbase.com
Subject: Re: getting default browser from registry
Message-Id: <35f7d191.0@news.new-era.net>
dlynch@morrisonscientific.com wrote:
> Does anyone know how to get the default browser from the registry?
You don't need to do this. Just system() the command "start [URL]".
The ability to launch a URL with the default browser is built into
Windows.
If you really need the browser, you can look up which program
.HTML is associated with.
Scott
--
Look at Softbase Systems' client/server tools, www.softbase.com
Check out the Essential 97 package for Windows 95 www.skwc.com/essent
All my other cool web pages are available from that site too!
My demo tape, artwork, poetry, The Windows 95 Book FAQ, and more.
------------------------------
Date: Thu, 10 Sep 1998 07:10:55 -0500
From: elaine ashton <elaine@cts.wustl.edu>
Subject: Re: History of Perl - round 1
Message-Id: <Pine.SOL.3.96.980910070954.1903K-100000@helen.cts.wustl.edu>
> That program is for a limited audience only.
It is so clever and original, surely that must have been implicit. ;)
e.
------------------------------
Date: Thu, 10 Sep 1998 12:16:54 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: History of Perl - round 1
Message-Id: <35F7C0D9.38F8AD40@bbnplanet.com>
> >Sorry. Couldn't resist. Please don't hit me.
>
> Ah, I see you've met elaine...
>
> running for cover...
David! Obviously one doesn't require physical violence to scare men as
they seem to run with only the mere suggestion. Quite simple. Tell me,
is it the sensible shoes or the luger?
e.
------------------------------
Date: 10 Sep 1998 04:54:16 GMT
From: gebis@welsh.ecn.purdue.edu (Michael J Gebis)
Subject: Re: How can I draw simple chart using perl?
Message-Id: <6t7m1o$bh3@mozo.cc.purdue.edu>
"novice" <peace1@writeme.com> writes:
}I wanna draw simple chart using perl like below but graphically.(not
}text!!!)
}(I actually wanna draw chart similar to UNIX performance meter.)
}| *** ***
}| * * * *
}| * * * *
}|* *** **
}|_______________________
}Which is the best & simple way to draw chart using perl?
http://www.cpan.org/CPAN.html#image
Specifically take a look at GD (which is probably good for simple
graphs) and PDL (which is probably overkill but can do some really
cool things a la Matlab). I've never used the PGPlot library, but
that looks promising too.
--
Mike Gebis gebis@ecn.purdue.edu mgebis@eternal.net
------------------------------
Date: Thu, 10 Sep 1998 12:24:05 GMT
From: Elaine -HappyFunBall- Ashton <eashton@bbnplanet.com>
Subject: Re: How can I draw simple chart using perl?
Message-Id: <35F7C287.BDF969D0@bbnplanet.com>
There is this wonderful package called GIFgraph. You will need GD and
perl to make it. Find it on CPAN. Martien should pipe up and champion
it. Enjoy.
e.
------------------------------
Date: 10 Sep 1998 11:04:28 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Inheritance
Message-Id: <6t8bns$gpd$2@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Brian Sayatovic" <BrianS@CGGSoftwareDOTcom> writes:
:sub new {
: my $proto = shift;
: my $class = ref($proto) || $proto;
: my $self = $class->SUPER::new;
: bless($self, $class);
: return $self;
:}
>From the Perl Cookbook:
sub new {
my $classname = shift; # What class are we constructing?
my $obref = $classname->SUPER::new(@_);
$obref->_init(@_);
return $obref; # And give it back
}
Note that SUPER only works on the first overridden method. If your
@ISA array has several classes, it only gets the first one. A manual
traversal of @ISA is possible, but probably not worth the hassle.
my $self = bless {}, $class;
for my $class (@ISA) {
my $meth = $class . "::_init";
$self->$meth(@_) if $class->can("_init");
}
This fragile code assumes that all superclasses initialize their
objects with _init() instead of initializing in the constructor.
It also assumes that a hash reference is used for the underlying
object.
At another point, the following, more specific code is shown:
sub new {
my $proto = shift;
my $class = ref($proto) || $proto;
my $parent = ref($proto) && $proto;
my $self;
# check whether we're shadowing a new from @ISA
if (@ISA && $proto->SUPER::can('new') {
$self = $proto->SUPER::new(@_);
} else {
$self = {};
bless ($self, $proto);
}
bless($self, $class);
$self->{PARENT} = $parent;
$self->{START} = time(); # init data fields
$self->{AGE} = 0;
return $self;
}
You can fetch all the code from
ftp://ftp.oreilly.com/published/oreilly/perl/cookbook/pcookexamples.tar.gz
--tom
--
Let us be charitable, and call it a misleading feature :-)
--Larry Wall in <2609@jato.Jpl.Nasa.Gov>
------------------------------
Date: Thu, 10 Sep 1998 13:20:13 +0100
From: Simon Matthews <sam@peritas.com>
Subject: Re: max function in perl
Message-Id: <35F7C3FD.41642E6D@peritas.com>
jasjeet14@my-dejanews.com wrote:
>
> How do we calculate the max or min value on particular field records in a
> database ie. if wish to display the maximum value of a field say rate in a
> database. Please help me on this.
An easy way to do this is when you get the data back from your database
use the SQL MAX function to get the data
Hope this helps
SAM
------------------------------
Date: 10 Sep 1998 11:07:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Passing file handles
Message-Id: <6t8bt5$gpd$3@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, cselton@hkp.hk (cs - Elton Kong) writes:
:I would like to know how I can pass a file handle to a sub-routine.
:I'm played with different syntax combinations to no success. Could
:anyone help? Thanks!
This is covered in the perlsub manpage, with a bit in perldata.
The 5.005 version can be found here:
http://www.perl.com/CPAN/doc/manual/html/pod/index.html
--tom
--
"No, I'm not going to explain it. If you can't figure it out,
you didn't want to know anyway..." --Larry Wall
------------------------------
Date: 10 Sep 1998 11:34:17 GMT
From: "Duncan Bates" <duncan.b@marchcom.co.uk>
Subject: PERL newbie needs some help
Message-Id: <01bddcae$e27ceca0$18646464@duncan.b>
Umm sorry for being stupid here but i have some code thats really bugging
me...
a syntax error is reported although i have done everything "to the book"
#!/usr/bin/perl
$printrun = $FORM{'printrun'};
$pages = $FORM{'pages'};
$coverpics = $FORM{'coverpics'};
$textpics = $FORM{'textpics'};
# Parse the form
&parse_form;
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}
}
# Check for zero entries
unless ($printrun == 0) { &html_die; }
# Limit the values
if ($printrun < 1000 || $printrun > 100000) { &html_die; }
# Work out the cost of printing the report
$a = (($pages) * ($printrun))
# Work out calculations for cover and textpics
if (($textpics == "0") && ($coverpics == "1")) {
$b = ($a * 1.25);
}
elsif (($textpics == "1") && ($coverpics == "0")) {
$b = ($a * 1.25);
}
elsif (($textpics == "1") && ($coverpics == "1")) {
$b = ($a * 1.25);
}
else (($textpics == "0") && ($coverpics == "0")) {
$b = ($a * 1.35);
}
this is supposed to take some figures (printrun) and multiply them with
another set of figures (pages) then work out the final calcualtion based on
whether they want cover pics text pics or both or neither...
its really got me stumped i'd appreciate any hints in the right direction
Thanks
Duncan Bates
duncan.b@marchcom.co.uk
------------------------------
Date: Thu, 10 Sep 1998 14:47:00 +0200
From: John Smith <CHANGE_THIS@CHANGE_THIS_ALSO.ch>
To: Duncan Bates <duncan.b@marchcom.co.uk>
Subject: Re: PERL newbie needs some help
Message-Id: <35F7CA44.9C7A5C66@CHANGE_THIS_ALSO.ch>
--------------C91B0A60C7906E2C4F8835E5
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Duncan Bates wrote:
> Umm sorry for being stupid here but i have some code thats really bugging
> me...
>
> a syntax error is reported although i have done everything "to the book"
>
> #!/usr/bin/perl
>
the varaible $FORM is not initialized yet
> $printrun = $FORM{'printrun'};
> $pages = $FORM{'pages'};
> $coverpics = $FORM{'coverpics'};
> $textpics = $FORM{'textpics'};
>
Here you are calling un subroutine parse_form which is not definedTo define a
subroutine you should have somewhere in your code:
sub parse_form {
code of parse_form.....
......
}to call the subroutine you should write in the main code: &parse_form; this
will execute the code of the subroutine parse_form.
> # Parse the form
> &parse_form;
>
why are you begining a bloc here ? (with the symbol '{ ' ???)
> {
> # Get the input
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
>
> # Split the name-value pairs
> @pairs = split(/&/, $buffer);
>
> foreach $pair (@pairs)
> {
> ($name, $value) = split(/=/, $pair);
>
> # Un-Webify plus signs and %-encoding
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $value =~ s/<!--(.|\n)*-->//g;
>
>
here you define the variable $FORM
> $FORM{$name} = $value;
> }
> }
>
> # Check for zero entries
> unless ($printrun == 0) { &html_die; }
>
> # Limit the values
> if ($printrun < 1000 || $printrun > 100000) { &html_die; }
>
you forgot the ; at the end of this line
> # Work out the cost of printing the report
> $a = (($pages) * ($printrun))
>
> # Work out calculations for cover and textpics
>
> if (($textpics == "0") && ($coverpics == "1")) {
> $b = ($a * 1.25);
> }
> elsif (($textpics == "1") && ($coverpics == "0")) {
> $b = ($a * 1.25);
> }
> elsif (($textpics == "1") && ($coverpics == "1")) {
> $b = ($a * 1.25);
> }
here you should use elsif instead of else
> else (($textpics == "0") && ($coverpics == "0")) {
> $b = ($a * 1.35);
> }
>
> this is supposed to take some figures (printrun) and multiply them with
> another set of figures (pages) then work out the final calcualtion based on
> whether they want cover pics text pics or both or neither...
>
> its really got me stumped i'd appreciate any hints in the right direction
>
> Thanks
>
> Duncan Bates
> duncan.b@marchcom.co.uk
Try this :
#!/usr/bin/perl
#
# call the parse_form subroutine to parse the form fields
#
&parse_form;
#
# initialisation
#
$printrun = $FORM{'printrun'};
$pages = $FORM{'pages'};
$coverpics = $FORM{'coverpics'};
$textpics = $FORM{'textpics'};
#
# this is what you would like to do
#
# Work out the cost of printing the report
$a = (($pages) * ($printrun));
# Work out calculations for cover and textpics
if (($textpics == "0") && ($coverpics == "1")) {
$b = ($a * 1.25);
}
elsif (($textpics == "1") && ($coverpics == "0")) {
$b = ($a * 1.25);
}
elsif (($textpics == "1") && ($coverpics == "1")) {
$b = ($a * 1.25);
}
elsif (($textpics == "0") && ($coverpics == "0")) {
$b = ($a * 1.35);
}
#
# definition of the subroutine parse_form
#
sub parse_form
{
# Get the input
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
# Split the name-value pairs
@pairs = split(/&/, $buffer);
foreach $pair (@pairs)
{
($name, $value) = split(/=/, $pair);
# Un-Webify plus signs and %-encoding
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$value =~ s/<!--(.|\n)*-->//g;
$FORM{$name} = $value;
}
}
good luck,
--------------C91B0A60C7906E2C4F8835E5
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
<P>Duncan Bates wrote:
<BLOCKQUOTE TYPE=CITE>Umm sorry for being stupid here but i have some code
thats really bugging
<BR>me...
<P>a syntax error is reported although i have done everything "to the book"
<P>#!/usr/bin/perl
<BR> </BLOCKQUOTE>
<FONT COLOR="#009900">the varaible $FORM is not initialized yet</FONT>
<BLOCKQUOTE TYPE=CITE>
<P>$printrun = $FORM{'printrun'};
<BR>$pages = $FORM{'pages'};
<BR>$coverpics = $FORM{'coverpics'};
<BR>$textpics = $FORM{'textpics'};
<BR><FONT COLOR="#009900"></FONT> </BLOCKQUOTE>
<FONT COLOR="#009900">Here you are calling un subroutine parse_form which
is not defined</FONT><FONT COLOR="#009900">To define a subroutine you should
have somewhere in your code:</FONT><FONT COLOR="#009900"></FONT>
<P><FONT COLOR="#009900">sub <B>parse_form</B> {</FONT>
<BR><FONT COLOR="#009900">code of parse_form.....</FONT>
<BR><FONT COLOR="#009900">......</FONT>
<BR><FONT COLOR="#009900">}</FONT><FONT COLOR="#009900">to call the subroutine
you should write in the main code: <B>&parse_form; </B>this will execute
the code of the subroutine parse_form.</FONT>
<BLOCKQUOTE TYPE=CITE>
<P># Parse the form
<BR>&parse_form;
<BR> </BLOCKQUOTE>
<B><FONT COLOR="#009900">why are you begining a bloc here ? (with the symbol
'{ ' ???)</FONT></B>
<BLOCKQUOTE TYPE=CITE>
<P>{
<BR> # Get the input
<BR> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
<P> # Split the name-value pairs
<BR> @pairs = split(/&/, $buffer);
<P> foreach $pair (@pairs)
<BR> {
<BR> ($name, $value) = split(/=/,
$pair);
<P> # Un-Webify plus signs and
%-encoding
<BR> $value =~ tr/+/ /;
<BR> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/eg;
<BR> $value =~ s/<!--(.|\n)*-->//g;
<BR>
<BR> </BLOCKQUOTE>
<FONT COLOR="#009900">here you define the variable $FORM</FONT>
<BLOCKQUOTE TYPE=CITE> $FORM{$name}
= $value;
<BR> }
<BR>}
<P># Check for zero entries
<BR>unless ($printrun == 0) { &html_die; }
<P># Limit the values
<BR>if ($printrun < 1000 || $printrun > 100000) { &html_die; }
<BR> </BLOCKQUOTE>
<B><FONT COLOR="#009900">you forgot the ; at the end of this line</FONT></B>
<BLOCKQUOTE TYPE=CITE>
<P># Work out the cost of printing the report
<BR>$a = (($pages) * ($printrun))
<P># Work out calculations for cover and textpics
<P>if (($textpics == "0") && ($coverpics == "1")) {
<BR> $b = ($a * 1.25);
<BR>}
<BR>elsif (($textpics == "1") && ($coverpics == "0")) {
<BR> $b = ($a * 1.25);
<BR>}
<BR>elsif (($textpics == "1") && ($coverpics == "1")) {
<BR> $b = ($a * 1.25);
<BR>}</BLOCKQUOTE>
<FONT COLOR="#009900">here you should use elsif instead of else</FONT>
<BLOCKQUOTE TYPE=CITE>
<P>else (($textpics == "0") && ($coverpics == "0")) {
<BR> $b = ($a * 1.35);
<BR>}
<P>this is supposed to take some figures (printrun) and multiply them with
<BR>another set of figures (pages) then work out the final calcualtion
based on
<BR>whether they want cover pics text pics or both or neither...
<P>its really got me stumped i'd appreciate any hints in the right direction
<P>Thanks
<P>Duncan Bates
<BR>duncan.b@marchcom.co.uk</BLOCKQUOTE>
<B><FONT COLOR="#009900"><FONT SIZE=+1> Try this :</FONT></FONT></B>
<BR>#!/usr/bin/perl
<BR>#
<BR># call the parse_form subroutine to parse the form fields
<BR>#
<BR>&parse_form;
<BR>#
<BR># initialisation
<BR>#
<BR>$printrun = $FORM{'printrun'};
<BR>$pages = $FORM{'pages'};
<BR>$coverpics = $FORM{'coverpics'};
<BR>$textpics = $FORM{'textpics'};
<P>#
<BR># this is what you would like to do
<BR>#
<BR># Work out the cost of printing the report
<BR>$a = (($pages) * ($printrun));
<P># Work out calculations for cover and textpics
<P>if (($textpics == "0") && ($coverpics == "1")) {
<BR> $b = ($a * 1.25);
<BR>}
<BR>elsif (($textpics == "1") && ($coverpics == "0")) {
<BR> $b = ($a * 1.25);
<BR>}
<BR>elsif (($textpics == "1") && ($coverpics == "1")) {
<BR> $b = ($a * 1.25);
<BR>}
<BR>elsif (($textpics == "0") && ($coverpics == "0")) {
<BR> $b = ($a * 1.35);
<BR>}
<P>#
<BR># definition of the subroutine parse_form
<BR>#
<BR>sub parse_form
<BR>{
<BR> # Get the input
<BR> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
<P> # Split the name-value pairs
<BR> @pairs = split(/&/, $buffer);
<P> foreach $pair (@pairs)
<BR> {
<BR> ($name, $value) = split(/=/,
$pair);
<P> # Un-Webify plus signs and
%-encoding
<BR> $value =~ tr/+/ /;
<BR> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",
hex($1))/eg;
<BR> $value =~ s/<!--(.|\n)*-->//g;
<BR> $FORM{$name} = $value;
<BR> }
<BR>}
<P>good luck,
<BR> </HTML>
--------------C91B0A60C7906E2C4F8835E5--
------------------------------
Date: 10 Sep 1998 13:25:37 GMT
From: f94stbe+news@dd.chalmers.se (Stefan Berglund)
Subject: Re: PERL newbie needs some help
Message-Id: <6t8k0h$ljl$1@eol.dd.chalmers.se>
The group comp.lang.perl is dead since long and just serves as some
"placeholder" for the top of the tree comp.lang.perl.*
comp.lang.perl.misc is where the action is!
"Duncan Bates" <duncan.b@marchcom.co.uk> wrote:
> a syntax error is reported although i have done everything "to the book"
No you haven't... :-)
Next time please supply errormessages from perl, version and platform.
As I really don't feel like disecting your code I will only give some
general hints.
These will probably overwhelm you with errors and warnings but your
program will benefit greatly from using them, not to mention that
in 6 months or so you will wish that you wrote it like this from the
very beginning.
> #!/usr/bin/perl
Should be:
#!/usr/bin/perl -w
use strict;
use diagnostics;
> $printrun = $FORM{'printrun'};
> $pages = $FORM{'pages'};
> $coverpics = $FORM{'coverpics'};
> $textpics = $FORM{'textpics'};
Each new variable should be "declared" with my as:
my $textpics = $FORM{'textpics'};
> # Parse the form
use CGI instead of doing all the form parsing "by hand".
Lookup the docs with perldoc CGI
A short example from your code:
$FORM{'textpics'} changed to conform with perl CGI module:
use CGI;
my $query = new CGI;
my $textpics = $query->param('textpics');
As you write a CGI add the -T option to perl so that the first line
becomes:
#!/usr/bin/perl -wT
This will enable taint checks which means that all input from the
a user is considerd "tainted" and certain fields of the data must be
choosen with a regexp match, consult the docs (perlsec) for more, and
accurate, info.
This will greatly enhance the security of your script as it will
prevent you from accidently executing data supplied from a user.
<code snipped>
> its really got me stumped i'd appreciate any hints in the right direction
I hope that this will help you a little bit. Don't be to alarmed with
all this, you will catch up pretty quick.
--
/Stefan
f94stbe+news@dd.chalmers.se
Life - the ultimate practical joke
finger f94stbe.pgp@dd.chalmers.se for public pgp-key
------------------------------
Date: Thu, 10 Sep 1998 13:34:24 GMT
From: rbell@hcdemocrat.com (Robert Bell)
Subject: Re: Perl Search Engine
Message-Id: <35f7d509.2267034@news.eclipse.net>
On Wed, 09 Sep 1998 15:37:36 -0300, John-Paul Arp <jpa@formalsys.ca>
wrote:
>I am working on a perl search engine for a massive and disorganized
>Intranet. (Nearly 2 gigs worth of text formatted files.)
>Is any body aware solutions that are already
>available, or have any ideas on how to organize 2 gigs worth of text
>files into a search-able index?
ICE by Christian Neuss (ice@isa.informatik.th-darmstadt.de) may do
what you want.
Robert Bell
rbell@hcdemocrat.com
------------------------------
Date: Thu, 10 Sep 1998 13:07:45 GMT
From: dogboy@doghouse.com
Subject: Perl/Html - mixing text and graphics
Message-Id: <6t7n74$3o$1@artemis.backbone.ou.edu>
I am trying to build a script that when run through a browser returns an
address and a graphic of the location. I can get the text to print perfectly,
but the second I try to add the graphic, the whole thing blows up.
I have a variable $AREA that is a letter from A to M. I'm starting the file
with the obligatory
print "Content-type: text/html\n\n";
I think this is where I'm losing myself. I then go ahead and read an ascii
file of addresses and spit out the data as asked for.
while(<ADDRESS>) {
($AREA,$ADMINISTRATOR,$ADDRESS,$PHONE) = split(':',$_);
All this works great until I try to add a map to $AREA. I add the following
and Perl generates an error.
print("<img src="/images/bitmaps/%s.gif" width=400 height=250>",$AREA);
I'm lost on this one and have read the FAQ's, scanned the usegroups and looked
just about everywhere I can think. Anybody have a suggestion?
Tom Baty
------------------------------
Date: Thu, 10 Sep 1998 13:01:16 BST
From: gml4410@ggr.co.uk (Lack Mr G M)
To: "Gary Evans" <ggy22@dial.pipex.com>
Subject: Re: problem with recursion in perl
Message-Id: <1998Sep10.130116@ukwit01>
In article <6t8apa$a2r$1@plug.news.pipex.net>, "Gary Evans" <ggy22@dial.pipex.com> writes:
|>...
|> It starts out OK but on the way out of the recursion it seems to lose the
|> ability to tell if a file is a directory or file.
|> I've tried it on NT and unix.
|> sub printdir {
|> if (chdir $_[0]){
|> foreach (<*>){
|> if (-d $_){
|> print "$_ is a directory\n";
|> &printdir($_[0] . "/" . $_);
|> }else{
|> print "$_ is a file\n";
|> }
|> }
|> }else{
|> print "error changing directory";
|> }
|> return;
|> }
You are chdir()in into directories, but never leaving them!
After the exit from the foreach (ie. at the end of the if (chdir)
clause) you need 'chdir .. or die 'Some usefule text';"
--
----------- Gordon Lack ----------------- gml4410@ggr.co.uk ------------
The contents of this message *may* reflect my personal opinion. They are
*not* intended to reflect those of my employer, or anyone else.
------------------------------
Date: 10 Sep 1998 15:08:33 +0200
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: problem with recursion in perl
Message-Id: <831zpknmi6.fsf@vcpc.univie.ac.at>
Re: problem with recursion in perl, Gary
<ggy22@dial.pipex.com> said:
Gary> I'm pretty new to perl (in fact this is the first
Gary> script I've written - and I already have problems!!).
Gary> The script below is a cut down version of the one I've
Gary> written, it's designed to recursively go through a
Gary> directory structure and print out whether it's a
Gary> directory or a file (the real version creates html
Gary> based on this information to create a directory
Gary> structure that can be navigated on the browser).
A combination of the
Find::File
and
CGI
modules would be my solution.
tony
--
Tony Curtis, Systems Manager, VCPC, | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien, | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds! | private email:
Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>
------------------------------
Date: 10 Sep 1998 09:46:07 -0400
From: wescott@cygnus.ColumbiaSC.NCR.COM (Mike Wescott)
To: "Gary Evans" <ggy22@dial.pipex.com>
Subject: Re: problem with recursion in perl
Message-Id: <x4hfygozde.fsf@cygnus.ColumbiaSC.NCR.COM>
[cc email sent]
In article <6t8apa$a2r$1@plug.news.pipex.net> Gary Evans writes:
> It starts out OK but on the way out of the recursion it seems to lose the
> ability to tell if a file is a directory or file.
> Is this a known problem?
It's a common one.
> Am I trying to do things I shouldn't?
You're not using File::Find.
> print "Content-type: text/html\n\n";
> &printdir("/home/gevans");
> sub printdir {
> if (chdir $_[0]){
> foreach (<*>){
> if (-d $_){
> print "$_ is a directory\n";
> &printdir($_[0] . "/" . $_);
> }else{
> print "$_ is a file\n";
> }
> }
chdir ".."; # reascend dir hierarchy <<<<<<<<<<<
> }else{
> print "error changing directory";
> }
> return;
> }
You enter a directory but never leave it. Except to descend into
another (lower) directory. You might want to put some error checking
with that added chdir.
--
-Mike Wescott
mike.wescott@ColumbiaSC.NCR.COM
------------------------------
Date: 10 Sep 1998 09:09:52 -0400
From: Mark Lehrer <mark@satch.markl.com>
Subject: replacing text in a string
Message-Id: <m367ewi067.fsf@satch.markl.com>
What is the best way to substitute a few characters in the middle of
a string? I am using the slowest possible method:
$foo="123abc789";
$newstr=substr($foo,0,3) . "456" . substr($foo,6);
This will be used quite heavily in a new project I'm working on, so
I would like to find a better way to replace text.
Thanks!
Mark
------------------------------
Date: 10 Sep 1998 13:44:55 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: replacing text in a string
Message-Id: <6t8l4n$pv1@news-central.tiac.net>
In article <m367ewi067.fsf@satch.markl.com>,
Mark Lehrer <mark@satch.markl.com> wrote:
>
>What is the best way to substitute a few characters in the middle of
>a string? I am using the slowest possible method:
>
>$foo="123abc789";
>
>$newstr=substr($foo,0,3) . "456" . substr($foo,6);
One way to do it might be (and this modifies the original string)
DB<1> $foo="123abc789"
DB<2> substr ($foo, 3, 3) = '456'
DB<3> X foo
$foo = 123456789
If you want to leave the original alone you could say
DB<4> $foo="123abc789"
DB<5> substr (($newstr = $foo), 3, 3) = '456'
DB<6> X foo
$foo = '123abc789'
DB<7> X newstr
$newstr = 123456789
(but I'd usually do the $foo -> $newstr assignment as a separate
statement)
Hope this helps,
Mike
--
mike@stok.co.uk | The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/ | 65 F3 3F 1D 27 22 B7 41
stok@colltech.com | Collective Technologies (work)
------------------------------
Date: 10 Sep 1998 10:57:17 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: What version does the CPAN doc document?
Message-Id: <6t8bad$gpd$1@csnews.cs.colorado.edu>
[courtesy cc of this posting sent to cited author via email]
In comp.lang.perl.misc, "Stephane Barizien" <stephane.barizien@ocegr.fr> writes:
:Is \z a 5.005 feature? If yes, where is this kind of addition documented
:(in a detailed "whatsnew for 5.005" kind of doc, maybe?) If not, what does
:this perlre.html refer to?
The feature changes are listed in the perldelta document in the same
place you found perlre, and yes, it's for the 5.005 release.
--tom
--
: 1. What is the possibility of this being added in the future?
In the near future, the probability is close to zero. In the distant
future, I'll be dead, and posterity can do whatever they like... :-) --lwall
------------------------------
Date: Wed, 09 Sep 1998 20:32:31 +0100
From: Chris Jones <cj.jones@zetnet.co.uk>
To: "Tracy Markham, N4LGH" <tracy54@earthlink.net>
Subject: Re: Where to start?
Message-Id: <35F6D7CE.91122976@zetnet.co.uk>
Hi Tracy,
If you find out where to go I would appreciate you telling me. Maybe the
apache.com site has a pointer to a newsgroup. My current little problem is
that Internet Explorer 3.02 offers to save the .pl file rather that seeing
its html output. My script is fine in MS Personal Web Server but not on
Apache which I have just started to use so its almost definately a config
problem.
Tracy Markham, N4LGH wrote:
> Which newsgroup and/or web sites would you kids suggest for a
> webmaster trying to implement Perl on an NT machine using Apache for
> Win32 ?
>
> I'm not new to NT ....
> I'm new to Apache, but have had it running a few months and it seems
> to be OK .....
> Am TOTALLY new to perl.
>
> I've downloaded the Perl for Win32, and it seems to run. If I try the
> example file in a dos window, it does what the example says.
>
> We keep geting "internal Server Error"s from attempts to write back to
> an html file. My HTML developer swears the Perl script should work,
> and that my server is not configured properly.
>
> Where to go?? I know this is probably not the appropriate group for
> the question, but alas, I'm lost ....
>
> Tracy Markham
CJ
========= Chris Jones = CJ.Jones@zetnet.co.uk =================
==FS Ate my web site=== http://www.users.zetnet.co.uk/cj_jones/
------------------------------
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 3677
**************************************