[17045] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4457 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 28 09:10:33 2000

Date: Thu, 28 Sep 2000 06:10:16 -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: <970146616-v9-i4457@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 28 Sep 2000     Volume: 9 Number: 4457

Today's topics:
        Improving Script Efficiency <waltonic@earbuzz.demon.co.uk>
    Re: Improving Script Efficiency (Tony L. Svanstrom)
    Re: Improving Script Efficiency <waltonic@earbuzz.demon.co.uk>
    Re: Improving Script Efficiency (Tony L. Svanstrom)
    Re: Is this routine OK? brianr@liffe.com
    Re: lowercase and UPPERCASE <hartleh1@westat.com>
    Re: MySQL vs. mSQL <fty@mediapulse.com>
        Newbie question about files <a4232.vollsaeter@sporveien.oslo.no>
    Re: Newbie question about files (Bernard El-Hagin)
        newbie: href and perl <hmacdonald@europarl.eu.int>
    Re: newbie: href and perl (Rafael Garcia-Suarez)
    Re: newbie: href and perl <hmacdonald@europarl.eu.int>
    Re: newbie: href and perl <anders@wall.alweb.dk>
    Re: newbie: href and perl (Tony L. Svanstrom)
    Re: Perl & SQL Server <fty@mediapulse.com>
        Perl & TK <alesr@siol.net>
    Re: perlscript .pl ------>>  perlscript.EXE ....compila <Master@sdswebspace.com>
    Re: REGEX problem <bart.lateur@skynet.be>
    Re: REGEX problem (Keith Calvert Ivey)
    Re: retrieve the date and size of a file running pim53@my-deja.com
    Re: SPAM SPAM SPAM SPAM SPAM SPAM SPAM <nico@monnet.to>
        steps to find memoryleaks? gumbygumbygumby@my-deja.com
        subroutines, print to a file not happening, cgi tjmurphy9677@my-deja.com
    Re: Substituting $variable strings in a file nobull@mail.com
        utf8 - file io with 5.6.0 <heiko.ahnert@intershop.de>
    Re: What is %{$_} <bart.lateur@skynet.be>
        Where is NDBM_File.pm? innoventures@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 28 Sep 2000 12:14:26 +0100
From: "Adam T Walton" <waltonic@earbuzz.demon.co.uk>
Subject: Improving Script Efficiency
Message-Id: <970139547.7141.0.nnrp-01.d4e441b4@news.demon.co.uk>

Hello everyone

I recently wrote a CGI script that would allow you to visit a web page,
enter the date of your birth (via a form and drop-down menus), with the
script returning the artist and title of the number one song on that date to
the browser. The script has run successfully for a couple of months now;
however, yesterday my ISP (Apache Unix server) disabled the script because
it was (in their words) "bringing our server to its knees". The script (in
its entirety below) opens a text file (based on parameters entered into the
HTML form) that, at most, is 2 - 300 bytes long!!!! Unless there were
thousands of accesses in a very short time I can't imagine this causing the
server a problem. Could someone scan through the code and point out to me
why it is so inefficient????

Thanks very much,

Adam Walton

PS Apologies for the length of this posting, I just don't know which part of
the script is responsible for the inefficiency, so thought it would be best
to post it in its entirety!

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


#!/usr/local/bin/perl -T

use CGI qw(:standard);
use CGI::Carp;
# qw(fatalsToBrowser);
use strict;


# call checkparams sub to get day, month and year info from <html> form
my ($tday, $tmonth, $tyear)=&checkparams();
# open .txt file containing number one info and report information
&open($tday, $tmonth, $tyear);

sub checkparams()
{
# initialise hash associating months with the right amount of days
my %monthdays= (JAN=>31, FEB=>28, MAR=>31, APR=>30, MAY=>31, JUN=>30,
JUL=>31, AUG=>31, SEP=>30, OCT=>31, NOV=>30, DEC=>31);

# initialise scalars to contain day / month / year information from
cgi.param values
my $tday=param('day');
my $tmonth=param('month');
my $tyear=param('year');

# using back references to untaint the info
$tday=~/(\d{1,2})/;
$tday=$1;
$tmonth=~/(\w{1,3})/;
$tmonth=$1;
$tyear=~/(\d{4})/;
$tyear=$1;

# check that all the required params are present and correct
if (!$tday) {&badnews(0);}
if (!$tmonth) {&badnews(1);}
if (!$tyear) {&badnews(2);}

# check that the $tday value doesn't exceed max days for the month ie 31
days in february!
my $maxday=$monthdays{$tmonth};


# check to see whether the year chosen is a leap year
if (($tyear%4==0) && ($tmonth eq "FEB")) {$maxday=29;}
if ($tday>$maxday) {&badnews(3);}

# check that we have chart information for that particular year (ie after
November 14 1952)
if($tyear<=1951) {&badnews(4);}
if(($tyear==1952) && (($tmonth ne "NOV") && ($tmonth ne "DEC")))
{&badnews(4);}
if( ($tyear==1952) && ($tmonth eq "NOV") && ($tday<14) ) {&badnews(4);}


# check that the date chosen isn't 'in the future'!
if ($tyear>2000) {&badnews(6);}

# return scalar amounts for day / month and year
return $tday, $tmonth, $tyear;
}

sub open()

{
# grab day / month and year from arguments array
my ($tday, $tmonth, $tyear)=@_;

# turn the month and year scalars into a filename relating to .txt file in
database
my $fname=$tmonth.$tyear.".txt";
$/="\n";

# change to the directory hosting the number one information
chdir  '###placebo directory path###' or &badnews(6);

# open the relevant .txt file containing number 1 info
open (OUTFILE, $fname) or &badnews(5);

# lock .txt file so that there are no data accessing problems
flock OUTFILE,2;

# loop through the .txt file a line at a time until we find the relevant
information
while (<OUTFILE>)
 {
 chomp (my $sday=<OUTFILE>);
 chomp (my $eday=<OUTFILE>);
 chomp (my $artist=<OUTFILE>);
 chomp (my $title=<OUTFILE>);

 # check the date info against the info contained in the file and extract
relevant artist and title info
 &check($tday, $tmonth, $tyear, $sday, $eday, $artist, $title);
 }


# close the .txt file and unlock it for others to access it
close OUTFILE;
flock OUTFILE,8;
}


# check that the dates match, report the number one info
sub check()
{
my ($tday, $tmonth, $tyear, $sday, $eday, $artist, $title)=@_;
if (  ($tday>=$sday)&&($tday<=$eday) ) { &report ($tday, $tmonth, $tyear,
$sday, $eday, $artist, $title); }
}

# report the number one information back to the browser
sub report()
{
my ($tday, $tmonth, $tyear, $sday, $eday, $artist, $title)=@_;


# work out the date postfix to follow numeric date
my %postfix= (0=>"th",1=>"st", 2=>"nd",3=>"rd", 4=>"th", 5=>"th", 6=>"th",
7=>"th", 8=>"th", 9=>"th");
my %mname= (JAN=>"January", FEB=>"February", MAR=>"March", APR=>"April",
MAY=>"May", JUN=>"June", JUL=>"July", AUG=>"August", SEP=>"September",
OCT=>"October", NOV=>"November", DEC=>"December");
my $copy=$tday;
my $post=chop($copy);
my $pfix=$postfix{$post};
my $mts=$mname{$tmonth};
if ($tday==11)
  {
  $pfix="th";
  }
if ($tday==12)
  {
  $pfix="th";
  }

if ($tday==13)
  {
  $pfix="th";
  }


# generate <html> header
&dohead("Number 1 on the $tday$pfix $mts $tyear.\n");

# generate <html> table for formatting purposes
&dotable;
print "<font face=\"Arial,Helvetica,Geneva,Swiss,SunSans-Regular\"
size=\"3\" color=\"#FFFF66\">\n";
print "<b>The number 1 on the  <font color=\"#00FFFF\">$tday<sup>$pfix</sup>
$mts $tyear<font color=\"#FFFF66\"> was \n";
print "<b><font color=\"#ffffff\"><u> $title<font color=\"#FFFF66\"></u> by
<u><font color=\"#ffffff\"><u>$artist</u></b>\n";

# generic 'Thanks for using...' info and link back to main site
&thefooter;

# generate end of table
&endtable;
die;
}

sub dohead {
my $htitle=$_[0];
print header;
print start_html($htitle);
print "<body bgcolor=\"#1e90ff\"
background=\"../images/bgline_blue.gif\">\n";
&dopara();
print "<font face=\"Arial,Helvetica,Geneva,Swiss,SunSans-Regular\"
size=\"2\" color=\"#ffffff\">\n";

}

sub dopara {
 print "<P ALIGN=\"CENTER\">";
}

sub dotable {
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
width=\"100\%\" height=\"100%\">\n";
print "<tr><td align=\"center\" valign=\"middle\">\n";
print "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"
width=\"350\">\n";
print "<tr><td><P ALIGN=\"CENTER\">\n";
}

sub endtable {
print "</b></td></tr></table>\n";
print "</td></tr></table>\n";
}

sub thefooter {
print "<P ALIGN=\"CENTER\">\n";
print "<font color=\"#ffffff\"
face=\"Arial,Helvetica,Geneva,Swiss,SunSans-Regular\"
size=\"2\"></u></b>Thanks for using <a
href=\"http://www.***placebodomainname***.com/tdcontent_1.html\"><font
color=\"#00FFFF\">www.***placebodomainname***.com</a></font>\n";
print end_html;
}

# error reporting subroutine
sub badnews()
{
my $astri='Please choose the ';
my $bstri=' from the drop-down menu.';
my @errorm=("${astri}day$bstri", "${astri}month$bstri",
"${astri}year$bstri", "There aren't that many days in the month!", "The
British Hit Singles charts did not begin until 14th November 1952, I'm
afraid there was no number one on your birthday!", "Please try again using a
date after 14/11/52 and only up to last week's charts.", "Cannot access the
information directory please inform the webmaster.");

my $err=$_[0];
&dohead('***placebodomainname***.com problems with data');
&dotable;
print "<font color=\"#ffffff\"
face=\"Arial,Helvetica,Geneva,Swiss,SunSans-Regular\"><size=\"2\"><b>$errorm
[$err]</b></font>";
dopara();
print "<font color=\"#ffffff\"
face=\"Arial,Helvetica,Geneva,Swiss,SunSans-Regular\"><size=\"2\"><b>CLICK
\n";
print "<a href=\"http://www.***placebodomainname***.com/cont/choose.html\"
target=\"td_content\"><font color=\"#00ffff\">HERE </a><font
color=\"#ffffff\">\n";
print "To have another go.\n";
&thefooter;
&endtable;
die;
}





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

Date: Thu, 28 Sep 2000 13:42:12 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Improving Script Efficiency
Message-Id: <1eho8jx.r2lj001ydcu7pN%tony@svanstrom.com>

Adam T Walton <waltonic@earbuzz.demon.co.uk> wrote:

> I recently wrote a CGI script that would allow you to visit a web page,
> enter the date of your birth (via a form and drop-down menus), with the
> script returning the artist and title of the number one song on that date
> to the browser. The script has run successfully for a couple of months
> now; however, yesterday my ISP (Apache Unix server) disabled the script
> because it was (in their words) "bringing our server to its knees". The
> script (in its entirety below) opens a text file (based on parameters
> entered into the HTML form) that, at most, is 2 - 300 bytes long!!!!
> Unless there were thousands of accesses in a very short time I can't
> imagine this causing the server a problem. Could someone scan through the
> code and point out to me why it is so inefficient????

I took a quick look at it and didn't like it at all. If you prepare the
data a lil bit better before running the script on it it will be much
easier on the server; you could get it down to a simple:

1. Accept date and clean it up (ie a simple s/// to remove
        anything dangerous that might have been sent to the script).
2. Open and directly print the file yymmdd.txt


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Thu, 28 Sep 2000 13:12:24 +0100
From: "Adam T Walton" <waltonic@earbuzz.demon.co.uk>
Subject: Re: Improving Script Efficiency
Message-Id: <970143231.20558.0.nnrp-13.d4e441b4@news.demon.co.uk>

Thanks for looking at it Tony but it has to be slightly more complicated
than I was indicating. The script will eventually offer people the chance to
check out Number 1 single and album information for whatever country they
come from in the world, hence the need to have .txt files that contain a
month's number 1 information at a time (which the script then has to search
through to find the information correct for that particular day). If I had
simple one line text files containing Number 1 information for every day of
the year since 1952 (albums, singles, different countries) as you are
perhaps recommending, then I would end up with tens of thousands of files...
48*365*however many countries I implement! It might be easier on the server,
but the administration of such a site would be a nightmare!

Also, if I stripped the script down to the bare necessities as you describe
below, there would be no error checking on the parameters coming in from the
HTML form. Because of the idiosyncratic nature of our calendar... leap
years, different amount of days per month etc etc... plus the fact that
chart information for different countries / albums and singles starts on
different days means that the bulky and cumbersome error checking is vital
to keep the script user-friendly. Maybe this is the difficult choice you
have to make when you write a CGI script... balancing user friendliness with
efficiency!

I'm keen to know what it is in the script that is using so many server /
system resources... too many variables? nested subroutines? I know that the
report subroutine is very unwieldly, but surely that isn't enough to slow
the script down? The data IS in the simplest and most usable format, I think
the problem stems from the script's popularity, and its scripting style...
although it adheres to both strict and taint pragmas that are considered
good practice for CGI scripts. Is there any way I can cut down on the amount
of system memory I am using?

Anyway, thanks for looking Tony, I should have described the nature of the
script better,

Adam


> I took a quick look at it and didn't like it at all. If you prepare the
> data a lil bit better before running the script on it it will be much
> easier on the server; you could get it down to a simple:
>
> 1. Accept date and clean it up (ie a simple s/// to remove
>         anything dangerous that might have been sent to the script).
> 2. Open and directly print the file yymmdd.txt
>
>
>      /Tony
> --
>      /\___/\ Who would you like to read your messages today? /\___/\
>      \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
>  --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
>    on the verge of frenzy - i think my mask of sanity is about to slip
>  ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
>     \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/




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

Date: Thu, 28 Sep 2000 14:36:43 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: Improving Script Efficiency
Message-Id: <1ehob4e.13dgzj91cn33s0N%tony@svanstrom.com>

Adam T Walton <waltonic@earbuzz.demon.co.uk> wrote:

> Thanks for looking at it Tony but it has to be slightly more complicated
> than I was indicating. The script will eventually offer people the chance
> to check out Number 1 single and album information for whatever country
> they come from in the world, hence the need to have .txt files that
> contain a month's number 1 information at a time (which the script then
> has to search through to find the information correct for that particular
> day). If I had simple one line text files containing Number 1 information
> for every day of the year since 1952 (albums, singles, different
> countries) as you are perhaps recommending, then I would end up with tens
> of thousands of files... 48*365*however many countries I implement! It
> might be easier on the server, but the administration of such a site would
> be a nightmare!

It doesn't have to be a nightmare to take care of such a site, it
actually wouldn't have to look any different than any other solution to
the same problem; it's just a matter about how you implement it. What
you need to do is to have a look at databases.

In it's most simple form you could simply use a tie:d hash.

And whatever you do don't be afraid of having to rewrite your solution
later on. You can't be prepared for everything, so I suggest that you
quickly get it back online using my first suggestion and then keep on
working on the rest. That way you don't lose anything visitors of this
while working on it; and you can simply use a second action-tag when
adding a second country... Then when you've rewritten your solution to
use a database-powered engine you simply switch over to that.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: 28 Sep 2000 13:29:27 +0100
From: brianr@liffe.com
Subject: Re: Is this routine OK?
Message-Id: <vtsnqkn1i0.fsf@liffe.com>

"Rick Freeman" <rick@iwtools.com> writes:

> I use this little routine quite a bit in various scripts to save data
> to disk (in my quirky but useful datafile formats).  I'm not very savy
> about file locking and concurrent file accesses, though, and wonder if
> I'm doing enough to avoid troubles. Would greatly appreciate feedback
> on that issue and anything else you see here.  I'm including the
> routines I use to read the data files, as well, just for reference.
> Of course, if anyone likes, feel free to use these :-)

[code snipped]

In addition to other comments re your code, is there any reason why
you don't use Data::Dumper?

-- 
Brian Raven
It's, uh, pseudo code.  Yeah, that's the ticket...
[...]
And "unicode" is pseudo code for $encoding.  :-)
             -- Larry Wall in <199808071717.KAA12628@wall.org>


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

Date: Thu, 28 Sep 2000 08:19:19 -0400
From: Henry Hartley <hartleh1@westat.com>
Subject: Re: lowercase and UPPERCASE
Message-Id: <39D33747.D95C605B@westat.com>

Richard Bossart wrote:
> 
> I'd like to compare an array of data with a single word independant of
> whether its UPPERCASE or lowercase. So far I have
> 
> for(@data)
>    {
>     if(/$name/)
>      {
>       print $_, "<br>";
>      }
>     }
> 
> If data is eg.. John, Marius, Peter, Hannah, then it will find Peter but
> not PETER or peTer... how can I correct this ?

if ( lc($name) eq lc ) {

Henry Hartley


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

Date: Wed, 27 Sep 2000 10:15:09 -0400
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: MySQL vs. mSQL
Message-Id: <8qsvfq$jje$1@news3.icx.net>

check out:
http://www.mysql.com/information/benchmarks.html
http://www.mysql.com/information/crash-me.php

jay
"Young Chi-Yeung Fan" <yf32@cornell.edu> wrote in message
news:39D152CF.BFD97C80@cornell.edu...
> Want to add a few related questions...what's the best free database to use
for
> web sites, and why? How does it / do they compare to databases like
Oracle's?
>
> Michael Satkevich wrote:
>
> > Is MySQL better than mSQL?  I see more books and references to MySQL, so
I
> > am beginning to think I should be using MySQL.
> >
> > So far I have used mSQL on 2 sites.  Should I switch to MySQL?
> >
> > Is another free database even better?  PostGre??
> >
> > -Mike
>



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

Date: Thu, 28 Sep 2000 09:12:40 +0200
From: "Glenn Vollsæter" <a4232.vollsaeter@sporveien.oslo.no>
Subject: Newbie question about files
Message-Id: <zcCA5.1611$o9.27770@news1.online.no>

just wondering how to delete a file in Perl. I can't seem to find a suitable
function for this. I trust there is one!

Can someone help me?

Glenn




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

Date: 28 Sep 2000 07:15:36 GMT
From: bernard.el-hagin@lido-tech.net (Bernard El-Hagin)
Subject: Re: Newbie question about files
Message-Id: <slrn8t5s0n.48l.bernard.el-hagin@gdndev25.lido-tech>

On Thu, 28 Sep 2000 09:12:40 +0200, Glenn Vollsæter
<a4232.vollsaeter@sporveien.oslo.no> wrote:
>just wondering how to delete a file in Perl. I can't seem to find a suitable
>function for this. I trust there is one!
>
>Can someone help me?

perldoc -f unlink

Cheers,
Bernard
--
perl -le 'open JustAnotherPerlHacker,""or$_="B$!e$!r$!n$!a$!r$!d$!";
print split/No such file or directory/;'


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

Date: Thu, 28 Sep 2000 11:00:19 +0200
From: macdo <hmacdonald@europarl.eu.int>
Subject: newbie: href and perl
Message-Id: <39D308A3.2014B669@europarl.eu.int>

Hi,
I am using CGI.pm and need to define my own GIF for the submit button (
from within a perl script).

At the moment I use
    print $q->p($q->submit("Login"));
But it gives me the standard submit button.

If I use
    print " <a href=\"my.pl\"><img src=\"my.gif\"></a>";
then the actual 'submit' never occurs.


EG :-
    print $q->start_form;
    print $q->p("User I.d.",
                  $q->textfield(-name => 'enter text',
                              ));
    print $q->p($q->submit("Do it"));
    print $q->end_form;

Any help would be much appreciated

Harry



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

Date: Thu, 28 Sep 2000 09:08:49 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: newbie: href and perl
Message-Id: <slrn8t631i.j6c.rgarciasuarez@rafael.kazibao.net>

macdo wrote in comp.lang.perl.misc:
>Hi,
>I am using CGI.pm and need to define my own GIF for the submit button (
>from within a perl script).
>
>At the moment I use
>    print $q->p($q->submit("Login"));
>But it gives me the standard submit button.
>
>If I use
>    print " <a href=\"my.pl\"><img src=\"my.gif\"></a>";
>then the actual 'submit' never occurs.

This is more an HTML question than a perl one.
Go ask in a more appropriate newsgroup, e.g.
comp.infosystems.www.authoring.html or comp.infosystems.www.authoring.cgi.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Thu, 28 Sep 2000 11:34:33 +0200
From: macdo <hmacdonald@europarl.eu.int>
Subject: Re: newbie: href and perl
Message-Id: <39D310A8.645C605C@europarl.eu.int>

I don't think this is an HTML question at all.
To do this in HTML is trivial. Infact it has already been done in my text
below.

But it has to be done in perl.
The only way I can think of it being possible is to rewrite some of the Perl
module CGI.pm
The problem comes from the limitations of the Perl CGI.pm submit function.

Harry
----------------------------------------
Rafael Garcia-Suarez wrote:

> macdo wrote in comp.lang.perl.misc:
> >Hi,
> >I am using CGI.pm and need to define my own GIF for the submit button (
> >from within a perl script).
> >
> >At the moment I use
> >    print $q->p($q->submit("Login"));
> >But it gives me the standard submit button.
> >
> >If I use
> >    print " <a href=\"my.pl\"><img src=\"my.gif\"></a>";
> >then the actual 'submit' never occurs.
>
> This is more an HTML question than a perl one.
> Go ask in a more appropriate newsgroup, e.g.
> comp.infosystems.www.authoring.html or comp.infosystems.www.authoring.cgi.
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/



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

Date: Thu, 28 Sep 2000 12:04:21 +0200
From: Anders Lund <anders@wall.alweb.dk>
Subject: Re: newbie: href and perl
Message-Id: <LJEA5.41$MD.156@news010.worldonline.dk>

macdo wrote:

> I don't think this is an HTML question at all.
> To do this in HTML is trivial. Infact it has already been done in my text
> below.
> 
> But it has to be done in perl.
> The only way I can think of it being possible is to rewrite some of the
> Perl module CGI.pm
> The problem comes from the limitations of the Perl CGI.pm submit function.
> 

Read the CGI.pm docs
Read the CGI.pm docs
Read the CGI.pm docs

print $q->image_button(-name=>'bla' -src=>'bla.gif');

-anders

-- 
[ the word wall - and the trailing dot - in my email address
is my _fire_wall - protecting me from the criminals abusing usenet]


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

Date: Thu, 28 Sep 2000 12:43:18 +0200
From: tony@svanstrom.com (Tony L. Svanstrom)
Subject: Re: newbie: href and perl
Message-Id: <1eho5xh.1lbxyk21mgteo0N%tony@svanstrom.com>

macdo <hmacdonald@europarl.eu.int> wrote:

> Rafael Garcia-Suarez wrote:
> 
> > macdo wrote in comp.lang.perl.misc:
> > >Hi,
> > >I am using CGI.pm and need to define my own GIF for the submit button (
> > >from within a perl script).
> > >
> > >At the moment I use
> > >    print $q->p($q->submit("Login"));
> > >But it gives me the standard submit button.
> > >
> > >If I use
> > >    print " <a href=\"my.pl\"><img src=\"my.gif\"></a>";
> > >then the actual 'submit' never occurs.
> >
> > This is more an HTML question than a perl one.
> > Go ask in a more appropriate newsgroup, e.g.
> > comp.infosystems.www.authoring.html or comp.infosystems.www.authoring.cgi.

> I don't think this is an HTML question at all.
> To do this in HTML is trivial. Infact it has already been done in my text
> below.

Don't quote jeopardy-style; it's considered a bad thing to do.

Besides, you don't even understand how it's done in HTML; so to begin
with you have to learn HTML and then you should read the CGI.pm
documentation.


     /Tony
-- 
     /\___/\ Who would you like to read your messages today? /\___/\
     \_@ @_/  Protect your privacy:  <http://www.pgpi.com/>  \_@ @_/
 --oOO-(_)-OOo---------------------------------------------oOO-(_)-OOo--
   on the verge of frenzy - i think my mask of sanity is about to slip
 ---ôôô---ôôô-----------------------------------------------ôôô---ôôô---
    \O/   \O/  ©99-00 <http://www.svanstrom.com/?ref=news>  \O/   \O/


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

Date: Wed, 27 Sep 2000 09:38:23 -0400
From: "Jay Flaherty" <fty@mediapulse.com>
Subject: Re: Perl & SQL Server
Message-Id: <8qstas$9ho$1@news3.icx.net>

install DBI and DBD::ODBC (use ppm) then read the docs located at
\Perl\html\site\lib

jay
"Neb" <berube@odyssee.net> wrote in message
news:sz7A5.496$hs2.20197@news.globetrotter.net...
> Hi,
>
> In the project I'm working on, I must be able to use SQL Server via ODBC
to
> make my Perl program interact with a database.  Can someone refer me to
> documentation about this?
>
> Thanks,
>
> Neb
>
>
>



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

Date: Thu, 28 Sep 2000 14:29:02 +0200
From: marvin <alesr@siol.net>
Subject: Perl & TK
Message-Id: <39D3398C.71DF@siol.net>

Hi !

I need to make a program in TK/TCL which would actuall
supervise a specified TCP/IP port and output everything it comes in
to a ListBox.
So now I have this part of code to create a listbox with 3 buttons:

use IO::Socket;
use Tk;

my $PORT=1900;

$mw=MainWindow->new;
$mw->title("TCP/IP Console");
$lb=$mw->Scrolled("Listbox")->pack(-expand=>1);
$mw->Button(-text=>"Start",-command=>\&begintrace)->pack(-side=>'right');
$mw->Button(-text=>"Stop",-command=>\&endtrace)->pack(-side=>'right');
$mw->Button(-text=>"Exit",-command=>\&endall)->pack(-side=>'right');
MailLoop;

sub begintrace
{
   ... opening TCP/IP connection
   ... listening for data in put all in Listbox
}

sub endtrace
{
   ... closing TCP/IP connection
}

sub endall
{
   exit;
}

The problem is that when I click on START button, event
steps into begintrace and is inside forever.
So I put before openint TCP/IP connection following code:

defined($PID=fork) or die "Cannot fork"
return if $PID;
setsif;

Now, when I press START button, procedure creates its child, but
now child doesnt see $lb .

Any help or hint would be appreciated.

Thanks


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

Date: Thu, 28 Sep 2000 05:19:21 -0400
From: "MASTER" <Master@sdswebspace.com>
Subject: Re: perlscript .pl ------>>  perlscript.EXE ....compilation
Message-Id: <W%DA5.31392$Z2.458655@nnrp1.uunet.ca>

Just went to that site www.indigostar.com   and has some great
stuff........thanks for the site... I really like the sendmail for win2k



"Mike Patton" <mpatton@acuitymedia.com> wrote in message
news:39D0C39B.CC2EB47C@i-report-spammers.acuitymedia.com...
> Yeah, check out perl2exe, available at www.indigostar.com
>
>
>
> mAdtriX23 wrote:
> >
> > Is there any way of compiling pelscripts into exe format ???????




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

Date: Thu, 28 Sep 2000 07:46:25 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: REGEX problem
Message-Id: <hmt5tsggc14majtdf3ono4ur8q9kdd1jra@4ax.com>

Gary E. Ansok wrote:

>Actually, to do the operation as requested it should be
>
>        tr/./ /s;

Oops, you're right. The example replacement for "..." looked a bit
narrow to me, but I blamed in on the proportional font. Spaces are
always narrower than any letter for such fonts. It turns out that
indeed:

:   ie. "." becomes " ", "...." becomes " ".

there's ONE space on the right side for both.

So:

	tr/./ /s;
or
	s/\.+/ /g;

-- 
	Bart.


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

Date: Thu, 28 Sep 2000 11:56:40 GMT
From: kcivey@cpcug.org (Keith Calvert Ivey)
Subject: Re: REGEX problem
Message-Id: <39d3315e.39478659@news.newsguy.com>

Bart Lateur <bart.lateur@skynet.be> wrote:

>Oops, you're right. The example replacement for "..." looked a bit
>narrow to me, but I blamed in on the proportional font.

You're reading Usenet (especially a programming newsgroup) in a
proportional font!?  Watch out, you'll be drifting into Jeopardy
posting next.  And then comes posting in HTML.

-- 
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC


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

Date: Thu, 28 Sep 2000 08:55:32 GMT
From: pim53@my-deja.com
Subject: Re: retrieve the date and size of a file running
Message-Id: <8qv123$ju6$1@nnrp1.deja.com>

In article <8qtco4$a2p$1@nnrp1.deja.com>,
  Glenn West <westxga@my-deja.com> wrote:
> In article <8qt6lf$4ao$1@nnrp1.deja.com>,
>   pim53@my-deja.com wrote:
> > Hi,
> > I want to retrieve the date of last modification
> > of a file and its size.
> > So I used -s and -M to get that.
> > But somehow, for a file that is running at the
> > same time this test return that the file doesn't
> > exist even it does.
> > SO I used th `ls`command but I cannot get a full
> > date like 09/27/2000 17:45:56
> > How can I do?
> > Thanks...
>
> perldoc -f stat
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

`stat` doesn't work since the file doesn't exist from the Perl script!


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 28 Sep 2000 10:47:37 +0100
From: "Nicolas MONNET" <nico@monnet.to>
Subject: Re: SPAM SPAM SPAM SPAM SPAM SPAM SPAM
Message-Id: <fHDA5.133$S3.4631@tengri.easynet.fr>

What the fuck was "Alan J. Flavell" <flavell@mail.cern.ch> trying to say:

> (whatever became of NoCem...?)

It worked fine for me, until you guys perpetuated this spammer's
message to the world ... 

-- 
perl -e 'print `echo Just a Lame Perl Luser | gzip -9 | cat | gzip -cd`'



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

Date: Thu, 28 Sep 2000 08:10:51 GMT
From: gumbygumbygumby@my-deja.com
Subject: steps to find memoryleaks?
Message-Id: <8quue9$i9r$1@nnrp1.deja.com>

Hi, i am curious about some resource on how to try to track down
memoryproblems.
I have problems with a script that seems to take to much memory.
I have made everything locally where possible, i have two packages, and
one of them has to access the other (have made a package for
Html::Parser, and it store the data in %main::items)
i suspect that this might be the problem; i parser several sgml-files,
and after each file i do an
undef %items;
will this really free the space taken by %items?

any tips for what one primarily shall look for to find memoryproblems,

cheers.

/carl


********************************************************************
*      *      My webpage about the author Tom Holt:                *
*     /_\     http://hem.passagen.se/gumby/holt/                   *
*  { ~._.~ }  Bookreviews can be found at: http://go.to/10         *
*   (  Y  )   other things like SF/Fantasy-articles & biographies  *
*  ( )~*~( )  and heaps of musiclinks can be found at              *
*  (__)-(__)  http://hem.passagen.se/gumby/                        *
********************************************************************


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 28 Sep 2000 10:59:39 GMT
From: tjmurphy9677@my-deja.com
Subject: subroutines, print to a file not happening, cgi
Message-Id: <8qv8ap$p2n$1@nnrp1.deja.com>

strange problem. i'm trying to write data to a file from a perl cgi
script (apache web server on NT) and its not writing anything to the
file that orginates from a subroutine.

the file is opened ok and if i add a line
print ERROR_STORE_FD "test";
which is not included in a subroutine, this will get written to the
file ok

any help appreciated,

heres a copy of file i'm working with

#!perl -wT

use CGI qw(:standard);

print <<EOD;
Content-type: text/html;

<!DOCTYPE HTML PUBLIC \"-//IETF//DTD HTML//EN\">
<html>
<head>
<title>sfd monitoring!</title>

</head>
EOD

$ERROR_STORE_FILE="error_store.txt";
&open_error_store;
&print_file_stat("sfd_errors.txt;");
close(ERROR_STORE_FD);

sub open_error_store {
  open(ERROR_STORE_FD,">$ERROR_STORE_FILE") || die ("Failed to Open
File $!");
}

sub print_file_stat {
  my $var="";
  my $dev=0;
  my $ino=0;
  my $mode="";
  my $nlink=0;
  my $uid=0;
  my $gid=0;
  my $rdev="";
  my $size=0;
  my $atime=0;
  my $ctime=0;
  my $blocks=0;
  my $blksize=0;


($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$blks
ize,$blocks) = stat $_[0];
  print ERROR_STORE_FD "$_[0]:$mode:$size:$mtime\n";
  print ("<P>File: $_[0]:$mode:$size:$mtime\n</P>");
}


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 28 Sep 2000 12:28:10 +0100
From: nobull@mail.com
Subject: Re: Substituting $variable strings in a file
Message-Id: <u9n1gs92np.fsf@wcl-l.bham.ac.uk>

Drew Simonis <dsimonis@fiderus.com> writes:

> tebrusca@my-deja.com wrote:
> > 
> > I want to embed variable names in a file
> > then read the file and have the variables
> > interpreted.
> 
> This is a FAQ.  Have you looked there?

Not only is it a FAQ, but is asked at least once a week.  The answer
in the FAQ is arguably actually not the best answer so it pays to read
the last half-dozen threads on this question too.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Thu, 28 Sep 2000 14:33:18 +0200
From: Heiko Ahnert <heiko.ahnert@intershop.de>
Subject: utf8 - file io with 5.6.0
Message-Id: <39D33A8E.93402BA@intershop.de>

This is a multi-part message in MIME format.
--------------03751F1B9269917D5836449A
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hi out there,

I'm trying to write and read a file with some unicode chars.

How to make perl (5.6.0/5.7.0) understand that the data stored in the
file are in unicode?

Any pointers are welcome.

Heiko

--------------03751F1B9269917D5836449A
Content-Type: application/x-unknown-content-type-pmfile;
 name="io_test.pm"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
 filename="io_test.pm"

dXNlIHN0cmljdDsNCnVzZSB3YXJuaW5nczsNCnVzZSB1dGY4Ow0KDQojIDFCeXRlIGNoYXJz
IDAuLjEyNw0KIyAyQnl0ZSBjaGFycyAxMjguLjIwNDcNCiMgM0J5dGUgY2hhcnMgMjA0OC4u
NjU1MzMNCg0KbXkgJEM7DQoNCnByaW50ICI+Pj4+PiBPVVQgPDw8PDxcblxuIjsNCg0Kb3Bl
biBGLCAiPmlvLnR4dCIgb3IgZGllICJPb3BzIC0gb3V0ISAoJCEpIjsNCg0KZm9yZWFjaCAo
IDEyNi4uMTI5LCAyMDQ2Li4yMDQ5ICkgew0KICAgIA0KICAgICRDID0gY2hyKCRfKTsNCiAg
ICBwcmludCAkQy4iOiBsZW4gIi5sZW5ndGgoJEMpLiIsIG9yZCAiLm9yZCgkQykuIlxuIjsN
CiAgICBwcmludCBGICRDOw0KfQ0KDQpjbG9zZSBGOw0KDQpwcmludCAiXG4+Pj4+PiBJTiA8
PDw8PFxuXG4iOw0KDQpvcGVuIEYsICJpby50eHQiIG9yIGRpZSAiT29wcyAtIGluISAoJCEp
IjsNCg0KIyBSZWFkIHRoZSBmaWxlLCB0ZXN0IGlmIHRoZSBjaGFycyBjYW1lIGFsb25nIGJ5
dGV3aXNlIT8NCg0KZm9yZWFjaCAkQyAoIHNwbGl0KC8vLDxGPikgKSB7DQoNCiAgICBwcmlu
dCAiJEM6IGxlbiAiLmxlbmd0aCgkQykuIiwgb3JkICIub3JkKCRDKS4iXG4iOw0KfQ0KDQoj
IFRoZXkgZG8gbm90IDotKCgoKCgoKCgNCg0KY2xvc2UgRjsNCg0KcHJpbnQgIlxuIjsNCg0K
dW5saW5rICJpby50eHQiOw0KDQoNCjE7DQo=
--------------03751F1B9269917D5836449A--



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

Date: Thu, 28 Sep 2000 07:49:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: What is %{$_}
Message-Id: <cst5ts4t3vtl8cpp9fjonu216h5vvfr423@4ax.com>

nlymbo@my-deja.com wrote:

>could someone explain the following??
>
>1) @{$list{$_}}

The hash item in %list for this instance of $_ is actually an arrar ref;
possibly an anonymous array. This gets the array items.

>2) %{$_}

$_ is a hash reference. This gets at the key/value pairs for that hash.
Same as %$_ .

Example:

	%hash = ( a => 'alpha', b => 'beta' );
	$ref = \%hash;
	print keys %$ref;	# a and b

-- 
	Bart.


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

Date: Thu, 28 Sep 2000 11:17:45 GMT
From: innoventures@my-deja.com
Subject: Where is NDBM_File.pm?
Message-Id: <8qv9cm$pkc$1@nnrp1.deja.com>

Okay, hopefully I'm not being as stupid as I suspect I'm being, but here
we go:

I upgraded to Perl 5.6.0, but I can't find NDBM_File.pm which one of my
CGI programs need.

Is it supposed to be installed as part of the standard distribution, as
a part of the AnyDBM_File.pm package.

How do I install this functionality?

Can you help me with this?

Sample Program:

#!/usr/bin/perl
use NDBM_File;
tie(%h, 'NDBM_File', 'userinfo.dbm', O_RDWR|O_CREAT, 0640);
print "Content-type: text/html\n\n";
print "<pre>\n";
print %h;
print "</pre>\n";
untie %h;

This should just dump the contents of the file, but instead it gives
this:

Can't locate loadable object for module NDBM_File in @INC (@INC
contains: /usr/lib/perl5/5.6.0/i686-linux /usr/lib/perl5/5.6.0
/usr/lib/perl5/site_perl/5.6.0/i686-linux /usr/lib/perl5/site_perl/5.6.0
/usr/lib/perl5/site_perl .) at ./test.cgi line 4
Compilation failed in require at ./test.cgi line 4.
BEGIN failed--compilation aborted at ./test.cgi line 4.

Can you PLEASE help me fix this so I can use this CGI program?

    Thanks!




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 4457
**************************************


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