[13537] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 947 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Sep 29 21:07:36 1999

Date: Wed, 29 Sep 1999 18:05:13 -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: <938653512-v9-i947@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 29 Sep 1999     Volume: 9 Number: 947

Today's topics:
        [Q] Memory Problems with Win32::Eventlog? <yui@usa.net>
        adding (summing) elements of an array (or hash) (NJPin)
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca (Matthew Bafford)
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca <pjl@fuckoff.com>
    Re: Bye Tom? (WAS: Re: injecting "my" varibales into ca <cassell@mail.cor.epa.gov>
        Catching errors in anouther name space. <admin@gatewaysolutions.net>
    Re: Catching errors in anouther name space. <admin@gatewaysolutions.net>
    Re: deprecated $[ (Martien Verbruggen)
    Re: deprecated $[ (Larry Rosler)
    Re: Form to Mail Script on NT. How? <cassell@mail.cor.epa.gov>
    Re: Form to Mail Script on NT. How? <cassell@mail.cor.epa.gov>
    Re: hyperlink submits (Larry Rosler)
    Re: hyperlink submits <flavell@mail.cern.ch>
    Re: LWP::UserAgent and timeout problem <jbc@shell2.la.best.com>
        newbie file transfer question <bedesign@webspan.net>
    Re: newbie help: sorting multidimensional arrays (Larry Rosler)
    Re: Perl - SQL examples <cassell@mail.cor.epa.gov>
        Please help re cgi script on FreeBSD running Apache <pcroghan@pacbell.net>
    Re: Problem to execute a program from CGI-script (Kragen Sitaker)
    Re: Problem to execute a program from CGI-script <cassell@mail.cor.epa.gov>
    Re: Reading from STDIN <cassell@mail.cor.epa.gov>
    Re: Regex for quotes in text database <cassell@mail.cor.epa.gov>
    Re: Sorting weird numeric data (Larry Rosler)
    Re: test <tech@tburg.net>
        Thread.pm nraghuram@my-deja.com
    Re: Thread::Signal troubles (Charles DeRykus)
    Re: threads?? (Ilya Zakharevich)
        Using multiple query strings <webmaster@roleplayinggames.net>
    Re: Using multiple query strings <jkline@one.net>
    Re: Using multiple query strings <makkulka@cisco.com>
    Re: Using multiple query strings <jeff@vpservices.com>
    Re: Why DBI ? Speed ? (Martien Verbruggen)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 29 Sep 1999 18:29:58 -0500
From: "Sasithorn Rattanawiwatpong" <yui@usa.net>
Subject: [Q] Memory Problems with Win32::Eventlog?
Message-Id: <7su7c0$1smg@news2.newsguy.com>

Hi,

I am writing a script trying to query NT eventlogs and post them into an SQL
database.  I am using the latest version of ActivePerl and the
Win32::Eventlog, Win32::ODBC modules that come with it.

When I run my script, the memory usage for perl.exe keeps growing until I
close it down.  I have a sleep routine running after each read and write of
the eventlog.  The memory usage goes up every time the Win32::Eventlog
routine gets called.  The same problem also occurs every time the
Win32::ODBC routine gets called.

Any clues as to what I am doing wrong?

Thanks in advance,
Yui

--------------- part of the program -------------
 ...
 ...
while (! -e $killfile)
{
      ...
      ...
     $preturn = &ReadEvents();
      ...
     $preturn  = &WriteDB($eventfile);
      ...
     sleep ($sleeptime);
}

sub ReadEvents()
{
   open (EVENTFILE, ">$eventfile") ||
   foreach $host (@hosts)
   {
      foreach $eventlog (@eventlogs)
      {
         my $numevents = 0;
         my $numeventunread = 0;
         my $oldestevent = 0;
         my $newestevent = 0;
         my $maxread = 0;
         my $eventoffset = 0;

         undef $EVENTHANDLE;
         !Win32::EventLog::Open($EVENTHANDLE, $eventlog, $host) && next;
         $EVENTHANDLE->GetNumber($numevents);
         ($numevents == 0) && next;
         $EVENTHANDLE->GetOldest($oldestevent);

         # Set Maximum number of events to read from eventlog
         ...
         ...

         # Reading events
         $eventoffset = 0;
         while ($eventoffset < $maxeventread)
         {
            my $mydate = '';
            my $mytime = '';
            my $user = '';
            my $sid = '';
            my $description = '';
            my $datahex = '';

            undef %eventdata;
            if ( $EVENTHANDLE->Read((EVENTLOG_SEEK_READ |
EVENTLOG_FORWARDS_READ),
                 $oldestevent + $eventoffset, \%eventdata) )
            {
               ++$eventoffset;
               Win32::EventLog::GetMessageText(\%eventdata);

               # Format and write events to file
               ...
               ...
            }
            else
            {
               $eventoffset = $maxeventread;
               next;
            }
         }   # end while $eventoffset
      }   # end foreach $eventlog
   }   # end foreach $host
   close EVENTFILE;
}   # end sub ReadEvent

#===========================================================
# WriteDB SUBROUTINE
# Write events to SQL database from text file
#===========================================================
sub WriteDB($;$)
{
   my ($eventtxt, $rewrite) = @_;
   my ($dberrn, $dberrt, $dberrc, $line);
   my $dbdriver = 'SQL Server';
   my %WriteDBError = (
      6, 'Server not found',
      208, 'Table not found',
      2627, 'Duplicate primary key',
      3701, 'Can\'t drop table - not exists',
      4060, 'Database not open - login fails',
   );

   if (!(-T $eventtxt) || !open(EVENTFILE, "$eventtxt")) { die $!;}

   # Connect to Database
   undef $DBHANDLE;
   $DBHANDLE = new Win32::ODBC("DRIVER=$dbdriver;SERVER=$dbserver;".
                               "DATABASE=$dbname;UID=$dbuid;PWD=$dbpwd");
   if (!$DBHANDLE)   { return $dberrn; }

   # Checking if database table exists.  If not, create tables.
   if ($DBHANDLE->Sql("SELECT * FROM $dbtable;"))
   {
      ($dberrn, $dberrt, $dberrc) = Win32::ODBC::Error();
      $dberrn != 208 && die Win32::ODBC::DumpError();
      ($dberrn, $dberrt, $dberrc) = &CreateEventTables();
      $dberrn && die Win32::ODBC::Error();
   }

   # Writing to tables
   while ( $line = <EVENTFILE>)
   {
      $line =~ /^\s*$/ && next;
      chomp $line;
      my ($host, $eventlog, $record, $etime, $mydate, $mytime,
          $type, $source, $category, $eventid, $user, $sid,
          $desc, $data) = split /\t/, $line;

      # Writing to primary event table
      my $tbcols = 'Computer, EventLog, Record, Date, Type, Source, '.
                   'Category, EventID, NTUser, SID';
      $dberrn = '';
      $dberrt = '';
      $dberrc = '';
      if ($DBHANDLE->Sql("INSERT INTO $dbtable ".
                "($tbcols) ".
                "values (".
                "\'$host\', ".
                "\'$eventlog\', ".
                "$record ,".
                "\'$mydate $mytime\', ".
                "\'$type\', ".
                "\'$source\', ".
                "$category, ".
                "$eventid, ".
                "\'$user\', ".
                "\'$sid\');"))
      { ($dberrn, $dberrt, $dberrc) = Win32::ODBC::Error(); }
      $dberrn == 2627 && next;
      ($dberrn) && next;

      # Write to description and data tables
      ...
      ...
   }   # end while $line
   close EVENTFILE;
   $DBHANDLE->Close();
}   # end sub WriteDB





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

Date: 29 Sep 1999 23:29:39 GMT
From: njpin@aol.com (NJPin)
Subject: adding (summing) elements of an array (or hash)
Message-Id: <19990929192939.04985.00000286@ng-cj1.aol.com>

I'm reading a VERY big file and creating a number of arrays using substring to
break up the appropriate columns into the appropriate arrays.  The arrays are
indexed off the value of the first substring (which is why I'm changing my code
to use hashes instead of arrays...I wasn't aware of the potential memory issues
until I re-read Advanced Perl Programming's section on memory allocation and
arrays -- what a great book!)...but anyway, that doesn't matter here...I was
wondering what the most efficient way to sum up all the values of my array (or
hash) is.  I am concerned with efficiency here because of the size of my infile
and because of the number of operations I'm already doing with the other
substrings.  Any suggestions would be greatly appreciated.


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

Date: Wed, 29 Sep 1999 23:11:21 GMT
From: *@dragons.duesouth.net (Matthew Bafford)
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <slrn7v56b3.3d2.*@dragons.duesouth.net>

[Copied to pjl@best.com]

Once upon a time (29 Sep 1999 22:27:59 GMT), Paul J. Lucas"
<pjl@best.com> was attempting to figure out Ilya's new Perl
regex features, and accidently sent the following to
comp.lang.perl.misc: 
: In <slrn7uuk78.k8j.*@dragons.duesouth.net> *@dragons.duesouth.net (Matthew Bafford) writes:
: >                                                       we'll miss you.
: >                                                                 [tom]
: 
: 	I won't.  How can anybody think he's NOT a major asshole?
: 	He seems like an angry, bitter little man.

You know, I almost put `most of us will miss you', but, although true,
that isn't exactly as nice a thing to say.  Anyway, I figured the
non-most people would have the sense and decency to keep their fingers
away from the keyboard.

Oh well.
 
: 	- Paul

--Matthew


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

Date: 30 Sep 1999 00:13:47 GMT
From: "Paul J. Lucas" <pjl@fuckoff.com>
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <37f2ab3b$0$219@nntp1.ba.best.com>

In <slrn7v56b3.3d2.*@dragons.duesouth.net> *@dragons.duesouth.net (Matthew Bafford) writes:

>Once upon a time (29 Sep 1999 22:27:59 GMT), Paul J. Lucas"
><pjl@best.com> was attempting to figure out Ilya's new Perl
>regex features, and accidently sent the following to
>comp.lang.perl.misc: 
>: In <slrn7uuk78.k8j.*@dragons.duesouth.net> *@dragons.duesouth.net (Matthew Bafford) writes:
>: >                                                       we'll miss you.
>: >                                                                 [tom]
>: 
>: 	I won't.  How can anybody think he's NOT a major asshole?
>: 	He seems like an angry, bitter little man.

>You know, I almost put `most of us will miss you', but, although true,
>that isn't exactly as nice a thing to say.  Anyway, I figured the
>non-most people would have the sense and decency to keep their fingers
>away from the keyboard.

	Since when does Tom deserve decency?

	- Paul


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

Date: Wed, 29 Sep 1999 17:51:56 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Bye Tom? (WAS: Re: injecting "my" varibales into callers scope)
Message-Id: <37F2B42C.AC4BF70D@mail.cor.epa.gov>

Paul J. Lucas wrote:
[snip]
>         Since when does Tom deserve decency?

Since people like you have been driving him nuts, ignoring
the thousands and thousands of person-hours of work he has
put into the FAQ and the docs and the free scripts and the
free modules and the Perl code and the Perl advocacy and 
everything else he has contributed to this NG and to Perl
over the years.

But I don't expect you to see my point.  Just visualize his
situation.  How would *you* feel if you worked for years
on something you felt was important enough that you poured
your life's blood into it, getting no remuneration for the
aforementioned work, and then had your work ignored,
day in and day out, by thousands of people who not only
can't be bothered to look up the advice and code you wrote,
but when firmly pointed in the right direction respond
by saying, "WELL FUCK YOU TOO ASSHOLE WHY DONT YOU JUST
TELL ME WHAT I WANT TO KNOW YOU FUCK!!!"

Well, that is what TomC has been dealing with daily for
longer than I have known what Perl was.  But he still tried
to maintain a presence here and assist others.  His 
contributions on the technical aspects are irreplaceable.

Larry Wall has gotten fed up with this NG.  Now TomC.
And any number of other Perl gurus, from Eryq and Joseph
Hall to Tad McClellan.

So, what's next?  To drive away everyone who can give
effective, insightful answers to hard questions, until
there's nothing left here but alt.perl.metoo ?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 19:15:21 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Catching errors in anouther name space.
Message-Id: <rv5ancfh3i550@corp.supernews.com>

I am having problems catching errors in a modules name space.
No matter what I do I continue to get server 500 errors.
Here is what I am attempting.

<SNIP>
#!/usr/bin/perl -wT

use CGI::Carp 'fatalsToBrowser';
use subs qw/end_html header escape/;
use lib qw(/www/xxxx/xxxxx/cgi-bin/libs);
use vars qw($sth $SQL);
use strict;

eval{
    require CGI;
    import CGI qw/:html :cgi -no_debug/;
    require Mysql;
    import Mysql;
}or die"Bad Error: $@";
</SNIP>

This is dying because of  CGI.pm but I have no way of knowing why because I
am only getting server 500 instead of  a nice error message.
I suspect it is because it is dying in CGI.pm's Package and not mine.
Does someone know of a way around this?

Thanks,
Scott Beck


--
Scott Beck



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

Date: Wed, 29 Sep 1999 19:39:33 -0500
From: "Scott Beck" <admin@gatewaysolutions.net>
Subject: Re: Catching errors in anouther name space.
Message-Id: <rv5c4kpj3i554@corp.supernews.com>

Well scrach that it is not dying there. I just ran it with no parameters and
it said my date was formatted incorrectly.
Well here is the whole script.
See if you can figure out where it is crashing.

<CODE>
#!/usr/bin/perl -w

use CGI::Carp 'fatalsToBrowser';
use subs qw/end_html p header escape/;
use lib qw(/www/hallofforums/cgi-bin/libs);
use vars qw($sth $SQL);
use strict;

eval{
require CGI;
import CGI qw/:html :cgi -no_debug/;
require Mysql;
import Mysql;
require "/www/hallofforums/cgi-bin/sqltest/mysql_tools.pl";
}or die"Bad Error: $@";



my $user_name            = escape(param("user_name"));
my $first_name            = escape(param("first_name"));
my $mi                         = escape(param("mi"));
my $last_name             = escape(param("last_name"));
my $show_name          = escape(param("show_name"));
my $signature               = escape(param("signature"));
my $email                    = escape(&check_email(param("email")));
my $show_email          = escape(param("show_email"));
my $password              = escape(param("password"));
my $icq                        = escape(param("icq"));
my $show_icq              = escape(param("show_icq"));
my $home_page            = escape(param("home_page"));
my $show_home_page = escape(param("show_home_page"));
my $interests                = escape(param("interests"));
my $show_interests     = escape(param("show_interests"));
my $occupation           = escape(param("occupation"));
my $show_occupation = escape(param("show_occupation"));
my $country                 = escape(param("country"));
my $state                     = escape(param("state"));
my $address                = escape(param("address"));
my $dob                      = escape(&check_combine_date);
my $show_dob            = escape(param("show_dob"));

print header;

&Create_DB_Connection;
&write_data;
&print_output;

sub write_data{
   $SQL = qq~INSERT INTO forum
(user_name,first_name,mi,last_name,show_name,signature,email,
         show_email,password,icq,show_icq,home_page,show_home_page,
         start_date,total_posts,last_post,interests,show_interests,
         occupation,show_occupation,country,state,address,dob,show_dob)
           VALUES
("$user_name","$first_name","$mi","$last_name","$show_name","$signature","$e
mail",

"$show_email","$password","$icq","$show_icq","$home_page","$show_home_page",
         "NULL","0","NULL","$interests","$show_interests","$occupation",

"$show_occupation","$country","$state","$address","$dob","$show_dob")~;
   &Do_SQL;
}
sub print_output{
print start_html(-title=>'Add to the Database',
    -bgcolor=>'#ffffff'),
    center(font({size=>'5',face=>'Arial'},
      'Record added to the database',
    p,
    a({href=>'mysql.html'},'Return to the Main Page'),
    ));
print end_html;
}
sub check_combine_date{
 if((param("month") !~ /\d/) or (param("day") !~ /\d/) or (param("year") !~
/\d{4}/))
 {
  die "Your date of birth is formated incorrectly.\n";
 }else{
  return param("year")."-".param("month")."-".param("day");
 }
}
sub check_email {
    my $email=$_[0];
    if (($email=~/\.\@/g) or ($email=~/\.\./g) or ($email=~/\@\./g) or
($email=~/\.$/) or ($email=~/^\./))


        die "$email is not a valid email address.\n";

se{ 
        return $email; 
    }
}
sub Create_DB_Connection{
   $dbh  = Mysql->connect('localhost','database','login','password');
   my $errmsg = Mysql->errmsg();
   die "Cannot connect: $errmsg" unless (defined $dbh);
   return;
}

sub Do_SQL{
 $sth = $dbh->query($SQL);
 my $errmsg = $dbh->errmsg();
 die "Error with $SQL,\n\n$errmsg" unless (defined $sth);
 return;
}
sub escape{
 my $var = $_[0];
 $var =~ s/(\\|\'|\")/\\$1/g;
 $var =~ s/\n/\\n/g;
 return $var;
}

Thanks,
-- 
Scott Beck

Scott Beck <admin@gatewaysolutions.net> wrote in message news:rv5ancfh3i550@corp.supernews.com...
> I am having problems catching errors in a modules name space.
> No matter what I do I continue to get server 500 errors.
> Here is wh
at I am attempting.
>
> <SNIP>
> #!/usr/bin/perl -wT
>
> use CGI::Carp 'fatalsToBrowser';
> use subs qw/end_html header escape/;
> use lib qw(/www/xxxx/xxxxx/cgi-bin/libs);
> use vars qw($sth $SQL);
> use strict;
>
> eval{
>     require CGI;
>     import CGI qw/:html :cgi -no_debug/;
>     require Mysql;
>     import Mysql;
> }or die"Bad Error: $@";
> </SNIP>
>
> This is dying because of  CGI.pm but I have no way of knowing why because
I
> am only getting server 500 instead of  a nice error message.
> I suspect it is because it is dying in CGI.pm's Package and not mine.
> Does someone know of a way around this?
>
> Thanks,
> Scott Beck
>
>
> --
> Scott Beck
>



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

Date: Wed, 29 Sep 1999 23:48:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: deprecated $[
Message-Id: <0zxI3.51$Ji1.3160@nsw.nnrp.telstra.net>

On 29 Sep 1999 20:24:56 -0000,
	Jonathan Stowe <gellyfish@gellyfish.com> wrote:
> On 29 Sep 1999 11:31:21 -0500 Abigail wrote:
>
> > Which raises the question, why was it ever introduced in the first place?
> > 
> 
> Some implementations of BASIC have this facility too - infact I think that
> certain BASICs defaulted to a '1' base and the 'OPTION BASE' thing was
> introduced to maintain compatibility.

And some fortrans I've worked with allowed you to change the base
offset in arrays as well (which is 1 in fortran77)

I suspect that it was introduced mainly to be able to work with array
offsets of 1, which might have been more 'natural' for people used to
that. The documentation mention awk as an example.

Good thing it's actively discouraged :)

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | 
Commercial Dynamics Pty. Ltd.       | Curiouser and curiouser, said Alice.
NSW, Australia                      | 


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

Date: Wed, 29 Sep 1999 10:45:29 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: deprecated $[
Message-Id: <MPG.125bf014d642db03989ffe@nntp.hpl.hp.com>

In article <slrn7v4g57.avl.abigail@alexandra.delanet.com> on 29 Sep 1999 
11:31:21 -0500, Abigail <abigail@delanet.com> says...
> Uri Guttman (uri@sysarch.com) wrote on MMCCXX September MCMXCIII in
> <URL:news:x7iu4twwj3.fsf@home.sysarch.com>:
> @@ >>>>> "TH" == Tracey Hughes <TH@Dymaxion.ca> writes:
> @@   TH> I was wondering if anyone knows why exactly the $[ variable was
> @@   TH> deprecated after release 5.
> @@ 
> @@ can you think of a good reason to use it? the powers that be thought
> @@ there was none and it was open to abuse.
> 
> Which raises the question, why was it ever introduced in the first place?

Fortran.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 29 Sep 1999 17:25:11 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Form to Mail Script on NT. How?
Message-Id: <37F2ADE7.B1BCA00F@mail.cor.epa.gov>

James Bodajlo wrote:
> 
> I am in need of a script which will work on an NT server and takes the
> info from an HTML form and sends it via e-mail. I have a script which
> works on UNIX, but I need to know what I need to change for it to work
> on NT.

You need to change a fair amount.  NT servers seldom have
sendmail.  If yours does not, you'll have to hack out that
portion of the script and replace it with something that
calls a Perl module appropriately.  I would recommend
Mail::Sender or Mail::Mailer , both available using the ppm
program Activestate ships with ActiveState Perl.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 17:27:41 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Form to Mail Script on NT. How?
Message-Id: <37F2AE7D.BF8CBAA6@mail.cor.epa.gov>

Henry Penninkilampi wrote:
> 
> In article <37F2341F.41F26CB0@videosoftwareltd.com>, James Bodajlo
> <james@videosoftwareltd.com> wrote:
> 
> > I am in need of a script which will work on an NT server and takes the
> > info from an HTML form and sends it via e-mail. I have a script which
> > works on UNIX, but I need to know what I need to change for it to work
> > on NT.
> 
> Heh, heh...
> 
> You ask (what most folks would classify as) an NT-related question in
> *this* newsgroup, demonstrate no evidence of having done any work to find
> out the answer yourself, repost the same message 32 minutes later, and
> don't even say 'please'?
> 
> Man, you're gonna regret that.

Well, we can't be mean to *everyone*.  There's not enough time,
given the vast number of posts every day.  Perhaps we can
distribute the crabbiness.  :-)

Actually, NT questions are legit if it's a matter of coding
which isn't in the FAQ or docs.  Just as MacPerl and VMS Perl
questions are acceptable.  But that 32-minute repost wasn't
considerate of him.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 10:59:25 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: hyperlink submits
Message-Id: <MPG.125bf35a74f7dadf98a000@nntp.hpl.hp.com>

In article <Pine.HPP.3.95a.990929190112.16629N-100000@hpplus01.cern.ch> 
on Wed, 29 Sep 1999 19:05:06 +0200, Alan J. Flavell 
<flavell@mail.cern.ch> says...
> On Wed, 29 Sep 1999, Michael Frost jeopardized the group with:
> > The syntax is: <A
> > HREF="http://your.domain/<path>/filename.cgi?parameter1=value1&parameter2=
> 
> Invalid HTML syntax.  You need to represent ampersand as &amp; in this
> kind of HTML attribute value. 

Totally wrong (as well as totally off-topic).

Some remarkably stupid tools (such as M$ FrontPage) make transformations 
like that in the submitting HTML page, and it is the responsibility of 
the CGI program to strip the resulting 'amp;' string from the front of 
the resulting parameter.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 30 Sep 1999 02:10:59 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: hyperlink submits
Message-Id: <Pine.HPP.3.95a.990930020858.13461B-100000@hpplus01.cern.ch>

On Wed, 29 Sep 1999, Larry Rosler wrote:

> > Invalid HTML syntax.  You need to represent ampersand as &amp; in this
> > kind of HTML attribute value. 
> 
> Totally wrong 

I assure you, you are mistaken, and any SGML validator will tell you 
as much.

> (as well as totally off-topic).

In that you are correct, so I'll say no more.



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

Date: 30 Sep 1999 00:20:23 GMT
From: John Callender <jbc@shell2.la.best.com>
Subject: Re: LWP::UserAgent and timeout problem
Message-Id: <37f2acc7$0$218@nntp1.ba.best.com>

Steve Linberg <slinberg@crocker.com> wrote:
> I'm having trouble getting the timeout method for LWP::UserAgent to act
> like it seems to me that it should.

I had the same experience over the weekend in trying to write a
link-checking script that would complete its run in a reasonable amount
of time when doing HEAD requests on a large collection of links. After
experiencing the same thing you did, I tried sticking the part of the
code that did the requesting inside an eval, and using the alarm()
function to bomb out after a set time, but the same thing happened:
certain requests would sit there for an unacceptably long time.

After some more head scratching (and some help from my local guru) I
came to the conclusion that my process was blocking (is that the
appropriate use of that term? I mean it was getting hung up, such that
it couldn't do anything) in the resolver part of the DNS lookup
process, such that the script itself (including the timeout processing
of either LWP::UserAgent or my alarm() function in the eval) wasn't
getting a chance to abort things.

Two possible approaches I thought about exploring at that point were to
either:

1) try to figure out Net::DNS, such that I could do a more fine-grained
hostname lookup with appropriate timing out purely within Perl, or

2) do the hostname lookup in an explicitly spawned child process,
which I could then kill off when it exceeded my timeout limit.

I ended up deciding that I'd just live with the long lookups, since
this was for a hopefully newbie-friendly demonstration script, and I
didn't want to get into the complexity required for either of the above
two approaches.

I'd appreciate any insights from the resident experts on whether it
sounds as if I was on the right track with my mental model of what was
going wrong.

-- 
John Callender
jbc@west.net
http://www.west.net/~jbc/


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

Date: Wed, 29 Sep 1999 19:57:44 -0400
From: "bruce" <bedesign@webspan.net>
Subject: newbie file transfer question
Message-Id: <rv59hge43i57@corp.supernews.com>

Hi All,

I download a series of text files from one of our suppliers once a week from
their web site. I wrote a perl script that converts the data in the text
files to html files for our sales people that I post on our website manually
(using my browser to save the text files to my pc, running the script on the
files locally, and then uploading the html files to our server). I wrote the
program in Perl so I could ultimately put the script on the server and get
the files as they are updated on the remote server, letting the computer do
the work instead of me. How get the files from the random website to my
server so I can get copies of the text files? Do I need to use CGI.pm or
something like this to make this happen?

Thanks,
Bruce




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

Date: Wed, 29 Sep 1999 10:49:50 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: newbie help: sorting multidimensional arrays
Message-Id: <MPG.125bf113ee6de436989fff@nntp.hpl.hp.com>

In article <37F23FAA.B9926C88@ife.ee.ethz.ch> on Wed, 29 Sep 1999 
18:34:50 +0200, Alex Rhomberg <rhomberg@ife.ee.ethz.ch> says...
+ Patrick Smith wrote:
+ > I'm kind of new to this. I need to know if there is a way to sort a
+ > multidimensional [10,5] array using the first element of each row as
+ > the sorted item and keeping the other 4 elements of the row in
+ > origional order together with the first element after having sorted
+ > all ten rows.
+ > All the elements will be numbers.
+ 
+ 1. create a hash with the first element as key and a ref to the
+ original array entry as value. Preserve the order of the refs
+ 2. sort the hash keys
+ 3. for the sorted hash keys, give out the original contents in order
+ 
+ my %th; #temporary hash
+ 
+ @sortedarray = map {@{delete $th{$_}||[]}}
+   sort
+   map {push @{$th{$$_[0]}}, $_; $$_[0]} @a;
+ 
+ Can this still count as ST?

Yes.  But why bother with that?

+ Note: Due to the map sort map construct, there are more elements in
+ the sort than necessary. That's the reason for the 'delete or empty
+ list ref' construct. I did it this way because I couldn't resist the
+ 'map sort map' :-)

What an amazing waste of resources!

  @sortedarray = sort { $a->[0] <=> $b->[0] } @a;

The ST is unnecessary, as the sortkeys are efficiently accessed.

This could also be done using a GRP (hmmm... :-) indexed sort, but it 
seems like too much trouble for such a trivial problem.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 29 Sep 1999 17:42:42 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl - SQL examples
Message-Id: <37F2B202.A91D2B9B@mail.cor.epa.gov>

Michael Peppler wrote:
[snip of my junk]
> True. But there are things that you can do with sybperl that you can't do
> with DBD::Sybase, so in certain circumstances that may be the better choice.
> sybperl is still actively maintained and supported (by yours truly)...

Sorry Michael, no slam intended.  But the original responder did
say "To access various databases you get various Modules..."
and I thought it behooved someone to discuss this.

I suspected that there were things one could do with sybperl
that aren't available in DBD::Sybase, as is the case with a
number of other databases.. but I didn't know for sure.

Thanks for the heads-up,
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 17:53:01 -0700
From: Paul Croghan <pcroghan@pacbell.net>
Subject: Please help re cgi script on FreeBSD running Apache
Message-Id: <37F2B46B.4E2C9CFA@pacbell.net>

I'm running a password file script which sticks at:  "System Error,
Could not open web data file +<../webauth/web.data."

The script is trying to open a data file with passwords, but apparently,

is unable to.  I've set full permissions.  I've pasted below, the part
of the script where I'm getting stuck.  Any help would be much
appreciated.

Thanks, Paul




$webfile  = "+<../webauth/web.data";

%input_values = &break_input;
$number = &normalize_query($input_values{"number"});
$email = &normalize_query($input_values{"email"});
if(length($number) != 7) {
        &system_error("Sorry, but $number is not a valid number\n");
        exit;
}
unless(open(WEB,"+<$webfile")) {
        &system_error("Could not open web data file $webfile.\n");
        exit;





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

Date: Thu, 30 Sep 1999 00:28:13 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Problem to execute a program from CGI-script
Message-Id: <x8yI3.2630$t%3.204199@typ11.nn.bcandid.com>

In article <37F26DDF.F9C70A52@cern.ch>,
Mats JANSSON  <Mats.Jansson@cern.ch> wrote:
>system("runrep25m cmdfile=cmdfile &");
>I have find out that the runrep25m get 'Killed' direct after it has been
>invoked. Why? 

The return value from system will tell you what signal killed the
program; presumably signal 9.  Possible causes:

- your web hosting provider doesn't like you running background jobs from CGI
- your script is running out of RAM
- ???

Why are you using the &?
-- 
<kragen@pobox.com>       Kragen Sitaker     <http://www.pobox.com/~kragen/>
Tue Sep 28 1999
43 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>


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

Date: Wed, 29 Sep 1999 17:34:30 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Problem to execute a program from CGI-script
Message-Id: <37F2B016.441783F7@mail.cor.epa.gov>

Mats JANSSON wrote:
> 
> Hi,
> 
> I have a problem to invoke a program from my CGI script. i have tried
> some diferent ideas to do it. I want to invoke Oracle report from a
> webpage and publish the result in a window.
> 
> I have tried following:
> `runrep25m cmdfile=cmdfile &`;
> 
> system("runrep25m cmdfile=cmdfile &");
> 
> I also have made a csh script which I invoke in the CGI but i doesn't
> work either.
> I have find out that the runrep25m get 'Killed' direct after it has been
> invoked. Why?

You'll want to use a line like

system("runrep25m cmdfile=cmdfile &") && die "runrep25m failed $?";

so you can get the return value.  Read the docs to see more
stuff you can do with the return value from system().

Since this is CGI, it could be anything from a path problem
or a permissions problem to a difficulty with database
connections.  You'd be better off in the long run to 
adapt the code to use DBI and DBD::Oracle, so you could
handle errors more gracefully in your program.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 17:39:36 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Reading from STDIN
Message-Id: <37F2B148.24D24E0C@mail.cor.epa.gov>

Kyle Brost wrote:
> 
> Hello,

Howdy,

> I am having troubles with reading from STDIN without blocking.
> Everytime that I read all the data, perl sits at the read statement and
> waits for more data.  I would like to trap the situation where there is
> no data and then continue in my code.  I know that I can use <STDIN>,
> but the data I am using won't have newlines.  (Example code attached
> below)

This is in the FAQ.  But it isn't obvious where you should look,
unless you know the right keywords.. in which case you might
already know enough programming to know the answer in C.

Look in perlfaq5 for:

"How can I tell whether there's a character waiting on a filehandle?"

It refers to Term::ReadKey but you may also want Term::ReadLine .

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 17:30:15 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Regex for quotes in text database
Message-Id: <37F2AF17.11E0B259@mail.cor.epa.gov>

Eric Bohlman wrote:
> 
> Abigail (abigail@delanet.com) wrote:
> : Kim Saunders (kims@emmerce.com.au) wrote on MMCCXX September MCMXCIII in
> : <URL:news:938579711.779677@draal.apex.net.au>:
> : ()
> : () Would someone be so kind as to help me out with a regex to strip *unwanted*
> : () (as opposed to all) double-quotes (") from a string. They are always at the
> : () start and end of the string.
> :
> :
> : You want the /u modifier. That only removes unwanted characters.
> 
> You forgot to mention that it's only enabled if you load the dwim pragma:
> 
> use dwim;

It didn't work for me in the stable version [5.005_03].
I had to use the PSI::ESP module instead:

use lib '/home/cassell/perllibs';
use PSI::ESP qw/dwim psych/;
 
David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Wed, 29 Sep 1999 12:34:24 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Sorting weird numeric data
Message-Id: <MPG.125c0990654fd91f98a002@nntp.hpl.hp.com>

In article <slrn7v4g2p.avl.abigail@alexandra.delanet.com> on 29 Sep 1999 
11:30:05 -0500, Abigail <abigail@delanet.com> says...
> Uri Guttman (uri@sysarch.com) wrote on MMCCXX September MCMXCIII in
> <URL:news:x7u2odwxpt.fsf@home.sysarch.com>:
 ...
> ,, sort method takes advantage of that for its speed. if you don't care
> ,, about sort speed, stick with the ST and variants. i am not stopping
> ,, you. but for such an algorithmic person always quoting knuth, i would
> ,, think you would embrace the speed up over the higher level perl
> 
> I do not care much for the constant. Never did. I am always interested
> in the asymptotic bounds though.

Sometimes the asymptotic bounds are irrelevant.  See below.

> ,, code. larry showed a 3 time improvement over your sort and that will
> ,, grow with the size of the dataset.
> 
> Oh? Your sorting algorithm beats O (N log N)?

No, but it reduces the constant (in which you aren't interested :-) so 
much that the processing time is dominated by the O(N) sortkey 
extraction.  For asymptotically large N, the O(N logN) processing would 
ultimately dominate, of course.  But the algorithm is limited by the 
size of memory, so thrashing takes over first -- while the processing 
time is still not much worse than linear -- and ruins the performance.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 29 Sep 1999 16:54:03 -0400
From: "Robert W. Byrd" <tech@tburg.net>
Subject: Re: test
Message-Id: <37F27C6B.D7D9FD21@tburg.net>

cuncua@hotbot.com wrote:
> 
> ignore

We will... some of us for longer than others, I'm sure :)

 .rob.

> 
>      -----  Posted via NewsOne.Net: Free Usenet News via the Web  -----
>      -----  http://newsone.net/ --  Discussions on every subject. -----
>    NewsOne.Net prohibits users from posting spam.  If this or other posts
> made through NewsOne.Net violate posting guidelines, email abuse@newsone.net

                                               done ->
^^^^^^^^^^^^^^^^^^^^^^^

-- 
Robert W. Byrd | Completely Computer Friendly
tech@tburg.net | 67-B Oxford St., Tillsonburg, ON CA N4G 2G3
------------------------------------------------------------
Nothing clever here          }|{         ereh revelc gnihtoN


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

Date: Wed, 29 Sep 1999 23:02:29 GMT
From: nraghuram@my-deja.com
Subject: Thread.pm
Message-Id: <7su5pt$rqi$1@nnrp1.deja.com>

is there any site from where Thread.pm can be downloaded.
what is the optimal way to communicate from a child to the parent in a
multi-child scenario. i tried using a combination of pipes and hash
arrays and have the parent poll before creation of the next child to
check if earlier children  have returned data. but it seems to be taking
too long.


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


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

Date: Wed, 29 Sep 1999 23:23:45 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Thread::Signal troubles
Message-Id: <FIuGzL.2G4@news.boeing.com>

In article <37f11d30.159060214@news.infinet.net>,
Jeff Magnusson <jeff@riverstyx.net> wrote:
>Hey, I'm having difficulty making an existing script that uses signals
>to work with the Thread::Signals system:
>
>Here's the REAPER function to clean up after a child exits:
>(with lots of debug code).  I'm consistently gettinga -1 from waitpid,
>which used to work perfectly.
>
>
>sub REAPER {
>   my ($pid,$exit_value,$signal_num,$core_dumped);
>   &log("DEBUG (REAPER): Starting...");
>    ...

I haven't seen Thread::Signals so the following may have
nothing to due with your problem. (I seem to recall seeing
some discouraging reports about signals in threaded  
programs though). 

However, some of the calls below could exacerabate the problems 
you're seeing. Perl signals in general aren't particularly 
robust as you probably know.  Moreover, the underlying signal 
mechanisms are vulnerable to calls that may generate a malloc.  
In other words, don't allocate those lexicals inside the handler; 
don't do any debugging I/O. 

--
Charles DeRykus


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

Date: 29 Sep 1999 23:09:18 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: threads??
Message-Id: <7su66u$6hs$1@charm.magnus.acs.ohio-state.edu>

[A complimentary Cc of this posting was sent to Dan Sugalski 
<dan@tuatha.sidhe.org>],
who wrote in article <tesI3.1129$S32.1868@news.rdc1.ct.home.com>:
> > It's wrong in a much more fundamental way.    The $SIG{CHLD} must
> > do a wait() for the child process, else you'll get loops and/or zombies.
> 
> The original, which got chopped out in the replies, did wait. It just
> didn't wait inside the signal handler. 

Read what is written: you *need* to wait() *inside* the signal
handler.  Some sloppy implementation of SIGCHLD will allow you to omit
this, but this will lead to lost children due to race conditions.

More robust implementations will send you a SIGCHLD until you wait() -
which basically means you will never get a chance to reach the point
of your code where you wait().

Ilya


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

Date: Wed, 29 Sep 1999 19:08:41 -0400
From: "Donboy" <webmaster@roleplayinggames.net>
Subject: Using multiple query strings
Message-Id: <k6xI3.1099$CL1.9275772@news-read1.qis.net>

I've been writing my own scripts for a little while now, but up to this
point, I've been using forms to input all the variables.  Now, I'm trying to
work with inserting the variables using query strings.  However, the only
way I'm able to do this is using a single query string like so....

www.whatever.com/cgi-bin/script.cgi?value

But now I'm getting to the point where a single variable inserted into the
script just isn't enough.  I'd like to use more than one query string in the
same line...

www.whatever.com/cgi-bin/script.cgi?&value1=something&value2=somethingelse

So how can I do this??  I've tried using a line similar to what I just
showed above, but the script won't recognize those values.  It's like I'm
not even defining those variables at all.

Now I've seen a script that uses them successfully and I thought I could
just clone it and it would work fine.  It looked as if the variables were
getting sorted out properly with a "parse form" subroutine like so....

sub parse_form {
 read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});
 if ($ENV{'QUERY_STRING'})  { $buffer = "$buffer\&$ENV{'QUERY_STRING'}"; }
 @pairs = split(/&/,$buffer);
 foreach $pair (@pairs)
  {($name,$value) = split(/=/,$pair);
  $value =~ tr/+/ /;
  $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C",hex($1))/eg;
  $FORM{$name} = $value;
 }
}


But it ain't quite working out!  So what's going wrong here?  Am I missing
something?  What tells the script to accept more than one query string from
the same line?

BTW, I bought the "Perl Cookbook" and it's pretty nice, but it assumes that
you already know your stuff to some degree.   I think I'm going to have to
try something simpler and work my way up to using the 'Cookbook' to solve my
problems!




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

Date: Wed, 29 Sep 1999 20:39:53 -0400
From: Joe Kline <jkline@one.net>
To: Donboy <webmaster@roleplayinggames.net>
Subject: Re: Using multiple query strings
Message-Id: <37F2B159.287D5FDE@one.net>

[posted and mailed]

Donboy wrote:
> 
> I've been writing my own scripts for a little while now, but up to this
> point, I've been using forms to input all the variables.  Now, I'm trying to
> work with inserting the variables using query strings.  However, the only
> way I'm able to do this is using a single query string like so....
> 
> www.whatever.com/cgi-bin/script.cgi?value

This is a CGI question. CGI is a protocol that various languages can
implement. Perl just happens to be a very popular language for CGI.

The most appropiate newsgroup for all CGI questions is:

comp.infosystems.www.authoring.cgi

Also, CGI.pm (which can be found on CPAN) takes care of a lot of the
pain of CGI.

joe


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Wed, 29 Sep 1999 17:41:48 -0700
From: Makarand Kulkarni <makkulka@cisco.com>
Subject: Re: Using multiple query strings
Message-Id: <37F2B1CB.85221A2D@cisco.com>

[ Donboy wrote:

> www.whatever.com/cgi-bin/script.cgi?&value1=something&value2=somethingelse

should actually be
www.whatever.com/cgi-bin/script.cgi?value1=something&value2=somethingelse

***take off the '&' after the '?' in the URL above   ****

> sub parse_form {
>  read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});

You really need to read from STDIN if  the request method is POST.
The method you are using here is GET because your name/value pairs are tucked at
the
end of the URL (unless this was deliberate).

Everything else works
--




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

Date: 29 Sep 1999 23:51:51 GMT
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Using multiple query strings
Message-Id: <37F2A44C.C6B4A20@vpservices.com>

Donboy wrote:
> 
> www.whatever.com/cgi-bin/script.cgi?&value1=something&value2=somethingelse
> 
> So how can I do this??  I've tried using a line similar to what I just
> showed above, but the script won't recognize those values. ...
>
> sub parse_form {
>  read(STDIN,$buffer,$ENV{'CONTENT_LENGTH'});

Get ready for a flood of replies that say the same thing.  Let me be the
first to say it (at least on my newsfeed): 

Don't do that.  Use CGI.pm.  

Among its many plusses, this module will transparently handle your
multi-valued query string and allow you to write a script that doesn't
care whether the names and values come from a query string, or from a
form, or from the command line, or from a file.

-- 
Jeff


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

Date: Thu, 30 Sep 1999 00:07:04 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Why DBI ? Speed ?
Message-Id: <IQxI3.57$Ji1.3160@nsw.nnrp.telstra.net>

On Wed, 29 Sep 1999 17:48:50 GMT,
	cuncua@yahoo.com <cuncua@yahoo.com> wrote:

> So, I am missing something or the DBI only brings easy use ?

Our main reason for using DBI is portability. Being able to write the
code in a way that's independent (mostly) of the RDBMS that we use is
a big, big bonus. 

We just had one of the vendors of a major piece of software in the
company announce that they do not support Sybase any longer. That
particular piece of Software now will only run on MS SQL (great.. now
we have a POB box in a production environment, and we are expected to
keep the thing running). None of the management code written in DBI
has to be changed.

That's worth a lot of money :)

Martien
-- 
Martien Verbruggen                  | 
Interactive Media Division          | Failure is not an option. It comes
Commercial Dynamics Pty. Ltd.       | bundled with your Microsoft product.
NSW, Australia                      | 


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

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 947
*************************************


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