[13850] in Perl-Users-Digest
Perl-Users Digest, Issue: 1260 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Nov 2 21:10:32 1999
Date: Tue, 2 Nov 1999 18:10:22 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <941595021-v9-i1260@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 2 Nov 1999 Volume: 9 Number: 1260
Today's topics:
Re: How do I create a library file of subroutines? (Brett W. McCoy)
Re: How do I create a library file of subroutines? (Eric Dew)
Re: HTTP::Date <cassell@mail.cor.epa.gov>
Re: I downloaded MacPerl 5.2.Or4 to blue and white G3 ()
Re: Including modules directly in a script (Brett W. McCoy)
Re: Including modules directly in a script (Kragen Sitaker)
Re: Including modules directly in a script <rick.delaney@home.com>
Re: Including modules directly in a script <rootbeer@redcat.com>
IP ToS and IP Precedence igor_koncevih@my-deja.com
Re: It is always like this here? <cassell@mail.cor.epa.gov>
Re: It is always like this here? (Abigail)
Re: It is always like this here? <aqumsieh@matrox.com>
Re: Just to get rid of dos prompt window. (David H. Adler)
Re: making a variable length string <lr@hpl.hp.com>
Re: Need routine to find banned or "Bad" words <cassell@mail.cor.epa.gov>
Re: New Modules: Conversion of C-structs to Perl (Kragen Sitaker)
Re: Perl and Excel Charting (Kragen Sitaker)
Re: Perl and Excel Charting <jtolley@bellatlantic.net>
Re: perl on ms PWS on win98 <cassell@mail.cor.epa.gov>
Re: Perl4 and Y2K (Paul Kimoto)
Re: Premature End Of Script Headers <cassell@mail.cor.epa.gov>
Re: Premature End Of Script Headers (Kragen Sitaker)
Problem With Delimited Field Sort <klessa@airmail.net>
Re: Problem With Delimited Field Sort (Joe Petolino)
Re: Problem With Delimited Field Sort <skilchen@swissonline.ch>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 02 Nov 1999 23:41:45 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: How do I create a library file of subroutines?
Message-Id: <slrn81v33l.hg.bmccoy@moebius.foiservices.com>
Also Sprach Eric Dew <edew@netcom.com>:
>I haven't seen this in the perl FAQ, but maybe because I'm not using the
>correct words.
>
>This is what I would like to do:
>
>I have a subroutine which I plan to use often in many scripts. Say,
>
>sub oftenUsed {
> my($this,$that);
> do this;
> do that;
> return those;
>}
>
>Instead of having the sub routine reproduced in almost all scripts, I would
>like to have it located in some library style file, say, fusr.pl (frequently
>used sub routines).
The safest way of doing this is to package things up in a Perl Module.
This way you can create its own namespace so you don't clash with
variables from other modules. So you would do this:
package MyLib;
sub oftenUsed {
my($this,$that);
do this;
do that;
return those;
}
and so on.
Then you could stick your library in a common Perl directory where held in
@INC, and do
use MyLib;
Take a look at 'perldoc perlmod' for more details. There are all kinds of
totally cool things you can do with this.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: 3 Nov 1999 00:48:45 GMT
From: edew@netcom.com (Eric Dew)
Subject: Re: How do I create a library file of subroutines?
Message-Id: <7vo0pd$pma$1@nntp6.atl.mindspring.net>
Thanks to all who have replied. Seems like some reading on modules
for tonight.
EDEW
In article <slrn81v33l.hg.bmccoy@moebius.foiservices.com>,
Brett W. McCoy <bmccoy@foiservices.com> wrote:
>Also Sprach Eric Dew <edew@netcom.com>:
>
>>I haven't seen this in the perl FAQ, but maybe because I'm not using the
>>correct words.
>>
>>This is what I would like to do:
>>
>>I have a subroutine which I plan to use often in many scripts. Say,
>>
>>sub oftenUsed {
>> my($this,$that);
>> do this;
>> do that;
>> return those;
>>}
>>
>>Instead of having the sub routine reproduced in almost all scripts, I would
>>like to have it located in some library style file, say, fusr.pl (frequently
>>used sub routines).
>
>The safest way of doing this is to package things up in a Perl Module.
>This way you can create its own namespace so you don't clash with
>variables from other modules. So you would do this:
>
>package MyLib;
>
>sub oftenUsed {
> my($this,$that);
> do this;
> do that;
> return those;
>}
>
>and so on.
>
>Then you could stick your library in a common Perl directory where held in
>@INC, and do
>
>use MyLib;
>
>
>Take a look at 'perldoc perlmod' for more details. There are all kinds of
>totally cool things you can do with this.
>
>--
>Brett W. McCoy bmccoy@foiservices.com
>Computer Operations Manager (Alpha Geek) http://www.foiservices.com
>FOI Services, Inc./DIOGENES 301-975-0110
>---------------------------------------------------------------------------
------------------------------
Date: Tue, 02 Nov 1999 15:13:44 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: HTTP::Date
Message-Id: <381F7028.5BD93B08@mail.cor.epa.gov>
Bill Moseley wrote:
>
> I'm using HTTP::Date::str2time() to convert the If-Modified-Since:
> header. It fails on this sent by Netscape:
>
> Tuesday, 02-Nov-99 20:15:45 GMT; length=20119
>
> Is there a HTTP::* method somewhere that will convert this date, or do I
> need to strip the ; length=20119 myself?
You need to strip it off yourself. Remember, there is no
predicting how idiotic the next output from Nyetscape may be.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 03 Nov 1999 00:10:55 GMT
From: schinder@c22234-c.scllg1.pa.home.com ()
Subject: Re: I downloaded MacPerl 5.2.Or4 to blue and white G3
Message-Id: <j4LT3.5653$pA2.27416@news.rdc1.pa.home.com>
In article <381F008C.4699BBF4@indiana.edu>,
Youyi Fong <yofang@indiana.edu> wrote:
>Hi there,
>
>I downloaded MacPerl 5.2.Or4 to blue and white G3 and experienced two
>problems beyond my comprehension. I apprieciate your oppinion very much!
>
>1) I wrote a program to extract a line "ORIGIN" from a file.
>
>Perl -Sx "{0}" {"Parameters"}; Exit {Status}
>#!perl
>
>open (IN, $ARGV[0]) or die "can't open input file: $!\n";
>open (OUT, ">".$ARGV[0]."new") or die "can't open output file: $!\n";
>while (<IN>){
> print OUT if /ORIGIN/ ;
>}
>
>But the if condition always evaluates to true, no matter what the input
>is. I moved the same code (the first two lines are replaced by
>#!/usr/bin/perl -w) to a Unix machine and it runs just fine. I couldn't
>figure out why.
I just tried your script using MacPerl and a suitable data file, and
it worked just fine. So I suspect the data. Is the file you're
trying to extract from a Unix text file rather than Mac text? If so,
MacPerl will only see a single line, will match any ORIGIN in the
file, and will print out the entire file. To check this, you can
just put a $/ = "\012" at the beginning of the script, which will
force MacPerl to treat the input file as a Unix text file.
>
>
>2) When I double clicked on "Install.MPW_Perl", I was told that MPW is
>not found. Isn't that what I try to install?
No. You can get MPW free from Apple, and a lot of people like it
(personally, when I want Unix I know where to find it). But you don't
need it to run MacPerl, and it doesn't come with MacPerl.
>
>Thanks in advance for any input!
>
>Youyi
>
--
Paul J. Schinder
NASA Goddard Space Flight Center
schinder@leprss.gsfc.nasa.gov
------------------------------
Date: Tue, 02 Nov 1999 23:24:19 GMT
From: bmccoy@foiservices.com (Brett W. McCoy)
Subject: Re: Including modules directly in a script
Message-Id: <slrn81v22v.hg.bmccoy@moebius.foiservices.com>
Also Sprach Peter Sundstrom <send@no.junk.mail>:
>I know this seems a totally crazy thing to do, but I have reasons for doing
>it.
>
>What I want to know is how can I directly include a perl module in my perl
>script. Obviously I can't just plonk in the module code without some mods.
>What modifications would I generally need to make, or is it too difficult?
I'm not sure what you are asking. You use the 'use' or 'require'
statement to use a module (they are kinda like the #include statement in
C/C++ or the import statement in Java).
Dude, this is a basic Perl concept that is covered in the probably the
first chapter of any decent Perl book. Check 'perlmod' using the perldoc
facility of your system.
--
Brett W. McCoy bmccoy@foiservices.com
Computer Operations Manager (Alpha Geek) http://www.foiservices.com
FOI Services, Inc./DIOGENES 301-975-0110
---------------------------------------------------------------------------
------------------------------
Date: Tue, 02 Nov 1999 23:50:25 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Including modules directly in a script
Message-Id: <5NKT3.22617$23.1166217@typ11.nn.bcandid.com>
In article <941570860.482740@shelley.paradise.net.nz>,
Peter Sundstrom <send@no.junk.mail> wrote:
>I know this seems a totally crazy thing to do, but I have reasons for doing
>it.
>
>What I want to know is how can I directly include a perl module in my perl
>script. Obviously I can't just plonk in the module code without some mods.
>What modifications would I generally need to make, or is it too difficult?
Well, lots of things have file scope by default, so you have to be
careful about those: I know about 'my' variables and package
declarations.
If you are careful to 'my' any variables you yourself use, and put a
'package main;' statement after the end of the included module text,
you should avoid these problems.
Obviously any AUTOLOAD magic stuff that goes out and finds files could
have some trouble, too.
I'm not confident that these are the only problems you will run into,
though; I don't know that much about making packages.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 03 Nov 1999 01:19:13 GMT
From: Rick Delaney <rick.delaney@home.com>
Subject: Re: Including modules directly in a script
Message-Id: <381F8DA4.C48BE296@home.com>
Peter Sundstrom wrote:
>
> Jonathan Stowe wrote in message <381ef536_2@newsread3.dircon.co.uk>...
> >In comp.lang.perl.misc Peter Sundstrom <send@no.junk.mail> wrote:
> >> What modifications would I generally need to make, or is it too
> difficult?
> >>
> >
> >What happened when you tried ?
> >
>
> I was using the MIME::Lite module. Some of the global variables
> aren't available in the subroutines.
They're probably available but just not in package main. You will need
to call MIME::Lite's import() method.
T. Yamada <tai@imasy.or.jp> wrote:
> #!/usr/bin/perl
>
> package Included::Perl::Module;
> ...just place source here...
>
> package main;
import Included::Perl::Module;
> ...your script comes here...
perldoc -f use
perldoc perlmod
--
Rick Delaney
rick.delaney@home.com
------------------------------
Date: Tue, 2 Nov 1999 16:54:01 -0800
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Including modules directly in a script
Message-Id: <Pine.GSO.4.10.9911021644530.29670-100000@user2.teleport.com>
On Tue, 2 Nov 1999, Peter Sundstrom wrote:
> Subject: Including modules directly in a script
>
> I know this seems a totally crazy thing to do, but I have reasons for
> doing it.
Not good ones, I'm sure. :-)
I'm suspecting that your reason is that you want to give the program to
someone who (won't|can't|isn't smart enough to) install modules. But
such people would be just as happy if you sold them a 24x CD audio player
so that they could listen to their music faster.
The best advice I can give you is to find a way to change your reasons.
Otherwise, next week, you're going to be trying to include a fast-food
restaurant directly in your bedroom, or include Texas in San Francisco.
Cheers!
--
Tom Phoenix Perl Training and Hacking Esperanto
Randal Schwartz Case: http://www.rahul.net/jeffrey/ovs/
------------------------------
Date: Wed, 03 Nov 1999 01:27:19 GMT
From: igor_koncevih@my-deja.com
Subject: IP ToS and IP Precedence
Message-Id: <7vo31k$svk$1@nnrp1.deja.com>
There is a programm for sending UDP packets:
use Socket;
$proto = getprotobyname('udp');
socket(SH, PF_INET, SOCK_DGRAM, $proto);
$sin = sockaddr_in(200, gethostbyname('host.address'));
for(1..32000){
send(SH,"Number of packet = $_", 0, $sin);
select(undef, undef, undef, 0.1);
}
How can I set IP ToS and IP Precedence in
header of packets?
Thank you.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Tue, 02 Nov 1999 15:06:57 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: It is always like this here?
Message-Id: <381F6E91.30DF146B@mail.cor.epa.gov>
Paul Rotering wrote:
>
> Ala Qumsieh <aqumsieh@matrox.com> writes:
>
> > In a forum discussing the C language, for example, you wouldn't find
> > people asking stupid questions (or you wouldn't find as many people,
[snip]
> You are obviously not a denizen of comp.lang.c. Their definition of what's
> on topic is considerably narrower than comp.lang.perl.misc's yet the
> floating "are discussions of what's on topic on topic" thread is usually
> present. As has been noted, that group has also become the help desk of
> those who cannot be bothered to read the documentation.
Yes, and they also are burdened with responders who give bad
advice, as well as posters who want to start flame wars.
But they don't seem to get the sheer *volume* of this stuff
that appears here.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 2 Nov 1999 17:29:03 -0600
From: abigail@delanet.com (Abigail)
Subject: Re: It is always like this here?
Message-Id: <slrn81usso.tjn.abigail@alexandra.delanet.com>
Jon Shemitz (jon@midnightbeach.com) wrote on MMCCLIV September MCMXCIII
in <URL:news:381F211A.55B2F77@midnightbeach.com>:
@@ Abigail wrote:
@@
@@ > Apparently, you are unware of c.l.p.moderated.
@@ >
@@ > Please do your homework, and come back if you have something new.
@@
@@ Nope, I read it, too. And I'm aware that people here complain that the
@@ moderated group is *too* low-volume. (Perhaps you haven't seen those
@@ messages?)
Message_S_? As in plural? I've seen Larry's complaint. Which got refuted
by Chris. I haven't seen others.
But, suppose it would be true. That a moderated group is too low-volume.
That what would creating another moderated group achieve?
@@ Actually, Abigail dear, I was thinking that you would be a perfect
@@ moderator. You seem to have way too much time on your hands.
I don't even bother to read c.l.p.moderated.
Abigail
--
echo "==== ======= ==== ======"|perl -pes/=/J/|perl -pes/==/us/|perl -pes/=/t/\
|perl -pes/=/A/|perl -pes/=/n/|perl -pes/=/o/|perl -pes/==/th/|perl -pes/=/e/\
|perl -pes/=/r/|perl -pes/=/P/|perl -pes/=/e/|perl -pes/==/rl/|perl -pes/=/H/\
|perl -pes/=/a/|perl -pes/=/c/|perl -pes/=/k/|perl -pes/==/er/|perl -pes/=/./;
-----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
http://www.newsfeeds.com The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including Dedicated Binaries Servers ==-----
------------------------------
Date: Tue, 2 Nov 1999 18:32:00 -0500
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: It is always like this here?
Message-Id: <x3y7lk0tqq7.fsf@tigre.matrox.com>
Jon Shemitz <jon@midnightbeach.com> writes:
> Abigail wrote:
>
> > () Perhaps this suggestion comes up a lot, too: Split the group.
> >
> > Yes it does. Apparently, you seem to suffer from the same disease
> > many people being flamed suffer from to: the inability to read.
> >
> > It's been suggested here, oh, about 12 times a week?
> >
> > Read the frigging group, and you would have known.
>
> Oooh, now I've been flamed by Abigail! How perfectly charming.
>
> You know, when I first subscribed to c.l.p.m, I read the subject lines
> on all the threads on my news feed. I read through quite a few of the
> threads. On a daily basis, I read the subject lines of threads with new
> material, and look into a few.
>
> Splitting the group may, indeed, have been suggested twelve times a week
> in this time - but I haven't seen it.
I was trying to avoid this discussion, but I just want to point out
one thing here.
Usually, the suggestion to split the group doesn't come under a
subject like "I suggest we split clpmisc" or "How about a new forum in
the clp hierarchy". So, scanning the subject lines will not lead you
into encountering such posts.
Almost all such suggestions come in threads that started by a newbie
that asked a simple question that is answered in a multiple locations
in the FAQs and docs. This newbie would then be flamed by someone, and
a whole thread would evolve as to why the atmosphere in clpm is the
way it is and end in various suggestions to improve things, one of
which is splitting clpmisc.
I do agree with Abigail in that we see this suggestion *very* often,
but it's not a solution.
--Ala
------------------------------
Date: 2 Nov 1999 18:33:11 -0500
From: dha@panix.com (David H. Adler)
Subject: Re: Just to get rid of dos prompt window.
Message-Id: <slrn81ut5m.7mh.dha@panix.com>
For what it's worth, I finally broke down and installed less on my
win32 box as my pager (and perldoc_pager). It's still dos, but it's a
bit more bearable... :-/
dha
--
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
however, if people don't like Perl, they don't have to use it. they
can stay at the office solving their problems while the Perl Mongers
go out and drink. ;) - brian d foy in c.l.p.misc
------------------------------
Date: Tue, 2 Nov 1999 15:28:14 -0800
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: making a variable length string
Message-Id: <MPG.12891367a52fb7e098a193@nntp.hpl.hp.com>
In article <381f6cd0$0$216@nntp1.ba.best.com> on 02 Nov 1999 22:59:28
GMT, Jim Matzdorff <syran@best.com> says...
> In article <MPG.1287dbd8c678339698a17c@nntp.hpl.hp.com>,
> Larry Rosler <lr@hpl.hp.com> wrote:
> >Immediately, I think of the 'x' operator.
>
> Ack. Yes, I have now been reminded. I wash trying to do something with
> the pack operator, which also uses 'x', but I completely forgot that it
> can be used on string alone. Which, obviously, makes this problem
> simple.
The 'x' in pack/unpack has to do with skipping bytes or producing null
bytes. No relation to repetition.
> ><SNIP> of agreedly ugly code, which doesn't even compile because of a
> >missing semicolon after 'use strict'. :-)
>
> Hmm... compiles fine for me. I agree, of course, it's wrong. but:
>
> prompt> perl icky 10 5
> SS 111110000000000 (15)
Using just the fragment below, I get a warning about an uninitialized
value in strict.pm line 90.
> prompt> cat icky
> #!/usr/local/bin/perl -w
> use strict
>
> $::initial_length = $ARGV[0];
> $::num_ones = $ARGV[1];
>
> (etc)....
>
> Any reason it should work?
Beats me!
What does this mean:
use strict $::initial_length = $ARGV[0];
Because that's what the compiler sees.
--
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com
------------------------------
Date: Tue, 02 Nov 1999 15:12:42 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Need routine to find banned or "Bad" words
Message-Id: <381F6FEA.B44D7D8B@mail.cor.epa.gov>
Jonathan Stowe wrote:
>
> On Mon, 01 Nov 1999 11:58:31 -0800 David Cassell wrote:
> > Geoff Roberts wrote:
> >
> >> I was after a routine that I could use to look up either reserved or
> >> banned words (eg. rude or offensive words and system reserved words).
[snip]
> > This has been discussed here before. I don't recall any such
> > list, or any pointer to a list. You'll just have to make up your
> > own. But consider how you'll handle these usernames:
> >
> > $h!thead
> > f_u_c_k_y_o_u
> > fsck_my_disk [this is a legal request to a helpdesk, too]
>
> and think of the poor burghers of Scunthorpe too ...
Actually, I included an example like this in some personal
e-mail to the poster, who had an additional [even further
off=topic] question which he wisely took out of the newsgroup.
Don't forget the sites which are *not* porn but which have
used the symbols 'XXX' for a long time. Like the New York
Stock Exchange.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Wed, 03 Nov 1999 00:48:04 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: New Modules: Conversion of C-structs to Perl
Message-Id: <8DLT3.22711$23.1176905@typ11.nn.bcandid.com>
In article <381D7E46.42C37F29@ife.ee.ethz.ch>,
Alex Rhomberg <rhomberg@ife.ee.ethz.ch> wrote:
>I did not find any documented method to convert a C/C++ struct to Perl.
>I therefore wrote something of my own.
Awesomely cool. Have you looked at swig? I think it does something a
bit like this too.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 02 Nov 1999 23:43:45 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Perl and Excel Charting
Message-Id: <RGKT3.22604$23.1164806@typ11.nn.bcandid.com>
In article <7vnpmq$9lj$1@nonews.col.hp.com>,
Paul Schwotzer <pws@col.hp.com> wrote:
>Anyone used Perl to access Excel's Automation interface and
>programmatically create charts/graphs from comma-separated data files?
>
>I'm looking to automate a data gathering and display process which
>currently relies upon manually loading Excel, making the graphs and
>exporting them as HTML pages.
You can probably do this with Win32::OLE.
Also, if your data is in CSV format to start with (as opposed to XLS),
you could probably do the whole deal in Perl -- depending on what level
of sophistication you need for your graphing. PNGgraph is quite
adequate for many needs.
This approach is likely to be much faster and more reliable.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Wed, 03 Nov 1999 02:07:41 GMT
From: James Tolley <jtolley@bellatlantic.net>
Subject: Re: Perl and Excel Charting
Message-Id: <381F9870.9AF80F50@bellatlantic.net>
Paul Schwotzer wrote:
> Anyone used Perl to access Excel's Automation interface and
> programmatically create charts/graphs from comma-separated data files?
>
> I'm looking to automate a data gathering and display process which
> currently relies upon manually loading Excel, making the graphs and
> exporting them as HTML pages.
I have not done this exact thing, but I'm pretty sure that you will find
it easy to do, once you know how to create an Excel object and call
methods on it.
The following will show you how one calls methods and sets/retrieves data.
The rest should be clearer upon viewing the excel ole interface that deals
with your specific issue... or was that what you were asking about...?
use strict;
use Win32::OLE;
my $app = Win32::OLE->new("Excel.Application") or die "no excel: $!";
$app->{'Visible'} = 1; # debug
my $wkbk = $app->Workbooks->Add();#or ->Open("D:\\Book2.xls");
my $sheet = $wkbk->Worksheets(1);
$sheet->Range("A1:A5")->{'Formula'} = "5";
my $range = $sheet->Range("A1:A5");
my $answer = $app->WorksheetFunction->Sum($range);
print "the answer is: $answer\n";
# insert a value into a sheet.
$testsheet->Cells(6,1)->{'Value'} = 10;
############################
On a similar note, I have yet to be able to create a new/save an old xls
file this way. Is there someone who knows how to translate the following
VB(Script?) into Perl?
Sub AddNew()
Set newBook = Workbooks.Add
With newBook
.Title = "1995 Sales"
.Subject = "Sales"
.SaveAs filename:="95Sales.xls" '<-- this is the line I have trouble
with...
End With
End Sub
for that line above, I've tried various things, but I usually get a 'can't
use "1" as a ref...' error.
[Also, inserting comments into cells has been a problem... hope you can
all forgive my skirting with off-topic-ness here.]
Hope this helps, and thanks for any help anyone might have on this
SaveAs("filename:=whatever.xls")?!? issue,
James
------------------------------
Date: Tue, 02 Nov 1999 15:08:56 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: perl on ms PWS on win98
Message-Id: <381F6F08.FB4EB6F8@mail.cor.epa.gov>
Chris Mannings wrote:
>
> Any body know an easy way to get perl to run on a web located on a ms
> Personnal Web Server running on w98? tried mapping to perl exe in regedit,
> tried file assoc in control panel, still getting 'server error 505'. Any
> good ideas?
Bill's post may seem a little snippy, but it is solid advice.
Hardly anyone gets PWS working with Perl without heroic
efforts. Look in the ActivePerl FAQ under Webserver Config
to see some guidance, as well as a few other webservers you
might find easier to get up and running on win98.
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: 2 Nov 1999 18:51:13 -0500
From: kimoto@lightlink.com (Paul Kimoto)
Subject: Re: Perl4 and Y2K
Message-Id: <slrn81uu7h.s5u.kimoto@adore.lightlink.com>
In article <Pine.GSO.4.10.9911021030440.29670-100000@user2.teleport.com>,
Tom Phoenix wrote:
> Okay.... But you should know that it is possible that someone could use a
> bug in an old perl binary to break into your system, depending on how
> things are set up. Many (many!) CERT advisories deal with exploits due to
> buffer overruns, including some advisories about buffer overruns in older
> versions of perl. So, that's why I wouldn't continue to let people use
> Perl 4.
Are these security problems all in suidperl, or are they also in the
regular perl interpreter?
--
Paul Kimoto <kimoto@lightlink.com>
------------------------------
Date: Tue, 02 Nov 1999 15:10:33 -0800
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Premature End Of Script Headers
Message-Id: <381F6F69.CF28D6E7@mail.cor.epa.gov>
Marcel Grunauer wrote:
>
> On Tue, 02 Nov 1999 03:08:46 GMT, kragen@dnaco.net (Kragen Sitaker)
> wrote:
>
> > >p.s. sorry for the cgi content, but I can't approve any messages to
> > >comp.infosystems...cgi.
> >
> > Why does it have to be our problem? If you aren't able to post on an
> > appropriate newsgroup, why do you have to pick comp.lang.perl?
> > Couldn't you post your question on alt.lemurs or alt.tasteless or
> > something?
>
> That sounds like an Abigailism :-)
Nah, to be an Abigailism it would have to have the word 'penguin'
in the newsgroup name. E.g., alt.lemurs.vs.penguins or
alt.tasteless.penguins.without.bbq.sauce . :-)
David
--
David Cassell, OAO cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician
------------------------------
Date: Tue, 02 Nov 1999 23:46:57 GMT
From: kragen@dnaco.net (Kragen Sitaker)
Subject: Re: Premature End Of Script Headers
Message-Id: <RJKT3.22610$23.1165326@typ11.nn.bcandid.com>
In article <ZEMfOOVhwxRIiVD=iIjFK5nUPin=@4ax.com>,
Marcel Grunauer <marcel.grunauer@lovely.net> wrote:
>On Tue, 02 Nov 1999 03:08:46 GMT, kragen@dnaco.net (Kragen Sitaker)
>wrote:
>> >p.s. sorry for the cgi content, but I can't approve any messages to
>> >comp.infosystems...cgi.
>>
>> Why does it have to be our problem? If you aren't able to post on an
>> appropriate newsgroup, why do you have to pick comp.lang.perl?
>> Couldn't you post your question on alt.lemurs or alt.tasteless or
>> something?
>
>That sounds like an Abigailism :-)
Wow. Abigail actually followed up to the same post and responded
exactly the same way, except that she didn't point lovely Marcel at the
Idiot's Guide.
I suppose this is a sign that I am suffering from Newbie Burnout.
My apologies.
--
<kragen@pobox.com> Kragen Sitaker <http://www.pobox.com/~kragen/>
Tue Nov 02 1999
6 days until the Internet stock bubble bursts on Monday, 1999-11-08.
<URL:http://www.pobox.com/~kragen/bubble.html>
------------------------------
Date: Tue, 02 Nov 1999 22:56:48 GMT
From: Kat <klessa@airmail.net>
Subject: Problem With Delimited Field Sort
Message-Id: <7vnq7f$mid$1@nnrp1.deja.com>
I've got a simple "search through a file" program running perfectly
well on a client's site, but now they want to do some sorting based on
the delimited file's contents.
So, I was thrilled to find a "perl recipe" that fit the problem
perfectly. I just cut and pasted it into my code and figured it would
work, but it's resulting in an error. I'm not familiar enough with
what the author is doing (I know sorts, I'm just not familiar with the
way he's doing it) to know what the problem is.
It's from the effectiveperl site, url:
http://www.effectiveperl.com/recipes/sorting.html#delimited_strings
Here's the code snippet in question, straight from that page:
sub fieldsort {
my ($sep, $cols);
if (ref $_[0]) {
$sep = '\\s+'
} else {
$sep = shift;
}
unless (ref($cols = shift) eq 'ARRAY') {
die "fieldsort columns must be in anon array";
}
my (@sortcode, @col);
my $col = 1;
for (@$cols) {
my ($a, $b) = /^-/ ? qw(b a) : qw(a b);
my $op = /n$/ ? '<=>' : 'cmp';
push @col, (/(\d+)/)[0] - 1;
push @sortcode, "\$${a}->[$col] $op \$${b}->[$col]";
$col++;
}
my $sortfunc = eval "sub { " . join (" or ", @sortcode) . " } ";
my $splitfunc = eval 'sub { (split /$sep/o, $_)[@col] } ';
return
map $_->[0],
sort { $sortfunc->() }
map [$_, $splitfunc->($_)],
@_;
}
Example usage:
# as per above
@sorted = fieldsort ':', ['2n', -1], @data;
# 2nd then 1st field, alpha, delimited by whitespace (\s+)
@sorted = fieldsort [2, 1], @data;
# 1st descending numeric, then 3rd alpha, then 2nd numeric,
# delimited by '+'
@sorted = fieldsort '+', ['-1n', 3, 2], @data;
It results in an error pointing to the very last of the actual function
code:
syntax error at locate.cgi line 274, near "->("
syntax error at locate.cgi line 275, near "->("
I'm befuddled. Could anyone tell me whether that code snippet works
for them, and if it does, any ideas about why it doesn't for me?
Kathy Lessa
klessa@airmail.net
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 3 Nov 1999 00:00:20 GMT
From: petolino@Eng.Sun.COM (Joe Petolino)
Subject: Re: Problem With Delimited Field Sort
Message-Id: <7vntuk$qtg$1@engnews3.Eng.Sun.COM>
In article <7vnq7f$mid$1@nnrp1.deja.com>, Kat <klessa@airmail.net> wrote:
>It results in an error pointing to the very last of the actual function
>code:
>
>syntax error at locate.cgi line 274, near "->("
>syntax error at locate.cgi line 275, near "->("
I assume these two lines are:
> sort { $sortfunc->() }
> map [$_, $splitfunc->($_)],
>I'm befuddled. Could anyone tell me whether that code snippet works
>for them, and if it does, any ideas about why it doesn't for me?
The sub compiles OK for me under perl version 5.005_03, but under
perl version 5.003 I get the same syntax error as you did. Sounds
like you're running an old version of perl. Do 'perl -v' to check this.
-Joe
------------------------------
Date: Wed, 03 Nov 1999 01:27:06 GMT
From: "Samuel Kilchenmann" <skilchen@swissonline.ch>
Subject: Re: Problem With Delimited Field Sort
Message-Id: <KbMT3.28481$m4.101918295@news.magma.ca>
Kat <klessa@airmail.net> wrote in message
news:7vnq7f$mid$1@nnrp1.deja.com...
>
> It's from the effectiveperl site, url:
>
> http://www.effectiveperl.com/recipes/sorting.html#delimited_strings
>
Thats a very interestig site! Thanks for the link.
> return
> map $_->[0],
> sort { $sortfunc->() }
> map [$_, $splitfunc->($_)],
> @_;
> }
>
>
> It results in an error pointing to the very last of the actual
> function code:
>
> syntax error at locate.cgi line 274, near "->("
> syntax error at locate.cgi line 275, near "->("
>
As Joe Petolino already pointed out, this is a Perl version problem.
You may want to try if it works with your older Perl if you make the
following modifications:
return
map $_->[0],
sort { &{$sortfunc}() }
map [$_, &{$splitfunc}($_)],
@_;
(The indentation changes are not important, i simply prefer it
this way. The important change is the alternative dereferencing
syntax of the coderefs $sortfunc and $splitfunc.)
But i have a followup question:
Joseph N. Hall writes:
my $sortfunc = eval "sub { " . join (" or ", @sortcode) . " } ";
my $splitfunc = eval 'sub { (split /$sep/o, $_)[@col] } ';
while i would write that as:
my $sortfunc = sub { eval join (" or ", @sortcode) };
my $splitfunc = sub { eval '(split /$sep/o, $_)[@col]' };
Are there any semantic differences between these two versions?
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V9 Issue 1260
**************************************