[24961] in Perl-Users-Digest
Perl-Users Digest, Issue: 7211 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 5 14:07:05 2004
Date: Tue, 5 Oct 2004 11:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Tue, 5 Oct 2004 Volume: 10 Number: 7211
Today's topics:
Error.pm and DBI.pm problem (Horst Walter)
Re: Error.pm and DBI.pm problem <perl&nntp@rhesa.com>
exit value not passed back <m.f.z.abdel-messeh@open.ac.uk>
finding the last element in a referenced array (.rhavin)
Re: finding the last element in a referenced array <toreau@gmail.com>
Re: finding the last element in a referenced array <perl&nntp@rhesa.com>
Re: finding the last element in a referenced array <shawn.corey@sympatico.ca>
Re: Getopt::Long install problems (Anno Siegel)
Re: Getopt::Long install problems <tadmc@augustmail.com>
How do I print from the cgi to which I am posting using (Diane)
Re: How Google/Amazon/eBay use? (R. Rajesh Jeba Anbiah)
Re: How Google/Amazon/eBay use? <tim@tt1lock.org>
map function problem <georgekinley@hotmail.com>
Re: map function problem (Anno Siegel)
Need robust commercial password manager service (Sandy)
Re: Need robust commercial password manager service (Randal L. Schwartz)
Re: Perl books on tape (Randal L. Schwartz)
Re: reading a list of files (krakle)
Re: Regular Expression help please <shawn.corey@sympatico.ca>
Re: Regular Expression help please <ebohlman@omsdev.com>
Re: Regular Expression help please <tadmc@augustmail.com>
Re: Regular Expression help please <iss025@bangor.ac.uk>
Re: Regular Expression help please (Shane)
Re: Signal handling and modules (Anno Siegel)
Re: Symbolic algebra (M.J.T. Guy)
Re: use sed in perl <someone@example.com>
Re: use sed in perl (perry zhou)
Using a string as a variable name. (Jeff)
Re: Using a string as a variable name. <jurgenex@hotmail.com>
Re: Using a string as a variable name. <mritty@gmail.com>
Re: Using a string as a variable name. <toreau@gmail.com>
What is @ <asdf@see.below.com.net.org.invalid>
Re: Which Counter is Perfect? (Randal L. Schwartz)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 5 Oct 2004 08:28:43 -0700
From: unkwb@web.de (Horst Walter)
Subject: Error.pm and DBI.pm problem
Message-Id: <53867fbe.0410050728.d42a5cc@posting.google.com>
As a newbie to Perl I run into the following problem. With this I get
the following problem with the code below:
Can't call method "with" without a package or object reference at
autodb.pm line 163
I have tried "use Error qw(:try);" and "use Error". I am confused
since this try/catch block works in other parts of my code pretty
fine. It seems to have something to do with DBI.
Any hints would be appreciated.
Thanks!
try {
my ($dbh) = @_;
unless ($dbh->disconnect) {
die("autodb::oracleLogoff $DBI::errstr");
};
}
catch Error with {
my $err = shift;
print "autodb::oracleLogoff(..) $err";
};
------------------------------
Date: Tue, 05 Oct 2004 19:34:29 +0200
From: Rhesa Rozendaal <perl&nntp@rhesa.com>
To: Horst Walter <unkwb@web.de>
Subject: Re: Error.pm and DBI.pm problem
Message-Id: <4162DB25.3050402@rhesa.com>
Horst Walter wrote:
> As a newbie to Perl I run into the following problem. With this I get
> the following problem with the code below:
>
> Can't call method "with" without a package or object reference at
> autodb.pm line 163
>
> I have tried "use Error qw(:try);" and "use Error". I am confused
> since this try/catch block works in other parts of my code pretty
> fine. It seems to have something to do with DBI.
It has to do with the way you raise exceptions within the try block. You "die" with an error message, but "catch" is expecting an object of class Error.
> Any hints would be appreciated.
> Thanks!
>
>
> try {
> my ($dbh) = @_;
> unless ($dbh->disconnect) {
> die("autodb::oracleLogoff $DBI::errstr");
change to
Error->Throw("autodb::oracleLogoff $DBI::errstr");
------------------------------
Date: Tue, 5 Oct 2004 17:22:25 +0100
From: "Mags" <m.f.z.abdel-messeh@open.ac.uk>
Subject: exit value not passed back
Message-Id: <cjuhim$7ki$1@yarrow.open.ac.uk>
Dear All,
I have a strange problem I am calling a perl script from another perl script
using the system command.
The called perl script can exit with different values which I want to
capture in the calling script. This works fine unless the called script is
interrupted by ctrl-c (although I have accounted for this), instead of
getting -2 (as below) I get 1 returned??
Any advice much appreciated.
Maged
Here is sample of my code:
calling.pl
#######
eval { system ("called.pl"); };
$exit_val = $? >> 8;
called.pl
#######
$SIG{INT} = \&exit_gracefully;
main block ...
$exit_value = 0;
exit $exit_value;
sub exit_gracefully
{
$SIG{INT} = \&exit_gracefully;
print "Program interrupted .. \n";
exit (-2);
}
------------------------------
Date: 5 Oct 2004 08:37:38 -0700
From: rhavin@shadowtec.de (.rhavin)
Subject: finding the last element in a referenced array
Message-Id: <5d65e7ed.0410050737.663d2718@posting.google.com>
i searched the usenet for a while and i wasn't able to find something
useful. perhaps i looked in the wrong places or i am to stupid -
whatever... here's my problem:
i want to access the last elemt of an array... sounds like $#array, i
know, but in my case, the array is stored as a reference in a
construction like this:
$hash{'%1'}{'%2'}=[1,2,3];
i can access the last element by
$hash{'%1'}{'%2'}[2]
cos i know it is the second, but i need a way to access the last
element without knowing whether it is the first, or the zeroth or
whatever.
i tried
$hash{'%1'}{'%2'}[$#hash{'%1'}{'%2'}]
but it doesn't work this way...
anybody willing to help, explain the mystics or simple
answer-pointing?
------------------------------
Date: Tue, 05 Oct 2004 17:55:12 +0200
From: Tore Aursand <toreau@gmail.com>
Subject: Re: finding the last element in a referenced array
Message-Id: <pan.2004.10.05.15.55.11.597702@gmail.com>
On Tue, 05 Oct 2004 08:37:38 -0700, .rhavin wrote:
> $hash{'%1'}{'%2'}=[1,2,3];
>
> i can access the last element by
>
> $hash{'%1'}{'%2'}[2]
>
> cos i know it is the second, but i need a way to access the last
> element without knowing whether it is the first, or the zeroth or
> whatever.
You want to approach the array "from behind";
my $last = $hash{'%1'}{'%2'}[-1];
--
Tore Aursand <toreau@gmail.com>
"What we anticipate seldom occurs. What we least expected generally
happens." (Benjamin Disraeli)
------------------------------
Date: Tue, 05 Oct 2004 18:05:42 +0200
From: Rhesa Rozendaal <perl&nntp@rhesa.com>
To: ".rhavin" <rhavin@shadowtec.de>
Subject: Re: finding the last element in a referenced array
Message-Id: <4162C656.8050301@rhesa.com>
.rhavin wrote:
> i want to access the last elemt of an array... sounds like $#array, i
> know, but in my case, the array is stored as a reference in a
> construction like this:
>
> $hash{'%1'}{'%2'}=[1,2,3];
>
> i can access the last element by
>
> $hash{'%1'}{'%2'}[2]
>
> cos i know it is the second, but i need a way to access the last
> element without knowing whether it is the first, or the zeroth or
> whatever.
luckily for you, perl can count backwards too:
@a = (1,2,3);
print $a[-1]; # prints 3
print $a[-2]; # prints 2
> i tried
>
> $hash{'%1'}{'%2'}[$#hash{'%1'}{'%2'}]
Look, the array is dereferenced by
@{ $hash{'%1'}{'%2'} }
so the last element index would be
$#{ $hash{'%1'}{'%2'} }
so you'd get at the last element with
$hash{'%1'}{'%2'}[ $#{ $hash{'%1'}{'%2'} } ];
Of course,
$hash{'%1'}{'%2'}[ -1 ]
is a bit more readable...
You could also have assigned the reference to a new variable:
$r = $hash{'%1'}{'%2'};
$last = $r->[ -1 ];
or
$last = $r->[ $#$r ];
Rhesa
------------------------------
Date: Tue, 05 Oct 2004 12:02:45 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: finding the last element in a referenced array
Message-Id: <Bzz8d.13368$jj2.722621@news20.bellglobal.com>
.rhavin wrote:
> i searched the usenet for a while and i wasn't able to find something
> useful. perhaps i looked in the wrong places or i am to stupid -
> whatever... here's my problem:
>
> i want to access the last elemt of an array... sounds like $#array, i
> know, but in my case, the array is stored as a reference in a
> construction like this:
>
> $hash{'%1'}{'%2'}=[1,2,3];
>
> i can access the last element by
>
> $hash{'%1'}{'%2'}[2]
>
> cos i know it is the second, but i need a way to access the last
^^^
Do you mean 'because?'
> element without knowing whether it is the first, or the zeroth or
> whatever.
>
> i tried
>
> $hash{'%1'}{'%2'}[$#hash{'%1'}{'%2'}]
>
> but it doesn't work this way...
>
> anybody willing to help, explain the mystics or simple
> answer-pointing?
To access the last element in an array use -1.
$hash{'%1'}{'%2'}[-1]
--- Shawn
------------------------------
Date: 5 Oct 2004 10:57:31 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Getopt::Long install problems
Message-Id: <cjtumr$h43$1@mamenchi.zrz.TU-Berlin.DE>
Mark J Fenbers <Mark.Fenbers@noaa.gov> wrote in comp.lang.perl.misc:
> -=-=-=-=-=-
>
> > I am going to suggest that you read the posting guidelines for this group
> > before proceeding any further.
>
> Why be so arrogant? I've read them long ago... I know what the "rules" are.
...but ignore them anyhow.
> > Avoid attachments.
>
> Right. But the v-card thing I can't help. You'll have to deal with it. I
We will. So long...
Anno
------------------------------
Date: Tue, 5 Oct 2004 08:41:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Getopt::Long install problems
Message-Id: <slrncm5953.3j8.tadmc@magna.augustmail.com>
Mark J Fenbers <Mark.Fenbers@noaa.gov> wrote:
[ snip MIME header ]
[ did NOT snip attributions because there were no attributions left ]
>> I am going to suggest that you read the posting guidelines for this group
>> before proceeding any further.
>
> Why be so arrogant?
Person1 inadvertently takes cuts in line, despite a clearly-formed
line and a sign that says "Please form a single line". Maybe he
was preoccupied or something and did not notice.
Person2 says "this is the middle of the line, the end is over there".
Why is Person2 so arrogant?
> I've read them long ago... I know what the "rules" are.
Oh, I see.
Person1 sees a clearly-formed line and a sign that says "Please form a
single line" but takes cuts anyway. Maybe he has "special circumstances"
that do not apply to everyone else standing there.
Person2 says "this is the middle of the line, the end is over there".
Why is Person2 so arrogant?
> But are you perfect? Excuse me for not being perfect (yet)!!
Missing one or two points of etiquette might be seen as imperfect.
Piling on a bunch of them might be seen as, errr..., arrogance.
I know everyone is supposed to follow some rules, but I
am not going to.
>> Avoid top-posting.
> What's the big deal?
It can cause you to become killfiled, hurting your chances of getting
answers to future questions.
> here at work we get all kinds of e-mail from the public and employees, and
> 99.9% of the 200+ e-mails I get daily from these combined are top-posters.
Email is not Usenet!
Confusing the two can lead to great peril, as seen in this thread...
> Why
> does this newsgroup have to be different?
1) Because Usenet is not email.
2) It is not "this newsgroup" that sees top-posting, MIME and whatnot
as unacceptable, they are unacceptable in nearly all newsgroups.
> It makes the group seem cliquey.
Since the "rules" apply on most newsgroups, most newsgroups *are* cliquey.
That is why they have separate newsgroups. A newsgroup for the Perl clique,
a newsgroup for the Disney World clique, a newsgroup for the photography
buff clique...
> Right. But the v-card thing I can't help. You'll have to deal with it.
Many people will have their newsreader set to auto-delete your posts then.
You decide whether you want to reduce your chances of getting an
answer or not, then you live with the consequences of your decision.
> need it there for all my other e-mail
^^^^^^^^^^^^
Usenet is not email!
> My hands are tied.
Then your articles are doomed to a reduced readership. Live with it.
>> And the main reason I am even bothering to write this, do not post multiple
>> copies of the same message. Given the fact that you posted the exact same
>> message at 6:49, 6:55, 6:58, 7:00, 7:03, 7:08, and 7:11 EST I am inclined
>> not to think it was by accident.
>
> Do you REALLY think I did this on purpose??
After observing a half dozen breaches of netiquette it is unfathomable
to think that there might have been seven?
> Hello?! Is anybody home??
Pot, kettle, black.
> Our T1
> line has been bouncing up and down like a yo-yo this evening (MCI has been
> dispatched) and I kept getting bounce-back errors which I thought were related
> to this.
Oh right, we should have known that somehow.
How silly to form a conclusion from only the information presently available.
> You have to realize that most people don't "live" on the newsgroup and spend
> hours and hours pouring through newsgroup messages
You have to realize that those are the people most likely to provide
you with your answer.
Do you want them to read your question or do you want it to be
auto-deleted as if it never existed?
You make your choice and then you live with the consequences of your choice.
> to know the rules or posting
> conventions.
But you don't have to spend "hours and hours" on that in "this newsgroup".
Some joker wrote them all down for you and posts them twice a week.
"hours and hours" has been reduced to about 10 minutes for "this newsgroup".
Your "hours and hours" scenario does not apply in this situation,
and so is not an argument that helps support your position.
> The majority of people post a question and hope or pray for an
> appropriate answer to solve their problem.
The majority of people get their questions answered without
flaunting the rules of netiquette.
You are not a member of that set of people.
> I don't feel
Your thoughts and opinions are sure to be seen as Very Important
to all observers, thank you for sharing your obvious wisdom.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 5 Oct 2004 09:08:05 -0700
From: diane@dmswebsupport.com (Diane)
Subject: How do I print from the cgi to which I am posting using post_https?
Message-Id: <44d292cb.0410050808.560e0f40@posting.google.com>
I am posting information from one perl cgi to another using
post_https, and would like to print from the second cgi, the one to
which I am posting. When I use a print statement in the second cgi,
rather than displaying the information in the browser, it prints to
the first cgi. I know I can then display that information in the
browser by using
print "$reply_data";
in the first cgi, but it there a way to actually get the second cgi to
send the information to the browser?
Thanks for any help.
Diane
------------------------------
Date: 5 Oct 2004 05:49:44 -0700
From: ng4rrjanbiah@rediffmail.com (R. Rajesh Jeba Anbiah)
Subject: Re: How Google/Amazon/eBay use?
Message-Id: <abc4d8b8.0410050449.6eb37692@posting.google.com>
"http://www-free.info" <aa@bb.cc> wrote in message news:<rvSdnb3DUews5f3cRVn-qA@rogers.com>...
> As far as I know
> Amazon uses Perl
> eBay uses C
> Google, was not using PHP at
> all before late 2003. I bet it is using C.
>
> I am pretty sure that Google does not use database. Not sure about Amazon or
> eBay
1. PHP <http://toolbar.google.com/failed.php>
2. PHP3 <http://toolbar.google.com/whatsnew.php3>
3. py <http://gmail.google.com/support/bin/request.py>
But heard that Google uses MySQL, not sure. But sure they use Linux.
--
| Just another PHP saint |
Email: rrjanbiah-at-Y!com
------------------------------
Date: Tue, 5 Oct 2004 16:27:28 GMT
From: Tim Tyler <tim@tt1lock.org>
Subject: Re: How Google/Amazon/eBay use?
Message-Id: <I54Dps.LAw@bath.ac.uk>
In comp.lang.php http://www-free.info <aa@bb.cc> wrote or quoted:
> As far as I know
> Amazon uses Perl
> eBay uses C
Ebay uses Java on Solaris servers running IBM's Websphere.
--
__________
|im |yler http://timtyler.org/ tim@tt1lock.org Remove lock to reply.
------------------------------
Date: Tue, 05 Oct 2004 12:52:54 GMT
From: "George Kinley" <georgekinley@hotmail.com>
Subject: map function problem
Message-Id: <GOw8d.26987$k4.523056@news1.nokia.com>
Hi
I have following command
@ar1=map {if (/\\/) {$_}} @arr;
which populates the ar1 with where it files"\" in @arr BUT it also
appends BLANK records where it does'nt ,
my question is how to avoid appending blank records
------------------------------
Date: 5 Oct 2004 13:13:08 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: map function problem
Message-Id: <cju6l4$m7e$1@mamenchi.zrz.TU-Berlin.DE>
George Kinley <georgekinley@hotmail.com> wrote in comp.lang.perl.misc:
> Hi
> I have following command
> @ar1=map {if (/\\/) {$_}} @arr;
> which populates the ar1 with where it files"\" in @arr BUT it also
> appends BLANK records where it does'nt ,
> my question is how to avoid appending blank records
Using map? That would be
my @ar1=map /\\/ ? $_ : (), @arr;
but that's really a job for grep:
my @ar1 = grep /\\/, @arr;
Anno
------------------------------
Date: 5 Oct 2004 08:02:15 -0700
From: cassini_rings@yahoo.com (Sandy)
Subject: Need robust commercial password manager service
Message-Id: <dffd34bd.0410050702.1aa1c541@posting.google.com>
I have a new commercial site that supports a subscription service
currently with 300 subscribers. I'm running a cgi Perl script to
manage my subscribers password needs, but it is constantly breaking
down, and I don't have the knowledge or experience to keep it working
properly.
I'm looking for a commercial password management service that will
work seamlessly with my site, manage up to 1,000-2,000 usernames and
passwords and not have to be maintained in my own cgi directory of my
site where I will have to manage and troubleshoot it. Subscribers will
need to modify their own usernames and passwords and it should
interface with my payment gateway to receive payment data and develop
subscription expiration notices.
Does anyone have any suggestions?
Many thanks,
-Pat
------------------------------
Date: 05 Oct 2004 08:09:31 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Need robust commercial password manager service
Message-Id: <1096989506.KTfl/cpaEVaafTiUs//dfA@teranews>
>>>>> "Sandy" == Sandy <cassini_rings@yahoo.com> writes:
Sandy> Does anyone have any suggestions?
Yes. Write it in Perl. If you have trouble when you're writing it in
Perl, post your Perl question here. This is a forum for Perl
programmers helping out other Perl programmers.
If you want to *hire* a Perl programmer to do your work, then you're
in the wrong place. See http://jobs.perl.org for assistance there.
If you're looking for a free handout, the door is that way ====>.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 05 Oct 2004 07:46:49 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Perl books on tape
Message-Id: <1096987704.CUwTY/B1+6nGRuluLpFv1w@teranews>
>>>>> "wana" == wana <ioneabu@yahoo.com> writes:
wana> How much could it cost to produce really? Sit at your computer and
wana> record yourself spewing out Perl pearls for an hour at a time, package
wana> into an mp3 and put up on your website for sale. If you're good,
wana> people will buy.
I'd consider that sort of tape rather useless without the associated
graphics, unless it was Perl Poetry. :)
And I wouldn't want someone driving beside me listening to a tape on
Perl (even of me :-), and then flipping down to look at the graphics.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: 5 Oct 2004 09:12:45 -0700
From: krakle@visto.com (krakle)
Subject: Re: reading a list of files
Message-Id: <237aaff8.0410050812.8c9e688@posting.google.com>
john_williams4321@hotmail.com (john williams) wrote in message news:<298e5c19.0410040652.4a8732e2@posting.google.com>...
> Hi,
>
> I have a list of files:
>
> basename_001.ext
> ...
> basename_1000.ext
Great.. If all the files are in a single directory throw all the file
names in an array...
my @filenames = </some/path/to/dir/*>;
Then loop through the array and perform whatever functions you want
to...
foreach my $file (@filenames) {
# some yadda perl
}
>
> I would like to be able to read them one by one,
open (FILE, $file) || die $!;
@src = <FILE>;
close (FILE);
-or-
open (FILE, $file) || die $!;
while (<FILE>) {
$src .= $_;
}
close (FILE);
> and process each
> file,
Process each file as in???
> then write the files one by one as:
>
> basename_out_0001.ext
> ...
> basename_out_1000.ext
This is all plain ol' simple Perl...
open (FILE, ">$file") || die $!; # Over write.. use >> to append
print FILE "whatever the hell you want\n";
close (FILE);
>
>
> due to the large number of files, I need this to be automated.
Automated as in ran on a schedule? cronjob...
>
> Any help would be appreciated, thanks in advance
> John
Actually, since this is all very simple you could of done it yourself
if you know basic Perl. Looks like you just wanted someone to write it
for you.
------------------------------
Date: Tue, 05 Oct 2004 06:47:38 -0400
From: Shawn Corey <shawn.corey@sympatico.ca>
Subject: Re: Regular Expression help please
Message-Id: <dYu8d.7209$HO1.464303@news20.bellglobal.com>
ZafT wrote:
> I do want to thank those of you who tactfully pointed me in the right
> direction and gave me bits of code. To the HUNDREDS of others that I
> bothered - sorry. To Abigail - I truly hope you find something better to do
> with your time that to pick on people asking for help.
>
> Shane
>
>
No bother at all. If I find you annoying, I'll use 'Ignore Thread' If I
find you really annoying, I'll stop reading the newsgroup.
--- Shawn
------------------------------
Date: 5 Oct 2004 11:01:18 GMT
From: Eric Bohlman <ebohlman@omsdev.com>
Subject: Re: Regular Expression help please
Message-Id: <Xns95793E08B6FE1ebohlmanomsdevcom@130.133.1.4>
"ZafT" <deja_nospam_@zaft.com> wrote in
news:0-udnc9ioNSfzv_cRVn-og@comcast.com:
> Third, i just didn't have a perl interpreter (and can't install one
> without nazis breaking down my door) on that box and am not allowed
> ftp, ssh, or telnet access from where I posted from. I really thought
> that it would be an easy one to figure out. I mean, really - if
> there's a group of people that use regular expressions a lot, here
> they are. Any other group would give me a blank stare. I may have
> picked the wrong group, but not the wrong group of people.
[I'm making more of a general observation here and not trying to single you
out personally, since you are by no means the first person to make this
mistake on Usenet]
I've come to the conclusion that one of the most common, if not *the* most
common, sources of friction in technical Usenet groups is the fact that
many people simply have no sense of just how much they're taking for
granted when they ask a question. In this case, for example, it was quite
obvious to the OP what the limitations of his environment were, but there
was *no* realistic way anyone reading his post could have known about them.
In fact, if he had *explicitly* stated those limitations, his query would
have been *much* better received here (even if most of the responses took
the form of "I can't help you out").
It would seem that the _reductio ad absurdum_ of taking things for granted
would be asking "my program doesn't work. What's wrong with it?" without
giving *any* details of what the program consisted of, what it was supposed
to do, and what it was doing that it wasn't supposed to do or what it
wasn't doing that it was supposed to do. And yet we get *exactly* that
several times a week!
Asking other people to help you solve a problem is very much like
delegating a task to someone else. When you do something yourself, you
take into consideration a whole bunch of "background knowledge" that you
often aren't even explicitly aware of. But when you ask someone else to do
it, they won't be able to (at least not to do it well) unless you
*explictly* state all the background details. That's part of the reason
why there's such a common perception that "if you want it done right, you
have to do it yourself" (another reason is that we tend, without being
consciously aware of it, to forgive our own slipups more than other
people's; this is part of a more general tendency that's so universal that
psychologists call it "the fundamental error of attribution").
And similarly, when you need someone else's help with a problem, you really
need to (if the someone else is going to be able to give you meaningful
help) make a *conscious effort* to determine which "background details" are
important and which aren't, and to *state the important details
explicitly*. If you don't make such an effort (and it *is* an effort, and
it doesn't come "naturally" to anybody), then you will almost certainly err
by omitting the very details that point to the solution (in fact, making
the effort often results in your solving the problem yourself because it
makes you aware of things that you overlooked).
Now you've got to realize that this phenomenon (posters asking questions
that could only be answered by a mind-reader) happens *so* frequently here
that anyone one poster who does it might well be the "straw that broke the
camel's back" for whoever is reading it. A very tall person who blew up at
the first person to ask him "how's the weather up there" would indeed be
oversensitive and ill-tempered, but he'd have to be a saint not to show at
least some signs of annoyance when he hears it for the twentieth time since
he woke up and it's still three hours until lunchtime.
BTW, when we ask someone to show what they've tried so far, we're not being
snotty. It's just that we don't want to waste our time suggesting "try
this" only to hear "I already did." And for that matter, until we know
what you tried, we have *no* way of knowing how those attempts could have
gone wrong.
------------------------------
Date: Tue, 5 Oct 2004 07:45:02 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Regular Expression help please
Message-Id: <slrncm55qe.3j8.tadmc@magna.augustmail.com>
ZafT <deja_nospam_@zaft.com> wrote:
>
>>
>> Asking on Usenet, and bothering hundreds of other people just to avoid
>> writing a one-liner in Perl, now *that* is overkill.
> and groveled at the group's feet
> for mercy to avoid getting flamed.
If you apologize before you act rude then nobody will think badly of you?
It appears that you are not a student of human nature.
If you don't want to appear rude, then don't do rude activities.
> Second, how much of a bother is it to post a message. Hundreds? I think
> not.
So you have been reading this newsgroup for a while then, since you
seem quite confident that you know the size of the group's readership?
We often get a hundred posts in a *single day* here, and that is
only the people who speak up, there are likely a whole lot more
who don't add posts.
I am certain that at least 200 people read this newsgroup, so "hundreds"
is completely accurate.
(Pardon me, but I think your ignorance is showing.)
> If so, then you just bothered the same group of people by posting a
> reply- a senseless one I might add.
When someone takes cuts in line, you think it is senseless to
say something about it?
It appears that you are not a student of human nature.
Angst at off-topic posts helps everyone reading who contemplates
making their own off-topic post to reconsider.
If nobody says anything, that reenforces the rude behavior.
> At least I really needed some help.
Nobody is upset that you need help, that is a non-issue.
What upsets people is that you do not need Perl help, yet here
you are in the Perl newsgroup.
> Now I just had to bother them all over again just to bitch at you.
^^^^^^^^^^^
No you didn't.
You could have just said "Sorry, I won't do it again", and people
would be able to see your future posts.
Your poorly argued attempt at justifying your off-topic post is
very likely to have more "cost" than "benefit".
benefit: You feel better for a few hours
cost: Many of the frequent-answerers will never see anymore of your posts.
That seems a poor trade-off to me, perhaps you should have tried just
a little harder to resist telling us how it should be here.
> Third, i just didn't have a perl interpreter (and can't install one without
> nazis breaking down my door) on that box and am not allowed ftp, ssh, or
> telnet access from where I posted from.
Your sad environment has no effect on what is seen as socially
acceptable on Usenet.
> I do want to thank those of you who tactfully pointed me in the right
> direction and gave me bits of code.
That is much less likely to happen in the future now, as your
followup pretty much demands that you be killfiled. So long!
> To the HUNDREDS of others that I
> bothered - sorry.
I have reason to doubt your sincerity there.
> To Abigail - I truly hope you find something better to do
> with your time that to pick on people asking for help.
To Anonymous Fool - I truly hope you find something better to do
with your time than to (attempt to) realign the social dynamic that has
developed here (and in nearly all newsgroups).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Tue, 05 Oct 2004 17:18:04 +0100
From: "P.R.Brady" <iss025@bangor.ac.uk>
Subject: Re: Regular Expression help please
Message-Id: <4162C93C.3080906@bangor.ac.uk>
ZafT wrote:
>>Asking on Usenet, and bothering hundreds of other people just to avoid
>>writing a one-liner in Perl, now *that* is overkill.
>>
>
>
> First of all, you don't have to read the frickin post. I tried to ask
> nicely, as I didn't know where elso to go, and groveled at the group's feet
> for mercy to avoid getting flamed.
>
[ ... snipped]
Actually, I don't think that remark takes us forward at all, and I find
it sad that you react angrily.
I've asked lots of naive, sometimes stupid questions on the group, and
always had very helpful answers, though occasionally had a tactful
pointer to perldoc which is perfectly valid.
Abigail is always in the forefront of helpful replies and I wouldn't
want him to stop!
Phil
------------------------------
Date: 5 Oct 2004 09:59:26 -0700
From: deja_NOSPAM_@zaft.com (Shane)
Subject: Re: Regular Expression help please
Message-Id: <d0cc80fa.0410050859.a580bc8@posting.google.com>
Shawn Corey <shawn.corey@sympatico.ca> wrote in message news:<dYu8d.7209$HO1.464303@news20.bellglobal.com>...
> ZafT wrote:
> > I do want to thank those of you who tactfully pointed me in the right
> > direction and gave me bits of code. To the HUNDREDS of others that I
> > bothered - sorry. To Abigail - I truly hope you find something better to do
> > with your time that to pick on people asking for help.
> >
> > Shane
> >
> >
>
> No bother at all. If I find you annoying, I'll use 'Ignore Thread' If I
> find you really annoying, I'll stop reading the newsgroup.
>
> --- Shawn
Thanks for understanding. Not to mean that I will make a habit of off
topic posts :-)
Really, sorry for the off topic post all. Again, I just didn't know
where else to go that I may actually get an answer. This has been a
pretty friendly newsgroup in the past, but I suppose that's because I
have never posted anything related to anything other than perl.
Shane
------------------------------
Date: 5 Oct 2004 10:22:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Signal handling and modules
Message-Id: <cjtskn$ead$3@mamenchi.zrz.TU-Berlin.DE>
William Ahern <william@wilbur.25thandClement.com> wrote in comp.lang.perl.misc:
> If I set a signal handler in Perl which does *not* die()--just simply
> returns--will Perl still longjmp()?
Perl doesn't longjmp(), its non-local control transfer is through
eval() and die(). (It may or may not use longjmp() internally, but
that's none of our business.)
When you return() from a handler, control goes back to the Perl program
where it was interrupted. The only side effect to be reckoned with
is that sleep() returns prematurely if it was interrupted.
> I suspect not, but I want to be sure. My
> Problem is that I'm using a large C module which could get very confused if
> Perl longjmp()d out of its execution path (deadlock, for instance). However,
> I still want to set an alarm. The C code will fail properly when a blocking
> call interrupts.
I'm not sure what situation you're describing here. If Perl longjmp()s,
(as it presumably does), it will be caught within the Perl interpreter.
Anno
------------------------------
Date: 5 Oct 2004 15:42:12 GMT
From: mjtg@cus.cam.ac.uk (M.J.T. Guy)
Subject: Re: Symbolic algebra
Message-Id: <cjufck$i5b$1@gemini.csx.cam.ac.uk>
Brian Troutwine <goofy_headed_punk@msn.com> wrote:
>I'm trying to write a program to output a Lagrange interpolating
>polynomial.
>http://mathworld.wolfram.com/LagrangeInterpolatingPolynomial.html
>
>So far what I'm getting is output that looks somewhat along the lines of:
>
>((x-2)(x-3)(x-4)(x-5)(1)/(24))+
>((x-1)(x-3)(x-4)(x-5)(2)/(-6))+
>((x-1)(x-2)(x-4)(x-5)(6)/(4))+
>((x-1)(x-2)(x-3)(x-5)(24)/(-6))+
>((x-1)(x-2)(x-3)(x-4)(120)/(24))
>
>What I want is to be able to take that and output it in the form of
>
>Ax^n + Bx^(n-1) ... + C
Implementing a general algebra package in Perl would be a substantial
task, but for your problem you need much less, so a full-blown algebra
package is massive overkill.
You only need to deal with polynomials in one variable (x), and only
need a few operations.
[ All following code untested ]
We represent a polynomial by a reference to an array of coefficients.
a) Create a constant polynomial $a
[ $a ];
b) Multiply the polynomial $b by (x-$a)
push @$b, 0; # degree increases by 1
for (my $i = $#$b; $i >= 0; $i--) { # NB must do backwards
$b->[$i] *= -$a;
$b->[$i] += $b->[$i-1] if $i; # don't reference $b[-1]
};
c) Add polynomial $a to $b
# next line not needed if your polynomials all have same degree
push @$b, (0) x (@a-@b) if @a > @b;
$b->[$_] += $a->[$_] for 0..$#a;
d) Stringify a polynomial $a
my $s = '';
for (my $i = $#$a; $i >= 0; $i--) {
my $c = $a->[$i] or next; # skip zero terms
$s .= ' ' if $s;
$s .= ($c > 0 ? "+ $c" : '- '.-$c);
$s .= 'x' if $i;
$s .= "^$i" if $i > 1;
};
print "The polynomial is $s\n";
Mike Guy
------------------------------
Date: Tue, 05 Oct 2004 12:06:18 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: use sed in perl
Message-Id: <_6w8d.27036$N%.25590@edtnps84>
perry zhou wrote:
> I used some legacy perl code to change a configuration file, it is
> working and it replaces the line starts with XT_SCREEN_COUNT=1 with
> the a new SCREEN_COUNT variable. But I don't quite understand what's
> the meaning of the ' . in front of $numscreens and after $numscreens.
> Could anyone give me a hint?
>
> Thanks in advance!
>
> $rc = system('sed -e
> "s/^XT_SCREEN_COUNT=1/XT_SCREEN_COUNT='.$numscreens. '/g" '.
> $resultdir.'tetexec.cfg>' . $resultdir. 'tetexec.cfg.tmp');
>
> $numscreens is a variable which equals to a number, for example 2.
> =======================================================================
> #Part of the configuration file:
>
> # available on the display, as returned by XScreenCount.
> # the code above will change the 1 to 2.
> XT_SCREEN_COUNT=1
You don't need sed, you can do that in perl:
open IN, '<', "$resultdir/tetexec.cfg" or die "Cannot open
$resultdir/tetexec.cfg: $!";
open OUT, '>', "$resultdir/tetexec.cfg.tmp" or die "Cannot open
$resultdir/tetexec.cfg.tmp: $!";
while ( <IN> ) {
s/(?<=^XT_SCREEN_COUNT=)1\b/$numscreens/;
print OUT
}
John
--
use Perl;
program
fulfillment
------------------------------
Date: 5 Oct 2004 08:50:22 -0700
From: pengxiang_zhou@yahoo.com (perry zhou)
Subject: Re: use sed in perl
Message-Id: <4204c44b.0410050750.51d4c22d@posting.google.com>
Simon Taylor <simon@unisolve.com.au> wrote in message news:<cjt837$2d28$1@otis.netspace.net.au>...
> Hello,
>
> > I used some legacy perl code to change a configuration file, it is
> > working and it replaces the line starts with XT_SCREEN_COUNT=1 with
> > the a new SCREEN_COUNT variable. But I don't quite understand what's
> > the meaning of the ' . in front of $numscreens and after $numscreens.
> > Could anyone give me a hint?
> >
> > Thanks in advance!
> >
> > $rc = system('sed -e
> > "s/^XT_SCREEN_COUNT=1/XT_SCREEN_COUNT='.$numscreens. '/g" '.
> > $resultdir.'tetexec.cfg>' . $resultdir. 'tetexec.cfg.tmp');
>
> The code is concatenating single-quoted strings together and
> interpolating variables to form an argument to the perl system() function.
>
> You can read it as:
>
> 'some text in single quotes' . $somevariable . 'more text'
>
> where the binary '.' operator is doing the string concatenation that the
> '+' operator does in some other languages.
>
> If the values of the perl variables $numscreens and $resultdir
> were, say, 2 and '/tmp/', respectively, then the system function
> would receive an argument that looked like:
>
> 'sed -e "s/^XT_SCREEN_COUNT=1/XT_SCREEN_COUNT=2/g" /tmp/tetexec.cfg>
> /tmp/tetexec.cfg.tmp'
>
> Needless to say, the original author of this code would find
> that the same functionality is more easily done directly in Perl.
> There's no need to use sed via a system call for this.
>
> I hope this helps,
>
> Simon Taylor
Thanks a lot for detailed explanation. As I don't know anything about
sed, and just started learning perl, I feel confused about the single
quotes used in the system call, now I understand it.
Thanks again!
------------------------------
Date: 5 Oct 2004 09:34:38 -0700
From: Jeff@aetherweb.co.uk (Jeff)
Subject: Using a string as a variable name.
Message-Id: <525192b4.0410050834.25c2ee5f@posting.google.com>
Hi,
I want to do things like this:
my $v1 = "varname";
my $varname = "it worked!";
print ${$v1};
And have the final statement know that it should print the content of $varname.
Is it possible?
Thanks,
Jeff
------------------------------
Date: Tue, 05 Oct 2004 16:41:47 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Using a string as a variable name.
Message-Id: <f9A8d.8298$1g5.3977@trnddc07>
Jeff wrote:
> I want to do things like this:
No, you don't. Please read the FAQ (perldoc -q "variable name") and
gazillions of previous articles why this is a _very_ bad idea.
> my $v1 = "varname";
> my $varname = "it worked!";
> print ${$v1};
>
> And have the final statement know that it should print the content of
> $varname.
>
> Is it possible?
Technically yes. But there is no good reason to use symbolic references
unless you do want to modify the system symbol table.
Just use a hash instead. Much easier to use, to maintain, and without all
the problems associated with symbolic references.
jue
------------------------------
Date: Tue, 05 Oct 2004 17:29:09 GMT
From: "Paul Lalli" <mritty@gmail.com>
Subject: Re: Using a string as a variable name.
Message-Id: <FRA8d.868$Ua.326@trndny01>
"Jeff" <Jeff@aetherweb.co.uk> wrote in message
news:525192b4.0410050834.25c2ee5f@posting.google.com...
> Hi,
>
> I want to do things like this:
>
> my $v1 = "varname";
> my $varname = "it worked!";
> print ${$v1};
>
> And have the final statement know that it should print the content of
$varname.
>
> Is it possible?
The standard response is "You don't want to do that. Read perldoc -q
"variable name" to understand why.
However, to answer the question you actually asked, yes, you are
technically able to do that - provided that
1) the variables are package variables, not lexicals (in your example
program, you'd have to change my to our, or disable strict vars (which
you also don't want to do))
2) strict refs has also been disabled (which yet again, is something
you don't want to do.)
In other words, "DON'T DO THIS". Use a hash. Read perldoc -q "variable
name"
Paul Lalli
------------------------------
Date: Tue, 05 Oct 2004 19:29:30 +0200
From: Tore Aursand <toreau@gmail.com>
Subject: Re: Using a string as a variable name.
Message-Id: <pan.2004.10.05.17.29.29.522613@gmail.com>
On Tue, 05 Oct 2004 09:34:38 -0700, Jeff wrote:
> I want to do things like this:
No. You _think_ you want this, but actually you don't. Please refer to
'perldoc -q "variable name"' for more information on why you should avoid
this.
> my $v1 = "varname";
> my $varname = "it worked!";
> print ${$v1};
Better off using a hash;
my %variables = ('v1' => 'it',
'v2' => 'worked');
print "$variables{v1} $variables{v2}\n";
--
Tore Aursand <toreau@gmail.com>
"The road to hell is full of good intentions." (Bruce Dickinson)
------------------------------
Date: 5 Oct 2004 17:32:08 GMT
From: asdf <asdf@see.below.com.net.org.invalid>
Subject: What is @
Message-Id: <cjulqo$1vd$0@pita.alt.net>
Hi,
I have a perl script for filtering spam. Did not write it, don't
know perl. The white list and black list files it looks to are just
lists of email addresses. I have been told since perl 5 came out I should
escape all @ with a \. What if I don't? Is is just another form of
wildcard? The chances of something other than the intended email
address having the same start and ending seems remote.
vic@some.com
vic\@some.com
Thanks,
Vic
------------------------------
Date: 05 Oct 2004 07:48:41 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Which Counter is Perfect?
Message-Id: <1096988610.ACcfEOlVE+rbmOvi+gA3ew@teranews>
>>>>> "nntp" == nntp <nntp@rogers.com> writes:
nntp> Counter 1: from Perldoc
nntp> Counter 2:
Counter 3:
use File::CounterFile;
(See docs for examples.)
Don't reinvent what is so readily available.
print "Just another Perl hacker,"; # the original
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
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.
NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice.
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 7211
***************************************