[17406] in Perl-Users-Digest
Perl-Users Digest, Issue: 4826 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 6 18:10:41 2000
Date: Mon, 6 Nov 2000 15:10:17 -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: <973552216-v9-i4826@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 6 Nov 2000 Volume: 9 Number: 4826
Today's topics:
Log.pm did not return a true value <ddijk@hetnet.nl>
Re: Log.pm did not return a true value <jeff@vpservices.com>
Re: Looking for idiom for getting value from @ARGV, or <bart.lateur@skynet.be>
Re: Looking for idiom for getting value from @ARGV, or <uri@sysarch.com>
Re: Looking for idiom for getting value from @ARGV, or (Martien Verbruggen)
Re: my giant hash <tim@ipac.caltech.edu>
Need help getting out of a foreach loop <kmillecam@novell.com>
Re: Need help getting out of a foreach loop <kstep@pepsdesign.com>
Re: Newbie question: Get date of 3rd Friday in a given <rosie@dozyrosy.plus.com>
Re: Novice silly question: Delete a file <tim@ipac.caltech.edu>
Re: Novice silly question: Delete a file <peter.sundstrom@eds.com>
Re: Passing Hash to Perl Module Update spcman@my-deja.com
Re: Passing Hash to Perl Module Update (Martien Verbruggen)
Re: Pattern Matching /isg <tim@ipac.caltech.edu>
Re: Performance/scaleablility question: Perl/CGI vs. J (Chris Fedde)
Re: perl for macintosh ibook <montuori@arrakisplanet.com>
Re: perl for macintosh ibook <elaine@chaos.wustl.edu>
Problem reading a binary file fgont@my-deja.com
Re: Script seems to be running twice each time saze@my-deja.com
Re: script: many very similar letters (emails) to many <james@NOSPAM.demon.co.uk>
Sorting hash of hashes by value dhartsough@my-deja.com
Re: Splitting variable length fixed records <tim@ipac.caltech.edu>
Re: Splitting variable length fixed records <peter.sundstrom@eds.com>
Re: Splitting variable length fixed records <ianb@ot.com.au>
Re: Timeout option on CGI script????? aboveandbeyond@my-deja.com
Re: Why is my hash coming untied? (Mark-Jason Dominus)
Re: Why is my hash coming untied? <ren.maddox@tivoli.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 6 Nov 2000 21:56:41 +0100
From: "dick dijk" <ddijk@hetnet.nl>
Subject: Log.pm did not return a true value
Message-Id: <#A#z0TDSAHA.279@net003s>
Hello,
I made a class called "Log" and a script called "test2" that uses Log. When
I put the implementation of "Log" inside "test2", the script works, but when
I move the impl. of Log to a seperate file, "Log.pm" (in the same dir), I
get the error msg:
"Log.pm did not return a true value"
What does this mean? How can I make it work?
Here is "test2":
#!/usr/bin/perl -w
use Log;
$a = Log->new();
$a->openlogfile("aap2");
$a->logmsg("effe");
$a->closelogfile();
Here is "Log.pm":
package Log;
sub openlogfile {
unlink("$_[1]");
open(FH, ">>$_[1]");
}
sub logmsg {
print FH $_[1];
}
sub closelogfile {
close(FH);
}
sub new {
my $invocant = shift;
my $class = ref($invocant) || $invocant;
my $self = {
naam => "log",
@_,
};
bless($self, $class);
return $self;
}
------------------------------
Date: Mon, 06 Nov 2000 13:16:29 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Log.pm did not return a true value
Message-Id: <3A071FAD.B6A69834@vpservices.com>
dick dijk wrote:
>
> I made a class called "Log" and a script called "test2" that uses Log. When
> I put the implementation of "Log" inside "test2", the script works, but when
> I move the impl. of Log to a seperate file, "Log.pm" (in the same dir), I
> get the error msg:
>
> "Log.pm did not return a true value"
>
> What does this mean?
All Perl warnings and error messages are listed in perldiag which comes
included with Perl. Either look up the message in the Camel or run
"perldoc perldiag" on the command line, or just open the perldiag file
and read it.
> How can I make it work?
By following the instructions as listed in perldiag: put "1;" at the end
of the file to be included (without the quotes).
--
Jeff
------------------------------
Date: Mon, 06 Nov 2000 20:07:22 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <bl3e0tc46m4eirpfia9evoqjig28h00a18@4ax.com>
Philip 'Yes, that's my address' Newton wrote:
>Where do you read that from?
>
> @ARGV = (undef, undef);
>
>works fine;
Of course it does. But why wopuld you want to do that? If you do
something like this, there is no reason to try an interpret what is in
the @ARGV array, anyway. You know. You put it there.
>Granted, you may not be able to get undef in there through the startup
>code,
PRecisely my point. I don't care for such tricks. Under normal
circumstances, i.e. anything but explicitely setting @ARGV in perl code,
there's NO WAY you could ever get an undef in there. And that is what
I'm starting out from.
In the same way, if you don't modify $/, there's no way you can ever
read a line from a file that contains a newline ("\n") in any other
position than at the end of the string.
--
Bart.
------------------------------
Date: Mon, 06 Nov 2000 21:02:04 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <x7aebchl0z.fsf@home.sysarch.com>
>>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:
MV> On Mon, 06 Nov 2000 05:49:33 GMT,
MV> Uri Guttman <uri@sysarch.com> wrote:
>>
>> $s = defined( $ARGV[0] ) ? shift : 'default' ;
MV> Yeah, Jeff Pinyan also posted this. I've never used this, which is why I
MV> didn't think of it. I probably never will use it either. Having short
MV> code is nice, but I find that just a teensie bit too unreadable. It
MV> needs a double take to extract the meaning :)
someone else posted a variant which checks if @ARGV has anything in
it. you can't get an undefined value in @ARGV from the command line. so
that way is simpler and probably clearer:
$s = @ARGV ? shift : 'default' ;
but that assumes the arg value is the next one in @ARGV.
2 statements is ok with me and i have done both depending on the
requirements and the phase of the moon.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page ----------- http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net ---------- http://www.northernlight.com
------------------------------
Date: Mon, 06 Nov 2000 22:34:02 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Looking for idiom for getting value from @ARGV, or a default
Message-Id: <slrn90eces.776.mgjv@verbruggen.comdyn.com.au>
On 6 Nov 2000 16:15:19 GMT,
Abigail <abigail@foad.org> wrote:
> On 6 Nov 2000 15:53:33 -0000, Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote in comp.lang.perl.misc <URL: news:<8u6k5t$tg5$1@lublin.zrz.tu-berlin.de>>:
> ++ Abigail <abigail@foad.org> wrote in comp.lang.perl.misc:
> ++ >On Mon, 06 Nov 2000 05:49:33 GMT, Uri Guttman (uri@sysarch.com) wrote in comp.lang.perl.misc <URL: news:<x7g0l5hcpe.fsf@home.sysarch.com>>:
>++ >++ >>>>> "MV" == Martien Verbruggen <mgjv@tradingpost.com.au> writes:
> ++ >++
> ++ >++
> ++ >++ MV> If you really need to test for defined-ness, then you need to use two
> ++ >++ MV> statements:
> ++ >++
> ++ >++ MV> $s = shift @ARGV;
> ++ >++ MV> $s = 'default' unless defined $s;
> ++ >++
> ++ >++ $s = defined( $ARGV[0] ) ? shift : 'default' ;
> ++ >
> ++ >
> ++ >That is not quite the same. For instance, if @ARGV && !defined $ARGV [0].
> ++
> ++ True, but that cannot happen if @ARGV is fresh from one of the shells.
> ++ So in the standard situation @ARGV != 0 implies that $ARGV[ 0] is defined.
>
> But then the test for definess isn't necessary, is it?
You could get 0 from the command line.
I know you all know this, but I'll just say it anyway. The people who
know it can skip it, others might be interested.
I think we're getting the issues a bit confused. @ARGV is a special
case; none of its arguments ever can be undefined IF it is present. In
other words, if @ARGV == 2, there are 2 arguments with a defined
value. However, the third, non-existent, argument will look like an
undefined value, and for all intents and purposes will be one.
So, in the case of @ARGV, the following are equivalent:
my $arg = shift @ARGV;
$arg = 'default' unless defined $arg;
my $arg = defined($ARGV[0]) ? shift @ARGV : 'default';
my $arg = @ARGV ? shift @ARGV : 'default';
However, the following is not equivalent:
my $arg = shift @ARGV || 'default';
because this will also be triggered when the argument is false (i.e.
"" or "0").
But this is not true in a general case. For example when processing
the arguments to a subroutine, each of the arguments can in fact be an
undefined value. The above equivalencies do not hold in that case.
They would only be 'equivalent' if you are testing for false values,
not specifically undefined values.
These are equivalent:
my $arg = shift @_;
$arg = 'default' unless defined $arg;
my $arg = defined($_[0]) ? shift @_ : 'default';
And this one is different:
my $arg = @_ ? shift @_ : 'default';
Their effect would be almost the same, but not entirely. Consider
this:
sub shifty
{
my $arg1 = @_ ? shift @_ : 'arg1';
my $arg2 = defined($_[0]) ? shift @_ : 'arg2';
}
shifty();
shifty(1);
shifty(1, 2);
shifty(undef, 2);
In this last $arg1 will not get its default value, even though the
first argument is undefined.
Martien
PS. Note that in the above, the argument to shift is optional. If
you're in the main body of the program, shift will operate on @ARGV.
If in a subroutine it will operate on @_.
--
Martien Verbruggen |
Interactive Media Division | That's not a lie, it's a
Commercial Dynamics Pty. Ltd. | terminological inexactitude.
NSW, Australia |
------------------------------
Date: Mon, 06 Nov 2000 13:16:34 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: my giant hash
Message-Id: <3A071FB2.670355ED@ipac.caltech.edu>
Brian McDonald wrote:
> i am writing a text-to-xml parser that operates on a CSV raw data file. as
> such, i have nearly 80 some-odd variable definitions/initializations...
> defining tags, attributes, variables and data structures... that i would
> like to put into a hash for inclusion in my script.
...snip...
>
> i.e. if i have variables so named...
>
> # cat (old)datadefs.pm
> # initialize CSV field vars
> $csv_doccharacteristics = "";
> $csv_filename = "";
> $csv_filelocn = "";
> (ad nauseum...)
>
> do i have to make up keys for them like
>
> # cat (new)datadefs.pm
> package datadefs;
> use Exporter;
> @ISA = qw(Exporter);
> @EXPORTER = qw(%G);
>
> %G = (
> docchars => $csv_doccharacteristics,
> filename => $csv_filename,
> filelocn => $csv_filelocn,
> authors => @authors,
> etc.
> );
I'm not sure I understand why you're still using the variables in that
assignment. Why not go directly to assigning the actual values? You could just
about do a global search/replace on your old file to upgrade to the hash. E.g.
perl -pe s/^\s*$(\W+)\s*=\s*(\S.*?)\s*$/$G{$1} = $2;/' datadefs.pm > DataDefs.pm
and you'd have your hash defined. THen just plug in the new module header and
your off.
$G{csv_doccharacteristics} = "";
$G{csv_filename} = "";
$G{csv_filelocn} = "";
Perhaps I don't understand the real issue?
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Mon, 6 Nov 2000 14:47:57 -0700
From: "Kevin Millecam" <kmillecam@novell.com>
Subject: Need help getting out of a foreach loop
Message-Id: <3a072717.0@news.provo.novell.com>
Hi,
I'm using Jonathan Eisenzopf's rss2html.pl script to parse XML files into
HTML files.
My problem is, in some cases, I would like to limit the number of iterations
in the following loop.
For example, let's say the file I'm parsing has a total of 15 "items" but I
only want the first 5 parsed and printed to HTML.
Here's the original code:
foreach my $item (@{$rss->{'items'}}) {
next unless defined($item->{'title'}) && defined($item->{'link'});
print <<HTML;
<tr>
<td</td>
<td><a
href=\"$item->{'link'}\">$item->{'title'}</a><br>$item->{'description'}<br><
/td>
</tr>
HTML
}
Thanks, in advance, for any help you can offer.
Kevin
------------------------------
Date: Mon, 6 Nov 2000 17:45:27 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: Need help getting out of a foreach loop
Message-Id: <8u7c9u$234$1@slb7.atl.mindspring.net>
Hi Kevin,
You can add a counter variable and exit the loop using the 'last' statement.
# Initialize the counter and maximum value
my $count = 0;
my $max = 5;
foreach my $item (@{$rss->{'items'}}) {
next unless defined($item->{'title'}) && defined($item->{'link'});
print <<HTML;
<tr>
<td</td>
<td><a
href=\"$item->{'link'}\">$item->{'title'}</a><br>$item->{'description'}<br><
/td>
</tr>
HTML
# Increment the counter and exit if finished
last if ++$count >= $max;
}
I hope this helps,
Kurt Stephens
kstep@pepsdesign.com
------------------------------
Date: Mon, 6 Nov 2000 22:10:43 -0000
From: Rosemary I H Powell <rosie@dozyrosy.plus.com>
Subject: Re: Newbie question: Get date of 3rd Friday in a given year/month?
Message-Id: <MPG.14713cbe761b976a98971d@usenet.plus.net>
In article <VrgN5.20261$%j.6372783@typhoon.southeast.rr.com> dated Sun,
05 Nov 2000 17:05:57 GMT, our revered colleague David Sisk
(davesisk@ipass.net) was so kind as to advise ...
> Any ideas on how to easily do this in a CGI script? Please post or email?
>
> Best regards,
> Dave
>
Yes:
#========================================================================
# Subroutine : falls_on_date
# Argument(s) : $week (first..fifth), $day_name (in full),
# $month (month name in full), $year (yyyy)
# Return Values : $date
#
# Based on an algorithm in the Calendar FAQ by Claus Tondering
# and Marcos J. Montes' adaptation of it
# Determines what date a particular day in a particular week will fall on
# e.g what is the date of the fourth Friday in June?
#
# an N-day is Sunday (N=0) through to Saturday (N=6)
# first N-day = 1 + (N - DoW(Year,Month,1))%7
# 2nd N-day = 8 + (N - DoW(Year,Month,8))%7
# 3rd N-day = 15 + (N - DoW(Year,Month,15))%7
# 4th N-day = 22 + (N - DoW(Year,Month,22))%7
# 5th N-day = 29 + (N - DoW(Year,Month,29))%7
#
# ND = Number of last day in month
# Last N-Day = ND - (DoW(Year,Month,ND) - N)%7
#========================================================================
sub falls_on_date {
#========================================================================
# grab the arguments from the calling script
# and set local values
#========================================================================
local($week, $day_name, $month_name, $year) = @_;
#========================================================================
# convert nth week to its computational value:
# first = 1
# second = 8
# third = 15
# fourth = 22
# fifth = 29
#========================================================================
%Nth_week = qw(first 1
second 8
third 15
fourth 22
fifth 29
last last
);
$day = $Nth_week{$week};
#========================================================================
# convert month name to its positional number:
# January = 1 ... December = 12
#========================================================================
%month_names = qw(
January 1
February 2
March 3
April 4
May 5
June 6
July 7
August 8
September 9
October 10
November 11
December 12
);
$month = $month_names{$month_name};
#========================================================================
# convert day name to its positional number:
# Sunday = 0 ... Saturday = 6
#========================================================================
%day_names = qw(Sunday 0
Monday 1
Tuesday 2
Wednesday 3
Thursday 4
Friday 5
Saturday 6
);
$day_number = $day_names{$day_name};
#========================================================================
# number of days in month table, start at zero so Jan is month 1!
#========================================================================
$feb_days = days_in_month($year, 2);
#( 0 Jan Feb Mar Apr May Jun Jul Aug
Sep Oct Nov Dec)
@days_in_month =
("0","31",$feb_days,"31","30","31","30","31","31","30","31","30","31");
#========================================================================
# do the incantations...
# n.b. last week in month is a special case
# ... and return the date to the calling script
#========================================================================
$a = int((14 - $month) / 12);
$y = $year - $a;
$m = $month + 12*$a - 2;
if ($day eq "last") {
$dow = $days_in_month[$month] + $y + int($y/4) - int($y/100)
+ int($y/400) + int((31*$m)/12)% 7;
return $days_in_month[$month] - ($dow - $day_number) % 7;
}
else{
$dow = $day + $y + int($y/4) - int($y/100) + int($y/400)+
int((31*$m)/12) % 7;
return $day + ($day_number - $dow) % 7;
}
} # end of subroutine falls_on_date
You will probably find one of the CPAN Date modules to do this also; but
I had to write this a couple of years back (for finding dates like
Thanksgiving and Mothers Day) for a "countdown to..." script I was
making, when I discovered I was not allowed by my (then) ISP to install
any modules...
HTH,
Rosemary
--
----------------------------------------------------------------
| Rosemary I.H.Powell EMail: Home: rosie@dozyrosy.plus.com |
| Work: r.i.h.powell@rl.ac.uk |
| http://NeedleworkSamplers.com/ |
| http://www.CavalierKingCharles.com/ |
----------------------------------------------------------------
------------------------------
Date: Mon, 06 Nov 2000 13:43:02 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Novice silly question: Delete a file
Message-Id: <3A0725E6.B578239A@ipac.caltech.edu>
Toni wrote:
> I know that rmdir delete a directory, but I can't find in my perl doc a way
> to delete a file without using a system() or exec() call to the OS delete
> file command.
> I suppose there is a Perl function to do this easily, can somebody help me?
unlink
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Tue, 7 Nov 2000 09:21:14 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Novice silly question: Delete a file
Message-Id: <8u741q$8oh$1@hermes.nz.eds.com>
Toni <trioinfoQUITAESTO@trioinfografia.com> wrote in message
news:8u6sa4$5pjf10@SGI3651ef0.iddeo.es...
> Hello!
> I know that rmdir delete a directory, but I can't find in my perl doc a
way
> to delete a file without using a system() or exec() call to the OS delete
> file command.
> I suppose there is a Perl function to do this easily, can somebody help
me?
unlink
------------------------------
Date: Mon, 06 Nov 2000 19:42:49 GMT
From: spcman@my-deja.com
Subject: Re: Passing Hash to Perl Module Update
Message-Id: <8u71jo$pck$1@nnrp1.deja.com>
> Firstly, are you sure you're not reinventing the wheel ? There are
many
> fine template modules on CPAN which you may wish to look at.
Thank you very much for the code. I pasted it in and it worked
perfectly. The reason im writing all this from scratch is so i can
learn cgi better. I like to work with my own scripts. The reason I've
been reverse engineering is because i cannot find any good documention
that lists things step by step for the more advanced programmer.
Perldoc is good but i havnt fully explored its depths. thanks again -
Al
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 06 Nov 2000 22:53:53 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Passing Hash to Perl Module Update
Message-Id: <slrn90edk3.776.mgjv@verbruggen.comdyn.com.au>
On Mon, 06 Nov 2000 14:39:33 GMT,
Gus <gus@black.hole-in-the.net> wrote:
> spcman@my-deja.com wrote:
>
>> $RunTemplate = New template;
>> $RunTemplate -> SetVariables(\%INFO);
>
>
> Fine, but make the "New" in to "new", you're not calling a subroutine
> called "New" you're creating an object.
\begin{pedantry}
While the general convention in Perl OO is that the standard
constructor is called new(), there is no reason that it should be. You
can call it create(), summon(), hocuspocus() or googleBlurph() if you
feel like it. There are also constructors with special semantics, but
only for the reader, not for Perl, like copy() and clone().
It's good practice to use new(), because that's what people expect,
but not a necessity. Sometimes it makes sense to use another name or
to allow multiple names.
my $thread = create MyThread(foo => 'bar');
I believe the Camel has something like
$mage = Wizard->summon('Gandalf');
# or
$mage = summon Wizard 'Gandalf';
\end{pedantry}
Martien
package Wizard;
sub summon { bless \"$_[1]", $_[0] }
sub identity { ${$_[0]} }
package main;
$mage = Wizard->summon('Gandalf');
$apprentice = summon Wizard 'Unknown';
print $mage->identity, " teaches ", $apprentice->identity, "\n";
--
Martien Verbruggen | My friend has a baby. I'm writing
Interactive Media Division | down all the noises the baby makes so
Commercial Dynamics Pty. Ltd. | later I can ask him what he meant -
NSW, Australia | Steven Wright
------------------------------
Date: Mon, 06 Nov 2000 12:39:02 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Pattern Matching /isg
Message-Id: <3A0716E6.69DB9651@ipac.caltech.edu>
bluearchtop@my-deja.com wrote:
>
> Can someone help me with this one. Let's say I have the following:
> $str=<<_EOF_;
> <LOOP>
> something...
> </LOOP>
>
> blah
>
> <LOOP>
> something
> </LOOP>
> ...
> _EOF_
>
> I want to pull out what is in between the <LOOP> </LOOP> blocks:
>
> $str=~s/<LOOP>(.+)<\/LOOP>/&myfunc($1)/is works fine if there is just
I'm not quite sure of the context this is operating in, but don't you want an
'e' modifier on that substitute?
> one loop block, but it is being greedy if multiple Loop blocks. I just
> want it to hit the first ending loop tag. I've tried .? and /isg and
> that didn't work.
"Greedy" being the operative word to use to search perlre. Look up the .+?
construct. I will leave the other well known problems of tag matching with REs
to you, except to say this not be the last problem you'll have, depending on
details...
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Mon, 06 Nov 2000 22:10:32 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Performance/scaleablility question: Perl/CGI vs. Java Servlets?
Message-Id: <s%FN5.208$Bf7.171120128@news.frii.net>
In article <rFgN5.20266$%j.6381401@typhoon.southeast.rr.com>,
David Sisk <davesisk@ipass.net> wrote:
>
>So, has anyone had experience with both of these technologies and been able
>to compare them from a performance and scaleability perspective? I'm
>looking for some objective answers, or some links with objective results to
>help answer this question for me...
>
Look at it this way. Most programmers will guess wrong when they
tell what is going to break when a new system goes under load. I
think that it is best to come up with a prototype soon and get some
feedback from the user community. Then solve the performance problem
when you actually have one to solve.
chris
--
This space intentionally left blank
------------------------------
Date: Mon, 6 Nov 2000 15:15:01 -0500
From: kevin montuori <montuori@arrakisplanet.com>
Subject: Re: perl for macintosh ibook
Message-Id: <ydy7l6ghn7c.fsf@kulon.arrakisplanet.com>
>>> Joseph J Alotta writes:
j> What is the best perl for a macintosh ibook and where can I get
j> it?
if you run OS X (beta), Perl comes preinstalled. i'm not sure
if gcc for darwin has been released; if it has not, you will
have issues compiling modules which use XS. good luck.
cheers,
k.
--
kevin montuori
support independent booksellers -- http://www.booksense.com
------------------------------
Date: Mon, 06 Nov 2000 22:40:44 GMT
From: "Elaine Ashton" <elaine@chaos.wustl.edu>
Subject: Re: perl for macintosh ibook
Message-Id: <MrGN5.13633$AM5.256095@news1.nokia.com>
"Joseph J. Alotta" <jalotta@earthlink.net> wrote in message
news:jalotta-0611001133440001@1cust125.tnt6.chi1.da.uu.net...
> What is the best perl for a macintosh ibook and where can I get it?
There is only one MacPerl and you may find it at [ drumroll please ]
http://www.macperl.com/ along with some very nice resources to help you
along.
enjoy.
e.
------------------------------
Date: Mon, 06 Nov 2000 21:52:09 GMT
From: fgont@my-deja.com
Subject: Problem reading a binary file
Message-Id: <8u7965$ld$1@nnrp1.deja.com>
Hi!
I have an executable file named "genvoto.exe", and tried to read its
contents in a variable.
I do it this way:
$thebin= "genvoto.exe";
open(thebin);
sysread(thebin, $binoutput, 19968);
The problem is that the variable $binoutput only gets 1600 bytes instead
of 19968. The 1600 bytes it gets are Ok _(I compared them with the
contents of the original file), but I don't know why I get only 1600
bytes, and not the 19968 I should get.
P.S.: I tried using read, but the same problem appears...
Kind regards,
Fernando Ariel Gont
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 06 Nov 2000 21:49:39 GMT
From: saze@my-deja.com
Subject: Re: Script seems to be running twice each time
Message-Id: <8u791h$i0$1@nnrp1.deja.com>
In article <m37l6hugfu.fsf@dhcp11-177.support.tivoli.com>,
Ren Maddox <ren.maddox@tivoli.com> wrote:
> aklop@my-deja.com writes:
>
> > Hi,
> > I am building a perl cgi script. When it is called by a persons
browser
> > it first reads a file, writes to another file and then prints the
> > results to their browser.
> >
> > Problem is everytime I test this script from the web it opens reads
and
> > writes these files twice before it prints to the browser.
This may or may not be part of the answer, but be aware that there are
times when MSIE makes TWO calls to a script for one click from the user.
As a for instance, if you right click on a link to a script, MSIE calls
the script to look at the headers to see what type of "file" is
incoming, then when you have decided what you want to call the file for
saving and entered it in the dialog box, MSIE calls the script AGAIN to
get the file to download it. Thanks a bunch MSIE.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 6 Nov 2000 22:17:40 +0000
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: script: many very similar letters (emails) to many different recipients
Message-Id: <ant062240965fNdQ@oakseed.demon.co.uk>
In article <3A05D078.9DC69473@mel222.sggw.waw.pl>, Jan
<URL:mailto:krupa@mel222.sggw.waw.pl> wrote:
>
> I need to send automatically many (say 50) very similar
> (but a little bit different) letters (emails) to many
> different recipients.
Sounds like you would benefit from a template system.
I recently used HTML::Template for both HTML templates and
plain text templates destined for email. I found it simple
to use and potentially quite powerful. You'll find it on
CPAN along with many other template systems, some of which
many be more suited to your needs.
--
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02
------------------------------
Date: Mon, 06 Nov 2000 22:33:19 GMT
From: dhartsough@my-deja.com
Subject: Sorting hash of hashes by value
Message-Id: <8u7bjf$2pn$1@nnrp1.deja.com>
Hi,
The subject line sort of says it all. I know how to sort a hash by
value and get the ordered list of keys. However, I do not see how to
sort a hash of hashes (or hash of hash of hashes...) by value returning
an ordered list of pairs of keys. Any help greatly appreciated...
dave
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 06 Nov 2000 13:33:04 -0800
From: Tim Conrow <tim@ipac.caltech.edu>
Subject: Re: Splitting variable length fixed records
Message-Id: <3A072390.CF3E5080@ipac.caltech.edu>
Peter Sundstrom wrote:
>
> I have a file of fixed records of variable length (newline terminated), eg:
>
> F1F2..F120
>
> Where
>
> F1 is 120 bytes
> F2 up to F120 is 60 bytes.
>
> The minimum number of fields is 2 and max is 120. What I want to do is to
> split each record onto a newline.
(untested)
while(<FILE>) {
chomp;
my @recs = ( substr($_,0,120,"") );
push @recs,substr($_,0,60,"")."\n" while length;
print @recs;
}
--
-- Tim Conrow tim@ipac.caltech.edu |
------------------------------
Date: Tue, 7 Nov 2000 08:58:50 +1300
From: "Peter Sundstrom" <peter.sundstrom@eds.com>
Subject: Re: Splitting variable length fixed records
Message-Id: <8u72nq$6mc$1@hermes.nz.eds.com>
Ian Boreham <ianb@ot.com.au> wrote in message
news:3A06513C.A66E0221@ot.com.au...
> Peter Sundstrom wrote:
>
> > I have a file of fixed records of variable length (newline terminated),
eg:
> >
> > F1F2..F120
> >
> > Where
> >
> > F1 is 120 bytes
> > F2 up to F120 is 60 bytes.
> >
> >
>
> This code (the marked line) does something like what you want (but note
that I
> have used smaller numbers for the sake of the example). It does not
enforce
> the maximum field count, but it does cope with short fields. If you don't
want
> that behaviour, change the quantifiers to {6}, {3}. Note the blank line
still
> counts as a very short single-field line.
>
> Regards,
>
>
> Ian
>
>
> #!/usr/bin/perl -w
>
> foreach(<DATA>)
> {
> $newrecord = join("\n", m/^.{0,6}|\G.{1,3}/g); # This line.
> print "---\n$newrecord\n";
> }
> print "---\n";
>
> __DATA__
> hello_there,_how_are_you_going?
>
> fine,_thanks,_and_yourself?
Thanks Ian. It does just want I want and runs pretty quickly too, although
I'm sure there are some golf players out there.
------------------------------
Date: Tue, 07 Nov 2000 08:31:11 +1100
From: Ian Boreham <ianb@ot.com.au>
Subject: Re: Splitting variable length fixed records
Message-Id: <3A07231F.EDBAD849@ot.com.au>
Peter Sundstrom wrote:
> Thanks Ian. It does just want I want and runs pretty quickly too, although
> I'm sure there are some golf players out there.
Hey, golf is a great form of (mental) exercise! I like to play a hole or two
each day...
Regards,
Ian
------------------------------
Date: Mon, 06 Nov 2000 22:16:14 GMT
From: aboveandbeyond@my-deja.com
Subject: Re: Timeout option on CGI script?????
Message-Id: <8u7aj6$233$1@nnrp1.deja.com>
I just add:
alarm(60);
near the top of my scripts somewhere. The default action when the
alarm goes off is for the process to be killed, so that works fine.
Don't know if that works in windows though.
In article <uloN5.123564$47.1802041@news.bc.tac.net>,
"D" <webmaster@kildare-signs.com> wrote:
> Good day, I am learing to write cgi scripts on my localmachine and
have
> installed ActivaState Perl. My question is this, Is there an option
or way
> to have a script 'timeout' and exit? i'm asking becuase when i make a
stupid
> mistake (like an infinate loop) perl.exe cannot be removed from the
task
> manager, I must reboot my computer to end the processes.......
>
> I use linux for my webservers. but for writing and testing scripts i
use
> windows2000, activestate, and apache 1.3.12.
>
> Thanks for your help
>
>
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: Mon, 06 Nov 2000 20:22:52 GMT
From: mjd@plover.com (Mark-Jason Dominus)
Subject: Re: Why is my hash coming untied?
Message-Id: <3a07131b.2a50$129@news.op.net>
Keywords: Gaul, anew, junction, snob
In article <8u6r3h$j95$1@nnrp1.deja.com>,
Daniel Berger <djberg96@my-deja.com> wrote:
>sub getHash{
> tie %myHash, "Tie::IxHash";
> %myHash = whatever...;
>
> #return \%myHash; - retains tie
> return %myHash; - comes untied
>}
>
>package Z;
>use X;
>
>my %newHash = &getHash;
>
>
>Is there any way to retain the tie in %newHash this way,
%newHash was never tied, so there's no question of 'retaining the
tie'. There's nothing to retain. %myHash is tied, and you have
extracted a list of keys and values from it, returned that *list*, and
used the list to initialize the untied hash %newHash.
Perhaps this is more like that you want:
sub getHash{
tie %myHash, "Tie::IxHash";
%myHash = whatever...;
return \%myHash;
}
package Z;
use X;
local *newHash = &getHash;
print %newHash; # %newHash is now tied
print $newHash{foo}; # calls 'FETCH' on tied hash object
Here's another alternative:
package X;
sub setup(\%) {
my $theHash = shift;
tie %$theHash, "Tie::IxHash";
%$theHash = whatever ...;
}
package Z;
use X;
my %newHash;
setup %newHash; # %newHash is now tied and initialized
--
@P=split//,".URRUU\c8R";@d=split//,"\nrekcah xinU / lreP rehtona tsuJ";sub p{
@p{"r$p","u$p"}=(P,P);pipe"r$p","u$p";++$p;($q*=2)+=$f=!fork;map{$P=$P[$f|ord
($p{$_})&6];$p{$_}=/ ^$P/ix?$P:close$_}keys%p}p;p;p;p;p;map{$p{$_}=~/^[P.]/&&
close$_}%p;wait until$?;map{/^r/&&<$_>}%p;$_=$d[$q];sleep rand(2)if/\S/;print
------------------------------
Date: 06 Nov 2000 13:56:26 -0600
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Why is my hash coming untied?
Message-Id: <m3snp4ub6d.fsf@dhcp11-177.support.tivoli.com>
Daniel Berger <djberg96@my-deja.com> writes:
> Is there any way to retain the tie in %newHash this way, or *must* I
> return a reference in order to keep that behavior?
You *must* return a reference to keep that behavior.
--
Ren Maddox
ren@tivoli.com
------------------------------
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 4826
**************************************