[23908] in Perl-Users-Digest
Perl-Users Digest, Issue: 6110 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 10 21:05:44 2004
Date: Tue, 10 Feb 2004 18:05:07 -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, 10 Feb 2004 Volume: 10 Number: 6110
Today's topics:
Re: Array size <dd-b@dd-b.net>
Re: Comparing a string to filenames in a directory <tadmc@augustmail.com>
excel export (naren)
Re: excel export <simon@unisolve.com.au>
Re: generate a list of file extensions? <dwall@fastmail.fm>
Re: generate a list of file extensions? <me@privacy.net>
Re: generate a list of file extensions? <tore@aursand.no>
MIME::Entity attaching from an open filehandle? <mb@uq.net.au.invalid>
Re: MIME::Entity attaching from an open filehandle? <usenet@morrow.me.uk>
Re: Performance patch to Parse-Yapp 1.05 (John M. Gamble)
Re: Perl usage these days? (at)FinancialDataCorp.com (Bob Mariotti)
Re: Perl usage these days? thumb_42@yahoo.com
Re: Perl usage these days? <pkent77tea@yahoo.com.tea>
Re: Perl usage these days? (Kevin Shay)
Re: Proc::Background killing parent process when child thumb_42@yahoo.com
Re: Proc::Background killing parent process when child <usenet@morrow.me.uk>
Re: trying to create a network script: <usenet@morrow.me.uk>
UNIX Find on Windows <brian.getridofthis.bygland@boeingDELETEthis.com>
Re: UNIX Find on Windows <emschwar@pobox.com>
Re: UNIX Find on Windows <tadmc@augustmail.com>
Re: Why is Perl losing ground? thumb_42@yahoo.com
Re: Why is Perl losing ground? <dd-b@dd-b.net>
Re: Why is Perl losing ground? (Walter Roberson)
Re: Why is Perl losing ground? <tore@aursand.no>
Re: Why references?? thumb_42@yahoo.com
Re: Why references?? <usenet@morrow.me.uk>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 10 Feb 2004 18:09:36 -0600
From: David Dyer-Bennet <dd-b@dd-b.net>
Subject: Re: Array size
Message-Id: <m23c9i5ven.fsf@gw.dd-b.net>
Richard Morse <remorse@partners.org> writes:
> In article <m2r7x3ao7a.fsf@gw.dd-b.net>,
> David Dyer-Bennet <dd-b@dd-b.net> wrote:
>> "gnari" <gnari@simnet.is> writes:
>> > did you try $#$f ?
>>
>> No, but I'm quite sure it's not in the man pages anywhere, because I
>> looked at all the $# hits, and didn't find it.
>
> $ perldoc perlintro
etc. Yes, I know there's doc on $#arrayname; plenty of it. It was
trying to apply it to a reference that I asked about, and was
talking. It's really better to understand the discussion before
jumping into the middle!
--
David Dyer-Bennet, <mailto:dd-b@dd-b.net>, <http://www.dd-b.net/dd-b/>
RKBA: <http://noguns-nomoney.com> <http://www.dd-b.net/carry/>
Photos: <dd-b.lighthunters.net> Snapshots: <www.dd-b.net/dd-b/SnapshotAlbum/>
Dragaera/Steven Brust: <http://dragaera.info/>
------------------------------
Date: Tue, 10 Feb 2004 17:55:43 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Comparing a string to filenames in a directory
Message-Id: <slrnc2irrv.5tt.tadmc@magna.augustmail.com>
Ben Morrow <usenet@morrow.me.uk> wrote:
> tadmc@augustmail.com wrote:
>> nj_perl_newbie <aotoole@optonline.net> wrote:
>> > chown 23456,23458, "$transdir/$_" || warn $!;
>>
>> It is easier to work with permissions if you think in octal
>> rather than in decimal...
>
> chown, not chmod... :)
Doh!
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 10 Feb 2004 15:30:05 -0800
From: naren_tech@yahoo.com (naren)
Subject: excel export
Message-Id: <c3260cc0.0402101530.25cc0201@posting.google.com>
Hi,
I am trying to export some data into excel through cgi script,
I am using a standard example given in Spreadsheet::WriteExcel
module,
here is the code:
--------------------------------------------------------
#!/apps/bin/perl -w
use strict;
use Spreadsheet::WriteExcel;
# Set the filename and send the content type
my $filename ="cgitest.xls";
print "Content-type: application/vnd.ms-excel\n";
# The Content-Disposition will generate a prompt to save the file. If
you want
# to stream the file to the browser, comment out the following line.
print "Content-Disposition: attachment; filename=$filename\n";
print "\n";
# Create a new workbook and add a worksheet. The special Perl
filehandle - will
# redirect the output to STDOUT
#
my $workbook = Spreadsheet::WriteExcel->new("-");
my $worksheet = $workbook->add_worksheet();
# Set the column width for column 1
$worksheet->set_column(0, 0, 20);
# Create a format
my $format = $workbook->add_format();
$format->set_bold();
$format->set_size(15);
$format->set_color('blue');
# Write to the workbook
$worksheet->write(0, 0, "Hi Excel!", $format);
----------------------------------------------------
But the script is failing at $workbook->add_worksheet(),
here is the error message:
---
Can't locate object method "add_worksheet" via package
"Spreadsheet::WriteExcel" (perhaps you forgot to load
"Spreadsheet::WriteExcel"?) at /cgi-excel.pl line 19.
---
I have checked the path, it should be getting the
Spreadsheet::WriteExcel module, this error may be missleading??
This code was working FINE till last week, but it has broken now;
recently we have updated some of our other perl modules like IO, MIME
etc,
if Spreadsheet::WriteExcel module is using some of those libraries
internally, is there a chance that it will be affected?? I assume it
is not.
Can any body any idea??
thanks,
Naren.
------------------------------
Date: Wed, 11 Feb 2004 11:13:15 +1100
From: Simon Taylor <simon@unisolve.com.au>
Subject: Re: excel export
Message-Id: <c0bs53$21om$1@otis.netspace.net.au>
Hello Naren,
> I am trying to export some data into excel through cgi script,
> I am using a standard example given in Spreadsheet::WriteExcel
> module,
> here is the code:
>
> --------------------------------------------------------
> #!/apps/bin/perl -w
>
> use strict;
> use Spreadsheet::WriteExcel;
[snip]
> my $workbook = Spreadsheet::WriteExcel->new("-");
> my $worksheet = $workbook->add_worksheet();
This should be:
my $worksheet = $workbook->addworksheet();
> my $format = $workbook->add_format();
and that should be:
my $format = $workbook->addformat();
Happy hacking.
Simon Taylor
--
Unisolve Pty Ltd - Melbourne, Australia
------------------------------
Date: Tue, 10 Feb 2004 23:21:00 -0000
From: "David K. Wall" <dwall@fastmail.fm>
Subject: Re: generate a list of file extensions?
Message-Id: <Xns948BBAAA0E221dkwwashere@216.168.3.30>
davido@codethought.nospamforme.com <me@privacy.net> wrote:
> I need to scan a directory tree and generate a list of file extensions
> from that tree for a search against a database. That way I can be
> sure the database is properly updated based on all of the extensions
> in this directory. The directory amounts to projects code and binary
> files. I know how to use File::Find to search a list of file types
> and get their *names*. Would searching and getting the file types be
> basically the same thing?
Yup.
> Could someone point me at some code that could help me accomplish
> this? Much appreciated.
Here's one way:
use strict;
use warnings;
use File::Find;
my %extensions;
find(sub {
$extensions{$1} = '' if /\.([^.]+)$/;
},
@list_of_dirs
);
print join "\n", keys %extensions;
I'm not sure what you want to do if the file has no extension....
--
David Wall
------------------------------
Date: Tue, 10 Feb 2004 15:34:24 -0800
From: "davido@codethought.nospamforme.com" <me@privacy.net>
Subject: Re: generate a list of file extensions?
Message-Id: <6gqi205071l1kr9v93cs8h1cqk0t4ha0b1@4ax.com>
On Tue, 10 Feb 2004 23:21:00 -0000, "David K. Wall"
<dwall@fastmail.fm> wrote:
>Yup.
>
>> Could someone point me at some code that could help me accomplish
>> this? Much appreciated.
>
>Here's one way:
>
Thank you!! It's always forming the regexp that bites me in the
butt.. ;)
> use strict;
> use warnings;
> use File::Find;
>
> my %extensions;
>
> find(sub {
> $extensions{$1} = '' if /\.([^.]+)$/;
> },
> @list_of_dirs
> );
>
> print join "\n", keys %extensions;
>
>I'm not sure what you want to do if the file has no extension....
If someone tries that, that's their problem... ;)
------------------------------
Date: Wed, 11 Feb 2004 02:06:59 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: generate a list of file extensions?
Message-Id: <pan.2004.02.10.23.14.47.117680@aursand.no>
On Tue, 10 Feb 2004 14:43:49 -0800, davido@codethought.nospamforme.com
wrote:
> I need to scan a directory tree and generate a list of file extensions
> from that tree for a search against a database.
perldoc File::Find
perldoc File::Basename
--
Tore Aursand <tore@aursand.no>
"I am become Death, shatterer of worlds." -- J. Robert Oppenheimer,
upon witnessing the explosion of the first atomic bomb.
------------------------------
Date: Wed, 11 Feb 2004 11:11:47 +1000
From: Matthew Braid <mb@uq.net.au.invalid>
Subject: MIME::Entity attaching from an open filehandle?
Message-Id: <c0bvgj$mvh$1@bunyip.cc.uq.edu.au>
Hi all,
I'm using MIME::Tools and all its sundry packages to do some basic mail
manipulation (a little bit unbasic enough to not make MIME::Lite an option).
One part of my code requires attaching a new part onto an existing
message, and while the attach method is simple enough, I have to jump
though hoops when my data is stored in a file and I only have the
filehandle, not the file name.
At the moment, since the data could be quite large, I'm using
File::Temp::tempfile to create a temp file (requesting both a filehandle
and a name), copy the contents from the data filehandle into the
tempfile and then pass the tempfile's name to attach(). This is kind of
irksome because I know the function that returns the data filehandle
(which I can't change at the moment and would be a horrible hack if I
did) has already used File::Temp::tempfile to store the data in the
first place.
So at the moment I've got something like:
# -- START CODE --
my $datah = get_data(...); # The function that returns the data handle
# Its a library function so altering its
# return value would have numerous knock-on
# effects
my $mime = MIME::Entity->build(Data => 'Test',
From => 'test@test.com.invalid',
To => 'test@test.com.invalid',
Subject => 'This is a test');
{
# Urk
my ($tfh, $tempfile) = File::Temp::tempfile(UNLINK => 1);
while (defined(my $line = <$datah>)) {
print $tfh, $line;
}
$mime->attach(Path => $tempfile,
Type => 'application/octet-stream',
Encoding => 'base64');
}
# -- END CODE --
Being able to do something like:
$mime->attach(FH => $datah,
Type => 'application/octet-stream',
Encoding => 'base64');
would be infinitely preferable.
Is there any hidden way to do this, or can someone give me some tips as
to how to add this functionality to MIME::Entity?
MB
------------------------------
Date: Wed, 11 Feb 2004 01:58:30 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: MIME::Entity attaching from an open filehandle?
Message-Id: <c0c286$13l$3@wisteria.csv.warwick.ac.uk>
Matthew Braid <mb@uq.net.au.invalid> wrote:
> At the moment, since the data could be quite large, I'm using
> File::Temp::tempfile to create a temp file (requesting both a filehandle
> and a name), copy the contents from the data filehandle into the
> tempfile and then pass the tempfile's name to attach(). This is kind of
> irksome because I know the function that returns the data filehandle
> (which I can't change at the moment and would be a horrible hack if I
> did) has already used File::Temp::tempfile to store the data in the
> first place.
<snip>
> Being able to do something like:
>
> $mime->attach(FH => $datah,
> Type => 'application/octet-stream',
> Encoding => 'base64');
>
> would be infinitely preferable.
>
> Is there any hidden way to do this, or can someone give me some tips as
> to how to add this functionality to MIME::Entity?
Hehehe a use for two-arg magic open :).
Try passing a path of '&=' . fileno($FH) . This should mean that
whenever the MIME::Body opens the filehandle, it will get the existing
FH on the tempfile.
Note that you are then responsible for making sure your temp file
stays open until after the MIME::Entity object is destroyed. Bad
Things *will* happen if you don't :).
Ben
--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-:-: ben@morrow.me.uk
------------------------------
Date: Wed, 11 Feb 2004 01:48:28 +0000 (UTC)
From: jgamble@ripco.com (John M. Gamble)
Subject: Re: Performance patch to Parse-Yapp 1.05
Message-Id: <c0c1lc$fco$3@e250.ripco.com>
In article <slrnc2eebt.6nq.clint@poly.0lsen.net>,
Clint Olsen <clint@0lsen.net> wrote:
>Hi:
>
>In the generated code, Yapp places in the entire yystate and yyrules array
>references directly in the call. For my application, which calls the
>Parser thousands of times on a grammar that is almost 1000 lines, the
>overhead to recreate this data structure each time dominates the run time.
>Intuition says that moving this to a file-scoped lexical or global in the
>package should mean that overhead is only paid once, and it does. For me,
>this change results in almost a 4x speed improvement.
Maybe to ensure that the patch actually gets implemented, you
could post this to a modules group, and cc the author of the module?
--
-john
February 28 1997: Last day libraries could order catalogue cards
from the Library of Congress.
------------------------------
Date: Tue, 10 Feb 2004 23:30:30 GMT
From: R.Mariotti(at)FinancialDataCorp.com (Bob Mariotti)
Subject: Re: Perl usage these days?
Message-Id: <40296941.1665202@news.cshore.com>
On Tue, 10 Feb 2004 12:50:12 GMT, thumb_42@yahoo.com wrote:
>Just a curious question:
>
>What is perl being used for these days?
>
>Seems almost everything web related I see is PHP or Java. (mostly PHP)
>
>My own experience is that Perl is wonderful for batch processing, command
>line stuff, cron and specialized servers but compared to what is available
>today, really doesn't seem suitable for serious web applications anymore.
>
>So... what are people doing with it? is it still alive? Do people actually
>get paid to work in perl, or is it strictly a labor of love?
>
>(Yes, I know these are FAQ's, but times change, I'm curious about what
>people think these days)
>
>Jamie
My $.02 worth:
Perl is wonderful for text processing. We use it for batch processing
of numerous types of files, generation of email from data content,
generation of forms and formatted letters, etc., etc., etc.
And, our production web site is 100% Perl.
Bob
------------------------------
Date: Wed, 11 Feb 2004 00:39:08 GMT
From: thumb_42@yahoo.com
Subject: Re: Perl usage these days?
Message-Id: <MQeWb.142846$U%5.649589@attbi_s03>
Bob Mariotti <R.Mariotti(at)FinancialDataCorp.com> wrote:
>
> My $.02 worth:
>
> Perl is wonderful for text processing. We use it for batch processing
> of numerous types of files, generation of email from data content,
> generation of forms and formatted letters, etc., etc., etc.
>
> And, our production web site is 100% Perl.
Sounds like you've got an excellent company.
Are they hiring? <g>
In my last company, all the perl was gradually phased out and replaced with
java. (I have to admit, java does have more stable XML handling abilities, and
we were an XML-centric place...)
Was kind of sad because we started the company as a bunch of perl coders.
I wonder, do you folks think maybe perl is declining because people are
waiting for perl 6? (and adopting different languages in the meantime?)
Jamie
------------------------------
Date: Wed, 11 Feb 2004 01:02:43 +0000
From: pkent <pkent77tea@yahoo.com.tea>
Subject: Re: Perl usage these days?
Message-Id: <pkent77tea-5DB376.01022711022004@pth-usenet-02.plus.net>
In article <8s4Wb.270436$xy6.1380339@attbi_s02>, thumb_42@yahoo.com
wrote:
> What is perl being used for these days?
>
> Seems almost everything web related I see is PHP or Java. (mostly PHP)
OK, but how exactly do you know what language many web apps are written
in, the ones that _don't_ have very obvious tell-tale marks (e.g.
certain cookies or query string params, or particular filename
extensions)? What about applications that are used in SSIs, so you never
even know about them? Or applications that run behind-the-scenes doing
on-demand content creation for example?
It could be that the sites you happen to use are ones that seem to use
PHP or Java, and you don't visit sites that seem to use perl.
Anyway, to answer your original question we use perl to provide several
hundred metric shedloads of dynamic content, a lot of constantly-updated
content, searches, quizzes, games, user personalization, community
software, message boards, weather forecasts, geographical data,
syndication feeds, data capture, and Much Much More, and that's just the
stuff on the web site.
Behind that we have a content distribution network, something involving
Real media serving, an array of Content Production and Management
Systems, content moderation services, data mining tools, user
administration, automated data munging pipelines, and a vast number of
greater or lesser scripts for a wide variety of purposes.
A quick 'du -sk' shows about 90 megabytes of stuff checked out of our
CVS repository, and (after a little find...) there seem to be 195,000
lines of .pl and .pm files, which is a subset of only our department's
CVS.
And that's just work stuff, so I think perl's quite popular in some
places :-)
P
--
pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
Remove the tea to reply
------------------------------
Date: 10 Feb 2004 17:36:04 -0800
From: kevin_shay@yahoo.com (Kevin Shay)
Subject: Re: Perl usage these days?
Message-Id: <5550ef1e.0402101736.11b91c4@posting.google.com>
thumb_42@yahoo.com wrote in message news:<8s4Wb.270436$xy6.1380339@attbi_s02>...
> What is perl being used for these days?
>
> Seems almost everything web related I see is PHP or Java. (mostly PHP)
Tens of thousands of websites (and not just weblogs, by any means) are
built and maintained with Movable Type, an application written in
Perl.
--Kevin
------------------------------
Date: Wed, 11 Feb 2004 00:45:40 GMT
From: thumb_42@yahoo.com
Subject: Re: Proc::Background killing parent process when child dies
Message-Id: <UWeWb.268146$I06.2864225@attbi_s01>
Paul Clements <paul.clements@istrat.co.uk> wrote:
> Hi,
>
> I have a perl script which spawns processes by use of Proc::Background
> and this works fine.
>
> One of the child processes accesses a database and if that database is
> down I want as well as the child process to die, I want the parent
> process to exit.
>
> Any clues on how to do this would be very much appreciated
>
> Regards
>
> Paul
I've never used Proc::Background, but in a fork() environment, you can store
the parent process ID to a variable (prior to fork()) and then from the child
send a signal to the parent. kill($PARENT_PID,<whatever_signal>); If you've
got multiple child processes, you'll probably want the parent to tell the
other child procs to exit as well. (just use an event handler in
the %SIG array to do this.)
Jamie
------------------------------
Date: Wed, 11 Feb 2004 01:49:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Proc::Background killing parent process when child dies
Message-Id: <c0c1md$13l$2@wisteria.csv.warwick.ac.uk>
paul.clements@istrat.co.uk (Paul Clements) wrote:
> I have a perl script which spawns processes by use of Proc::Background
> and this works fine.
>
> One of the child processes accesses a database and if that database is
> down I want as well as the child process to die, I want the parent
> process to exit.
>
> Any clues on how to do this would be very much appreciated
If you're on a Unix system, catch SIGCHLD and check it against a list
of spawned processes.
Ben
--
Musica Dei donum optimi, trahit homines, trahit deos. |
Musica truces molit animos, tristesque mentes erigit. | ben@morrow.me.uk
Musica vel ipsas arbores et horridas movet feras. |
------------------------------
Date: Wed, 11 Feb 2004 01:30:33 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: trying to create a network script:
Message-Id: <c0c0jp$oe$1@wisteria.csv.warwick.ac.uk>
[quoting fixed. please quote properly]
Nex6 <Nex6@nospam.com> wrote:
> Ben Morrow wrote:
>
> > open my $FH, '+<', "//$file/c\$/reset.reg" or die "can't open $file: $!";
>
> It did not work,
>
> it just says can't open file....
can't open file... what? There should be an error message. If there
isn't, change the $! to $^E.
> no matter how i try and open it, it does njot open.????
Do you have permission? Can you open the file in Explorer, as the user
the perl script is running as?
I have to admit my knowledge of Windows Networking is hazy at best,
but I wouldn't usually have used one of the $ shares: what happens if
you create an ordinary share?
Ben
--
I've seen things you people wouldn't believe: attack ships on fire off the
shoulder of Orion; I've watched C-beams glitter in the darkness near the
Tannhauser Gate. All these moments will be lost, in time, like tears in rain.
Time to die. |-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-| ben@morrow.me.uk
------------------------------
Date: Tue, 10 Feb 2004 23:13:36 GMT
From: Brian <brian.getridofthis.bygland@boeingDELETEthis.com>
Subject: UNIX Find on Windows
Message-Id: <402965A0.ECC43D08@boeingDELETEthis.com>
I'm fairly new to using Perl on Windows. I need to find all of the
files in a folder and its sub folders that match a pattern. On UNIX I'd
do:
$FOUND = `find $DIRROOT -name "$PATTERN" -print`;
Is there a way to do this on Windows using Perl and/or native Windows
commands?
Brian
------------------------------
Date: Tue, 10 Feb 2004 16:51:30 -0700
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: UNIX Find on Windows
Message-Id: <etosmhiwl19.fsf@fc.hp.com>
Brian <brian.getridofthis.bygland@boeingDELETEthis.com> writes:
> I'm fairly new to using Perl on Windows. I need to find all of the
> files in a folder and its sub folders that match a pattern. On UNIX I'd
> do:
>
> $FOUND = `find $DIRROOT -name "$PATTERN" -print`;
>
> Is there a way to do this on Windows using Perl and/or native Windows
> commands?
perldoc File::Find
also, see find2perl (in the standard distribution on Unix; I'd assume
also on Windows), which converts find commands into equivalent (but
not necessarily optimal) Perl programs that use File::Find.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Tue, 10 Feb 2004 17:59:30 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: UNIX Find on Windows
Message-Id: <slrnc2is32.5tt.tadmc@magna.augustmail.com>
Eric Schwartz <emschwar@pobox.com> wrote:
> Brian <brian.getridofthis.bygland@boeingDELETEthis.com> writes:
>> I need to find all of the
>> files in a folder and its sub folders that match a pattern.
>> Is there a way to do this on Windows using Perl
> perldoc File::Find
>
> also, see find2perl
See also also:
http://www.perl.com/language/ppt/src/find/
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 10 Feb 2004 23:09:20 GMT
From: thumb_42@yahoo.com
Subject: Re: Why is Perl losing ground?
Message-Id: <AwdWb.277148$na.438328@attbi_s04>
Dominic <roqetman@hotmail.com> wrote:
> As a programmer who is addicted to Perl, I am curious as to why Perl is
> losing ground to another bunch of languages, namely: Python, PHP and
> Ruby. I'd like to hear your opinions. Is Perl just not "trendy" anymore?
> Does it still scare programmers who haven't used it? Or do the other
> languages have any major advantages over Perl? I haven't worked in these
> other languages, so I'm not qualified to have much of an opinion here.
> What do you think?
This is an interesting thread.
For _me_ I find perl to be horrible when it comes to large scale stuff. It's
alright if you're the only developer, but if 2 or more people need to work
on it, then it's kind of tough. Java is more "corporate friendly" perl is
seen as more "script kiddie" stuff to some. (hey, I'm trying to be objective
here, I *do* actually like perl)
For the web, I used to like perl, I think all of us have written our own
template engines at some point. (I've written a few..) but perl falls apart
when it comes to big-ticket web stuff because you have to load it each time
OR involve yourself with a bunch of 'AUTOLOAD' code OR use mod_perl which
crashes and burns if there are a lot of modules and such, and anyhow, most
ISP's won't give you mod_perl anyway.
PHP fills this nicely. One thing I can't understand is why the PHP folks are
trying to design PHP to write stuff like graphical interfaces or command
utilities. If they just kept PHP a simple, web-oriented language it'd be
great.
PHP (when I last used it, they may have changed since then..) falls
on it's a** when it comes to exception handling, though. I don't trust PHP
to complex databases that have lots of relations that need updating. The
proliferation of mysql + PHP has some how made a lot of people oblivious to
the need of transaction handling.
They'll find out when the customer gets billed, but the code craps out
before the database was able to insert the customers shipping address.. :-)
Perl + DBI + eval { .... }; handles this problem rather nicely. (as does
java and it's try {} stuff)
Java is really seen more as a profesional language. It's not very fun to
program in, takes 5X more time to do the same thing in perl, but it enforces
a lot of strict rules, so you're less likely to shoot yourself in the foot.
Something about corporations that says "Creativity is a bad thing" java
fills this "strictly no creative processes allowed" void nicely. Perl's
probably loosing ground to java because managers want to make sure their
employees aren't having any fun. (the resourceful perl coder can get around
java's lack of creative abilities by making extensive use of the reflection
API, but Shhhh don't tell Mr. BigWig. :-) )
As for Python or Ruby, has that really taken a bite out of perl?
Jamie
------------------------------
Date: Tue, 10 Feb 2004 18:00:07 -0600
From: David Dyer-Bennet <dd-b@dd-b.net>
Subject: Re: Why is Perl losing ground?
Message-Id: <m27jyu5vug.fsf@gw.dd-b.net>
Tore Aursand <tore@aursand.no> writes:
> Well. For me, mod_perl has never been a problem in a "shared hosting
> environment". mod_perl has never been a problem no matter what.
Look around at how many cheap virtual hosting companies allow
mod_perl, however. And if they say they do, try to find out exactly
how much they let you do in your .htaccess to actually get any use out
of it. And, reading about mod_perl configuration issues (I do use
mod_perl on *my own* server), it looks like there really isn't that
much isolation between the clients. So I can see why virtual hosting
often comes without mod_perl.
mod_php, however, seems to be plenty safe, and very widely supported,
for virtual hosting.
--
David Dyer-Bennet, <mailto:dd-b@dd-b.net>, <http://www.dd-b.net/dd-b/>
RKBA: <http://noguns-nomoney.com> <http://www.dd-b.net/carry/>
Photos: <dd-b.lighthunters.net> Snapshots: <www.dd-b.net/dd-b/SnapshotAlbum/>
Dragaera/Steven Brust: <http://dragaera.info/>
------------------------------
Date: 11 Feb 2004 00:02:59 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Why is Perl losing ground?
Message-Id: <c0brfj$6in$1@canopus.cc.umanitoba.ca>
In article <AwdWb.277148$na.438328@attbi_s04>, <thumb_42@yahoo.com> wrote:
:For _me_ I find perl to be horrible when it comes to large scale stuff. It's
:alright if you're the only developer, but if 2 or more people need to work
:on it, then it's kind of tough. Java is more "corporate friendly" perl is
:seen as more "script kiddie" stuff to some.
One of our programming teams decided to scrap several person-years
worth of Java code -- it was too inflexible at how it handled
array slices, resulting in too much data copying [they are using
fair sized datasets so it really adds up for them.] They've decided
to go pure C++ except perhaps for a graphics toolkit.
perl would not be my first choice for performance... but then
neither would C++.
--
Positrons can be described as electrons traveling backwards in time.
Certainly many Usenet arguments about the past become clearer when they
are re-interpreted as uncertainty about the future.
-- Walter Roberson
------------------------------
Date: Wed, 11 Feb 2004 02:19:34 +0100
From: Tore Aursand <tore@aursand.no>
Subject: Re: Why is Perl losing ground?
Message-Id: <pan.2004.02.11.01.11.59.205242@aursand.no>
On Tue, 10 Feb 2004 18:00:07 -0600, David Dyer-Bennet wrote:
>> Well. For me, mod_perl has never been a problem in a "shared hosting
>> environment". mod_perl has never been a problem no matter what.
> Look around at how many cheap virtual hosting companies allow mod_perl,
> however.
That's not a problem that has to do with Perl, the programming language,
compared to PHP (or any other language).
This is the _choice_ of many hosting companies. I have almost never come
upon companies that doesn't install mod_perl if you ask them to.
> And if they say they do, try to find out exactly how much they let you
> do in your .htaccess to actually get any use out of it.
Your .htaccess file is your .htaccess file. You should consider changing
to another hosting company if they monitor your changes in the .htaccess
file and/or limit what you can do with it.
> And, reading about mod_perl configuration issues (I do use mod_perl on
> *my own* server), it looks like there really isn't that much isolation
> between the clients. So I can see why virtual hosting often comes
> without mod_perl.
I really don't understand this argument: What do you actually mean with
"isolation between clients"?
I have never had problems with my mod_perl application, and I've been
fiddling around with them for more than 4 years.
The only thing close to "client sharing" I can thing of is shared memory,
and that is without doubt a good thing.
--
Tore Aursand <tore@aursand.no>
"I am become Death, shatterer of worlds." -- J. Robert Oppenheimer,
upon witnessing the explosion of the first atomic bomb.
------------------------------
Date: Wed, 11 Feb 2004 00:12:57 GMT
From: thumb_42@yahoo.com
Subject: Re: Why references??
Message-Id: <dseWb.277282$na.438540@attbi_s04>
Thomas Deschepper <thomas.deschepper.ecol@sintjozefscollege.be> wrote:
> I've been reading Beginning Per & Programming Perl from O'Reilly for some time
> now and I'm getting used to references and how to grow them..
>
> But why would someone use a reference if they can use a normal variable? Yeah, I
> know, with references you can grow complex data structures, but in simple
> programs, why would you use them (=references)?
>
> Thanks for your (smart) answers :)
Aside from making it more efficient, references are handy ways of tracking
variables when processing stream data. Parsing an XML document and storing
the character data is an example:
Say you want something like:
$NAMES{E2620} = "John";
And an XML document with ah, <Employee id="E2620">John</Employee>
$garbage = "";
$char_ptr = \$garbage;
Using a reference you could do this:
# Start an element.
$start = sub {
my($expat,$tag) = (shift,shift);
my(%ats) = @_;
# For a complex structure, the tagname should be table driven,
# another use of references, since the table of expected tags
# will change with each parent tag.
if($tag eq 'Employee'){
my($id) = $ats{id}; # Get employee ID from id="E2620".
$NAMES{$id} = ""; # Clear, and make it a string.
$char_ptr = \$NAMES{$id}; # We want our CDATA here now.
}
};
# Deal with CDATA.
$char = sub {
shift; # Get rid of expat.
$$char_ptr .= shift; # Store character data to whatever area.
};
$end = sub {
...
clear $garbage,
put $char_ptr back to $garbage, or parent,
or wherever you need to store the CDATA from here.
..
};
Using a reference, you don't need to have much logic in your character
handler. (In the above case, it'd be simple to just:
if($id) {
$NAME{$id} .= shift;
}
Try doing that if you need chardata from several XML elements to several
hash elements. (probably most of us have tried the 'non-reference' approach
when learning XML::Parser, increasing the sale of aspirin.. :-) ) If you
don't use references you'll end up tracking which ID, obtain the
current_element() determine which hash element (of which hash variable) to
store your chardata and it gets really messy.
That same bit of 'state logic' helps when parsing other kinds of data, too.
(any time you need to store stuff some place dependent on some prior bit
of info you got from the stream)
So references take what could be a complicated script and turn it into a
simple one. I've simplified a LOT of stuff this way.
There are times when I don't like references, it's a style issue.
an example is a cursor type of implementation:
package MyCursor;
# init.. or whatever you need to do to create $self with a filehandle, etc..
sub fetch {
my($self) = shift;
# Do what is needed for the next "row","entry","thingy".
return(%row);
}
1;
You could return \%row, and it'd probably be faster but then you'd have a
variable that was lexically scoped to MyCursor::fetch() and that just "feels
wrong" to me. (if %row were a large hash, then it's different) Feels better
to have my(%row) = $cursor->fetch(); then my($row) = $cursor->fetch(); I
regard that as a personal choice. (can always use 'wantarray()' and
do either if you're a people pleaser. <g> )
Jamie
------------------------------
Date: Wed, 11 Feb 2004 01:47:17 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: Why references??
Message-Id: <c0c1j5$13l$1@wisteria.csv.warwick.ac.uk>
thumb_42@yahoo.com wrote:
> There are times when I don't like references, it's a style issue.
> an example is a cursor type of implementation:
>
> package MyCursor;
> # init.. or whatever you need to do to create $self with a filehandle, etc..
> sub fetch {
> my($self) = shift;
> # Do what is needed for the next "row","entry","thingy".
> return(%row);
> }
> 1;
>
> You could return \%row, and it'd probably be faster but then you'd have a
> variable that was lexically scoped to MyCursor::fetch() and that just "feels
> wrong" to me.
You haven't made the distinction in your mind between 'variables' and
'values'. If we have
sub hash {
my %h = (a => 'b');
return \%h;
}
my $h = hash;
then the *variable* %h is lexically scoped to the sub. It never gets
out, as in there is nowhere else in the program where %h refers to the
same data. The value, i.e. the hash (the HV), is refcounted like all
Perl values. It starts with a refcount of 1, held by the %h name, then
taking a reference increases its refcount to 2, then when the name %h
goes out of scope it goes back to 1 again, this time held by the
reference in $h.
The distinction is an important dichotomy in Perl (indeed, in all
compiled languages): variables are lexical, values dynamic; variables
are created at compile-time, values at run-time. my acts on variables,
local on values; this is the source of the differences between them.
Ben
--
Joy and Woe are woven fine,
A Clothing for the Soul divine William Blake
Under every grief and pine 'Auguries of Innocence'
Runs a joy with silken twine. ben@morrow.me.uk
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 6110
***************************************