[19856] in Perl-Users-Digest
Perl-Users Digest, Issue: 2051 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Nov 2 00:05:43 2001
Date: Thu, 1 Nov 2001 21:05:08 -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: <1004677508-v10-i2051@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 1 Nov 2001 Volume: 10 Number: 2051
Today's topics:
Re: Categories and sub categories. <its_mr_impossible@hotmail.com>
Re: digital signature <iltzu@sci.invalid>
Failed scripts leave Perl behind <perl@omnibus-systems.net>
Re: Failed scripts leave Perl behind (John J. Trammell)
Re: File handle leak- how bad? <goldbb2@earthlink.net>
Re: ms-word doc's & perl <bart.lateur@skynet.be>
Newbie Hash Slice Question <aeropaul@sbcglobal.net>
Re: Newbie Hash Slice Question (Garry Williams)
Re: Newbie Hash Slice Question <uri@stemsystems.com>
Re: Newbie Hash Slice Question <krahnj@acm.org>
Re: Newbie Hash Slice Question <uri@stemsystems.com>
Re: Newbie Hash Slice Question (Tad McClellan)
Problem adding quotes to a message-id <graham.drabble@lineone.net>
Re: Problem adding quotes to a message-id (Tad McClellan)
Re: Problem adding quotes to a message-id <Jon.Ericson@jpl.nasa.gov>
Re: Problem adding quotes to a message-id <graham.drabble@lineone.net>
Re: Problem adding quotes to a message-id <jeff@vpservices.com>
Re: Problem adding quotes to a message-id (Tad McClellan)
Processing portions of an array <htmailing.nospam@yahoo.com>
Re: Processing portions of an array (Tad McClellan)
Re: Processing portions of an array <uri@stemsystems.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 1 Nov 2001 23:36:49 -0000
From: "John Taylor" <its_mr_impossible@hotmail.com>
Subject: Re: Categories and sub categories.
Message-Id: <9rsma1$leu$1@newsg1.svr.pol.co.uk>
Thanks for the reply Steffen,
I am using MySQL and DBI. What fieldnames and datatypes would you use? I am
thinking:
category_tbl (
category_id : integer unsigned auto_increment
parent_id : integer unsigned
name : varchar(255)
)
Thanks,
John.
"John Taylor" <its_mr_impossible@hotmail.com> wrote in message
news:1004625407.14743.0.nnrp-10.c2de1f0e@news.demon.co.uk...
> Hi all,
>
> What is the best data structure and algorithm/s to inplement ordered
product
> categories and sub categories. There are 6000 categories and several leves
> of sub categories.
>
> Users will need to insert/change/remove categories at any level. I will
also
> need to allow users to select any category to store/remove/change products
> below these categories.
>
> I am really scratching my head over this one!
>
> Do I need to use a binary sort tree for this.
>
>
> Thanks,
>
> John.
>
> -----------------
> He Without Sin, Cast The First Stone.
>
> Love one another.
> -----------------
>
>
------------------------------
Date: 2 Nov 2001 00:01:21 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: digital signature
Message-Id: <1004657931.19673@itz.pp.sci.fi>
In article <584a8362.0110290708.7abc27ca@posting.google.com>, TD wrote:
>
>Is there any way we can create digital signature using Perl
>I am fairly new in this....
Easy enough, with some modules from the CPAN, http://www.cpan.org/
>1) my current XML="<xml data....>"
I assume this is just treated as an arbitrary string, so no actual XML
processing is required. (Although there are modules for that, too.)
>2) signature = sign XML with private key using MD5 or SHA1
http://search.cpan.org/search?dist=Digest-HMAC
>3) encodedsignature = base64.encode(signature)
>4) publiccertificate= base64.encode(public cert)
The Digest:: modules already know how to base64-encode their output, but
for more general use, see http://search.cpan.org/search?dist=MIME-Base64
>5) now I can post data as
>requestxml=XML&digitalsignature=encodedsignature&certificate=publiccertificate
See http://search.cpan.org/search?dist=libwww-perl if you want to submit
HTTP requests using Perl.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Thu, 01 Nov 2001 23:37:20 -0500
From: Ken <perl@omnibus-systems.net>
Subject: Failed scripts leave Perl behind
Message-Id: <4d84ut4q79otmhtg2lmm1v8p34p93soek9@4ax.com>
When my students write perl scripts and the script fails for whatever
reason, the Perl interpretor is not shut down. The server is Windows
2000 with ActiveState Perl. It doesn't matter is we use .pl or .plx
extensions (.pl use Perl and .plx goes thru dllhost). The only mention
of this issue I found was in an apache news thread where the
participants said only that it was necessary to reboot the server. I
have found pskill from sysinternals able to stop Perl so I don't have
to reboot.
But I dont want to continuely monitor the server for orphan/zombie
Perl processes (they hog resources and brings the server to a crawl).
Any suggestions?
TIA
------------------------------
Date: Thu, 1 Nov 2001 22:45:01 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Failed scripts leave Perl behind
Message-Id: <slrn9u496b.8ut.trammell@haqq.el-swifto.com>
On Thu, 01 Nov 2001 23:37:20 -0500, Ken <perl@omnibus-systems.net> wrote:
> When my students write perl scripts and the script fails for whatever
> reason, the Perl interpretor is not shut down. The server is Windows
> 2000 with ActiveState Perl. It doesn't matter is we use .pl or .plx
> extensions (.pl use Perl and .plx goes thru dllhost). The only mention
> of this issue I found was in an apache news thread where the
> participants said only that it was necessary to reboot the server. I
> have found pskill from sysinternals able to stop Perl so I don't have
> to reboot.
>
> But I dont want to continuely monitor the server for orphan/zombie
> Perl processes (they hog resources and brings the server to a crawl).
> Any suggestions?
>
Use Linux.
--
If the organizational structure is threatening in any way, nothing is
going to be documented until it is completely defensible.
- F. Brooks, _The Mythical Man-Month_
------------------------------
Date: Thu, 01 Nov 2001 20:25:20 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: File handle leak- how bad?
Message-Id: <3BE1F600.65C660BB@earthlink.net>
Bart Lateur wrote:
>
> Ilya Martynov wrote:
>
> > You don't have to close FILEHANDLE if you are immediately going
> > to do another "open" on it, because "open" will close it for
> > you. (See "open".)
>
> An implicit close() also happens if the filehandle goes out of scope.
Assuming of course that the filehandle *is* scoped, a la local or my.
If it's a bareword filehandle, as in the OP's example, and there is no
preceding local(*AFILE), then it doesn't ever go out of scope.
> Unforunately the same thing doesn't happen with directories i.e.
> opendir/closedir.
Is this documented anywhere?
--
Klein bottle for rent - inquire within.
------------------------------
Date: Thu, 01 Nov 2001 23:52:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: ms-word doc's & perl
Message-Id: <ean3uto47ghbj4v5gv3rfmcgntpmccp1h5@4ax.com>
peter wrote:
>alas, i'm a UNIX guy with no knowledge of
>vb, m$-woid macros or perl on m$ and they dont allow freeware here on the
>pc's and i probably wont be "allowed" to pursue this...but i will try :)
Did they pay for their MS Internet Explorer? No? Thought so. That's
freeware too, you know.
Anyway: I think you'd best tackle this through Win32::OLE. See the
Win32::OLE FAQ for a kickstart, sortof.
<http://aspn.activestate.com/ASPN/Reference/Products/ActivePerl/faq/Windows/ActivePerl-Winfaq12.html>
Without MS Word itself, and Win32::OLE, you just might get somewhere by
using one of the OLE::Storage or OLE::Storage_Lite modules.
--
Bart.
------------------------------
Date: Fri, 02 Nov 2001 03:28:52 GMT
From: Paul Johnson <aeropaul@sbcglobal.net>
Subject: Newbie Hash Slice Question
Message-Id: <bn44utg5otkfq99pml8bs34997v45l14k0@4ax.com>
I'm working my way through the O'Reilly book "Learning Perl on Win32
Systems," and everything is quite clear up to page 77. Here they use
the example:
@score{"fred","barney","dino"} = (205,195,30);
Now, @score refers to a list, but apparently @score{...} refers to a
slice of the hash %score, right?
Doesn't this become ambiguous if there is also a list named @score, or
is it the curly braces that disambiguate it as the square brackets
disambiguate $score[...]?
If I'm right so far, then what about the second to last example on
this page, which obviously contains a typo:
%league{keys %score) = values %score;
Should this be {keys %score} or (keys %score)? In either case, I
don't understand this syntax. "values %score" creates a list, right?
Assuming that @score{"able","baker"} = ("charley","dog"), wouldn't the
above assignment be equivalent to:
%league{"able","baker"}={"charley","dog"};
In which case, shouldn't it be:
@league{"able","baker"}={"charley","dog"};
...as in the above examples from the book?
TIA,
Paul
------------------------------
Date: Fri, 02 Nov 2001 03:53:35 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Newbie Hash Slice Question
Message-Id: <slrn9u465u.1jd.garry@zfw.zvolve.net>
On Fri, 02 Nov 2001 03:28:52 GMT, Paul Johnson
<aeropaul@sbcglobal.net> wrote:
> I'm working my way through the O'Reilly book "Learning Perl on Win32
> Systems," and everything is quite clear up to page 77.
I don't have a copy of the book, but I'll assume that your quotes are
accurate.
> Here they use
> the example:
>
> @score{"fred","barney","dino"} = (205,195,30);
>
> Now, @score refers to a list, but apparently @score{...} refers to a
> slice of the hash %score, right?
Right.
> Doesn't this become ambiguous if there is also a list named @score, or
> is it the curly braces that disambiguate it as the square brackets
> disambiguate $score[...]?
The latter is the case. @blah{ ... } is a hash slice and @blah[ ... ]
is an array slice. See the perldata manual page. This is introduced
in the very first section.
$ perldoc perldata
> If I'm right so far, then what about the second to last example on
> this page, which obviously contains a typo:
>
> %league{keys %score) = values %score;
That contains more than one typo!
$ perl -cwe '%league{keys %score) = values %score;'
syntax error at -e line 1, near "%league{"
Missing right curly or square bracket at -e line 1, at end of line
-e had compilation errors.
$ perl -cwe '%league{keys %score} = values %score;'
syntax error at -e line 1, near "%league{"
-e had compilation errors.
$ perl -cwe '@league{keys %score} = values %score;'
Name "main::league" used only once: possible typo at -e line 1.
-e syntax OK
$
> Should this be {keys %score} or (keys %score)?
Don't have the book, but it's almost certainly the former because the
keys of %score are almost certainly not integers. In addition, the
`%league' hints of the real intent.
> In either case, I
> don't understand this syntax. "values %score" creates a list, right?
Right.
> Assuming that @score{"able","baker"} = ("charley","dog"), wouldn't the
> above assignment be equivalent to:
>
> %league{"able","baker"}={"charley","dog"};
>
> In which case, shouldn't it be:
>
> @league{"able","baker"}={"charley","dog"};
>
> ...as in the above examples from the book?
Absolutely correct.
Whew! It's a good thing that you're reading this book. A mere mortal
might not be able to sort it out. :-)
--
Garry Williams
------------------------------
Date: Fri, 02 Nov 2001 03:53:52 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Newbie Hash Slice Question
Message-Id: <x7hesdx1xa.fsf@home.sysarch.com>
>>>>> "PJ" == Paul Johnson <aeropaul@sbcglobal.net> writes:
PJ> I'm working my way through the O'Reilly book "Learning Perl on Win32
PJ> Systems," and everything is quite clear up to page 77. Here they use
PJ> the example:
PJ> @score{"fred","barney","dino"} = (205,195,30);
PJ> Now, @score refers to a list, but apparently @score{...} refers to a
PJ> slice of the hash %score, right?
yes.
PJ> Doesn't this become ambiguous if there is also a list named @score, or
PJ> is it the curly braces that disambiguate it as the square brackets
PJ> disambiguate $score[...]?
the {} disambiguates it to make it a hash no matter the sigil in front.
PJ> If I'm right so far, then what about the second to last example on
PJ> this page, which obviously contains a typo:
PJ> %league{keys %score) = values %score;
PJ> Should this be {keys %score} or (keys %score)? In either case, I
the braces are correct. it still is a hash.
PJ> don't understand this syntax. "values %score" creates a list, right?
yes.
PJ> Assuming that @score{"able","baker"} = ("charley","dog"), wouldn't the
PJ> above assignment be equivalent to:
PJ> %league{"able","baker"}={"charley","dog"};
no.
PJ> In which case, shouldn't it be:
PJ> @league{"able","baker"}={"charley","dog"};
yes. the typo is a % instead of a @ for the hash slice.
PJ> ...as in the above examples from the book?
this might be a known typo. go to oreilly.com and look for that
book. they have errata pages.
also for more on hash slices see my tutorial at:
http://www.sysarch.com/perl/tutorials/hash_slices.txt
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 02 Nov 2001 03:57:04 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Newbie Hash Slice Question
Message-Id: <3BE21A40.A0BB24B4@acm.org>
Paul Johnson wrote:
>
> I'm working my way through the O'Reilly book "Learning Perl on Win32
> Systems," and everything is quite clear up to page 77. Here they use
> the example:
>
> @score{"fred","barney","dino"} = (205,195,30);
>
> Now, @score refers to a list, but apparently @score{...} refers to a
> slice of the hash %score, right?
Right.
> Doesn't this become ambiguous if there is also a list named @score,
No.
> or is it the curly braces that disambiguate it as the square brackets
> disambiguate $score[...]?
Yes. @x{...} is a hash slice and @x[...] is an array slice.
> If I'm right so far, then what about the second to last example on
> this page, which obviously contains a typo:
>
> %league{keys %score) = values %score;
It should be: @league{keys %score) = values %score;
> Should this be {keys %score} or (keys %score)? In either case, I
> don't understand this syntax. "values %score" creates a list, right?
Right.
> Assuming that @score{"able","baker"} = ("charley","dog"), wouldn't the
> above assignment be equivalent to:
>
> %league{"able","baker"}={"charley","dog"};
No, this won't compile.
$ perl -e'%league{"able","baker"}={"charley","dog"};'
syntax error at -e line 1, near "%league{"
Execution of -e aborted due to compilation errors.
> In which case, shouldn't it be:
>
> @league{"able","baker"}={"charley","dog"};
No, this assigns an anonymous hash to the key "able".
$ perl -e'@league{"able","baker"}={"charley","dog"};print"$_ =
$league{$_}\n" for keys %league'
baker =
able = HASH(0x80f47a0)
perldoc perldata
perldoc perldsc
perldoc perllol
Maybe if you report the error to Randal he'll pay you (like D. Knuth
does ;-) .)
John
--
use Perl;
program
fulfillment
------------------------------
Date: Fri, 02 Nov 2001 04:02:04 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Newbie Hash Slice Question
Message-Id: <x7d731x1jn.fsf@home.sysarch.com>
>>>>> "UG" == Uri Guttman <uri@stemsystems.com> writes:
UG> this might be a known typo. go to oreilly.com and look for that
UG> book. they have errata pages.
http://www.oreilly.com/catalog/lperlwin/errata/lperlwin.498
that errata page covers this typo.
it doesn't show a mixed { and ) so that must be your mistyping.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
Date: Fri, 02 Nov 2001 04:54:37 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Newbie Hash Slice Question
Message-Id: <slrn9u4751.b8a.tadmc@tadmc26.august.net>
Paul Johnson <aeropaul@sbcglobal.net> wrote:
>Now, @score refers to a list
There have been plenty of other followups about your direct
questions, but nobody mentioned this, so I will:
@score refers to an _array_, not to a list.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 2 Nov 2001 00:20:52 GMT
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Problem adding quotes to a message-id
Message-Id: <Xns914D34E7495Cgrahamdrabblelineone@ID-77355.user.dfncis.de>
I'm trying to write a perl script that will run a program to delete
messages out of Hamster by looking up the individual message-ids in a
file and then putting them into Hamster's delete function.
To run the command succesfully I can type:
C:\usenet\hamster-fr\ham delete "<s>"
and because <s> is not a message-id in it's database it returns
ERROR: Message-ID "<s>" not found.
I have a list of messages-ids in a text file that looks like this
2837 <2001Oct31.5743816344@xenitec.on.ca>
2838 <2001Oct31.3336065225@xenitec.on.ca>
2839 <2001Oct31.6783043346@xenitec.on.ca>
2840 <2001Oct31.7831331521@xenitec.on.ca>
2841 <2001Oct31.1426341052@xenitec.on.ca>
in a file called C:\usenet\msg-id.log.
I therefore wrote the following script which I thought would take each
message-id and put it in place of the <s> above.
#!c:/perl/perl.exe
open(MSGIDFILE, 'C:\usenet\msg-id.log') || die "Error opening file 1.
$!\n";
open(ANSWER, '>C:\usenet\return.log') || die "Error opening file 2.
$!\n";
system('C:\usenet\hamster-fr\hamster');
while(<MSGIDFILE>){
($ARTNO, $MSGID) = split / /;
$return = `C:\\usenet\\hamster\-fr\\ham delete "$MSGID"`;
print ANSWER "$ARTNO $return";
}
close MSGIDFILE or warn('cannot close MSGIDFILE');
close ANSWER or warn('cannot close ANSWER');
Unfortunately this doesn't work. The first 5 lines of
C:\usenet\return.log look like
2837 ERROR: Message-ID "<2001Oct31.5743816344@xenitec.on.ca> >" not
found.
2838 ERROR: Message-ID "<2001Oct31.3336065225@xenitec.on.ca> >" not
found.
2839 ERROR: Message-ID "<2001Oct31.6783043346@xenitec.on.ca> >" not
found.
2840 ERROR: Message-ID "<2001Oct31.7831331521@xenitec.on.ca> >" not
found.
2841 ERROR: Message-ID "<2001Oct31.1426341052@xenitec.on.ca> >" not
found.
indicating that perl is adding a " >" (without quotes) before the qote
marks. Can anyone give me a clue to why and more importantly what to do
to fix it.
TIA
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: Fri, 02 Nov 2001 01:19:41 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem adding quotes to a message-id
Message-Id: <slrn9u3qj5.aog.tadmc@tadmc26.august.net>
Graham Drabble <graham.drabble@lineone.net> wrote:
>#!c:/perl/perl.exe
use warnings;
use strict;
>open(MSGIDFILE, 'C:\usenet\msg-id.log') || die "Error opening file 1.
>$!\n";
Did you know that you can use sane slashes in your paths?
open(MSGIDFILE, 'C:/usenet/msg-id.log') || die ...
>while(<MSGIDFILE>){
chomp; # I dunno what Windoze will do when there's a newline
# before the final double quote, maybe that is the problem.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 01 Nov 2001 17:30:22 +0000
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Problem adding quotes to a message-id
Message-Id: <86g07yo0up.fsf@jon_ericson.jpl.nasa.gov>
Graham Drabble <graham.drabble@lineone.net> writes:
> #!c:/perl/perl.exe
What?!? No warnings and no strictures? See `perldoc -q debug`.
> open(MSGIDFILE, 'C:\usenet\msg-id.log') || die "Error opening file
> 1. $!\n";
Good to see you're checking the return status of that open, but I
wonder if it might not be useful to put the file name there instead of
"file 1". Little known Microsoft secret: you can almost always use
the forward slash ('/') to construct path names.
> open(ANSWER, '>C:\usenet\return.log') || die "Error opening file 2.
> $!\n";
> system('C:\usenet\hamster-fr\hamster');
How do you know this worked? Look at `perldoc -f system` for how to
interpret the return code of this command.
> while(<MSGIDFILE>){
> ($ARTNO, $MSGID) = split / /;
With strictures you'd have to throw a "my" in there. Also, you can
eliminate the pattern:
my ($ARTNO, $MSGID) = split;
Most people prefer lowercase variables.
> $return = `C:\\usenet\\hamster\-fr\\ham delete "$MSGID"`;
The forward slash would make this line a lot more clear. Since you
are using the output of the backticks, this is better than using
system. On the other hand, you could redirect stdout to the file so
that you could test the return code:
my $return = system
qq(C:/usenet/hamster-fr/ham delete "$MSGID" > C:/usenet/return.log)
die "C:/usenet/hamster-fr/ham failed with a $? status";
This is also a good place to print the $MSGID variable to be sure it
contains what you expect.
> print ANSWER "$ARTNO $return";
> }
> close MSGIDFILE or warn('cannot close MSGIDFILE');
> close ANSWER or warn('cannot close ANSWER');
I don't see what could be causing you problem, but I suspect that it
is either your "ham" or "hamster" program. The easiest way to check
is to print the command the script is trying to run and run it by
hand.
Good luck,
Jon
--
"Consider carefully what you hear," he continued. "With the measure
you use, it will be measured to you--and even more. Whoever has
will be given more; whoever does not have, even what he has will be
taken from him." -- Mark 4:24-25 (NIV)
------------------------------
Date: 2 Nov 2001 02:06:55 GMT
From: Graham Drabble <graham.drabble@lineone.net>
Subject: Re: Problem adding quotes to a message-id
Message-Id: <Xns914DEDF18FCAgrahamdrabblelineone@ID-77355.user.dfncis.de>
tadmc@augustmail.com (Tad McClellan) wrote in
news:slrn9u3qj5.aog.tadmc@tadmc26.august.net:
> Graham Drabble <graham.drabble@lineone.net> wrote:
>>#!c:/perl/perl.exe
>
> use warnings;
> use strict;
Adding thse did not help. I know I probably ought to declare variables
bet I'm lazy.
>
>>open(MSGIDFILE, 'C:\usenet\msg-id.log') || die "Error opening file
>>1. $!\n";
>
>
> Did you know that you can use sane slashes in your paths?
>
> open(MSGIDFILE, 'C:/usenet/msg-id.log') || die ...
Why would I want to? There is next to no chance of me ever running it
on a Unix machine.
>>while(<MSGIDFILE>){
>
>
> chomp; # I dunno what Windoze will do when there's a newline
> # before the final double quote, maybe that is the
> problem.
That solved the problem. I'd forgotten about the newline charecters.
Thanks,
--
Graham Drabble
If you're interested in what goes on in other groups or want to find
an interesting group to read then check news.groups.reviews for what
others have to say or contribute a review for others to read.
------------------------------
Date: Thu, 01 Nov 2001 18:21:12 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Problem adding quotes to a message-id
Message-Id: <3BE20318.DEC17304@vpservices.com>
Graham Drabble wrote:
>
> tadmc@augustmail.com (Tad McClellan) wrote in
> news:slrn9u3qj5.aog.tadmc@tadmc26.august.net:
>
> > Graham Drabble <graham.drabble@lineone.net> wrote:
> >>
> >>open(MSGIDFILE, 'C:\usenet\msg-id.log') || die ...
> >
> > Did you know that you can use sane slashes in your paths?
> >
> > open(MSGIDFILE, 'C:/usenet/msg-id.log') || die ...
>
> Why would I want to? There is next to no chance of me ever running it
> on a Unix machine.
Reason #1: try using double quotes instead of single quotes and see what
happens. Maybe you'll remember the results of that test everytime you
put backwhacks in a place they can get interpolated, but it's alot
easier to just always use forward slashes and forget about what kind of
quotes you'll use.
Reason #2: to be more legible for the rest of us who might have to debug
your code :-)
--
Jeff
------------------------------
Date: Fri, 02 Nov 2001 04:41:03 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Problem adding quotes to a message-id
Message-Id: <slrn9u44hi.b1s.tadmc@tadmc26.august.net>
Graham Drabble <graham.drabble@lineone.net> wrote:
>tadmc@augustmail.com (Tad McClellan) wrote in
>news:slrn9u3qj5.aog.tadmc@tadmc26.august.net:
>
>> Graham Drabble <graham.drabble@lineone.net> wrote:
>>>#!c:/perl/perl.exe
>>
>> use warnings;
>> use strict;
>
>Adding thse did not help. I know I probably ought to declare variables
>bet I'm lazy.
^^^^^^^^
No you're not. Lazy programmers want all the help they can get.
Hard working programmers would rather spend minutes/hours/days
debugging something themselves instead of having a machine
find the problem in milliseconds.
I'm just some guy on Usenet, so feel free to ignore me, but
if you worked for me, you wouldn't work for me.
Paying a person to do a machine's work is not Good Business.
>>>open(MSGIDFILE, 'C:\usenet\msg-id.log') || die "Error opening file
>>>1. $!\n";
>>
>>
>> Did you know that you can use sane slashes in your paths?
>>
>> open(MSGIDFILE, 'C:/usenet/msg-id.log') || die ...
>
>Why would I want to?
Because one of these days you will have part of the path
in a variable and you will need double quotes, and your
code's readability will suffer.
>There is next to no chance of me ever running it
>on a Unix machine.
I did not say anything about portability, so I don't know
what your point is with that part.
The reason for my suggestion (_all_ of my suggestions as a
matter of fact) was to make your programming easier and
faster (ie. less bug prone).
Program like a hobbyist or a professional, as you choose.
>> chomp;
>That solved the problem. I'd forgotten about the newline charecters.
>
>Thanks,
You're welcome.
My fee is that you enable warnings and strictures on all
of your Perl programs :-)
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 2 Nov 2001 00:21:52 +0100
From: "htmailing" <htmailing.nospam@yahoo.com>
Subject: Processing portions of an array
Message-Id: <3be1d716$1@post.usenet.com>
**** Post for FREE via your newsreader at post.usenet.com ****
Heiya,
I'm pretty new to Perl and programming, so excuse my cluelessness.
I have an @array which is basically a listing of names and which the script
processes in a simple manner:
foreach $name (@array) {
whatever;
}
What I need to do is to break the @array down into pieces of 50 names (50
being a variable which I can set) and have them processed 50 at a time.
I cannot figure out how to break down the array and pass "mini-arrays" of 50
to the sub. Also, if @array contains 160 names, I want the script to pass
the first 150 to the whatever() sub in 3 mini-arrays, and then the remaining
10 should be also passed to whatever().
Is this possible in Perl?
TIA !
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
*** Usenet.com - The #1 Usenet Newsgroup Service on The Planet! ***
http://www.usenet.com
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
------------------------------
Date: Fri, 02 Nov 2001 00:06:47 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Processing portions of an array
Message-Id: <slrn9u3ma1.ajm.tadmc@tadmc26.august.net>
htmailing <htmailing.nospam@yahoo.com> wrote:
>I cannot figure out how to break down the array and pass "mini-arrays" of 50
>to the sub.
perldoc -f splice
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Fri, 02 Nov 2001 00:45:21 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Processing portions of an array
Message-Id: <x7k7xavw31.fsf@home.sysarch.com>
>>>>> "h" == htmailing <htmailing.nospam@yahoo.com> writes:
h> What I need to do is to break the @array down into pieces of 50
h> names (50 being a variable which I can set) and have them processed
h> 50 at a time.
h> I cannot figure out how to break down the array and pass
h> "mini-arrays" of 50 to the sub. Also, if @array contains 160
h> names, I want the script to pass the first 150 to the whatever()
h> sub in 3 mini-arrays, and then the remaining 10 should be also
h> passed to whatever().
perldoc -f splice
also look into array slices.
uri
--
Uri Guttman --------- uri@sysarch.com ---------- http://www.sysarch.com
SYStems ARCHitecture and Stem Development ------ http://www.stemsystems.com
Search or Offer Perl Jobs -------------------------- http://jobs.perl.org
------------------------------
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 2051
***************************************