[23800] in Perl-Users-Digest
Perl-Users Digest, Issue: 6003 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jan 29 19:11:08 2004
Date: Thu, 29 Jan 2004 16:10:33 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Thu, 29 Jan 2004 Volume: 10 Number: 6003
Today's topics:
dumping web pages secured with integrated windows authe <guneyn74@yahoo.com>
Re: dumping web pages secured with integrated windows a <sithglan@stud.uni-erlangen.de>
Re: dumping web pages secured with integrated windows a <guneyn74@yahoo.com>
Re: dumping web pages secured with integrated windows a <guneyn74@yahoo.com>
dynamic scalar-naming problem (Hiro San Feng)
Re: dynamic scalar-naming problem <noreply@gunnar.cc>
Re: dynamic scalar-naming problem <gnari@simnet.is>
Re: dynamic scalar-naming problem <news4@earthsong.null.free-online.co.uk>
Re: dynamic scalar-naming problem (Mark Jason Dominus)
Re: dynamic scalar-naming problem (Hiro San Feng)
Re: dynamic scalar-naming problem <uri@stemsystems.com>
Re: dynamic scalar-naming problem <gnari@simnet.is>
Re: dynamic scalar-naming problem <bik.mido@tiscalinet.it>
Re: dynamic scalar-naming problem <bik.mido@tiscalinet.it>
Encyption for Credit Card numbers <sbryce@scottbryce.com>
evaluating success of command run with backticks <parimi@nowhere.none.com>
Re: evaluating success of command run with backticks <jwillmore@remove.adelphia.net>
Re: evaluating success of command run with backticks <usenet@morrow.me.uk>
Re: evaluating success of command run with backticks <ittyspam@yahoo.com>
Re: evaluating success of command run with backticks <me@privacy.net>
Re: evaluating success of command run with backticks <gnari@simnet.is>
Re: evaluating success of command run with backticks (Mark Jason Dominus)
Re: evaluating success of command run with backticks <jwillmore@remove.adelphia.net>
Re: evaluating success of command run with backticks <me@privacy.net>
Executing stored substitutions... <noone@nowhere.com>
Re: Executing stored substitutions... <noreply@gunnar.cc>
Re: Executing stored substitutions... <usenet@expires03-2004.tinita.de>
Re: Executing stored substitutions... <tadmc@augustmail.com>
Re: Executing stored substitutions... (ko)
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 22 Jan 2004 13:19:18 -0600
From: "NoSf3RaTu" <guneyn74@yahoo.com>
Subject: dumping web pages secured with integrated windows authentication
Message-Id: <10108hpc1n0041e@corp.supernews.com>
Hello,
I need to dump NTLM secured web pages, I tried to use LWP but somehow it did
not work for me. Does anyone know a working method of doing this?
Thanks
------------------------------
Date: 22 Jan 2004 19:21:29 GMT
From: Thomas Glanzmann <sithglan@stud.uni-erlangen.de>
Subject: Re: dumping web pages secured with integrated windows authentication
Message-Id: <slrnc108lp.fbk.sithglan@faui00u.informatik.uni-erlangen.de>
Hi,
> I need to dump NTLM secured web pages, I tried to use LWP but somehow it did
~~~~ -> [Windows] NT LAN Manager (MS, Windows NT, LAN)?
> not work for me. Does anyone know a working method of doing this?
did you mean that you tried to access TLS secured websites? If so ... it
works for me. :-)
Thomas
------------------------------
Date: Thu, 22 Jan 2004 13:24:56 -0600
From: "NoSf3RaTu" <guneyn74@yahoo.com>
Subject: Re: dumping web pages secured with integrated windows authentication
Message-Id: <10108samqsgk459@corp.supernews.com>
I thought it used NTLM/Kerberos 5
The server is running IIS 5 on Win 2000 Server
Thanks,
"Thomas Glanzmann" <sithglan@stud.uni-erlangen.de> wrote in message
news:slrnc108lp.fbk.sithglan@faui00u.informatik.uni-erlangen.de...
> Hi,
>
> > I need to dump NTLM secured web pages, I tried to use LWP but somehow it
did
> ~~~~ -> [Windows] NT LAN Manager (MS, Windows NT, LAN)?
>
> > not work for me. Does anyone know a working method of doing this?
>
> did you mean that you tried to access TLS secured websites? If so ... it
> works for me. :-)
>
> Thomas
------------------------------
Date: Thu, 22 Jan 2004 14:25:02 -0600
From: "NoSf3RaTu" <guneyn74@yahoo.com>
Subject: Re: dumping web pages secured with integrated windows authentication
Message-Id: <1010cd6o246c9c3@corp.supernews.com>
Ok I solved it
I used curl
curl http://web.com --ntlm -u user:pass
Thanks...
"NoSf3RaTu" <guneyn74@yahoo.com> wrote in message
news:10108hpc1n0041e@corp.supernews.com...
> Hello,
>
> I need to dump NTLM secured web pages, I tried to use LWP but somehow it
did
> not work for me. Does anyone know a working method of doing this?
>
> Thanks
>
>
------------------------------
Date: Sun, 25 Jan 2004 15:51:11 GMT
From: hiro.rpg@aol.com (Hiro San Feng)
Subject: dynamic scalar-naming problem
Message-Id: <4013e3f9.8928015@news.rz.uni-duesseldorf.de>
key="hi" to the perl community!
what is wrong with this code?
for html reasons is need 3 version of a field-value,
1. the pure value as in the db
2. a " " to "+" version for the URL
3. a complete built link
all data-field scalars are name field-n
now I iterate thtough them... and get syntax errors!
for(my $i = 1; $i <= 55; $i++)
# add a leading zero to first 9 fields
# so field-9 becomes field-09
if($i < 10){ $i = "0" . $i; }
# do the conversion
{"field-" . $i . "_A"} = {"field" . $i};
{"field-" . $i}=~ tr/ /+/;
{"field-" . $i . "_B"} = "<A HREF='foo.com?key=" .
"field-" . $i .
"'>" . {"field-" . $i} . "</A>";
}
thanks for any hints!
as it seems the perl syntax is not so logic as it seems... at least to
me.
------------------------------
Date: Sun, 25 Jan 2004 17:31:04 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: dynamic scalar-naming problem
Message-Id: <bv0rbb$mlips$1@ID-184292.news.uni-berlin.de>
Hiro San Feng wrote:
> for html reasons is need 3 version of a field-value,
> 1. the pure value as in the db
> 2. a " " to "+" version for the URL
> 3. a complete built link
>
> all data-field scalars are name field-n
> now I iterate thtough them...
No you don't.
> and get syntax errors!
Yes, that sounds more likely.
> # do the conversion
> {"field-" . $i . "_A"} = {"field" . $i};
> {"field-" . $i}=~ tr/ /+/;
> {"field-" . $i . "_B"} = "<A HREF='foo.com?key=" .
> "field-" . $i .
> "'>" . {"field-" . $i} . "</A>";
> }
>
> thanks for any hints!
Have you possibly considered to assign the various versions to Perl
variables?
http://learn.perl.org/
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 25 Jan 2004 16:06:46 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: dynamic scalar-naming problem
Message-Id: <bv0po8$7c0$1@news.simnet.is>
"Hiro San Feng" <hiro.rpg@aol.com> wrote in message
news:4013e3f9.8928015@news.rz.uni-duesseldorf.de...
> key="hi" to the perl community!
>
> what is wrong with this code?
>
> for(my $i = 1; $i <= 55; $i++)
> # add a leading zero to first 9 fields
> # so field-9 becomes field-09
> if($i < 10){ $i = "0" . $i; }
take a look at sprintf
> # do the conversion
> {"field-" . $i . "_A"} = {"field" . $i};
[snipped rest of ths horror]
what you are trying to do is ${"field$i"}, but
you should use a hash or an array for this kind of data.
do not keep you fields in scalars $field01, $field02 ... $field55
but rather if the array @fields
gnari
------------------------------
Date: Sun, 25 Jan 2004 17:54:29 +0000
From: Andy Baxter <news4@earthsong.null.free-online.co.uk>
Subject: Re: dynamic scalar-naming problem
Message-Id: <pan.2004.01.25.17.54.27.770293@earthsong.null.free-online.co.uk>
At earth time Sun, 25 Jan 2004 15:51:11 +0000, the following transmission
was received from the entity known as Hiro San Feng:
> key="hi" to the perl community!
>
> what is wrong with this code?
>
>
> for html reasons is need 3 version of a field-value,
> 1. the pure value as in the db
> 2. a " " to "+" version for the URL
> 3. a complete built link
>
> all data-field scalars are name field-n
> now I iterate thtough them... and get syntax errors!
>
>
> for(my $i = 1; $i <= 55; $i++)
> # add a leading zero to first 9 fields
> # so field-9 becomes field-09
> if($i < 10){ $i = "0" . $i; }
> # do the conversion
> {"field-" . $i . "_A"} = {"field" . $i};
> {"field-" . $i}=~ tr/ /+/;
> {"field-" . $i . "_B"} = "<A HREF='foo.com?key=" .
> "field-" . $i .
> "'>" . {"field-" . $i} . "</A>";
> }
>
> thanks for any hints!
> as it seems the perl syntax is not so logic as it seems... at least to
> me.
why not just keep all the raw values in a hash or array, then convert them
to the other two forms as needed?
e.g.
my @fields=('field1-value','field2-value','field3value' etc. );
for (my $i=0; $i<scalar (@fields); $i++) {
my $field=$fields[i];
my $htmlfield="<A HREF='foo.com?key=field-" . $i .
"'>" . $field . "</A>";
my $plusfield=$field;
$plusfield =~ tr/ /+/;
# do something with $field, $htmlfield, and $plusfield
# ...
} # and go on to the next one.
--
http://www.niftybits.ukfsn.org/
remove 'n-u-l-l' to email me. html mail or attachments will go in the spam
bin unless notified with [html] or [attachment] in the subject line.
------------------------------
Date: Sun, 25 Jan 2004 19:03:24 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: dynamic scalar-naming problem
Message-Id: <bv13ts$jtu$1@plover.com>
In article <4013e3f9.8928015@news.rz.uni-duesseldorf.de>,
Hiro San Feng <hiro.rpg@aol.com> wrote:
>
>for(my $i = 1; $i <= 55; $i++)
> # add a leading zero to first 9 fields
> # so field-9 becomes field-09
> if($i < 10){ $i = "0" . $i; }
> # do the conversion
> {"field-" . $i . "_A"} = {"field" . $i};
> {"field-" . $i}=~ tr/ /+/;
> {"field-" . $i . "_B"} = "<A HREF='foo.com?key=" .
> "field-" . $i .
> "'>" . {"field-" . $i} . "</A>";
>}
Sir,
I suggest the following:
for my $i ( "01" .. "55" ) {
$field[$i]{A} = ${"field$i"};
$field[$i]{C} = ${"field$i"};
$field[$i]{C} =~ tr/ /+/;
$field[$i]{B} = "<A HREF='foo.com?key=field-$i'>$field[$i]{C}</A>";
}
>as it seems the perl syntax is not so logic as it seems...
You may be the first person ever to suggest that the Perl syntax seems logical.
My best regards, and a happy new year.
------------------------------
Date: Sun, 25 Jan 2004 19:12:42 GMT
From: hiro.rpg@aol.com (Hiro San Feng)
Subject: Re: dynamic scalar-naming problem
Message-Id: <40141451.4853015@news.rz.uni-duesseldorf.de>
On Sun, 25 Jan 2004 15:51:11 GMT, hiro.rpg@aol.com (Hiro San Feng)
wrote:
>key="hi" to the perl community!
>
<snip>
"@?!;!!" doesn't express how blind I was,
I should switch off the box for today...
now it works:
# test
$field09 = "Hello World";
for(my $i = 1; $i <= 55; $i++)
{
if($i < 10){ $i = sprintf("%02d", $i); }
#
${"field" . "$i". "_A"} = ${"field$i"};
${"field$i"}=~ tr/ /+/;
${"field" . "$i" . "_B"} = "<A HREF='foo.com?field$i=" . ${"field" .
"$i"} . "'>" . ${"field" . $i . "_A"} . "</A>";
}
print "$i: $field09; $field09_A; $field09_B";
------------------------------
Date: Sun, 25 Jan 2004 20:40:51 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: dynamic scalar-naming problem
Message-Id: <x7d697wylp.fsf@mail.sysarch.com>
>>>>> "HSF" == Hiro San Feng <hiro.rpg@aol.com> writes:
HSF> "@?!;!!" doesn't express how blind I was,
HSF> I should switch off the box for today...
you are still blind. see below
HSF> now it works:
HSF> #
HSF> ${"field" . "$i". "_A"} = ${"field$i"};
HSF> ${"field$i"}=~ tr/ /+/;
HSF> ${"field" . "$i" . "_B"} = "<A HREF='foo.com?field$i=" . ${"field" .
HSF> "$i"} . "'>" . ${"field" . $i . "_A"} . "</A>";
HSF> }
those are symbolic references and should not be used for simple data
structures. the symbol table is just a special hash tree and gives you
no benefits over a plain hash structure. but using the symbol table like
that can be very dangerous and make for hard to find bugs.
another benefit of plain hashes is you can pass them around (by ref or
by copy) and make many of them. hard to do that with the single global
symbol table.
read perlreftut, perlref, perldsc and perllol to learn how to do proper
perl data structures. others mentioned this in this thread but you have
gone on the symref path of evil code.
rule: use symrefs only when you must mung the symbol table. otherwise a
plain hash is safer, more useful and strict clean.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Sun, 25 Jan 2004 20:12:14 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: dynamic scalar-naming problem
Message-Id: <bv184g$92m$1@news.simnet.is>
"Hiro San Feng" <hiro.rpg@aol.com> wrote in message
news:40141451.4853015@news.rz.uni-duesseldorf.de...
> On Sun, 25 Jan 2004 15:51:11 GMT, hiro.rpg@aol.com (Hiro San Feng)
> now it works:
>
> # test
> $field09 = "Hello World";
>
> for(my $i = 1; $i <= 55; $i++)
> {
> if($i < 10){ $i = sprintf("%02d", $i); }
the point of the sprintf is you dont really need the test
also, I get nervous when I see assignements to the index
of this type of loop. I would either use :
for my $i (1..55) {...
or
for(my $x = 1; $x <= 55; $x++) {
my $i=sprintf("%02d", $x);
> #
> ${"field" . "$i". "_A"} = ${"field$i"};
> ${"field$i"}=~ tr/ /+/;
> ${"field" . "$i" . "_B"} = "<A HREF='foo.com?field$i=" . ${"field" .
> "$i"} . "'>" . ${"field" . $i . "_A"} . "</A>";
> }
>
> print "$i: $field09; $field09_A; $field09_B";
here I would again suggest using some different datastructures.
either 3 arrays, or an array of hashs
gnari
------------------------------
Date: Tue, 27 Jan 2004 09:20:05 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: dynamic scalar-naming problem
Message-Id: <rv6c1012pievgslojb3bb1nl367mqc877g@4ax.com>
On Sun, 25 Jan 2004 19:12:42 GMT, hiro.rpg@aol.com (Hiro San Feng)
wrote:
>now it works:
^^^^^^^^^^^^
>
># test
>$field09 = "Hello World";
>
>for(my $i = 1; $i <= 55; $i++)
>{
> if($i < 10){ $i = sprintf("%02d", $i); }
> #
> ${"field" . "$i". "_A"} = ${"field$i"};
> ${"field$i"}=~ tr/ /+/;
> ${"field" . "$i" . "_B"} = "<A HREF='foo.com?field$i=" . ${"field" .
>"$i"} . "'>" . ${"field" . $i . "_A"} . "</A>";
>}
Beware though: you've followed only some of the advices you've been
given! More explicitly, you should know that generally an article like
yours tends to raise meta-discussions about what one should tell to a
newbie about such questions.
The key point is the use of symbolic references. They all agree that
it is potentially dangerous. Now, there are two main "parties" in this
respect: some think that it is better to tell about them anyway,
others that you should not mention them at all.
A good point about the first policy is that if the newbie is not told
about symbolic references and uses, say, a hash instead, when he later
will discover them he'll think, *erroneusly*, he's found a better way
to do it.
Now trust me: there are good reasons why the "best way to do it" is by
avoiding the use of symrefs. In your code snippet above this wouldn't
make much difference, but if you get used to them you will be bitten
first or later.
Other posters will be more than happy to shed some more light on this
topic, if you're interested. Also, googling may help...
Michele
------------------------------
Date: Tue, 27 Jan 2004 09:20:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: dynamic scalar-naming problem
Message-Id: <62va10l2v6muhpv3q2r80f7g3vrd06vu7k@4ax.com>
On Sun, 25 Jan 2004 19:03:24 +0000 (UTC), mjd@plover.com (Mark Jason
Dominus) wrote:
[snip]
<OT>
FWIW, *welcome back here*! Even if maybe this is not appropriate since
IIRC you weren't here when *I* started to read the ng regularly, but
kinda felt like saying so...
</OT>
Michele
--
# This prints: Just another Perl hacker,
seek DATA,15,0 and print q... <DATA>;
__END__
------------------------------
Date: Tue, 27 Jan 2004 21:34:10 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Encyption for Credit Card numbers
Message-Id: <101eetubd851ibf@corp.supernews.com>
Can someone recommend a module for encrypting credit card numbers and
bank routing numbers? I see that Crypt::CreditCard is still under
development.
------------------------------
Date: Fri, 23 Jan 2004 10:25:27 -0700
From: Ravi Parimi <parimi@nowhere.none.com>
Subject: evaluating success of command run with backticks
Message-Id: <Pine.GSO.4.58.0401231022100.4940@shellfish.ece.arizona.edu>
Hi,
Is there a way to know if a command executed via backticks was
successful or not?
my $res = `shell_command`;
What would I have to check to obtain this information? Would it be one of
$? variables? Any pointers to perldocs will be helpful.
Thanks a lot,
--ravi
------------------------------
Date: Fri, 23 Jan 2004 12:47:45 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: evaluating success of command run with backticks
Message-Id: <pan.2004.01.23.17.47.43.351904@remove.adelphia.net>
On Fri, 23 Jan 2004 10:25:27 -0700, Ravi Parimi wrote:
> Hi,
> Is there a way to know if a command executed via backticks was
> successful or not?
>
> my $res = `shell_command`;
>
> What would I have to check to obtain this information? Would it be one of
> $? variables? Any pointers to perldocs will be helpful.
>
> Thanks a lot,
> --ravi
(long link to recently asked question that may answer your question)
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=buf4kf%24sr7%242%40wisteria.csv.warwick.ac.uk&rnum=31&prev=/groups%3Fq%3Dperl%2Bsystem%2Bcomp.lang.perl.misc%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26scoring%3Dd%26start%3D30%26sa%3DN
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Mickey Mouse wears a Spiro Agnew watch.
------------------------------
Date: Fri, 23 Jan 2004 17:52:01 +0000 (UTC)
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: evaluating success of command run with backticks
Message-Id: <burn01$34u$1@wisteria.csv.warwick.ac.uk>
Ravi Parimi <parimi@nowhere.none.com> wrote:
> Is there a way to know if a command executed via backticks was
> successful or not?
>
> my $res = `shell_command`;
>
> What would I have to check to obtain this information? Would it be one of
> $? variables?
^^
You have answered your own question :)
> Any pointers to perldocs will be helpful.
perldoc perlvar
Ben
--
If I were a butterfly I'd live for a day, / I would be free, just blowing away.
This cruel country has driven me down / Teased me and lied, teased me and lied.
I've only sad stories to tell to this town: / My dreams have withered and died.
ben@morrow.me.uk <=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=>=<=> (Kate Rusby)
------------------------------
Date: Fri, 23 Jan 2004 12:52:12 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: evaluating success of command run with backticks
Message-Id: <20040123125057.I15931@dishwasher.cs.rpi.edu>
On Fri, 23 Jan 2004, Ravi Parimi wrote:
> Hi,
> Is there a way to know if a command executed via backticks was
> successful or not?
>
> my $res = `shell_command`;
>
> What would I have to check to obtain this information? Would it be one of
> $? variables? Any pointers to perldocs will be helpful.
>
> Thanks a lot,
> --ravi
>
perldoc perlvar
look up $? just as you thought. It contains the status of any program
started with system(), backticks, wait(), waitpid(), or pipes.
Paul Lalli
------------------------------
Date: Sun, 25 Jan 2004 18:35:33 +1300
From: "Peter Sundstrom" <me@privacy.net>
Subject: Re: evaluating success of command run with backticks
Message-Id: <buvklf$m736p$1@ID-172104.news.uni-berlin.de>
"Ravi Parimi" <parimi@nowhere.none.com> wrote in message
news:Pine.GSO.4.58.0401231022100.4940@shellfish.ece.arizona.edu...
> Hi,
> Is there a way to know if a command executed via backticks was
> successful or not?
>
> my $res = `shell_command`;
>
> What would I have to check to obtain this information? Would it be one of
> $? variables? Any pointers to perldocs will be helpful.
Congratulations!!!
You've earned an entry in the Perl SAQ.
http://www.ginini.com/perlsaq.html
------------------------------
Date: Sun, 25 Jan 2004 11:59:21 -0000
From: "gnari" <gnari@simnet.is>
Subject: Re: evaluating success of command run with backticks
Message-Id: <bv0b8c$5lp$1@news.simnet.is>
"Peter Sundstrom" <me@privacy.net> wrote in message
news:buvklf$m736p$1@ID-172104.news.uni-berlin.de...
>
> "Ravi Parimi" <parimi@nowhere.none.com> wrote in message
> news:Pine.GSO.4.58.0401231022100.4940@shellfish.ece.arizona.edu...
> > Hi,
> > Is there a way to know if a command executed via backticks was
> > successful or not?
> >
> > my $res = `shell_command`;
> >
> > What would I have to check to obtain this information? Would it be one
of
> > $? variables? Any pointers to perldocs will be helpful.
>
> Congratulations!!!
>
> You've earned an entry in the Perl SAQ.
>
> http://www.ginini.com/perlsaq.html
is it not just a repeat of entry 2 ?
gnari
------------------------------
Date: Sun, 25 Jan 2004 19:20:24 +0000 (UTC)
From: mjd@plover.com (Mark Jason Dominus)
Subject: Re: evaluating success of command run with backticks
Message-Id: <bv14to$kjd$1@plover.com>
In article <pan.2004.01.23.17.47.43.351904@remove.adelphia.net>,
James Willmore <jwillmore@adelphia.net> wrote:
>(long link to recently asked question that may answer your question)
>
>http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=buf4kf%24sr7%242%40wisteria.csv.warwick.ac.uk&rnum=31&prev=/groups%3Fq%3Dperl%2Bsystem%2Bcomp.lang.perl.misc%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26scoring%3Dd%26start%3D30%26sa%3DN
In these Google URLs, there is a lot of extraneous information that
you don't need to pass along. For example, the 'hl=en' tells Google
that you want to use the English interface. There's no need to
include this in your news article. Usually you only need the
'threadm' or 'selm' component, as:
http://groups.google.com/groups?threadm=buf4kf%24sr7%242%40wisteria.csv.warwick.ac.uk
Voila.
------------------------------
Date: Sun, 25 Jan 2004 14:49:37 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: evaluating success of command run with backticks
Message-Id: <pan.2004.01.25.19.49.35.384323@remove.adelphia.net>
On Sun, 25 Jan 2004 19:20:24 +0000, Mark Jason Dominus wrote:
> In article <pan.2004.01.23.17.47.43.351904@remove.adelphia.net>,
> James Willmore <jwillmore@adelphia.net> wrote:
>>(long link to recently asked question that may answer your question)
>>
>>http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=utf-8&threadm=buf4kf%24sr7%242%40wisteria.csv.warwick.ac.uk&rnum=31&prev=/groups%3Fq%3Dperl%2Bsystem%2Bcomp.lang.perl.misc%26hl%3Den%26lr%3D%26ie%3DUTF-8%26oe%3Dutf-8%26scoring%3Dd%26start%3D30%26sa%3DN
>
> In these Google URLs, there is a lot of extraneous information that
> you don't need to pass along. For example, the 'hl=en' tells Google
> that you want to use the English interface. There's no need to
> include this in your news article. Usually you only need the
> 'threadm' or 'selm' component, as:
>
> http://groups.google.com/groups?threadm=buf4kf%24sr7%242%40wisteria.csv.warwick.ac.uk
>
> Voila.
Thanks.
--
Jim
Copyright notice: all code written by the author in this post is
released under the GPL. http://www.gnu.org/licenses/gpl.txt
for more information.
a fortune quote ...
Very few profundities can be expressed in less than 80
characters.
------------------------------
Date: Mon, 26 Jan 2004 22:10:21 +1300
From: "Peter Sundstrom" <me@privacy.net>
Subject: Re: evaluating success of command run with backticks
Message-Id: <bv2lk2$ncmkt$1@ID-172104.news.uni-berlin.de>
"gnari" <gnari@simnet.is> wrote in message
news:bv0b8c$5lp$1@news.simnet.is...
> "Peter Sundstrom" <me@privacy.net> wrote in message
> news:buvklf$m736p$1@ID-172104.news.uni-berlin.de...
> >
> > "Ravi Parimi" <parimi@nowhere.none.com> wrote in message
> > news:Pine.GSO.4.58.0401231022100.4940@shellfish.ece.arizona.edu...
> > > Hi,
> > > Is there a way to know if a command executed via backticks was
> > > successful or not?
> > >
> > > my $res = `shell_command`;
> > >
> > > What would I have to check to obtain this information? Would it be one
> of
> > > $? variables? Any pointers to perldocs will be helpful.
> >
> > Congratulations!!!
> >
> > You've earned an entry in the Perl SAQ.
> >
> > http://www.ginini.com/perlsaq.html
>
> is it not just a repeat of entry 2 ?
Certainly there's a few repeats, but asked in different ways.
Perhaps I could start a FASAQ!
------------------------------
Date: Thu, 22 Jan 2004 00:09:13 GMT
From: "gibbering poster" <noone@nowhere.com>
Subject: Executing stored substitutions...
Message-Id: <JwEPb.14542$k8.4503@newssvr27.news.prodigy.com>
Suppose I has some coderefs in an array, and wanted to loop through them
and apply them... more specifically to a string:
my @subs = (
{ s/\s+//g }, { s/-/ /g },
);
my $string = "\tJoe-Smith ";
for (@subs) {
local *_ = $string;
do &{$_}; # I know this is horribly wrong
}
print $string; # Want this to print "Joe Smith"
Can someone please show me the way here? Sorry in advance if I missed a
perldoc.
Thanks!
PS ... Is there a way to catch the return value of those substitions
(i.e. their success or failure)?
------------------------------
Date: Thu, 22 Jan 2004 01:34:14 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: Executing stored substitutions...
Message-Id: <bun5ta$ka7o9$1@ID-184292.news.uni-berlin.de>
gibbering poster wrote:
> Suppose I has some coderefs in an array, and wanted to loop
> through them and apply them... more specifically to a string:
>
> my @subs = (
> { s/\s+//g }, { s/-/ /g },
You need to say that they are code refs:
sub { s/\s+//g }, sub { s/-/ /g },
> );
>
> my $string = "\tJoe-Smith ";
>
> for (@subs) {
> local *_ = $string;
> do &{$_}; # I know this is horribly wrong
> }
You may want to try this:
for my $sub (@subs) {
local $_ = $string;
do &{$sub};
$string = $_;
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: 22 Jan 2004 00:48:20 GMT
From: Tina Mueller <usenet@expires03-2004.tinita.de>
Subject: Re: Executing stored substitutions...
Message-Id: <bun6kk$jh8p9$1@ID-24002.news.uni-berlin.de>
Gunnar Hjalmarsson wrote:
> You may want to try this:
[...]
> do &{$sub};
or just:
$sub->();
regards, tina
--
http://www.tinita.de/ http://www.perlquotes.de/ http://www.darkdance.net/
Enter the Doors of P e r c e p t i o n
http://www.perl-community.de/ http://berlin.pm.org/
- the above mail address expires end of march 2004 -
------------------------------
Date: Wed, 21 Jan 2004 19:00:01 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Executing stored substitutions...
Message-Id: <slrnc0u84h.7t1.tadmc@magna.augustmail.com>
gibbering poster <noone@nowhere.com> wrote:
> Suppose I has some coderefs in an array,
> my @subs = (
> { s/\s+//g }, { s/-/ /g },
> );
There are no coderefs in that array you know.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 21 Jan 2004 22:12:39 -0800
From: kuujinbo@hotmail.com (ko)
Subject: Re: Executing stored substitutions...
Message-Id: <92d64088.0401212212.b52c2ee@posting.google.com>
"gibbering poster" <noone@nowhere.com> wrote in message news:<JwEPb.14542$k8.4503@newssvr27.news.prodigy.com>...
> Suppose I has some coderefs in an array, and wanted to loop through them
> and apply them... more specifically to a string:
>
> my @subs = (
> { s/\s+//g }, { s/-/ /g },
> );
Those are (empty) hashrefs...
> my $string = "\tJoe-Smith ";
>
> for (@subs) {
> local *_ = $string;
> do &{$_}; # I know this is horribly wrong
> }
>
> print $string; # Want this to print "Joe Smith"
>
> Can someone please show me the way here? Sorry in advance if I missed a
> perldoc.
>
> Thanks!
One way to do what you had in mind:
my @subs = (
sub { $_[0] =~ s#\s+##g },
sub { $_[0] =~ s#-# #g },
);
foreach ( @subs ) {
$_->($string);
}
print "$string\n";
But really, if you want to apply *all* the substitutions on the
string(s), put all of them in one sub...
If, on the other hand, you want to *selectively* perform the
substitutions (or run whatever code you like) use a dispatch table:
my $dt = {
whitespace => sub { $_[0] =~ s#\s+##g },
dashes => sub { $_[0] =~ s#-# #g },
# other coderefs...
};
foreach my $hrkey( qw[whitespace dashes] ) {
$dt->{$hrkey}->($string);
}
print "$string\n";
The following documentation are good reading in this case:
perlreftut
perldsc
perllol
> PS ... Is there a way to catch the return value of those substitions
> (i.e. their success or failure)?
From perlop:
s/PATTERN/REPLACEMENT/egimosx
Searches a string for a pattern, and if found, replaces that pattern
with the replacement text and returns the number of substitutions
made.
HTH - keith
------------------------------
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 6003
***************************************