[11158] in Perl-Users-Digest
Perl-Users Digest, Issue: 4758 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 27 04:07:14 1999
Date: Wed, 27 Jan 99 01:00:21 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Wed, 27 Jan 1999 Volume: 8 Number: 4758
Today's topics:
Re: a beginner's question: about making a chatroom <troyk@basspro.com>
Re: ARGV; Is there a length restriction? (Ronald J Kimball)
Re: Camand line params into a perl script. <bill@highwater.co.uk>
Re: Camand line params into a perl script. <bill@highwater.co.uk>
Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus <joemama@roundtrip.net>
Re: Counting characters with tr/// (in perl) (Martin Vorlaender)
Re: Deleting duplicates in a text file <eugene@snailgem.org>
Re: dupes in Perl <uri@home.sysarch.com>
Re: encrypting with PGP (Elf Sternberg)
getting hwnd of a running Perl program (in Win32) <abramov@pacbell.net>
Re: HELP - with redirect of STDERR and STDOUT (Ronald J Kimball)
Re: Help a newbie with a custom shipping script? <8_maf_8@usa.net>
Re: Help a newbie with a custom shipping script? (Ronald J Kimball)
How could this NOT work? <webqueen@bol.net>
Re: How could this NOT work? (Ethan H. Poole)
How to write perl Echo off in Win32 <kotaro@geocities.com>
Re: HTML files exported from Quark <ebohlman@netcom.com>
Re: Looking for SNMP Poller (Michael Fuhr)
Re: loops (Ronald J Kimball)
Perl and output with page-breaks & graphics <abentley@interlog.com>
Re: Perl error/exception strings... (Ronald J Kimball)
Re: Perl from the Market viewpoint (Elf Sternberg)
Re: split file into multiple... <m_ching@hotmail.com>
system function, Pros and Cons?? (Abraham Grief)
Re: tryin' to learn (Ronald J Kimball)
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 24 Jan 1999 08:50:34 -0600
From: Troy Kittrell <troyk@basspro.com>
Subject: Re: a beginner's question: about making a chatroom
Message-Id: <36AB333A.D4CFF9F7@basspro.com>
One example can be found at
http://www.stonehenge.com/merlyn/WebTechniques/col16.html. Not sure if
that's what you're looking for...
unknown wrote:
>
> i've visited some chatrooms. they seem to poll all clients enter the
> chatroom to execute the server-side perl script to refresh the content
> displayed, how to do this?
--
Troy
------------------------------
Date: Wed, 27 Jan 1999 00:40:36 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: ARGV; Is there a length restriction?
Message-Id: <1dm9fqn.elcvswyqz8yN@bay1-123.quincy.ziplink.net>
Bob Freedman <bfreedman@esdim.noaa.gov> wrote:
> It seems when I send a long url as an argument I get an error that
> displays the name of my script and the words No match!
I don't suppose your "long url" includes a question mark?
[hint: that error comes from the shell, not from Perl]
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Wed, 27 Jan 1999 08:26:28 +0000
From: Billy Bagshaw <bill@highwater.co.uk>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Camand line params into a perl script.
Message-Id: <36AECDB4.F871C0DE@highwater.co.uk>
Jonathan Feinberg wrote:
> Billy Bagshaw <bill@highwater.co.uk> writes:
>
> > I'm running perl scripts under Win NT4 using bat files.
> > Can I pass command line params to the script from the bat file ?
>
> What happened when you tried it?
>
Hi Jonathan,
I'm not 100% sure what to do.
What would be your stsrting point as a script and bat file ?
Thanks Billy B.
------------------------------
Date: Wed, 27 Jan 1999 08:27:11 +0000
From: Billy Bagshaw <bill@highwater.co.uk>
To: Jonathan Feinberg <jdf@pobox.com>
Subject: Re: Camand line params into a perl script.
Message-Id: <36AECDDF.8A49D4BD@highwater.co.uk>
Jonathan Feinberg wrote:
> Billy Bagshaw <bill@highwater.co.uk> writes:
>
> > I'm running perl scripts under Win NT4 using bat files.
> > Can I pass command line params to the script from the bat file ?
>
> What happened when you tried it?
>
Hi Jonathan,
I'm not 100% sure what to do.
What would be your stsrting point as a script and bat file ?
Thanks Billy B.
------------------------------
Date: Tue, 26 Jan 1999 22:03:12 -0800
From: Joe Mama <joemama@roundtrip.net>
Subject: Re: CONCLUSIVE PROOF: The Beatles are bigger than Jesus!
Message-Id: <36AEAC20.7CC0@roundtrip.net>
Barbara Day wrote:
> The posting above is under my wife's name, but make no mistake, I was
> the author. Please, for goodness sake-it is just a song. Let it go at
> that, and please take your political drivel, conservative-liberal or
> whatever, and go somewhere else. I love astronomy and optics and don't
> give a damn for your pseudo-analysis of some mundane rock and roll
> song. The cat was an artist shot by a loon. Don't make more of it than
> necessary. Howard Day
I don't particularly care what you think about John Lennon. I think he
was a jerk. This thread is about two weeks old and has been run through
the ringer on about fifteen newsgroups which are completely irrelevant
to this topic, so i'll give you the same advice that I have been given.
Why don't you take you and your attitude somewhere else besides this and
the other newsgroups that don't want to hear it, and we can all live
happily ever after..
If you choose to take this further, please do it by e-mail and give the
people who don't want to hear it a break..
--
-jm
---
To reply no spam, change "roundtrip" to "rarebird"
cuz for the spam it's gonna be a literal round trip..
------------------------------
Date: Wed, 27 Jan 1999 06:23:55 +0100
From: martin@RADIOGAGA.HARZ.DE (Martin Vorlaender)
Subject: Re: Counting characters with tr/// (in perl)
Message-Id: <36aea2eb.524144494f47414741@radiogaga.harz.de>
David Pratt (David_J_Pratt@sbphrd.com) wrote:
: > eval "\$count = \$search =~ tr/$find//";
:
: Thanks, that works nicely!
I've got notice via e-mail that while this works, it's very slow (because
of the eval). Probably the best (most performant) solution is
$count = $search =~ s/$find/$find/g;
cu,
Martin
--
| Martin Vorlaender | VMS & WNT programmer
VMS is today what | work: mv@pdv-systeme.de
Microsoft wants | http://www.pdv-systeme.de/users/martinv/
Windows NT 8.0 to be! | home: martin@radiogaga.harz.de
------------------------------
Date: Tue, 26 Jan 1999 20:44:15 -0500
From: Eugene Sotirescu <eugene@snailgem.org>
Subject: Re: Deleting duplicates in a text file
Message-Id: <36AE6F6F.293E82EA@snailgem.org>
wilsonjf@nima.mil wrote:
>
> I'm a beginner Perl user and I'm working on a project to take log files from
> an Exchange server and look for recipients for that day. I've written enough
> to compile a list with all the users names, but now I need to delete the
> duplicates... Could anyone tell me a good way to do this? The file would
> look like this:
>
> jonesfw
> smithjd
> jonesfw
> doejf
> smithjd
>
> And I need to send a report with only:
>
> jonesfw
> smithjd
> doejf
>
> Thanks in advance!
>
> -Jim Wilson
See:
"How can I extract just the unique elements of an array?"
In perlfaq4
--
Eugene
"I have an Apache Web Server that uses CGI forms written in COBOL."
Post in clpm
------------------------------
Date: 27 Jan 1999 00:19:17 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: dupes in Perl
Message-Id: <x7ww29s36y.fsf@home.sysarch.com>
>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:
LR> 01:00:06 GMT, dturley@pobox.com <dturley@pobox.com> says...
LR> + Larry Rosler send in email:
LR> + >
LR> + >This also deletes entries whose value is false, such as '0', as is
LR> + >mentioned in the FAQ you copied this from. Why not simply aim the
LR> + >questioner to the FAQ (as two of us have already), so he can get the
LR> + >whole story?
LR> +
LR> + Well, excuse the fuck out of me. I didn't realize that the great Larry
LR> Rosler
LR> You have such an elegant vocabulary! I leave it to my colleagues in
LR> this newsgroup -- whose judgment and respect mean a great deal to me --
LR> to decide if my comment, which you quote above, deserves this kind of
LR> response.
LR> Others would say PLONK! at this point, but I've never done that and
LR> won't now. Who knows? Some day you may grow up and have something
LR> useful to offer.
i don't plonk either (tho i have gotten plonked. hi abby). dturley has
been around long enough that he should know larry as a welcome and
capable contributor to this group. he is unfailingly polite and usually
correct and when he is not, he takes full credit for his snafu's. so you
have no reason to flame him for a basic comment on the fact that your
code and the FAQ was the same, others had pointed to it and the FAQ
answer has a logical bug in it. the fact that the timing of posts and
emails threw you for a loop is no reason to get so pissed off.
larry has no reason to worry about your nasty response. if you wish
to start a flame war here about his posts, you will lose as badly as
bottommind and reese. so calm down, take a bottle of valium and let each
contribute here as they wish.
this is usenet, a synonym for anarchy.
uri
--
Uri Guttman ----------------- SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire ---------------------- Perl, Internet, UNIX Consulting
uri@sysarch.com ------------------------------------ http://www.sysarch.com
The Best Search Engine on the Net ------------- http://www.northernlight.com
------------------------------
Date: 27 Jan 1999 04:59:23 GMT
From: elf@halcyon.com (Elf Sternberg)
Subject: Re: encrypting with PGP
Message-Id: <78m6fb$5gg$1@brokaw.wa.com>
In article <7889t6$1rq$1@camel18.mindspring.com>
"Brian Thompson" <hitbyabus@mindspring.com> writes:
>does anyone know where I can get PGP for *nix?
Consider GnuPG. Ask freshmeat (www.freshmeat.net).
>Also, do you know the command line for encrypting data written to a log file
>from a .cgi script?
Do you have access to the webserver's log writing mechanism?
If so, and if it's Apache, look up the use of the pipe '|' command and
how it relates to the TransferLog configuration keyword.
Elf
--
Elf M. Sternberg, rational romantic mystic cynical idealist
If you're so smart, why aren't you naked?
http://www.halcyon.com/elf/
------------------------------
Date: Wed, 27 Jan 1999 00:22:30 -0800
From: "Andrey L. Abramov" <abramov@pacbell.net>
Subject: getting hwnd of a running Perl program (in Win32)
Message-Id: <36AECCC6.E0779441@pacbell.net>
I need to call a function in a Win32 DLL (i know how to do that).
The function requires hwnd (window handler) of the calling application
(in my case it's ..... surprise!... a Perl program).
How can I get it? There has to be a way........
Help!!!
Please!
--
===================================================================
Andrey L. Abramov | "Try not. Do.
MBA'97, Stanford Graduate School Of Business | Or do not.
mailto:abramoa@leland.stanford.edu | There is no 'try'".
Phone: (650)947-8827 | - Yoda
=====================================================================
------------------------------
Date: Wed, 27 Jan 1999 00:40:37 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: HELP - with redirect of STDERR and STDOUT
Message-Id: <1dm9gme.1610m78hmewyzN@bay1-123.quincy.ziplink.net>
[comp.lang.perl no longer exists]
Richard Nilsson <qdtrini@jdicms88.ericsson.se> wrote:
> What I need to do is to execute a command, and redirect STDOUT to my own
> filehandle, and redirect SDTERR to another filehandle.
This is an FAQ. Please refer to perlfaq8.
<http://language.perl.com/newdocs/pod/perlfaq8.html#How_can_I_capture_STDERR_from_an>
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 26 Jan 1999 22:45:04 -0600
From: "maf" <8_maf_8@usa.net>
Subject: Re: Help a newbie with a custom shipping script?
Message-Id: <78m5ko$hlj$1@remarQ.com>
Okay, now I feel really stupid but thanks a bunch. It was driving me
nuts trying to figure out why it wouldn't process correctly.
As for indents, I noted a couple of different styles in the books I've
been reading so there doesn't seem to be any agreed upon convention.
Initially I tried to follow one style from one of the books but it
didn't make sense to me after awhile and I started to develop my own
style of indenting. Then why I cut and paste the script into the
e-mail to post to the group, I noticed it didn't show up the same way
it was in Notepad (?!?)
Anyhow, I greatly appreciate your response--the old typo error.....
Mark
Mike Stok wrote in message <#FCvYjZS#GA.189@news1.texas.rr.com>...
>In article <78lnsa$pjq$1@nnrp1.dejanews.com>,
<mfrey@my-dejanews.com> wrote:
>
>>Have set up a shopping cart for my churches web site and I am trying
>>to add a custom shipping script. It works great except when the
weight
>>is greater than or equal 125 for Canada or Mexico or greater than or
>>equal to 100 for all other non-US countries. If you look at the
>>script, it seems to ignore my last "else" statement in each section.
>>See the comments in the script.
>>
>>I just started learning Perl last week in order to do this so go
easy
>>on me. Running Perl -w doesn't give me any real info--I know I'm not
>>really using all the variables. What am I really doing wrong?
>
>You might want to read the script carefully and adopt a consistent
>indenting style. i
>
>There's a difference between $customShippingCost and
>$customerShippingCost and -w will usually warn you if a variable
appears
>once in a script, but maybe you cut and pasted the Canadian and
Mexican
>code segments so -w didn't spot the $customerShippingCost as an
accident.
>
>In recent perl's it's possible to use a pragma to make perl complain
about
>variable which you haven't explicitly declared.
>
>Hope this helps,
>
>Mike
>
> if( $totalItems > 0 ) {
> if( $country =~ /US/i ) {
> if( $totalWeight < 33 ) {
> $customShippingCost = 4;
> }
> else {
> $customShippingCost = ((($totalWeight - 32) * .1) +
4);
> }
> }
> elsif( $country =~ /CA/i ) {
> if( $totalWeight < 30 ) {
> $customShippingCost = 6;
> }
> elsif( $totalWeight >= 30 && $totalWeight < 125 ) {
> $customShippingCost = ($totalWeight * .16);
> }
> else {
> $customerShippingCost = ($totalWeight * .13);
> #______^^
> }
> }
> elsif( $country =~ /MX/i ) {
> if( $totalWeight < 30 ) {
> $customShippingCost = 6;
> }
> elsif( $totalWeight >= 30 && $totalWeight < 125 ) {
> $customShippingCost = ($totalWeight * .26);
> }
> else {
> $customerShippingCost = ($totalWeight * .22 );
> #______^^
> }
> }
> else {
> if( $totalWeight < 19 ) {
> $customShippingCost = 10;
> }
> elsif( $totalWeight >= 19 && $totalWeight < 100 ) {
> $customShippingCost = ($totalWeight * .55);
> }
> else {
> $customerShippingCost = ($totalWeight * .45);
> #______^^
> }
> }
> }
> else {
> $customShippingCost = 0;
> }
>--
>mike@stok.co.uk | The "`Stok'
disclaimers" apply.
>http://www.stok.co.uk/~mike/ | PGP fingerprint FE 56 4D 7D 42
1A 4A 9C
> | 65 F3 3F 1D 27
22 B7 41
>stok@colltech.com | Collective
Technologies (work)
------------------------------
Date: Wed, 27 Jan 1999 00:40:38 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Help a newbie with a custom shipping script?
Message-Id: <1dm9gse.yk2m7ip1i6uoN@bay1-123.quincy.ziplink.net>
[posted and mailed]
maf <8_maf_8@usa.net> wrote:
> I just started learning Perl last week in order to do this so go easy
> on me. Running Perl -w doesn't give me any real info--I know I'm not
> really using all the variables. What am I really doing wrong?
Since you made the mistake in question several times, -w would not have
helped in this case. In general, though, -w is extremely helpful.
> if( $totalWeight < 30 ) { $customShippingCost = 6; }
> elsif( $totalWeight >= 30 && $totalWeight < 125 )
> { $customShippingCost =
^^^^^^
> ( $totalWeight * .16 ); }
>
> # When I test this script with country = CA, it calculates shipping
> # fine for all weights less than 125. When the totalWeight is 125
> # or more, it returns a customShippingCost of 0. It seems to skip
> # the line below which is supposed to calculate the shipping for
> # any totalWeight over 124 (ounces).
>
> else { $customerShippingCost =
^^^^^^^^
> ( $totalWeight * .13 ); }
You need to correct your variable names.
With 'use strict' Perl would have been able to point this out to you.
'use strict' is extremely helpful as well.
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 26 Jan 1999 23:16:32 -0500
From: sara starre <webqueen@bol.net>
Subject: How could this NOT work?
Message-Id: <36AE930E.763D16EF@bol.net>
Hi there-
OK I racked my tiny brain all night on this- how could this code NOT
work? This is my cgi:
my $fin= "../test/test.txt";
my $fout= "\>../test/test2";
open(NEW, $fin) || pmessage::SayError($fin, "old file");
open(OLD, $fout) || pmessage::SayError($fout, "new file");
If I put an invalid path in $fin, I sucessfully get an error message
(SayError generates an HTML error message). Then I correct the $fin
path, but no matter what I do the second open causes the dreaded "The
Document contains no data" message.
Both test.txt and test2 exist and have rw privs..
I don't see how this is logically possible. If $fin is bad, SayError
generates the correct error message, so I'm sure that it works. Yet if
$fout is bad, the script seems to abort. And if its good, it aborts too.
No matter what, it aborts. My only conclusion is that perl is somehow
hosing up the open wen a ">" is present?
If I run the script from the prompt I get no errrors..
I also tried it without the \> using just > instead. Same result..
Any suggestions of whats going on here? I can't see how this could
happen.. Maybe I'm dumb? Woulnd't be the first time!
please RSVP me at perlgirl@hotmail.com
--
"I'll quit using PERL when they pry my cold, dead fingers off the
mouse.."
-Sara Starre 1998
------------------------------
Date: Wed, 27 Jan 1999 06:12:13 GMT
From: ehpoole@ingress.com (Ethan H. Poole)
Subject: Re: How could this NOT work?
Message-Id: <17yr2.472$ho4.1877@news15.ispnews.com>
[Posted and Emailed] In article <36AE930E.763D16EF@bol.net>,
webqueen@bol.net says...
>
>Hi there-
>
>OK I racked my tiny brain all night on this- how could this code NOT
>work? This is my cgi:
>
> my $fin= "../test/test.txt";
> my $fout= "\>../test/test2";
> open(NEW, $fin) || pmessage::SayError($fin, "old file");
> open(OLD, $fout) || pmessage::SayError($fout, "new file");
>
>If I put an invalid path in $fin, I sucessfully get an error message
>(SayError generates an HTML error message). Then I correct the $fin
>path, but no matter what I do the second open causes the dreaded "The
>Document contains no data" message.
>
>Both test.txt and test2 exist and have rw privs..
>
>I don't see how this is logically possible. If $fin is bad, SayError
>generates the correct error message, so I'm sure that it works. Yet if
>$fout is bad, the script seems to abort. And if its good, it aborts too.
>No matter what, it aborts. My only conclusion is that perl is somehow
>hosing up the open wen a ">" is present?
>
>If I run the script from the prompt I get no errrors..
>
>I also tried it without the \> using just > instead. Same result..
>
>Any suggestions of whats going on here? I can't see how this could
>happen.. Maybe I'm dumb? Woulnd't be the first time!
If that is the entire CGI script, then, when no errors are present, you
should receive an error along the lines of "CGI Failed To Provide A Valid
Header". But I have this suspicion (well, actually I'm quite certain) that
you have provided only a snippet of the actual code.
The "Document Contains No Data" message means exactly what it says. Your
script provided a valid header (from some section of code you have ommitted),
but provided no data beyond the header.
FWIW, the line should be:
my $fout= ">../test/test2";
There should be no backslash in front of the '>' operator. That and your
'error' messages seem to indicate the exact opposite of what your file handle
names would suggest.
--
Ethan H. Poole | Website Design and Hosting,
| CGI Programming (Perl & C)..
========Personal=========== | ============================
* ehpoole @ ingress . com * | --Interact2Day, Inc.--
| http://www.interact2day.com/
------------------------------
Date: Wed, 27 Jan 1999 11:07:11 +0700
From: Kotaro Yama <kotaro@geocities.com>
Subject: How to write perl Echo off in Win32
Message-Id: <36AE90EE.8F6D4CA8@geocities.com>
Hello Sir,
I used to wrote perl in UNIX :-
system "stty -echo";
print "Enter your password : ";
chop($password=<STDIN>);
system "stty echo";
This script doesn't work in Win32 (Windows95),How I can write this in
Win32 Environment.
Thanks you.
Kotaro.
kotaro@geocities.com
------------------------------
Date: Wed, 27 Jan 1999 06:52:25 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: HTML files exported from Quark
Message-Id: <ebohlmanF67HrD.88x@netcom.com>
David Buttrick <buttrick@sportingnews.com> wrote:
: I am looking to parse some HTML documents.
Surprisingly, the best way to do that is to use HTML::Parser.
: The documents are structured as one single long line.
HTML::Parser doesn't care about such things.
: The perl that I have written in the past has been very much so line
: oriented, and I am not accustomed to thinking about reading a single line
: and looking for patterns in it.
HTML::Parser *is* accustomed to such things.
: I am specifically looking for <table> and </table> tags that will be perhaps
: on separate lines. How can I find the <table>, and flag that all the stuff
: on that line past the table tag is stuff that I want to load to an array for
: later processing, and still maintain that stuff if I'm going to have to read
: the next line to find the closing </table>
HTML::Parser can help you do that. It will separate your HTML into start
tags (complete with attributes conveniently broken out into a hash), end
tags, and text in between tags (it will also separate out comments and
DOCTYPE declarations). You can them deal with them at a high level
rather than mucking about at the character level. It's definitely worth
learning (and the time you take to learn it will be much less than the
time you'd spend debugging your own attempts to parse HTML).
------------------------------
Date: 26 Jan 1999 22:25:10 -0700
From: mfuhr@dimensional.com (Michael Fuhr)
Subject: Re: Looking for SNMP Poller
Message-Id: <78m7vm$cqt@flatland.dimensional.com>
Tom Grossi <grossi@fas.harvard.edu> writes:
> I am looking for an SNMP poller written in Perl which does not block
> when
> devices are not responding (e.g. one which receives and sendslls with
> separate processes
> or threads.) Any help on where I could find such a module or how to
> modify an existing
> module to do this would be greatly appreciated. Thanks. -Tom
If none of the SNMP modules on CPAN will do what you want, consider
trying Scotty (a Tcl extension):
http://wwwhome.cs.utwente.nl/~schoenw/scotty/
Scotty allows you to make SNMP queries with callbacks, so you can have
multiple outstanding queries without blocking for each one.
--
Michael Fuhr
http://www.fuhr.net/~mfuhr/
------------------------------
Date: Wed, 27 Jan 1999 00:40:39 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: loops
Message-Id: <1dm9hf1.at7enufz4pcfN@bay1-123.quincy.ziplink.net>
Daniel Grisinger <dgris@moiraine.dimensional.com> wrote:
> Just like he said, use for (or foreach, they're synonymous).
>
> $ perl -le '@a=(1..2);print for @a'
> 1
> 2
> $
Perhaps Ying Hu actually wanted to print:
(n choose 1)
(n choose 2)
(n choose 3)
...
(n choose n)
i.e. for n = 4:
a
b
c
d
a b
a c
a d
b c
b d
c d
a b c
a b d
a c d
b c d
a b c d
Here's one way to do it:
#!/usr/local/bin/perl -w
# elements to print
@stuff = ('a' .. 'd');
# initialize array of indices
@i = 0;
while (1) {
# print current subset
print "@stuff[@i]\n";
# increment last index
$i[-1]++;
# repeat until last index is legal
# or all indices have been incremented
for ($j=$#i-1; $j>=0 && $i[-1]>$#stuff; --$j) {
# increment the current index
# and reset the following indices
@i[$j .. $#i] = ($i[$j]+1 .. $i[$j]+$#i+1);
}
# if the last index is not legal...
if ($i[-1] > $#stuff) {
# ...reset all indices and add one more index
@i = 0 .. @i;
}
# done if more indices than elements
last if @i > @stuff;
}
__END__
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: Tue, 26 Jan 1999 23:45:01 -0500
From: Aaron Bentley <abentley@interlog.com>
Subject: Perl and output with page-breaks & graphics
Message-Id: <36AE99CC.7B428053@interlog.com>
I'm trying to write a CGI script in perl that outputs bar charts in some
format or other that supports page-breaks.
This is for inexperienced people to use, so the output would have to be
a common win/mac format, like Acrobat, Microsoft Word, or something.
Any suggestions on formats or modules that will output them?
--
Aaron Bentley
www.interlog.com/~abentley/music
------------------------------
Date: Wed, 27 Jan 1999 00:40:41 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Perl error/exception strings...
Message-Id: <1dm9ktj.1exavxp1pwlr76N@bay1-123.quincy.ziplink.net>
Olson, D. A. <dolson093@sprintmail-ns.com> wrote:
> In a nutshell, I need to get a list of
> all possible error/exception strings produced by Perl if possible ( via $!
> and $@ ). Does such a list exist?
The error strings produced via $! are defined by the operating system,
not be Perl.
The error strings produced via $@ are the fatal error messages list in
perldiag. $@ can also have an arbitrary string, as in
eval qq{die "arbitrary string\n" };
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 27 Jan 1999 04:59:20 GMT
From: elf@halcyon.com (Elf Sternberg)
Subject: Re: Perl from the Market viewpoint
Message-Id: <78m6f8$4hd$1@brokaw.wa.com>
In article <785n7g$c8q@bgtnsc02.worldnet.att.net>
"sysadmin" <charlesjourdan@worldnet.att.net> writes:
>If I wanted to focus on programming Perl in a UNIX environment, could I
>expect to a make a living just doing that?
>What kind of work is out there where the focus is Perl and UNIX, and what
>types of industries/companies are looking for this kind of narrow (?)
>skillset?
I think it's a very narrow skillset to try and market. I
would ask other questions of you like what other than perl do you
bring to the job-- what makes you a valuable employee? While it's
true that I currently do about 90% of my work in Perl, I couldn't
function without a working knowledge of C, Bourne shell, and the inner
working of HTTP and CGI-- and I don't do much web work these days. In
short, if you want a job, you must have more skills than "just" a
programming language.
Elf
--
Elf M. Sternberg, rational romantic mystic cynical idealist
If you're so smart, why aren't you naked?
http://www.halcyon.com/elf/
------------------------------
Date: Tue, 26 Jan 1999 10:00:03 -1000
From: Michael Ching <m_ching@hotmail.com>
Subject: Re: split file into multiple...
Message-Id: <36AE1EC3.C1456920@hotmail.com>
perldoc -f binmode
perldoc -f split
Rahul K wrote:
>
> Hi,
>
> I have a file that contains *binary data*. The data is such that it
> contains repetitions of a string , say xoox. I want to split this file
> at this string into multiple files.
>
> ie lets say my binary file contained
> xoox11111xoox22222xoox33333xoox44444
>
> after running the program, I will have four files which contain
>
> xoox11111
>
> xoox22222
>
> xoox33333
>
> xoox44444
>
> Thanks in advance,
>
> -rahul
------------------------------
Date: Wed, 27 Jan 1999 00:33:21 -0800
From: abey@cs.ucr.edu (Abraham Grief)
Subject: system function, Pros and Cons??
Message-Id: <mbAr2.15509$h5.113684607@WReNphoon1>
Using the system function is not portable. If you
write a perl script that uses the system function, you
might have to rewrite it for every operating system
you want to run it on.
*** Posted from RemarQ - http://www.remarq.com - Discussions Start Here (tm) ***
------------------------------
Date: Wed, 27 Jan 1999 00:40:42 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: tryin' to learn
Message-Id: <1dm9lgu.10y8qhp1aw8z7kN@bay1-123.quincy.ziplink.net>
root <paulturner@home.com> wrote:
> format not terminated ...
If this is at the end of the file, did you remember to put a newline
after the period?
--
_ / ' _ / - aka - rjk@linguist.dartmouth.edu
( /)//)//)(//)/( Ronald J Kimball chipmunk@m-net.arbornet.org
/ http://www.ziplink.net/~rjk/
"It's funny 'cause it's true ... and vice versa."
------------------------------
Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>
Administrivia:
Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing.
]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body. Majordomo will then send you instructions on how to confirm your
]subscription. This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.
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.misc (and this Digest), send your
article to perl-users@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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 4758
**************************************