[22489] in Perl-Users-Digest
Perl-Users Digest, Issue: 4710 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 14 14:06:52 2003
Date: Fri, 14 Mar 2003 11:05:09 -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 Fri, 14 Mar 2003 Volume: 10 Number: 4710
Today's topics:
Re: ActiveState 5.6 - Making a local repository? <finisterre@postmaster.co.uk>
Re: Alternatives to FormMail (Dave Cross)
ANNOUNCE: Business::WorldPay::Junior security update <jason@ukpost.com>
ANNOUNCE: MP3::M3U::Parser V1.02 (Burak Gürsoy)
DBI Resources <jc_va@hotmail.com>
Re: DBI Resources (Helgi Briem)
Getting list of files from Win32 clipboard (Phil Hibbs)
Re: Getting list of files from Win32 clipboard <noreply@gunnar.cc>
Re: how to install dbi Module on perl <tore@aursand.no>
Re: it's true but can I say so ? <noemail@nowhere.net>
Re: it's true but can I say so ? <wksmith@optonline.net>
map - sort - lc in one statement <oxmard.Rules@ab.ab>
Re: map - sort - lc in one statement <uri@stemsystems.com>
Re: map - sort - lc in one statement <me@verizon.invalid>
Re: new Perl feature request: call into shared libs <goldbb2@earthlink.net>
Re: pass multiple lines in ? <ericosman@rcn.com>
Re: pass multiple lines in ? <a@c.com>
Re: Question about the filehandle example in the perl F <grazz@nyc.rr.com>
Spreadsheet causes 100% CPUload for over a min!? (Laslo)
Re: Spreadsheet causes 100% CPUload for over a min!? (Christopher Hamel)
Re: Spreadsheet causes 100% CPUload for over a min!? <goldbb2@earthlink.net>
Re: Stupid Perl Questions <barryk2@SPAM-KILLER.mts.net>
Re: Stupid Perl Questions (Helgi Briem)
Re: Stupid Perl Questions <tore@aursand.no>
Re: Stupid Perl Questions <wsegrave@mindspring.com>
Re: Stupid Perl Questions <wsegrave@mindspring.com>
Re: What's wrong with the Perl docs <REMOVEsdnCAPS@comcast.net>
Re: What's wrong with the Perl docs <chang0@adelphia.net>
where's $1? <prlawrence@lehigh.edu>
Re: where's $1? (Malcolm Dew-Jones)
Re: where's $1? <noreply@gunnar.cc>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Fri, 14 Mar 2003 11:19:46 -0000
From: "Fred Finisterre" <finisterre@postmaster.co.uk>
Subject: Re: ActiveState 5.6 - Making a local repository?
Message-Id: <b4sdr4$k1f$1@newsg1.svr.pol.co.uk>
> "In DOS"? Leaving aside the fact that DOS hasn't been used
> in Windows since 1995 except for the first few seconds of
> installation, you should set environment variable
> through the System control panel. Setting them
> via a command prompt makes them transient only.
> --
> Regards, Helgi Briem
> helgi AT decode DOT is
Yeah, yeah, we all know it's not really DOS anymore - it's a figure of
speech for heck's sake! And I tried adding the environment variables in DOS
(sic) and control panel.
Anyway, I've been playing around with making a local repository, but having
some trouble
I copied a loada zips from ppm.activestate.com into c:\repos
Deleted the old repositories using rep del 1 etc
Added using rep add local c:\repos
But the search command in PPM3 doesn't find my modules.
Is it the zips, the .gz files, or the .ppd files I need to have in c:\repos
? I'm guessing it's the zips, since thats whats in the online repositories.
Thanks,
Fred (now using ActivePerl 5.6 and PPM3)
------------------------------
Date: 14 Mar 2003 04:04:36 -0800
From: dave@dave.org.uk (Dave Cross)
Subject: Re: Alternatives to FormMail
Message-Id: <9d3debce.0303140404.7ee920e9@posting.google.com>
Stephan Bour <sbour@niaid.nih.gov> wrote in message news:<BA9636B6.6092%sbour@niaid.nih.gov>...
> in article 9d3debce.0303130621.4106c290@posting.google.com, Dave Cross at
> dave@dave.org.uk wrote on 3/13/03 09:21:
> >
> > Or, the latest version of the nms formmail script don't need an
> > external email program, you can configure it to talk directly to an
> > SMTP server.
> >
> > Dave...
>
> Thanks for the tips Dave. However, it appears that nms-formmmail 2.22 still
> uses /usr/sbin/sendmail by default. It's true though that nms-sendmail can
> replace /usr/sbin/sendmail and that nms-formmail can be configured to use
> nms-sendmail. However, that still leaves me with a 2 elements system to
> support and configure. The SendMail script here
> <http://www.tneoh.zoneit.com/perl/SendMail/> appears to work under Mac OS X
> client with no mail server installed and an external SMTP.
> Please correct me if I'm wrong.
From the description of $mailprog in the README for nms formmail 2.22:
If your web server lacks a sendmail binary, you can
use an SMTP relay instead, by setting $mailprog like
this:
$mailprog = 'SMTP:mailhost.your.domain';
You will need to replace mailhost.your.domain with
the name or IP address of an SMTP server configured
to relay mail for the web server.
Your system administrator or hosting provider should
be able to tell you either the path to sendmail on the
web server or the name of a host that will act as an
SMTP relay for the web server.
So if you send $mailprog to a string that starts with "SMTP:", then
formmail will assume that the rest of the variable contains the name
of an SMTP server and will send email by talking raw SMTP to that
server.
If you have further questions on this, then a better place to get help
is the nms support mailing list. Send an email to
nms-cgi-support@lists.sourceforge.net.
hth,
Dave...
------------------------------
Date: Fri, 14 Mar 2003 18:03:41 GMT
From: Jason Clifford <jason@ukpost.com>
Subject: ANNOUNCE: Business::WorldPay::Junior security update
Message-Id: <144e00382cc1bffbd00adb432b3c6173@news.teranews.com>
Business::WorldPay::Junior version 1.06 has been released today.
This perl module was previously known as
Business::OnlinePayment::WorldPay::Junior and has been renamed to avoid
namespace conflicts with the Business::OnlinePayments API.
This is an important security update. All users of
Business::OnlinePayment::WorldPay::Junior should remove the module and
install the new version.
Existing scripts using the module should be updated as follows:
s/Business::OnlinePayment::WorldPay::Junior/Business::WorldPay::Junior/
You can obtain Business::WorldPay::Junior via CPAN.
Jason Clifford
--
UKFSN.ORG Finance Free Software while you surf the 'net
http://www.ukfsn.org/ Get the T-Shirt Now
UKPOST.COM get your @ukpost.com address now...
http://www.ukpost.com/ professional hosting and colocation
.
------------------------------
Date: Fri, 14 Mar 2003 18:03:32 GMT
From: burakgursoy@gmx.net (Burak Gürsoy)
Subject: ANNOUNCE: MP3::M3U::Parser V1.02
Message-Id: <56cb8585ec943c54fd3c5fea66d2df4e@news.teranews.com>
A m3u (mp3 playlist) parser module. Parses the path and EXINF lines in
a list. It can also export the parsed tree to several formats.
Change LOG:
1.02 Mon Mar 10 22:33:04 2003
Fixed the comma bug. Reported by Brandon Lederer.
Fixed a bug in the formatting seconds part.
Empty result keys (if a search didn't find any matches in a list for
example) are ignored when exporting to xml.
Fixed the html playlist (css code was wrong and only IE was
displaying it correctly).
Updated the POD.
You can get it from CPAN:
http://search.cpan.org/author/BURAK/MP3-M3U-Parser-1.02/
------------------------------
Date: Fri, 14 Mar 2003 13:56:39 GMT
From: "Buck Turgidson" <jc_va@hotmail.com>
Subject: DBI Resources
Message-Id: <b8e7e4839a5238b57dc3b1ab07e82510@news.teranews.com>
I have been looking for some good material on how to implement DBI for
Oracle, but can't find anything of much use.
I want to learn more about Perl, and I figure that going against a live
database will give me something more interesting to do that write "hello
world" programs all day.
Can someone suggest any sites or books on how to get up and running using
DBI?
------------------------------
Date: Fri, 14 Mar 2003 14:18:30 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: DBI Resources
Message-Id: <3e71e34d.3032749443@news.cis.dfn.de>
On Fri, 14 Mar 2003 13:56:39 GMT, "Buck Turgidson"
<jc_va@hotmail.com> wrote:
>I have been looking for some good material on how to implement
>DBI for Oracle, but can't find anything of much use.
You need to install an Oracle client for your
system,DBD::Oracle and DBI.
Then read 'perldoc DBI' for great detail on how to use it.
As suggested in perldoc DBI, you may want to join the
DBI users mailing list dbi-users-help@perl.org
or visit the DBI website: http://dbi.perl.org/
>Can someone suggest any sites or books on how to get up
>and running using DBI?
Books, we don't need no steenking books!
People speak well of "Programming the Perl DBI"
by Alligator Descartes and Tim Bunce
http://www.oreilly.com/catalog/perldbi/
It has a sample chapter at:
http://www.oreilly.com/catalog/perldbi/chapter/
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: 14 Mar 2003 05:01:11 -0800
From: gg@snark.freeserve.co.uk (Phil Hibbs)
Subject: Getting list of files from Win32 clipboard
Message-Id: <a9ec249e.0303140501.2d257005@posting.google.com>
I have a perl script that does this:
use Win32::Clipboard;
my $CLIP = Win32::Clipboard();
if ($CLIP->IsFiles()) {
$CLIP->Set($CLIP->GetFiles);
} else {
$CLIP->Set($CLIP->GetText);
}
This is very useful, for instance, I can copy a file in Explorer, run
this script (which I have bound to a double bucky), and then paste the
full path and name of the file into a text file, or a File Open dialog
box. However, the perldoc says that it should convert multiple files
into a list of file names, but I only get one of them. Any idea how I
get all the file names out of the clipboard?
Phil Hibbs.
------------------------------
Date: Fri, 14 Mar 2003 15:58:50 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Getting list of files from Win32 clipboard
Message-Id: <b4sqto$2332mb$1@ID-184292.news.dfncis.de>
Phil Hibbs wrote:
> I have a perl script that does this:
>
> use Win32::Clipboard;
> my $CLIP = Win32::Clipboard();
> if ($CLIP->IsFiles()) {
> $CLIP->Set($CLIP->GetFiles);
$CLIP->GetFiles is an array. Maybe you may want to try:
$CLIP->Set(join "\n", $CLIP->GetFiles);
> } else {
> $CLIP->Set($CLIP->GetText);
What's the point with that? As far as I understand, it just pastes the
very same text string to the clipboard as was just copied from the
clipboard...
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Fri, 14 Mar 2003 17:17:46 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: how to install dbi Module on perl
Message-Id: <pan.2003.03.13.15.11.47.31572@aursand.no>
On Thu, 13 Mar 2003 06:44:38 -0800, ramesh wrote:
> I am trying to install DBI module on perl...but I am not able to.
Why can't you tell us what you're doing to install it, and what errors you
get?
I'm running Linux, and I _always_ use the CPAN module to install/update
modules;
'perl -MCPAN -e shell'
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: 14 Mar 2003 13:50:07 GMT
From: nobody <noemail@nowhere.net>
Subject: Re: it's true but can I say so ?
Message-Id: <Xns933E5A6CF159Dabccbaabc@129.250.170.100>
>> use strict;
>> sub true{
>> return (1==1)
>> };
>> sub false{
>> return (1==0)
>> };
> ...
> If you tweak the above just a tad:
> ... (This is part
> of how "use constant" works).
Then how about
use constant true => (1==1);
use constant false => (1==0);
if you really must use symbols for true & false.
(See other responses for discussion).
------------------------------
Date: Fri, 14 Mar 2003 15:24:23 GMT
From: "Bill Smith" <wksmith@optonline.net>
Subject: Re: it's true but can I say so ?
Message-Id: <Humca.23003$b8.4181318@news4.srv.hcvlny.cv.net>
"Eric Osman" <ericosman@rcn.com> wrote in message
news:3E711854.1010807@rcn.com...
>
>
--snip--
> I want to ask here : Does Perl provide some builtin way to declare
> something to be "true" or "false" ? Or must some representative
> expressions such as 0 and 1 be used instead ?
>
--snip--
No, but typeglobs provide an obscure but convenient way to declare
constants.
use strict;
use warnings;
use vars qw($TRUE $FALSE);
*TRUE = \1;
*FALSE = \0;
my $found_content = $TRUE;
print "$found_content\n";
$TRUE = 3; # runtime error
I remember seeing this method documented in the online documentation,
but I am unable to find it in the 5.6.1 documentation.
Bill
------------------------------
Date: Fri, 14 Mar 2003 11:44:29 -0600
From: "Peter Shankey" <oxmard.Rules@ab.ab>
Subject: map - sort - lc in one statement
Message-Id: <pqWcnVL_MfCsiO-jXTWc3Q@comcast.com>
#!/bin/perl
#give data in the form of:
my @lines = qw(
aaa:bbb:Y
aaA:bbB:y
aAa:bBb:Y
aAA:bBB:y
ccc:ddd:y
ccC:ddD:y
cCc:dDd:Y
cCC:dDD:y
aaa:bbb:Y
aaA:bbB:y
aAa:bBb:Y
aAA:bBB:y
ccc:ddd:y
ccC:ddD:y
cCc:dDd:Y
cCC:dDD:y
);
# I want the second column (b's and d's) to be case sensitive on a sort and
the
# primary column in the sort. As in reality the second column is a unix
# directory path.
# The first column is not case sensitive. I want the entries ordered
# alpha-numeric. The first column is the secondary sort
# I found I could do this in 2 steps:
@lines = map { $_->[0] }
sort {
$a->[2] cmp $b->[2]
||
lc($a->[1]) cmp lc($b->[1])
||
lc($a->[3]) cmp lc($b->[3])
}
map { [ $_, (split /:/) ] }
@lines;
@lines = map { join ':', lc($_->[0]), $_->[1], lc($_->[2]) }
map { [ @_,@_,@_, (split /:/) ] }
@lines;
foreach (@lines){
print($_, "\n");
}
# I tied to combine the lines into one line but I could not get it to work
# Is there anyway to combine the two steps into one?
Thank you
Pete
------------------------------
Date: Fri, 14 Mar 2003 18:42:31 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: map - sort - lc in one statement
Message-Id: <x7u1e5aiy0.fsf@mail.sysarch.com>
>>>>> "PS" == Peter Shankey <oxmard.Rules@ab.ab> writes:
PS> my @lines = qw(
PS> aaa:bbb:Y
PS> cCC:dDD:y
PS> );
PS> # I want the second column (b's and d's) to be case sensitive on a
PS> sort and the # primary column in the sort. As in reality the
PS> second column is a unix # directory path. # The first column is
PS> not case sensitive. I want the entries ordered #
PS> alpha-numeric. The first column is the secondary sort
PS> # I found I could do this in 2 steps:
PS> @lines = map { $_->[0] }
PS> sort {
PS> $a->[2] cmp $b->[2]
PS> ||
PS> lc($a->[1]) cmp lc($b->[1])
PS> ||
PS> lc($a->[3]) cmp lc($b->[3])
PS> }
PS> map { [ $_, (split /:/) ] }
PS> @lines;
PS> @lines = map { join ':', lc($_->[0]), $_->[1], lc($_->[2]) }
PS> map { [ @_,@_,@_, (split /:/) ] }
what is @_ there? i assume you meant $_
PS> @lines;
PS> # I tied to combine the lines into one line but I could not get it to work
PS> # Is there anyway to combine the two steps into one?
just put your second statement before the first instead of assigning to
@lines there. the output of the first map is the input to the map where
you split.
but since you have the key fields split and you really want to rejoin
them after the lc changes, why even keep the full original line? that is
there since most sorts don't sort on all the parts of the records and
you need the original record in the output.
so do this:
@lines = map { join ':', lc $_->[0], $_->[1], lc $_->[2] }
sort {
$a->[1] cmp $b->[1]
||
lc($a->[0]) cmp lc($b->[0])
||
lc($a->[2]) cmp lc($b->[2])
}
map { [ split /:/ ] }
@lines;
note that i shifted down the field indices in the sort since i don't
keep $_ anymore.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
Damian Conway Perl Classes - January 2003 -- http://www.stemsystems.com/class
------------------------------
Date: Fri, 14 Mar 2003 18:50:34 GMT
From: "dw" <me@verizon.invalid>
Subject: Re: map - sort - lc in one statement
Message-Id: <_vpca.55130$gi1.20696@nwrdny02.gnilink.net>
"Peter Shankey" <oxmard.Rules@ab.ab> wrote in message
news:pqWcnVL_MfCsiO-jXTWc3Q@comcast.com...
> #!/bin/perl
>
> #give data in the form of:
> my @lines = qw(
> aaa:bbb:Y
> aaA:bbB:y
> aAa:bBb:Y
> aAA:bBB:y
> ccc:ddd:y
> ccC:ddD:y
> cCc:dDd:Y
> cCC:dDD:y
> aaa:bbb:Y
> aaA:bbB:y
> aAa:bBb:Y
> aAA:bBB:y
> ccc:ddd:y
> ccC:ddD:y
> cCc:dDd:Y
> cCC:dDD:y
> );
>
> # I want the second column (b's and d's) to be case sensitive on a sort
and
> the
> # primary column in the sort. As in reality the second column is a unix
> # directory path.
> # The first column is not case sensitive. I want the entries ordered
> # alpha-numeric. The first column is the secondary sort
>
> # I found I could do this in 2 steps:
> @lines = map { $_->[0] }
> sort {
> $a->[2] cmp $b->[2]
> ||
> lc($a->[1]) cmp lc($b->[1])
> ||
> lc($a->[3]) cmp lc($b->[3])
> }
> map { [ $_, (split /:/) ] }
> @lines;
>
> @lines = map { join ':', lc($_->[0]), $_->[1], lc($_->[2]) }
> map { [ @_,@_,@_, (split /:/) ] }
> @lines;
>
> foreach (@lines){
> print($_, "\n");
> }
>
> # I tied to combine the lines into one line but I could not get it to work
> # Is there anyway to combine the two steps into one?
>
> Thank you
> Pete
>
Since it appears that you want the final results to have a lowercase first
and last field, I would suggest doing the lc conversion early so you only
have to do it once instead of once for each comparison and once at the end.
@lines = map { join ":", @{$_} }
sort { $a->[1] cmp $b->[1]
||
$a->[0] cmp $b->[0]
||
$a->[2] cmp $b->[2] }
map { my (@sp) = split /:/, $_, 3;
[lc $sp[0], $sp[1], lc $sp[2]] } @lines;
------------------------------
Date: Fri, 14 Mar 2003 14:07:40 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: new Perl feature request: call into shared libs
Message-Id: <3E72287C.7BD0F462@earthlink.net>
Matt Taylor wrote:
[snip]
> Speaking strictly about x86, it is -still- very difficult to generically
> describe all of the calling conventions that are commonly used let alone
> describe weird cases. Register parameter schemes are a -big- problem because
> they put some of the parameters in registers. This is ok, but it changes the
> stack because these parameters no longer appear on the stack. It's not
> predictable because you don't know whether a register calling convention was
> used or not, and without that knowledge you can't set up the stack
> correctly. You can make good guesses, but beware of guessing wrong.
Hmm... that sounds a bit like calling conventions for parrot (the perl6
VM) functions. Depending on what meta-information is known about a
subroutine, arguments may be passed in registers, or on the stack.
I'll admit, I'm a bit unclear about *when* the stack is used, versus
registers, but I'm still learning.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 14 Mar 2003 08:36:27 -0500
From: Eric Osman <ericosman@rcn.com>
Subject: Re: pass multiple lines in ?
Message-Id: <3E71DADB.1070209@rcn.com>
> In the CGI context a browser will send textarea line breaks
> URL-encoded. CGI.pm will decode. Just use %0D%0A
>
> perl reFormat.pl digestContents="123%0D%0A456%0D%0A567%0D%0A"
Thanks Sharon. Your solution worked well ! /Eric
------------------------------
Date: Fri, 14 Mar 2003 08:35:13 -0800
From: "Alan C." <a@c.com>
Subject: Re: pass multiple lines in ?
Message-Id: <v740k4c46fbc7e@corp.supernews.com>
"Eric Osman" <ericosman@rcn.com> wrote in message
news:3E71DADB.1070209@rcn.com...
>
>
> > In the CGI context a browser will send textarea line breaks
> > URL-encoded. CGI.pm will decode. Just use %0D%0A
> >
> > perl reFormat.pl digestContents="123%0D%0A456%0D%0A567%0D%0A"
>
>
> Thanks Sharon. Your solution worked well ! /Eric
>
News to me. That is, the issue of whenever a web browser's address bar slot
or field became the same thing as the windows command line. Glad a solution
for you.
--
Have fun people.
------------------------------
Date: Fri, 14 Mar 2003 15:41:40 GMT
From: Steve Grazzini <grazz@nyc.rr.com>
Subject: Re: Question about the filehandle example in the perl FAQ
Message-Id: <UKmca.133345$ma2.25359375@twister.nyc.rr.com>
Bob Walton <bwalton@rochester.rr.com> wrote:
> Peter Shankey wrote:
>
> ...
>> Sounds like what perldoc is say the <> operator will try
>> and glod, in my case $FHArray[0]. In my case:
>> print ("FHArray is: ", $FHArray[0], "\n\n");
>> returned:
>> *main::FH
>> So my while(<$FHArray[0]>) was looking for a file with
>> the name of:
>> *main::FH
>> Is that what was going on?
>
> No, it was attempting to glob the literal filename pattern
> $FHArray[0]. So if you had a file named '$FHArray[0]', it
> would match and return that name. Just like if you did:
>
> $v='$FHArray[0]';
> ... <$v> ...
The angle bracket glob does interpolation -- which probably
makes little difference here, but if $FHArray[0] contained a
matchable wildcard...
$ perl -le '$a[1] = "/etc/*"; print for <$a[1]>'
/etc/adjtime
/etc/aliases
...
--
Steve
perldoc -qa.j | perl -lpe '($_)=m("(.*)")'
------------------------------
Date: 14 Mar 2003 03:45:51 -0800
From: laslo.bodza@a1.net (Laslo)
Subject: Spreadsheet causes 100% CPUload for over a min!?
Message-Id: <5a5d772e.0303140345.5a46c4@posting.google.com>
Hi Folks,
I'm using McNamara's SpreadSheet with great enthusiasm and it funcs
well. The only trouble is, that the simple (and maybe a little ugly)
script below is swallowing the full power of my CPU for over 70-80 s,
even if source- and target-files are on the local machine (im on W2K,
1GHz, 1024MB, with perl v5.6.1).
There are apparently no errors, but I'm wondering, if I missed
something essential or it DOES need that much time&power? Some other,
similar scripts I wrote are running almost 10x faster on the same
machine...
Any reply will be higly appreciated!
Thanks, Laslo
##########################################################
#!perl -w
use Spreadsheet::ParseExcel;
use Spreadsheet::WriteExcel;
use Data::Dumper;
# Just a quick&dirty time-declaration
(undef,undef,undef,undef,$M,$Y,undef)=localtime(time);
@M = (1..12);
$Y += 1900;
$M = $M[$M];
if ($M < 10) {$M = "0$M";}
# $src is always generated as "YEAR_MONTH.xls" on a substituded drive
$src = "S:\\$Y\_$M.xls";
$tgt = "C:\\MY\\bu_work.xls";
$me = 'myname';
# Parse the source-file
$src_file = Spreadsheet::ParseExcel -> new -> Parse("$src") || "Can't
open $src: $!";
# We need only a particular sheet in $src
$src_sheet = $src_file->Worksheet("$me");
# Read only a particular range in $src_file
foreach $row (0 .. 39) {
foreach $col (0 .. 31) {
$src_cell = $src_sheet->{Cells}[$row][$col];
if ($src_cell) {
$read->{$src_sheet->{Name}}->{$row}->{$col} = $src_cell->Value;}}}
# Open / create a local xls-file to write the data from "$src"-range
into
$dest_file = Spreadsheet::WriteExcel -> new ("$tgt") || "Can't create
$tgt: $!";
foreach $sheet (keys %$read) {
$dest_sheet = $dest_file->addworksheet($sheet);
foreach $row (keys %{$read->{$sheet}}) {
foreach $col (keys %{$read->{$sheet}->{$row}}) {
$dest_sheet->write($row, $col, $read->{$sheet}->{$row}->{$col});}}}
$dest_file->close();
print "Wrote \"$tgt\".\n";
__END__
##########################################################
------------------------------
Date: 14 Mar 2003 07:01:57 -0800
From: hamelcd@hotmail.com (Christopher Hamel)
Subject: Re: Spreadsheet causes 100% CPUload for over a min!?
Message-Id: <4f60d5b3.0303140701.260f4ec3@posting.google.com>
laslo.bodza@a1.net (Laslo) wrote in message news:<5a5d772e.0303140345.5a46c4@posting.google.com>...
> Hi Folks,
>
> I'm using McNamara's SpreadSheet with great enthusiasm and it funcs
> well. The only trouble is, that the simple (and maybe a little ugly)
> script below is swallowing the full power of my CPU for over 70-80 s,
> even if source- and target-files are on the local machine (im on W2K,
> 1GHz, 1024MB, with perl v5.6.1).
> There are apparently no errors, but I'm wondering, if I missed
> something essential or it DOES need that much time&power? Some other,
> similar scripts I wrote are running almost 10x faster on the same
> machine...
No idea what could be wrong. However, for what it's worth, I ran your
program on my machine, 256MB, W2K, Perl 5.8.0 on a spreadsheet that
had every cell you copied filled with some data, and it ran perfectly
in a tad under two seconds.
I don't use ::ParseExcel a lot, but I use ::WriteExcel like crazy. We
routinely generate .xls files on our Unix server in excess of 20MB
with no performance issues. A 40 x 32 spreadsheet should not take
that long to process. Something else has to be going on.
> # Just a quick&dirty time-declaration
> (undef,undef,undef,undef,$M,$Y,undef)=localtime(time);
> @M = (1..12);
> $Y += 1900;
> $M = $M[$M];
> if ($M < 10) {$M = "0$M";}
> # $src is always generated as "YEAR_MONTH.xls" on a substituded drive
> $src = "S:\\$Y\_$M.xls";
Not that you're seeking critique, but a couple of side notes:
1. You can use '/' instead of '\\' to separate directories.
2. Incrementing localtime's month here created a gratuitous @M array.
You can accomplish all of this a little more succinctly with something
like:
my ($M, $Y) = (localtime time)[4,5];
my $src = sprintf "c:/%04d_%02d.xls", $Y + 1900, $M + 1;
3. Oh yes, and strictures are your friend.
------------------------------
Date: Fri, 14 Mar 2003 14:10:52 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Spreadsheet causes 100% CPUload for over a min!?
Message-Id: <3E72293C.AADAB155@earthlink.net>
Laslo wrote:
[snip]
> Any reply will be higly appreciated!
use strict;
use warnings;
And read perldoc perlstyle.
--
$a=24;split//,240513;s/\B/ => /for@@=qw(ac ab bc ba cb ca
);{push(@b,$a),($a-=6)^=1 for 2..$a/6x--$|;print "$@[$a%6
]\n";((6<=($a-=6))?$a+=$_[$a%6]-$a%6:($a=pop @b))&&redo;}
------------------------------
Date: Fri, 14 Mar 2003 08:09:55 -0600
From: Barry Kimelman <barryk2@SPAM-KILLER.mts.net>
Subject: Re: Stupid Perl Questions
Message-Id: <MPG.18db9eaef820a2e989747@news.mts.net>
In article <16008e62.0303130636.5d55706c@posting.google.com>, JohnFrog
(j0hnfr0g@yahoo.com) says...
> I have never used Perl, and I am wondering about this following things
> (OS=Win2K):
>
> 1) Can I call and run DOS executables from a Perl script?
YES
>
> 2) Can I easily create a standalone program (1 file) that runs under
> DOS (command prompt) that contains my script and the Perl interpreter
> (or just what is needed for my script), so that from an end-user
> perspective it just looks like a DOS executable?
YES. Although your script does NOT contain the Perl interpreter.
>
> 3) Is there a preferred place to download a Perl interpreter from?
www.activestate.com
>
> Thanks,
> John
>
--
---------
Barry Kimelman
Winnipeg, Manitoba, Canada
email : bkimelman@hotmail.com
------------------------------
Date: Fri, 14 Mar 2003 14:23:03 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: Stupid Perl Questions
Message-Id: <3e71e558.3033272064@news.cis.dfn.de>
On Fri, 14 Mar 2003 08:09:55 -0600, Barry Kimelman
<barryk2@SPAM-KILLER.mts.net> wrote:
>> 2) Can I easily create a standalone program (1 file) that runs under
>> DOS (command prompt) that contains my script and the Perl interpreter
>> (or just what is needed for my script), so that from an end-user
>> perspective it just looks like a DOS executable?
> YES. Although your script does NOT contain the Perl interpreter.
Wrong. PerlApp from Activestate and Perl2exe and PAR
all work by bundling the Perl interpreter with your script
into a single file. With at least Perl2exe, the only one
I have used, the Perl interpreter can be put in a separate
.dll but I don't know about the others.
--
Regards, Helgi Briem
helgi AT decode DOT is
------------------------------
Date: Fri, 14 Mar 2003 17:17:47 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Stupid Perl Questions
Message-Id: <pan.2003.03.13.15.10.29.294337@aursand.no>
On Thu, 13 Mar 2003 06:36:38 -0800, JohnFrog wrote:
> 1) Can I call and run DOS executables from a Perl script?
Yes;
'perldoc -f system'
'perldoc -f exec'
> 2) Can I easily create a standalone program (1 file) that runs under DOS
> (command prompt) that contains my script and the Perl interpreter (or
> just what is needed for my script), so that from an end-user perspective
> it just looks like a DOS executable?
Not so easily, but it's possible. Take a look at 'perlcc'.
> 3) Is there a preferred place to download a Perl interpreter from?
IF you're running Windows, you should take a look at ActiveState's Perl
and/or IndigoPerl (from IndigoStar);
http://www.activestate.com/
http://www.indigostar.com/
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Fri, 14 Mar 2003 11:06:03 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Stupid Perl Questions
Message-Id: <b4t2m9$jfp$1@slb2.atl.mindspring.net>
"JohnFrog" <j0hnfr0g@yahoo.com> wrote in message
news:16008e62.0303130636.5d55706c@posting.google.com...
> I have never used Perl, and I am wondering about this following things
> (OS=Win2K):
<snip>
> 2) Can I easily create a standalone program (1 file) that runs under
> DOS (command prompt) that contains my script and the Perl interpreter
> (or just what is needed for my script), so that from an end-user
> perspective it just looks like a DOS executable?
TinyPerl, http://tinyperl.sourceforge.net/page.htm.
After downloading and installing TinyPerl,
tinyperl -bin src_name.pl obj_name.exe
produces an executable program that meets your end-user criteria.
With TinyPerl and TinyWeb, several TinyPerl executable files, as well as a
(TinyWeb) web server, can be run from a single floppy disk.
Cheers.
Bill Segraves
------------------------------
Date: Fri, 14 Mar 2003 11:11:31 -0600
From: "William Alexander Segraves" <wsegrave@mindspring.com>
Subject: Re: Stupid Perl Questions
Message-Id: <b4t2oc$4g6$1@slb4.atl.mindspring.net>
"JohnFrog" <j0hnfr0g@yahoo.com> wrote in message
news:16008e62.0303130636.5d55706c@posting.google.com...
> I have never used Perl, and I am wondering about this following things
> (OS=Win2K):
<snip>
BTW, your choice of subject needs work. Please see the posting guidelines.
Cheers.
Bill Segraves
------------------------------
Date: Fri, 14 Mar 2003 06:36:48 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: What's wrong with the Perl docs
Message-Id: <Xns933E4D8584460sdn.comcast@216.166.71.239>
-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1
"John W. Krahn" <krahnj@acm.org> wrote in
news:3E71580F.9676D192@acm.org:
> "Eric J. Roode" wrote:
>>
>> I wonder how hard it would be to write source code filters to map the
>> keywords into a different language?
>
> You should ask Damian. :-)
>
> http://search.cpan.org/author/DCONWAY/Lingua-Romana-Perligata-0.50/lib/
> Lingua/Romana/Perligata.pm
Yes, I did have Perligata in mind when I posted that :-)
- --
Eric
print scalar reverse sort qw p ekca lre reh
ts uJ p, $/.r, map $_.$", qw e p h tona e;
-----BEGIN xxx SIGNATURE-----
Version: GnuPG v1.2.1 (MingW32) - WinPT 0.5.13
iD8DBQE+cczyY96i4h5M0egRAocQAKCGbBln/MwydbIMTd1X+i0teQN79QCgqItr
Xy0SNsYOQeYO99OALjMgxS4=
=AXgA
-----END PGP SIGNATURE-----
------------------------------
Date: Fri, 14 Mar 2003 14:03:47 GMT
From: ebchang <chang0@adelphia.net>
Subject: Re: What's wrong with the Perl docs
Message-Id: <Xns933E5C30CE429chang0adelphia.net@24.48.107.54>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote in
news:slrnb72b8g.bkm.mgjv@verbruggen.comdyn.com.au:
> On Fri, 14 Mar 2003 00:36:52 GMT,
> ebchang <chang0@adelphia.net> wrote:
>> helgi@decode.is (Helgi Briem) wrote in news:3e7087e1.2943802053
>> @news.cis.dfn.de:
>>
>>> On Thu, 13 Mar 2003 20:24:02 +1100, "Tintin"
>>> <me@privacy.net> wrote:
>>>
>>>>>Anyone seen http://clueless.justsomeguy.com/
>>>>>
>>>>>Anyone agree with any of his points?
>>>
>>> Let's see:
>>
>> [snip]
>>
>>>>Some functions documented by saying "works like it does in C"
>>>
>>> Which ones? That is a bug, if true.
>>
>> A couple of function descriptions are similar to the following one
>> for sprintf. That is, they provide good detail, but assume you
>> already know the general principles, without which the details can be
>> confusing.
>>
>> "Returns a string formatted by the usual printf conventions of the C
>> library function sprintf. See below for more details and see
>> sprintf(3) or printf(3) on your system for an explanation of the
>> general principles."
>>
>> Most, however, provide a general explanation in addition to the
>> mention of the C library.
>
> You need to install a newer version of perl than 5.005_03.
C:\>perl -v
This is perl, v5.6.1 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)
Copyright 1987-2001, Larry Wall
Binary build 633 provided by ActiveState Corp. http://www.ActiveState.com
Built 21:33:05 Jun 17 2002
> Note that it is unreasonable to expect the perl developers to rewrite
> documentation for a distribution that is 3 versions behind, and 4
> years old.
Agreed.
> Also note that you cannot just use the documentation for 5.6.1 or
> 5.8.0 with perl 5.005_03 and expect things to work. Perl changes, so
> does the documentation. The most recent documentation belongs to the
> most recent version of Perl. The correct documentation for your
> version of Perl comes with the distribution of that version. If that
> documentation is insufficient, consider upgrading your Perl.
Also Agreed.
> Before insisting on agreeing with the points the OP about the perl
> documentation, at least base that opinion on the latest version of
> Perl.
I wasn't insisting, nor was I particularly agreeing with the creator of the
web site that had the comments. In fact, I thought I was pointing out that
the indicated descriptions were exceptions, not the common practice. The
qualifying words I used were "A couple" and "Most". Helgi Briem asked
"Which ones?" so I responded. (I realize 5.6.1 isn't the latest version,
but I did check the 5.8.0 docs on perldoc.com before using the example.)
> A lot of work has gone into the documentation since 5.005_03.
> It's still not perfect, but you can easily contribute by fixing the
> things that you think are not perfect.
Agreed again, and have already been sending in suggestions.
--
EBC
------------------------------
Date: Fri, 14 Mar 2003 13:09:17 -0500
From: Phil R Lawrence <prlawrence@lehigh.edu>
Subject: where's $1?
Message-Id: <3E721ACD.3020903@lehigh.edu>
Geez, this is so basic... I want to capture 'http://' in $1. What am
I doing wrong?
DB<1> $url = 'http://www.lehigh.edu/foo'
DB<2> $url =~ s{^(.*//)}{}
DB<3> print $1
DB<4> print $url
www.lehigh.edu/foo
Thanks,
Phil R Lawrence
------------------------------
Date: 14 Mar 2003 10:31:05 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: where's $1?
Message-Id: <3e721fe9@news.victoria.tc.ca>
Phil R Lawrence (prlawrence@lehigh.edu) wrote:
: Geez, this is so basic... I want to capture 'http://' in $1. What am
: I doing wrong?
: DB<1> $url = 'http://www.lehigh.edu/foo'
: DB<2> $url =~ s{^(.*//)}{}
: DB<3> print $1
: DB<4> print $url
: www.lehigh.edu/foo
$url = 'http://www.lehigh.edu/foo';
$url =~ s{^(.*//)}{};
print $1;
print $/; # add line break
print $url;
works for me as a script. perhaps the debugger is not.
------------------------------
Date: Fri, 14 Mar 2003 19:27:33 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: where's $1?
Message-Id: <b4t75q$2320e1$1@ID-184292.news.dfncis.de>
Phil R Lawrence wrote:
> Geez, this is so basic... I want to capture 'http://' in $1. What am
> I doing wrong?
>
> DB<1> $url = 'http://www.lehigh.edu/foo'
>
> DB<2> $url =~ s{^(.*//)}{}
>
> DB<3> print $1
>
> DB<4> print $url
> www.lehigh.edu/foo
Well, your syntax is a little odd, but this:
$url = 'http://www.lehigh.edu/foo';
$url =~ s{^(.*//)}{};
sets $1 to 'http://' and $url to 'www.lehigh.edu/foo'.
What's the problem?
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
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 4710
***************************************