[21988] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4210 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 3 14:07:20 2002

Date: Tue, 3 Dec 2002 11:05:14 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Tue, 3 Dec 2002     Volume: 10 Number: 4210

Today's topics:
        [FTP] Downloading a file by matching part of its name ( (Bob)
    Re: [FTP] Downloading a file by matching part of its na <krahnj@acm.org>
        a rather inefficient algorithm (anocelot)
    Re: a rather inefficient algorithm <ian@WINDOZEdigiserv.net>
    Re: a rather inefficient algorithm <dover@nortelnetworks.com>
    Re: A regex 'whoa' <wsegrave@mindspring.com>
    Re: A regex 'whoa' <wsegrave@mindspring.com>
    Re: advanced html form question <wsegrave@mindspring.com>
    Re: advanced html form question <wsegrave@mindspring.com>
        ANSWER - Closing excel spreadsheet. <spikey-wan@bigfoot.com>
    Re: Cache the execution of a Perl CGI? <flavell@mail.cern.ch>
    Re: Cache the execution of a Perl CGI? <bart.lateur@pandora.be>
    Re: Cache the execution of a Perl CGI? <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
        Cannot get SASL module to work <tim@remove.deadgoodsolutions.com>
    Re: Closing an unsaved modded Excel spreadsheet? <spikey-wan@bigfoot.com>
        Code segfaults on 5.8 but works on 5.6 <goltermann@attbi.com>
        displaying $ symbol in output?? (flinky)
    Re: displaying $ symbol in output?? (Walter Roberson)
        Future of Perl as an application server language? (Simon)
    Re: HELP! Looking for a cgi <nobody@dev.null>
    Re: how to get it quoted? <du_bing@hotmail.com>
    Re: how to get it quoted? (Walter Roberson)
        hyphens in CGI parameters (Bruce Tobin)
    Re: Installing of Win32::API on Win2K <josef.moellers@fujitsu-siemens.com>
    Re: Kicking off commands on a remote machine (Ben Morrow)
    Re: Mime Header Problem <mememe@meme.com>
    Re: mysql <jeff@vpservices.com>
        Perl Packages question (Kasp)
    Re: Perl Packages question <paladin@techmonkeys.org>
        problems with die; <spikey-wan@bigfoot.com>
    Re: problems with die; <bart.lateur@pandora.be>
    Re: problems with die; <nobody@dev.null>
    Re: problems with die; <spikey-wan@bigfoot.com>
    Re: Timezone (BrianWhitehead)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 3 Dec 2002 06:48:24 -0800
From: bobx@linuxmail.org (Bob)
Subject: [FTP] Downloading a file by matching part of its name (code incl.)
Message-Id: <1001ff04.0212030648.4fd5b736@posting.google.com>

# This Perl script will go out and get the latest NAV(CE)
# definitions.

# file name ex:  20021202-05-x86.exe

# pragmas
use strict;
use warnings;

# modules
use Net::FTP;

# my declares
my $ftp;
my $hostname = 'symantec.com';
my $navhome = '/public/path_to/norton_antivirus/';
my $username = 'anonymous';
my $password = 'nobody\@spammer.com';
my $local_dir = 'c:\\temp';
my $net_dir = 'p:\\public\\navtemp';
my $filename;

# format the first part of the file
sub filename {
    my($day, $month, $year) = (localtime)[3, 4, 5];
    $month++;
    $year += 1900;
    $day--;  # subtract a day
    
    my $file = sprintf '%04d%02d%02d', $year, $month, $day;
}

# connect to the ftp site
$ftp = Net::FTP->new($hostname);
$ftp->login($username, $password);
$ftp->cwd($navhome);

# now get the file
$ftp->type("binary");
$ftp->get($filename);
$ftp->quit;

The NAV file has a particular format of 20021202-05-x86.exe and I want
to match the date in the first part (20021202) and make sure I get the
EXE file and not the ZIP. I have muddled through the above (I am
learning!) but now I need to match the the sprintf from the sub to the
file name and make sure it is the EXE, and that is where I am stuck.

Help?

Bob

P.S. I read c.l.p.misc quite frequently so post here please.  : )


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

Date: Tue, 03 Dec 2002 16:34:14 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: [FTP] Downloading a file by matching part of its name (code incl.)
Message-Id: <3DECDCCE.D3D1E4CA@acm.org>

Bob wrote:
> 
> # This Perl script will go out and get the latest NAV(CE)
> # definitions.
> 
> # file name ex:  20021202-05-x86.exe
> 
> # pragmas
> use strict;
> use warnings;
> 
> # modules
> use Net::FTP;
> 
> # my declares
> my $ftp;
> my $hostname = 'symantec.com';
> my $navhome = '/public/path_to/norton_antivirus/';
> my $username = 'anonymous';
> my $password = 'nobody\@spammer.com';
> my $local_dir = 'c:\\temp';
> my $net_dir = 'p:\\public\\navtemp';

You are using single quotes so the backslashes are not required.

my $password = 'nobody@spammer.com';
my $local_dir = 'c:\temp';
my $net_dir = 'p:\public\navtemp';


> my $filename;
> 
> # format the first part of the file
> sub filename {
>     my($day, $month, $year) = (localtime)[3, 4, 5];
>     $month++;
>     $year += 1900;
>     $day--;  # subtract a day
> 
>     my $file = sprintf '%04d%02d%02d', $year, $month, $day;
> }
> 
> # connect to the ftp site
> $ftp = Net::FTP->new($hostname);
> $ftp->login($username, $password);
> $ftp->cwd($navhome);
> 
> # now get the file
> $ftp->type("binary");
> $ftp->get($filename);
> $ftp->quit;
> 
> The NAV file has a particular format of 20021202-05-x86.exe and I want
> to match the date in the first part (20021202) and make sure I get the
> EXE file and not the ZIP. I have muddled through the above (I am
> learning!) but now I need to match the the sprintf from the sub to the
> file name and make sure it is the EXE, and that is where I am stuck.



Use file globbing with the ls command to find out if the file is there


# pragmas
use strict;
use warnings;

# modules
use Net::FTP;

# my declares
my $hostname  = 'ftp.symantec.com';
my $navhome   =
'/public/english_us_canada/antivirus_definitions/norton_antivirus';
my $username  = 'anonymous';
my $password  = 'nobody@spammer.com';
my $local_dir = 'c:\temp';
my $net_dir   = 'p:\public\navtemp';

my ( $day, $month, $year ) = ( localtime( time - 86_400 ) )[3, 4, 5];
# file name ex:  20021202-05-x86.exe
my $fileglob = sprintf '%04d%02d%02d*x86.exe', $year + 1900, $month + 1,
$day;

# connect to the ftp site
my $ftp = Net::FTP->new( $hostname ) or die "Cannot connect to
$hostname: $@\n";

$ftp->login( $username, $password ) or die "Cannot log in to
$hostname\n";
$ftp->cwd( $navhome ) or die "Cannot change to directory $navhome\n";

my @files = $ftp->ls( $fileglob ) or die "Cannot list remote files\n";
@files > 1 and warn "More than one file was found: @files\n";

# now get the file(s)
$ftp->binary or die "Cannot set binary mode\n";
for my $file ( @files ) {
    $ftp->get( $file ) or die "Cannot get $file\n";
    }
$ftp->quit;




John
-- 
use Perl;
program
fulfillment


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

Date: 3 Dec 2002 07:12:38 -0800
From: djact@flactem.com (anocelot)
Subject: a rather inefficient algorithm
Message-Id: <b4513453.0212030712.bb3df2@posting.google.com>

I recently needed to pause for a certain amount of time.  The
pertainent code I used is below.  There has to be a better way to do
this.  Ideas?

#!/usr/bin/perl -w
$finished=0;            # define toggle var
$time1 = time;          # set the start time
while ($finished==0) {  # loop until found
 $time2 = time;         # set the current time
 if ($time2-$time1 > 5) # if 5 seconds have passed...
  { $finished=1; }      # flip the toggle.
}


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

Date: Tue, 03 Dec 2002 15:23:07 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: a rather inefficient algorithm
Message-Id: <53jpuu4f3ushgfqt0es47ngc26eoihtj07@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on 3 Dec 2002 07:12:38 -0800, djact@flactem.com
(anocelot) managed to scribble:

> I recently needed to pause for a certain amount of time.  The
> pertainent code I used is below.  There has to be a better way to do
> this.  Ideas?
> 
> #!/usr/bin/perl -w
> $finished=0;            # define toggle var
> $time1 = time;          # set the start time
> while ($finished==0) {  # loop until found
>  $time2 = time;         # set the current time
>  if ($time2-$time1 > 5) # if 5 seconds have passed...
>   { $finished=1; }      # flip the toggle.
> }

#!/usr/local/bin/perl

use strict;
use warnings;

[...]

sleep(5);  # Pause for 5 seconds

[...]


HTH.


Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP Personal Privacy 6.5.3

iQA/AwUBPezMpmfqtj251CDhEQIoHACfWIQKi6giAOqaffBFbH6w4iqszNkAoNoC
hWtO7tN8dsNTLV8rMz/rPfe7
=HlVx
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Tue, 3 Dec 2002 11:39:26 -0600
From: "Bob Dover" <dover@nortelnetworks.com>
Subject: Re: a rather inefficient algorithm
Message-Id: <asiq2l$38u$1@bcarh8ab.ca.nortel.com>

"anocelot" wrote...
> I recently needed to pause for a certain amount of time.  The
> pertainent code I used is below.  There has to be a better way to do
> this.  Ideas?

See perldoc -f sleep.




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

Date: Tue, 3 Dec 2002 12:15:45 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: A regex 'whoa'
Message-Id: <asismq$ha0$3@slb4.atl.mindspring.net>

"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:q97puugm26k7qp7n1jtt5juqmmvt96287a@4ax.com...
<snip>
> >$part1 =~
>
>/^(\d+)\s*\t\s*(\d+)\s*\t\s*(\d+)\s*\t\s*(\d+)\s*\t\s*(\d+)\s*\t\s*\d+\s*\t
\s*(\d+)\s*\t\s*\d+\s*\t\s*([-|\+])\s*\t*$/;
<snip>
> Tabs are whitespace. All occurrences of "\s*\t\s*" can be replaced with
> just "\s+".

Yes, but the match would not fail on absence of a tab as a separator. It
seems to me that the author of the regex intended tab as a separator, as it
is stated explicitly. Bart's substution would render the regex inop for
tab-sep values.

Bill Segraves




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

Date: Tue, 3 Dec 2002 12:38:20 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: A regex 'whoa'
Message-Id: <asitr8$toh$1@slb9.atl.mindspring.net>

"William Alexander Segraves" <wsegrave@mindspring.com> wrote in message
news:asismq$ha0$3@slb4.atl.mindspring.net...
<snip>

Clarification:
>Bart's substitution would render the regex inop,

i.e., incorrect behavior,

> for tab-sep values

in which the tab is replaced by any other white space character(s), if that,
i.e., checking for tab-sep values, was the author's original intent.

Bill Segraves






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

Date: Tue, 3 Dec 2002 11:53:53 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: advanced html form question
Message-Id: <asismo$ha0$1@slb4.atl.mindspring.net>

"Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
message news:asho6k$t0e$1@nets3.rz.RWTH-Aachen.DE...
<snip>
> [ CGI.pm's HTML generation ]
<snip>
> > I just felt the OP would be better served if he learned to use CGI.pm
_and_
> > the shortcuts it includes, as long as he's using it.
>
> Consistency isn't the worst for a beginner. It probably requires some
> experience to come up with one's own preferences and style.

Indeed! When I was a *new* beginner with Perl, CGI and HTML, I preferred
hand coding my parsers and HTML. Thanks to the urging of the good folks in
this newsgroup, I tried CGI.pm, eventually developing a preference for its
use in favor of hand coding of parsers (especially) and HTML.

As an *older* beginner, I've come to agree with those who favor use of
CGI.pm by *new* beginners. The time saved can be used to learn how to hand
code any HTML that cannot be done correctly by CGI.pm's HTML shortcuts.

Thanks for your insights, Tassilo.

[Note added before sending: I see Alan Flavell has called for a "truce". I
wasn't aware of anything needing a truce. perhaps I missed something. ;-)]

Cheers to Tassilo and Alan.

Bill Segraves






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

Date: Tue, 3 Dec 2002 12:03:51 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: advanced html form question
Message-Id: <asismp$ha0$2@slb4.atl.mindspring.net>

"Alan J. Flavell" <flavell@mail.cern.ch> wrote in message
news:Pine.LNX.4.40.0212031149320.20938-100000@lxplus073.cern.ch...
> On Dec 3, Tassilo v. Parseval inscribed on the eternal scroll:
>
> > Also sprach William Alexander Segraves:
> >
> > > "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de> wrote in
> > > message news:asgq6c$aum$1@nets3.rz.RWTH-Aachen.DE...
> >
> > [ CGI.pm's HTML generation ]
>
> I suggest that you guys call a truce ;-)

O.K. Truce. Where was the battle? ;-)

> I've used both methods of
> generating snippets of HTML - on the one hand CGI.pm's methods, seeing
> that I'd be using CGI.pm already, or on the other hand Here-documents
> or other sources of snippets of HTML boilerplate - and could be
> comfortable with either in many contexts.
>

The OP should read Alan's commentary.

> Generating form elements, I'd certainly veer towards fully exploiting
> the CGI.pm methods, I guess that speaks for itself.  Generating simple
> boilerplate (with maybe the occasional variable interpolation) I think
> I'd more often veer towards Here-docs.

O.K. I think I see your point.

> But I don't think it's worth
> arguing the point one way or the other, compared with some
> more-important aspects of CGI programming (like security...)
>

I agree. I don't think anyone was arguing for one or the other. The style
issue that I raised was a different issue, based on my own experiences as a
*new* beginner transitioning to *old* beginner status.

All the Best.

Bill Segraves




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

Date: Tue, 3 Dec 2002 16:01:38 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: ANSWER - Closing excel spreadsheet.
Message-Id: <asikif$lel$1@newshost.mot.com>

Hello World\n ;-)

I have finally solved my problem of closing a modified excel spreadsheet
without getting prompted to save changes.

I finally tracked the problem down to something some 1500ish lines away, so
it was my own stupidity that was the problem, but I thought I'd share the
solution, as it may help others.

These lines...

$book -> Close (0);
$excel -> Quit;

will close the spreadsheet, no matter what, without giving a prompt, and
then exit excel. The spreadsheet will be closed if the changes are not
saved. Even if the spreadsheet is already closed, you will not get any kind
of error, so it would work well in an END block, which is where I was using
it.

Share and Enjoy!

R.




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

Date: Tue, 3 Dec 2002 14:27:27 +0100
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Cache the execution of a Perl CGI?
Message-Id: <Pine.LNX.4.40.0212031422200.20938-100000@lxplus073.cern.ch>

On Dec 3, Peter Wu inscribed on the eternal scroll:

> "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> >
> > What is your Perl question?
>
> The Perl question is whether there is a way to cache the native code
> generated by the interpreter.

The FAQ answer to that question isn't really very useful to this
situation.

Use mod_perl instead of CGI.  http://perl.apache.org




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

Date: Tue, 03 Dec 2002 14:41:41 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Cache the execution of a Perl CGI?
Message-Id: <rhgpuusn807i7jji6f0h54j9brti9q96bj@4ax.com>

Peter Wu wrote:

>The Perl question is whether there is a way to cache the native code
>generated by the interpreter. I just use CGI in Perl as an example. Hope you
>have some ideas.

The interpreter doesn't produce native code. However, it does produce
interpretable token code, which could pass as it... PErhaps using
mod_perl (with APache), PerlIIS (with ActivePerl and IIS on Windows), or
FastCGI can help. These al work on the principle that the script never
ends, but the same sub is called again for the next request.

-- 
	Bart.


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

Date: Tue, 03 Dec 2002 16:45:33 +0100
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: Cache the execution of a Perl CGI?
Message-Id: <newscache$xrvj6h$9ud$1@news.emea.compuware.com>

Peter Wu wrote (Tuesday 03 December 2002 14:01):

[snip]
> I wonder if there is anything that can *cache* the native code generated
> by the 1st execution of that particular CGI.
[snip]


Take a look at SpeedyCGI (at CPAN). You can use this as a drop-in 
replacement for #!/usr/bin/perl. It will keep your Perl interpreter alive 
and have your scripts only "compiled" once. Very convenient software.

-- 
KP



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

Date: Tue, 3 Dec 2002 18:09:31 -0000
From: "tim" <tim@remove.deadgoodsolutions.com>
Subject: Cannot get SASL module to work
Message-Id: <1038938701.78201.0@despina.uk.clara.net>

I have a small perl script that uses SMTP Auth and it works fine under
W2K/ActivePerl 5.6.1.  However under RH8/Perl 5.8.0 I'm having trouble.  I
have installed the Authen package correctly, but when I run my script I get
"No SASL mechanism found".  I'm at a loss as to what to try - could anyone
offer me any pointers?

regards,




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

Date: Tue, 3 Dec 2002 14:07:22 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: Closing an unsaved modded Excel spreadsheet?
Message-Id: <asids5$jnk$1@newshost.mot.com>


"Michele Ouellet" <ouellmi@videotron.ca> wrote in message
news:oO0H9.24106$QT3.279959@weber.videotron.net...

> Actually, the best source of information for this kind of problem is the
> "Programming Information" chapter in the Help system for Excel; in
> particular, the API documentation for Open() and Close(). I think the
> hardest part of using OLE is the object model and that is not really a
Perl
> question. ( I have had similar problems with Word... )
>
> Good Luck,
>
> Michele Ouellet.

Thanks Michelle.

I have now read the Excel documantation...

It says that to close without saving, do this:

ThisWorkbookSaved = True
ThisWorkbookClose

I have translated this into my script as:

$excel -> {ThisWorkbookSaved} = "True";
$excel -> {ThisWorkbookClose};
and
$book -> Saved = "True";
$book -> Close;

But (yes you guessed it!) it STILL doesn't work!

Did I do that right? Please save me from premature baldness.

Thanks.

R.




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

Date: Tue, 03 Dec 2002 16:34:26 GMT
From: Wilbur Goltermann <goltermann@attbi.com>
Subject: Code segfaults on 5.8 but works on 5.6
Message-Id: <m25H9.14131$pN3.1341@sccrnsc03>

The following snippet of code regularly blows up with a segfault
on perl 5.8, but works perfectly on perl 5.6.1:

***faulty snippet***
#!/usr/bin/perl
open TEXT, "TestSong.txt" || die "Unable to open lyrics text file";
#Add the rest of the lines of the text file
print "We seem to be opening the file\n";

LYRIC:while ( $line = <TEXT> ) {
    #show the line before segfault occurs
    print "1: $line";

    #capitalize the first letter of each linethis ; line causes a segfault
        $line =~ s/^(\s*)(\w*)/$1\u$2/;

    #and show again, should we successfully; execute the offending line
    print "2: $line";
}

***end of faulty snippet****


Just to be sure we end up testing the same thing, here is the 
context of the file I used bor my test case, here it is: 

***TestSong.txt***
Unknown

abeline, abeline prettiest town that i've ever seen
women there don't treat you mean in abeline my abeline

i sit alone most every night
watch those trains pull out of sight
don't i wish they were carrying me back to abeline my abeline

crowded city there ain't nothing free
nothing in this town for me
wish to the lord that i could be in abeline my abeline
***end of TestSong.txt***

On an equally curious note, It appears that the thing blows up
only when processing blank lines.  If I preceed the faulty line
with a statement which does not process a line unless it is
non-blank, the thing works yust-fine-yah-shoor-you-betcha!
Here's a version of the snippet which does not blow up.

***working snippet***
#!/usr/bin/perl
open TEXT, "TestSong.txt" || die "Unable to open lyrics text file";
#Add the rest of the lines of the text file
print "We seem to be opening the file\n";

LYRIC:while ( $line = <TEXT> ) {
    #show the line before segfault occurs
    print "1: $line";

    #capitalize the first letter of each line
    #process the line only if non-blank
    if ( $line =! m/^$/ ) {
        $line =~ s/^(\s*)(\w*)/$1\u$2/;
    }

    #and show again, should be successfully execute the offending line
    print "2: $line";
}
***end of working snippet***

The whole thing works perfectly under 5.6.1, and even does the
intended job.  It appears that something is wrong with Perl
5.8;  it doesn't matter what you feed an interpreter - if it
is bug-free, it shouldn't seg fault under any circumstances.

Wilbur


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

Date: 3 Dec 2002 08:32:42 -0800
From: alanluc@rogers.com (flinky)
Subject: displaying $ symbol in output??
Message-Id: <9b921b8d.0212030832.34bcb01a@posting.google.com>

Hello All

I am very new to perl and I have one very basic question.  I am having
trouble displaying the $ as a text format.  I just want to write lets
say $100 to a file.  but whenever I use the dollar sign, something
will be missing or the format will be messed up.  Any help is greatly
appreciated.  Advance thanks for everyone!


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

Date: 3 Dec 2002 16:34:35 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: displaying $ symbol in output??
Message-Id: <asimer$8fk$1@canopus.cc.umanitoba.ca>

In article <9b921b8d.0212030832.34bcb01a@posting.google.com>,
flinky <alanluc@rogers.com> wrote:
:I am very new to perl and I have one very basic question.  I am having
:trouble displaying the $ as a text format.  I just want to write lets
:say $100 to a file.  but whenever I use the dollar sign, something
:will be missing or the format will be messed up.

print 'The price is $100', "\n";
print "The price is \$100\n";
--
Contents: 100% recycled post-consumer statements.


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

Date: 3 Dec 2002 09:47:58 -0800
From: simonf@simonf.com (Simon)
Subject: Future of Perl as an application server language?
Message-Id: <3226c4d3.0212030947.556f7ed1@posting.google.com>

Hello fellow Perl monks!

I have recently went to the Software Development Conference/Expo in
Boston and was faced with the fact that Java seems to be the language
of choice for serious web applications.

I am developing intranet applications in Perl, borrowing and writing
code that slowly becomes an application server framework. I am sure
lots of people do the same thing in Perl. However, I think the lack of
standards is killing us.

On the level of the language itself, Java is probably about as
productive as Perl (though Craig Larman noted that scripting languages
tend to yield better productivity). However, Java folks don't reinvent
database access modules, Model-View-Controller patterns or
configuration file locations - this is pretty much settled, and they
keep moving forward.

Do you know that coarse-grained session beans give you better
performance than any kind of entity beans, even with caching? This is
just a condensed form of saying that fetching objects from the
database is best done in one fell swoop into some kind of data
structure, rather than going to the database every time an object is
created. Nothing groundbreaking, but the Java folks have enough common
terminology to pack more bandwidth into the conversation, which makes
it easier to pursue higher level concepts.

I am proud of using Perl, the "duct tape of the Internet" (tm). But
how many real-world companies will start new projects with nothing but
duct tape?

I wonder what the community thinks about an emergence of some kind of
standard for Perl application servers. Is this possible/desirable at
all? Who would have the authority to push it? Is there something close
enough to a standard which is not well known?

Yes, there are a few projects listed on
http://perl.apache.org/products/app-server.html . However, only Bivio
and OpenInteract seem to be comprehensive enough. Bivio is new, and
OpenInteract is mentioned once in a while in the newsgroups, but its
Sourceforge project has only three developers. There is the barely
alive PAS project, plus a great paper about Camelot (but with no
implementation to follow). Pretty bleak, I would say. :(

If you are still having doubts, check out your nearest bookstore. You
will see shelves upon shelves of Java/Tomcat/EJB books, plus a few on
Zope. How come Zope is a strong Python brand, but there is no strong
Perl brand?

Simon


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

Date: Tue, 03 Dec 2002 16:01:52 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: HELP! Looking for a cgi
Message-Id: <3DECD50B.2020501@dev.null>



Jorge Mesa wrote:

> I want to thank to everyone, for your posts and for your support,
> This my cgi resulted:
> =================
> #!/usr/bin/perl
> #redirect.pl
> 
> use CGI qw/:standard/;
> 
> print header(1,'301 Moved Permanently'),
> print redirect('http://www.terra.es/');
> ==================
> 
> When I check it on: http://www.searchengineworld.com/cgi-bin/servercheck.cgi
> 
> The results:
> Status: HTTP/1.1 302 Object Moved  
> Location: http://www.terra.es/  
> Server: Microsoft-IIS/5.0  
> Content-Type: text/html  
> Connection: close  
> Content-Length: 153  
> 
> But if I cut the last line: print redirect('http://www.terra.es/');
> The results:
> Status: HTTP/1.1 301 Moved Permanently  
> Server: Microsoft-IIS/5.0  
> Date: Tue, 03 Dec 2002 01:22:06 GMT  
> Connection: close  
> HTTP/1.0 301 Moved Permanently  
> Content-type: 1  
> 
> Why my cgi can not send the header and redirect???


Because in a sense header() and redirect() overlap in functionality. You 
either use one or the other. Luckily, redirect takes much the same 
arguments as header. You can do something along the lines of

#!/usr/bin/perl

use strict; #neither here nor there, but nice to have anyway
use CGI;

my $q=new CGI;

print $q->redirect(	-uri=>'http://www.terra.es/',
			-status=>'301 Moved Permanently'
);

This gives me the headers:

Status: HTTP/1.1 301 Moved Permanently
Date: Tue, 03 Dec 2002 16:40:41 GMT
Server: Apache/1.3.26 (Unix) mod_perl/1.26
location: http://www.terra.es/
Keep-Alive: timeout=15, max=100
Connection: Keep-Alive
Transfer-Encoding: chunked
Content-Type: text/plain
X-Pad: avoid browser bug

 ...and I'm forwarded to www.terra.es

By the way, "HELP! Looking for a cgi" is a terrible thing to put in your 
subject field. Subjects like this are typically followed by requests for 
cool counter and guestbook scripts by budding webmasters. I bet half the 
people who could have answered your question chose not to read your post 
because of the poorly chosen subject.



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

Date: Tue, 03 Dec 2002 10:23:25 -0600
From: user <du_bing@hotmail.com>
Subject: Re: how to get it quoted?
Message-Id: <3DECDA7D.90CCF59A@hotmail.com>

I tried open(MAIL,"|mailx -s 'for test' 'c24b18d4bb4afdf052330678af9a601d+sent
mail\@neo.tamu.edu'") as you suggested.  No luck either.

mailx still treat 'c24b18d4bb4afdf052330678af9a601d+sent mail\@neo.tamu.edu' as two separate
email addresses even though it's quoted.

Bing

Tad McClellan wrote:

> user <du_bing@hotmail.com> wrote:
>
> > Subject: how to get it quoted?
>
> Errr, by using quote marks?
>
> > open(MAIL,"|mailx -s 'for test' c24b18d4bb4afdf052330678af9a601d+
>                         ^^^^^^^^
> > sent-mail\@neo.tamu.edu");
>
> You already have an argument with a space in it there, do
> the same thing for any other arguments with spaces.
>
> > However, we have many users whose folder names have space, e.g. 'sent
> > mail'.
>
> > So the question is how should I get mail delivered to folders with space
> > in name?
>
> Put quotes around the argument that contains a space, just like
> you did for the other argument that contained a space.
>
> > open(MAIL,"|mailx -s 'for test' c24b18d4bb4afdf052330678af9a601d+sent
> > mail\@neo.tamu.edu") does not work.
>
> open(MAIL,"|mailx -s 'for test' 'c24b18d4bb4afdf052330678af9a601d+sent mail\@neo.tamu.edu'")
>
> --
>     Tad McClellan                          SGML consulting
>     tadmc@augustmail.com                   Perl programming
>     Fort Worth, Texas



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

Date: 3 Dec 2002 18:38:13 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: how to get it quoted?
Message-Id: <asitml$boq$1@canopus.cc.umanitoba.ca>

In article <3DEBE50E.FCC655E7@hotmail.com>, user  <du_bing@hotmail.com> wrote:
:However, we have many users whose folder names have space, e.g. 'sent
:mail'.  In this case, changing 'sent-mail' to 'sent mail' will break the
:above script and result in '9389edec9f36467e34cfb759e0c4359c+sent...
:User unknown'.  Apparently, 'c24b18d4bb4afdf052330678af9a601d+sent
:mail@neo.tamu.edu' is treated by mailx as two separate email addresses,
:one is c24b18d4bb4afdf052330678af9a601d+sent and the other is
:mail@neo.tamu.edu.

:So the question is how should I get mail delivered to folders with space
:in name?

:open(MAIL,"|mailx -s 'for test' c24b18d4bb4afdf052330678af9a601d+sent
:mail\@neo.tamu.edu") does not work.

This isn't really a perl question. This is an RFC822 question.
According to RFC822, space can only occur in a local-part if the
local-part is quoted. See RFC822 "D.  ALPHABETICAL LISTING OF SYNTAX RULES"
at your favorite RFC server such as http://www.faqs.org

The task of your perl code would thus be to deliver to mailx
a destination address such as
 "c24b18d4bb4afdf052330678af9a601d+sent mail"@neo.tamu.edu
*complete with the double-quotes*. You will have to take into account
that the command will be executed through a shell so you have to account
for normal shell quoting. Try this:

open(MAIL,"|mailx -s 'for test' '"c24b18d4bb4afdf052330678af9a601d+sent mail"\@neo.tamu.edu'")
--
   "The human genome is powerless in the face of chocolate."
   -- Dr. Adam Drewnowski


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

Date: 3 Dec 2002 06:24:00 -0800
From: btobin@columbus.rr.com (Bruce Tobin)
Subject: hyphens in CGI parameters
Message-Id: <7fdbcb63.0212030624.5d05a188@posting.google.com>

The following code works:

#!c:\FoxServ\perl\bin\perl.exe

use CGI qw(:standard);
$query = new CGI;
$upfile = $query->upload('inputdata');

open(OUT,">c:\\newfile.txt") || die "Couldn't open output file";

while(<$upfile>) {
  print OUT;
}

close(OUT);

print header;


The following code, which differs from the preceding only in that the
form parameter used has a hyphen, does not work:

#!c:\FoxServ\perl\bin\perl.exe

use CGI qw(:standard);
$query = new CGI;
$upfile = $query->upload('input-data');

open(OUT,">c:\\newfile.txt") || die "Couldn't open output file";

while(<$upfile>) {
  print OUT;
}

close(OUT);

print header;


Is there any way to use hyphenated parameter names successfully with
CGI.pm?


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

Date: Tue, 03 Dec 2002 15:27:27 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: Installing of Win32::API on Win2K
Message-Id: <3DECBF4F.2EF2DBDE@fujitsu-siemens.com>

Helgi Briem wrote:

> However, I repeat what I said earlier.  Win32::API
> comes standard with Activeperl.  If your install does
> not have it already, it is broken and needs to be
> fixed.  Installing each missing module by hand is
> the *wrong* way to go about it  (presumably they are all
> missing, since  your @INC array is much too short)

I removed it yesterday (and re-installed it today) when I gave up
because I wanted to die another day B-{)

Perhaps I'll re-install Win2k ...

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Tue, 3 Dec 2002 14:07:01 +0000 (UTC)
From: mauzo@ux-ma160-15.csv.warwick.ac.uk (Ben Morrow)
Subject: Re: Kicking off commands on a remote machine
Message-Id: <asidq5$m4f$1@wisteria.csv.warwick.ac.uk>

"Rob" <robconvery@totalise.co.uk> wrote:
>Currently I have a program which runs on a single machine. I now want this
>perl app to kick off a command on a remote machine. Which module would I use
>for doing this and does anyone have any pointer to any good online guides?
>Below is a summary of what I am looking to do.

I presume from your .exxe that you're using Win32? It would have been a good
idea to say...

>Have the main perl program running on machine 1.
>I have a perl app waiting/listening on machine 2
>The main program sends a smessage to machine 2 to run "some_command.exe"
>app on machine 2 gets message and then runs command.

I would start with perldoc IO::Socket.

Basically, you want to have a program listening on a socket on machine 2, and
then you connect and send something like
"c:/path/to/some_command.exe\012\015"
from machine 1. You will have to define your own protocol: something simple
like the above is probably best; though you may choose to just close the 
connection rather than bothering with a line terminator.

USE TAINT CHECKING. perldoc perlsec.

OTOH, if you don't care about security (or your network is not connected to the
internet and you trust your users) an easier solution may be to enable telnet
on machine 2 and then send it a command line. Or, preferably, set up some
flavour of sshd and public-key authentication so you don't need to hardcode
passwords.

Or there may be some Win32 RPC which lets you do this without a daemon on
machine2: I have no idea. Anyone?

Probably it's easier to do by hand.

If you're using NT, the srvany and instserv(?) programs from the resource kit
may come in handy to set up you script as a service.

Ben


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

Date: Tue, 3 Dec 2002 09:33:57 -0700
From: "Cold Cathoid" <mememe@meme.com>
Subject: Re: Mime Header Problem
Message-Id: <asimdn$q5v0u$1@ID-158028.news.dfncis.de>


"Ben Morrow" <mauzo@mimosa.csv.warwick.ac.uk> wrote in message
news:ase6s9$nb9$1@wisteria.csv.warwick.ac.uk...
> "Cold Cathoid" <meme@meme.com> wrote:
> >
>
<snip>

> I think this is a CGI error, rather than a Perl error; and the answer is
that
> you're not printing a Content-type header before the rest of your output
so
> httpd is scanning your long query to find if it says Content-type and
fills up
> it's buffer.
>
> Have you got a line like
>
> print <<HTTP;
> Status: 200 OK
> Content-type: text/plain
>
> HTTP
>
> at the top?
>
Actually it turns out that it was a Micro$oft is a POS error. =) I was at my
folks house for supper over the weekend and decided to try the site out on
my dad's computer. Well surprise surprise it works! I tried it on a friend's
computer ... and it works ... tried it on my other networked computer and it
works. I run Phoenix web browser as well and it works there too.

Here's the crazy part ... up until a couple weeks ago I was running Win98 on
my computer. I upgraded to XP Professional and dropped in a new harddrive.
The exact same problem occured after the upgrade. Talk about crazy! For the
life of me I can't figure out why the problem prosisted on my computer after
the upgrade.

Oh well it seems to work on everyone else's computer so it's all good.
Thanks for everyone's responses.




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

Date: Tue, 03 Dec 2002 09:28:33 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: mysql
Message-Id: <3DECE9C1.2000008@vpservices.com>

Bart Lateur wrote:

> ^darkage wrote:
> 
> 
>>>$mysql->query(qq!
>>>   INSERT INTO logs (field1, field2, field3, field4, field5, field6) VALUES
>>>   (@fields)
>>>!);
>>>
> 
>>Is this a reliable method?
>>
> 
> Most definitely not. It'll work for numbers


OT: Really?  MySQL accepts a values list with spaces separating the 
values instead of commas as required by the SQL standard?

[snip other good advice from Bart]

-- 
Jeff



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

Date: 3 Dec 2002 09:20:03 -0800
From: kasp@epatra.com (Kasp)
Subject: Perl Packages question
Message-Id: <3b04990d.0212030920.7cffa9cd@posting.google.com>

I am quite new to Perl and still am grasping the basics. I have seen
many code use packages like IO::File and Mail::Mailer etc etc.

The question I had:-

1. How and from where can I get Perl Packages like Mail::Mailer etc.
From CPAN? But where exactly?

2. How do I install these packages and start using them? A small
example would be greatly appreciated.

Thanks
Kasp.


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

Date: Tue, 03 Dec 2002 18:15:14 GMT
From: Alan Cameron <paladin@techmonkeys.org>
Subject: Re: Perl Packages question
Message-Id: <0frisa.ed5.ln@paladin>

On 3 Dec 2002 09:20:03 -0800, Kasp <kasp@epatra.com> wrote:
> I am quite new to Perl and still am grasping the basics. I have seen
> many code use packages like IO::File and Mail::Mailer etc etc.

> The question I had:-

> 1. How and from where can I get Perl Packages like Mail::Mailer etc.
> From CPAN? But where exactly?

Perl comes with a whole bunch of modules by default.  You can see if you
have a particular module installed by typing at the command line

perl -MSome::Module -e1

Note: the M in -M is not part of the module name. in the above, the module
is Some::Module.

If you don't get an error message about not being able to find the module
in @INC then you have it installed.

You can look through and search for modules at search.cpan.org.

> 2. How do I install these packages and start using them? A small
> example would be greatly appreciated.

There are a number of ways to install modules depending on your OS.  Some
OS's have packages pre-made for popular CPAN modules.  You can download
the source code from CPAN and compile and install it yourself, or get the
CPAN modules that comes with Perl to do that for you (perldoc CPAN) for 
more info on that.

Note: If you are using Windows and ActivePerl for it, use the ppm program
that comes with it to install modules.

To use a module you use -MSome::Module on the command line, or

use Some::Module;

in your script.  To see what a module does, do perldoc Some::Module once the
module is installed.

There is a lot more information on modules in the Perl docs.  Read
perldoc perl for a list of the standard docs.  The ones dealing with
modules should be fairly self-evident.

-- 
Mother is the name for GOD on the lips and
hearts of all children.  - Eric Draven


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

Date: Tue, 3 Dec 2002 14:15:59 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: problems with die;
Message-Id: <asiecb$jrl$1@newshost.mot.com>

Hello again! :-)

I want to be able to do three things, if a command fails, the last one being
to die, but I've tried every way I can think of, and they've all failed.

This works fine:

use Tk::ErrorDialog;
$ftp = Net::FTP -> new ($host, Debug => 1) or die "Can't connect to
$host.\n$@\n";

I get a TK::ErrorDialog box with the "Can't connect to $host.\n$@\n" warning
in it.

However, I have a status box in my main window, and I want to pass the same
message to it as well. Here's what I want to do, but it doesn't work. How
_should_ this command be worded?

use Tk::ErrorDialog;
$ftp = Net::FTP -> new ($pop_host, Debug => 1) or {
     $status = "Can't connect to $pop_host.\n$@";
     $main_window -> update;
     die "Can't connect to $pop_host.\n$@\n";
}

Thanks.

R.




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

Date: Tue, 03 Dec 2002 14:39:18 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: problems with die;
Message-Id: <ucgpuusjqokmpngtb7spgpcvv8n9at1ui9@4ax.com>

Richard S Beckett wrote:

>However, I have a status box in my main window, and I want to pass the same
>message to it as well.

Perhaps you can set the message in a $SIG{__DIE__} handler.

	$SIG{__DIE__} = sub {
	   setstatus(@_);
	   die shift;	# proceed
	}

>How
>_should_ this command be worded?
>
>use Tk::ErrorDialog;
>$ftp = Net::FTP -> new ($pop_host, Debug => 1) or {
>     $status = "Can't connect to $pop_host.\n$@";
>     $main_window -> update;
>     die "Can't connect to $pop_host.\n$@\n";
>}

Put a "do" between the "or" and the "{", and put a ";" after the closing
"}".

-- 
	Bart.


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

Date: Tue, 03 Dec 2002 15:01:49 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: problems with die;
Message-Id: <3DECC6F9.20504@dev.null>



Richard S Beckett wrote:


> I want to be able to do three things, if a command fails, the last one being
> to die, but I've tried every way I can think of, and they've all failed.

Pack your three things into a sub like this:

open FILE, '\no\such\file\on\this\system' or die_another_day($!);

sub die_another_day(){
	my $errormessage=shift;
	my %colors=(	roses=>'red',
			violets=>'blue',
			ilove=>'you'
	);
	die $errormessage;
};



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

Date: Tue, 3 Dec 2002 15:46:43 -0000
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Re: problems with die;
Message-Id: <asijmg$l5m$1@newshost.mot.com>

"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:ucgpuusjqokmpngtb7spgpcvv8n9at1ui9@4ax.com...
> Richard S Beckett wrote:
>
> >However, I have a status box in my main window, and I want to pass the
same
> >message to it as well.
>
> Perhaps you can set the message in a $SIG{__DIE__} handler.
>
> $SIG{__DIE__} = sub {
>    setstatus(@_);
>    die shift; # proceed
> }
>
> >How
> >_should_ this command be worded?
> >
> >use Tk::ErrorDialog;
> >$ftp = Net::FTP -> new ($pop_host, Debug => 1) or {
> >     $status = "Can't connect to $pop_host.\n$@";
> >     $main_window -> update;
> >     die "Can't connect to $pop_host.\n$@\n";
> >}
>
> Put a "do" between the "or" and the "{", and put a ";" after the closing
> "}".

BART, I LOVE YOU!!!!!! :-)

I'd already tried the $SIG{__DIE__} handler, but it wasn't appropriate for
what I was trying to do, but the other method you mentioned works
beautifully, thankyou very much!! :-)

I had to slightly modify my code, though, because $@ is lost too quickly.
This does exactly what I wanted it to do:

$ftp = Net::FTP -> new ($host, Debug => 1) or do {
     my $error = $@;
     $status = "Can't connect to $host.\n$error";
     $main_window -> update;
     die "Can't connect to $host.\n$error\n";
};

R.





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

Date: 3 Dec 2002 09:23:58 -0800
From: bgwhite@uofu.net (BrianWhitehead)
Subject: Re: Timezone
Message-Id: <945814d4.0212030923.1492fe18@posting.google.com>

Darren Dunham <ddunham@redwood.taos.com> wrote in message news:<KNNG9.416$p71.5792078@newssvr14.news.prodigy.com>...
> BrianWhitehead <bgwhite@uofu.net> wrote:
> > Howdy,
>  
> > I receive data from all different timezones.  I usually convert the
> > data and store it in one common timezone.
>  
> > In the past I do this by minipulating the TZ variable.  For example:
>  
> > $ENV{TZ} = "GMT+8";
> > print scalar localtime;
> > print "\n";
>  
> > $ENV{TZ} = "GMT+9";
> > print scalar localtime;
> > print "\n";
>  
> > This is supposed to print out two different times... it does work on a
> > Sun box, but when I move to a linux (Redhat 7.2, Redhat 7.3 and Redhat
> > 8.0), it doesn't work
> 
> Works fine on a redhat box here..
> 
> # uname -a
> Linux tester 2.4.18-5smp #1 SMP Mon Jun 10 15:19:40 EDT
> 2002 i686 unknown
> # perl /tmp/perl
> Mon Dec  2 10:36:16 2002
> Mon Dec  2 09:36:16 2002
> # perl -v
> 
> This is perl, v5.6.1 built for i386-linux
> [...]
> 
> > From the command line it does work on linux, for example:
> > perl -e '$ENV{TZ}="GMT+8"; print scalar localtime, "\n"'
> > perl -e '$ENV{TZ}="GMT+9"; print scalar localtime, "\n"'
> 
> Verrry interesting.  That would seem to rule out problems with the
> actual time libraries.  
> 
> > Does anyone have any help?
> 
> What version of perl is on the Linux box?

I use the the stock perl that came with redhat.  

On redhat 8.0
# uname -a
Linux meteor 2.4.18-17.8.0smp #1 SMP Tue Oct 8 10:52:32 EDT
2002 i686 athlon i386 GNU/Linux
# perl -v
This is perl, v5.8.0 built for i386-linux-thread-multi

On redhat 7.3
# uname -a
Linux quark 2.4.18-10smp #1 SMP Wed Aug 7 09:36:38 EDT
2002 i686 unknown
# perl -v
This is perl, v5.6.1 built for i386-linux


Brian


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


------------------------------
End of Perl-Users Digest V10 Issue 4210
***************************************


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