[25040] in Perl-Users-Digest
Perl-Users Digest, Issue: 7290 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 23 06:05:48 2004
Date: Sat, 23 Oct 2004 03:05:05 -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 Sat, 23 Oct 2004 Volume: 10 Number: 7290
Today's topics:
Re: deciphering emails in PERL <bik.mido@tiscalinet.it>
Re: Guestbook hacked? <matthew.garrish@sympatico.ca>
Re: Hard regexp problem <nobull@mail.com>
Re: How to insert new lines in string? <joey01@cfl.rr.com>
Re: How to insert new lines in string? <joey01@cfl.rr.com>
Re: How to insert new lines in string? <matthew.garrish@sympatico.ca>
Re: How to redefine warnings on recursion level <Jon.Ericson@jpl.nasa.gov>
Re: How to redefine warnings on recursion level <abigail@abigail.nl>
Re: HTML::Parser and <p> behaviour? <a.newmane.remove@eastcoastcz.com>
Re: HTTP Proxy via HTTP Layer by Perl? <Joe.Smith@inwap.com>
Re: list vs array <bik.mido@tiscalinet.it>
Re: Net::POP3 Install <matthew.garrish@sympatico.ca>
Re: Net::POP3 Install <nospam@nospam.com>
Re: Net::POP3 Install <spamtrap@dot-app.org>
Re: overriding perl switch (Aaron Sherman)
Re: printing to web browser (Aaron Sherman)
Re: Remote Permissions Problem (Aaron Sherman)
Re: Special encoded character (Aaron Sherman)
Re: Trouble understanding data structure <nobull@mail.com>
Re: using range gives warning <nobull@mail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 23 Oct 2004 08:02:43 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: deciphering emails in PERL
Message-Id: <n32jn09apj3u3get2khunku2mkg1hqtsob@4ax.com>
On Fri, 22 Oct 2004 07:39:22 -0500, Tad McClellan
<tadmc@augustmail.com> wrote:
<OT>
>>>i have to think, with the vast exapnse of lib. i see out there for PERL,
>>>someone has written something? no?
>
>> But what is an "exapnse" supposed to be?
>> Sorry, I'm not a native English speaker...
>
>I expect he meant "expanse".
Of course I was kind of joking... however... would *that* be the/a
correct term, anyway?
</OT>
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 22 Oct 2004 21:05:59 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Guestbook hacked?
Message-Id: <T7ied.35086$J16.2010995@news20.bellglobal.com>
"Gunnar Hjalmarsson" <noreply@gunnar.cc> wrote in message
news:2ttk79F22spevU1@uni-berlin.de...
> Matt Garrish wrote:
>> Gunnar Hjalmarsson wrote:
>>> J.Postma wrote:
>>>> I am using the perl script of Matt version 2.3.1
>>>
>>> Matt's scripts have a bad reputation because of security holes, but
>>> personally I don't think the problem has anything to do with that.
>>
>> It's more likely the problem of using popular software written by
>> someone else, especially open source code. If a spammer knows it has
>> no particular security, and that many people are using it, it becomes
>> the perfect opportunity (especially when you know most users aren't
>> smart enough to change the input ids or alter the code in any way).
>
> Yeah, that may be true. But isn't the main issue that guestbooks, just
> like any open forum, are designed to let anybody post. It's beyond the
> scope of the concept to beforehand prevent spammers from posting.
>
Yes, I'd agree that's the biggest problem in making them spam-proof. A
little forethought, however, will put an end to most bots that search out
the forms and submit them. And I can't imagine too many spammers would waste
their time if they had to go to each page and submit their messages
individually.
Of course, you're always going to have to allow some laxity in security if
you don't want to inconvenience your posters. You could, for example,
generate a password in an image and require that password to be submitted
with your data, but how annoyed will users get about having to submit a
password to post a message?
A more draconian way would be to create a bot-trap to stop the spammers
before they get to your form (which I recently did for a friend, except his
problem was not spammers in his guestbook but automated downloaders sucking
up his bandwidth). Put an invisible link on a page so only a bot will find
it, and then when it requests the page deny the IP access to your site in
your htaccess file. I'm sure you can think of the problems inherent in that
method, but freeing up the bandwidth was a greater concern to him than who
might get inconvenienced.
Anyway, I'm starting to feel preachy and this is surely way off-topic by
now...
Matt
------------------------------
Date: Sat, 23 Oct 2004 08:44:02 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Hard regexp problem
Message-Id: <cld243$b09$1@slavica.ukpost.com>
Abigail wrote:
> Aaron Sherman (AaronJSherman@gmail.com) wrote on MMMMLXX September
> MCMXCIII in <URL:news:a2d0070.0410221555.37ea14c8@posting.google.com>:
> () I was stumped for a while today, when I ran into a regular expression
> () problem. Now, I'm a pretty good regexp hacker, but this problem was so
> () constrained and seemed at first glance to be so wrong for a regexp
> () that I didn't think it could be done. However, in specifying it to a
> () friend, I realized that it could.
> ()
> () I'm curious to see if there's a better solution.
> ()
> () The problem is this: You have a function call in a library that takes
> () a regexp, anchors it on both ends by adding "^" and "$" to the
> () beginning end, and then applies that to an input string.
> ()
> () sub foo {
> () my $re = shift;
> () my $in = <STDIN>;
> () die "'$in' is bad" unless $in =~ /^$re$/;
> () }
> ()
> () It exits with an error if the string does not match the regexp. I
> () wanted to accept strings that did NOT contain a particular substring.
> () Normally, I would have written:
> ()
> () !/xyz/
>
> /^[^x]*(?:x(?!yx)[^x]*)*$/
>
> Or:
>
> /^(?:(?!xyz).)*$/
>
Er no,
/^(?!.*xyz).*$/
There have been numerous previous threads on this question.
------------------------------
Date: Sat, 23 Oct 2004 01:43:26 GMT
From: "roach" <joey01@cfl.rr.com>
Subject: Re: How to insert new lines in string?
Message-Id: <2Hied.14440$1f.616@tornado.tampabay.rr.com>
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrncngij9.8li.tadmc@magna.augustmail.com...
> roach <joey01@cfl.rr.com> wrote:
>
> > How can I insert a newline every nth character?
>
>
> $string =~ s/(.{$n})/$1\n/g;
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
Thanks for the replys!
It works like a charm =)
------------------------------
Date: Sat, 23 Oct 2004 01:44:56 GMT
From: "roach" <joey01@cfl.rr.com>
Subject: Re: How to insert new lines in string?
Message-Id: <sIied.14441$1f.1579@tornado.tampabay.rr.com>
Thanks!
I works like a charm, =)
"Tad McClellan" <tadmc@augustmail.com> wrote in message
news:slrncngij9.8li.tadmc@magna.augustmail.com...
> roach <joey01@cfl.rr.com> wrote:
>
> > How can I insert a newline every nth character?
>
>
> $string =~ s/(.{$n})/$1\n/g;
>
>
> --
> Tad McClellan SGML consulting
> tadmc@augustmail.com Perl programming
> Fort Worth, Texas
------------------------------
Date: Fri, 22 Oct 2004 22:18:52 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: How to insert new lines in string?
Message-Id: <bcjed.35359$J16.2040686@news20.bellglobal.com>
"roach" <joey01@cfl.rr.com> wrote in message
news:2Hied.14440$1f.616@tornado.tampabay.rr.com...
>
> "Tad McClellan" <tadmc@augustmail.com> wrote in message
> news:slrncngij9.8li.tadmc@magna.augustmail.com...
>> roach <joey01@cfl.rr.com> wrote:
>>
>> > How can I insert a newline every nth character?
>>
>>
>> $string =~ s/(.{$n})/$1\n/g;
>>
>>
<snip signature>
>
>
> Thanks for the replys!
>
> It works like a charm =)
>
Weren't sure whether to top post or not? You got it right this time, but no
need to quote an entire message plus signature.
Matt
------------------------------
Date: Fri, 22 Oct 2004 17:56:37 -0700
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: How to redefine warnings on recursion level
Message-Id: <rcghdomxnei.fsf@Jon-Ericson.sdsio.prv>
Abigail <abigail@abigail.nl> writes:
> Jon Ericson (Jon.Ericson@jpl.nasa.gov) wrote on MMMMLXX September
> MCMXCIII in <URL:news:rcgzn2exta5.fsf@Jon-Ericson.sdsio.prv>:
> == In either case, the more realist example would be x! - y! repeated
> == many times for arbitrary values of x and y.
>
>
> x! - y! == (x * (x - 1) * (x - 2) ... * (y + 1) - 1) * y!
>
>
> sub facdiff {
> local $" = "*";
> eval "(@{[($_ [1] + 1) .. $_ [0]]} - 1) * @{[1 .. $_ [1]]}";
> }
Hmmm... facdiff(100, 100) = -9.33262154439441e+157 ?!?
Clever, though. :-)
Jon
------------------------------
Date: 23 Oct 2004 07:37:47 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: How to redefine warnings on recursion level
Message-Id: <slrncnk2ib.3ac.abigail@alexandra.abigail.nl>
Jon Ericson (Jon.Ericson@jpl.nasa.gov) wrote on MMMMLXXI September
MCMXCIII in <URL:news:rcghdomxnei.fsf@Jon-Ericson.sdsio.prv>:
<> Abigail <abigail@abigail.nl> writes:
<>
<> > Jon Ericson (Jon.Ericson@jpl.nasa.gov) wrote on MMMMLXX September
<> > MCMXCIII in <URL:news:rcgzn2exta5.fsf@Jon-Ericson.sdsio.prv>:
<>
<> > == In either case, the more realist example would be x! - y! repeated
<> > == many times for arbitrary values of x and y.
<> >
<> >
<> > x! - y! == (x * (x - 1) * (x - 2) ... * (y + 1) - 1) * y!
<> >
<> >
<> > sub facdiff {
<> > local $" = "*";
<> > eval "(@{[($_ [1] + 1) .. $_ [0]]} - 1) * @{[1 .. $_ [1]]}";
<> > }
<>
<> Hmmm... facdiff(100, 100) = -9.33262154439441e+157 ?!?
It only works if $_ [0] > $_ [1] >= 1.
Abigail
--
perl -wle 'eval {die [[qq [Just another Perl Hacker]]]};; print
${${${@}}[$#{@{${@}}}]}[$#{${@{${@}}}[$#{@{${@}}}]}]'
------------------------------
Date: Fri, 22 Oct 2004 19:59:57 -0700
From: "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com>
Subject: Re: HTML::Parser and <p> behaviour?
Message-Id: <2ttvteF24k8acU1@uni-berlin.de>
krakle wrote:
> "Alfred Z. Newmane" <a.newmane.remove@eastcoastcz.com> wrote in
> message news:<2tnr42F212vt3U1@uni-berlin.de>...
>> krakle wrote:
>>> Tad McClellan <tadmc@augustmail.com> wrote in message
>>> news:<slrncmssf8.3ss.tadmc@magna.augustmail.com>...
>>>> Pinocchio (aka: Fred Canis, aka: 187, aka: krakle...)
>>>
>>> uhh no.
>>
>> It too suprises me how someone as smart as Tad can make such
>> mistakes as this. (I'm formerly 187, my old nick name - my /only/
>> other usenet/forum name.) If someone wants to cast doubt, then post
>> some actual evidence - which obviously doesn't exist, for hopefully
>> obvious reaons.
>
> This isn't the first time Tad thought I was someone else... He's
> fixated on me...
And apparently he atempted to tie($me) into his little @x_list of his
too. (Nothing really wrong with having a list, but it's always good to
check your facts before making such attacks in public.) Guess it comes
to show even the more knowledgeable among us are not incapable of
commiting rather embarassing errors($!) I don't think of him any less a
seasoned tech (he /is/ a wise person), but rather more human.
:-)
------------------------------
Date: Sat, 23 Oct 2004 07:52:03 GMT
From: Joe Smith <Joe.Smith@inwap.com>
Subject: Re: HTTP Proxy via HTTP Layer by Perl?
Message-Id: <C4oed.517185$8_6.127187@attbi_s04>
nntp wrote:
> I am not sure how proxy works. The basic is it got a request then forward
> it.
Yes, that is what a proxy server does.
The standard http proxy requires that you inform your browser that
you are using a proxy, so that the browser (MSIE, Netscape) will use
the proxy for all requests.
> However, I have to have broadband to use it, then it will cost $50 a
> month for only fast down, but slow up.
That is typical for residential broadband access to the Internet.
It allows high speed for download (to your computer from the Internet)
but has slow speed for upload (from your computer to the Internet).
> If I have a Perl/PHP proxy, and use web server port 80, then I only need to
> pay $10 web hosting fee for super fast connections up and down.
I seriously doubt that. Most $10/month web sites do not allow CGI.
Even if you are allowed to run programs there, the super fast connections
are between the web hosting server and the rest of the Internet.
It will *not* make the connection between your computer and anywhere
else faster.
> I need about 5-10 private proxy servers set up around the
> world for a trading business. I need the lowest cost way.
It would make sense to have mirror servers around the world, not proxy
servers. A proxy server may make things faster if you and everyone who
does business with you are all on the same high speed network. But since
you're not using broadband, a proxy won't help.
If you are serious about doing business, you should sign up for a
business-grade shared server at a colocation site. More than $50/month.
Perl is not the solution.
-Joe
------------------------------
Date: Sat, 23 Oct 2004 08:02:44 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: list vs array
Message-Id: <b6qin095ice8h92nr2hdolf6pq42a4ja9j@4ax.com>
On Fri, 22 Oct 2004 15:34:21 -0400, "daniel kaplan"
<nospam@nospam.com> wrote:
>and if you want to talk about lazy, look at your first response to my frist
>post, where i had a LIST/ ARRAY question, and you just assuemd i was asking
>about Net::Pop3....so who did not properly read what then?
?!?
Michele
--
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
.'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,
------------------------------
Date: Fri, 22 Oct 2004 22:14:23 -0400
From: "Matt Garrish" <matthew.garrish@sympatico.ca>
Subject: Re: Net::POP3 Install
Message-Id: <_7jed.35356$J16.2038783@news20.bellglobal.com>
"daniel kaplan" <nospam@nospam.com> wrote in message
news:1098488248.537389@nntp.acecape.com...
>
> anyone familiar with ActiveState Perl and repositories? truth is I need
> more than one module installed....
>
Your question about POP3 has already been answered, but I would also stress
that you should read the documentation before posting:
For 5.6:
http://aspn.activestate.com/ASPN/docs/ActivePerl-5.6/faq/ActivePerl-faq2.html
For 5.8:
http://aspn.activestate.com/ASPN/docs/ActivePerl/faq/ActivePerl-faq2.html
In particular, I would recommend adding the University of Winnipeg and Jan
Krynicky's repositories on Windows boxes. And every once in a blue moon Dave
Roth's is useful, so no harm in adding it as well.
Matt
------------------------------
Date: Sat, 23 Oct 2004 03:41:45 -0400
From: "daniel kaplan" <nospam@nospam.com>
Subject: Re: Net::POP3 Install
Message-Id: <1098517334.335878@nntp.acecape.com>
just quickly, if it returns to me that DBI is already installed when i say
add DBI, shouldnt it do the same for Net::POP3???
------------------------------
Date: Sat, 23 Oct 2004 05:42:23 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Net::POP3 Install
Message-Id: <ZKednSRVefMduufcRVn-tg@adelphia.com>
daniel kaplan wrote:
> just quickly, if it returns to me that DBI is already installed when i say
> add DBI, shouldnt it do the same for Net::POP3???
Not necessarily. Net::POP3 is a core module, but DBI is not. So even
though the DBI PPD happens to be bundled with the ActiveState installer,
it's still a separate PPD. Net::POP3 is core, so there's no separate PPD
to report as being installed.
Normally, you'd use a Perl one-liner to determine if you have a module:
perl -MModule::Name -e1
This and many other methods, are thoroughly documented in the Perl FAQ.
The FAQ is searchable, so the "perldoc" tool can help you:
perldoc -q "which modules are installed"
Although I'll freely admit that figuring out which magic words you need
to use to find a given question can be tough... For that reason (and
many others), it's a good idea to review the full FAQ. Don't bother
trying to memorize it, just get a general idea of what questions are in
it. You can always look up the answers when you need them.
perldoc perlfaq
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: 22 Oct 2004 18:39:17 -0700
From: AaronJSherman@gmail.com (Aaron Sherman)
Subject: Re: overriding perl switch
Message-Id: <a2d0070.0410221739.3966868c@posting.google.com>
jl_post@hotmail.com (J. Romano) wrote in message news:<b893f5d4.0410220709.13e27864@posting.google.com>...
> "sravi" <sravi.in@gmail.com> wrote in message news:<1098077002.510869.242450@f14g2000cwb.googlegroups.com>...
> Say that you want to run a script called myscript.pl as if it didn't
> have any switches. You can run it like this:
>
> perl -pe "BEGIN{<>}" myscript.pl | perl
Or for your specific case, just:
perl -X myscript.pl
------------------------------
Date: 22 Oct 2004 18:24:44 -0700
From: AaronJSherman@gmail.com (Aaron Sherman)
Subject: Re: printing to web browser
Message-Id: <a2d0070.0410221724.18ae0da9@posting.google.com>
"daniel kaplan" <nospam@nospam.com> wrote in message news:<1098395030.248283@nntp.acecape.com>...
> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
> with:
>
> print $q->header();
> print $out;
[...]
> is there a way to do this, so the browser does NOT print using HTML
> formating, and just prints everything in plain text?
Yep, try:
use CGI qw(escapeHTML);
my $cgi = new CGI;
print $cgi->header();
print $cgi->start_html("Plain text output");
print $cgi->pre(escapeHTML($out));
print $cgi->end_html();
exit 0;
------------------------------
Date: 22 Oct 2004 18:54:11 -0700
From: AaronJSherman@gmail.com (Aaron Sherman)
Subject: Re: Remote Permissions Problem
Message-Id: <a2d0070.0410221754.4b833847@posting.google.com>
"David Gale" <dsgSPAMFILTER@alum.dartmouth.org> wrote in message news:<2tsfg8F22jutnU1@uni-berlin.de>...
> True, this aspect of it isn't specifically a perl problem. However, my
> current attempt is to use Perl::Expect; I'm just not sure how to tell if the
> process completes successfully--does expect give you access to the exit
> value of the process once its terminated? How do you access it?
>
> This question, at least, seems to be group-appropriate. Perhaps I wasn't
> clear enough in my original post.
Expect gives you access to the exit status of the program that it ran
via the exitstatus method. However, if you're running a command on a
remote system, you don't have direct access to that command's exit
status. You can instead get that status through the remote access
program you're using, such as:
use Expect;
my $ssh = Expect->spawn('ssh',$host,'/bin/true');
$ssh->expect(10,
[qr/word:/ => sub {
my $exp = shift;
$exp->send($mypassword."\n");
exp_continue } ],
['eof' => sub {
my $exp = shift;
$exit = $exp->exitstatus << 8;
print "Exit stauts: $exit\n" } ] );
------------------------------
Date: 22 Oct 2004 18:17:20 -0700
From: AaronJSherman@gmail.com (Aaron Sherman)
Subject: Re: Special encoded character
Message-Id: <a2d0070.0410221717.1f291c02@posting.google.com>
"Yoann Wyffels" <yoann.wyffels@iloahosting.com> wrote in message news:<417939a3$0$8961$636a15ce@news.free.fr>...
> > This script might help...but it might corrupt your terminal.
> > remember "reset".
> Don't really understand the script, can u explain ?
Well, it's hard to explain. The assumption that he was making is that
your problem is related to the remote side sending you Unicode
characters in UTF-8 encoding. That is, characters that normally would
not fit in the 0..255 range that you are reading from Net::Telnet.
> > #!/usr/bin/perl -C
The -C is described in the documentation:
"... the standard I/O handles and the default "open()" layer are
UTF-8-fied but only if the locale environment variables indicate a
UTF-8 locale. This behaviour follows the implicit (and problematic)
UTF-8 behaviour of Perl 5.8.0."
This means that when you read in something like 0xd0 followed by 0x94
then you should interpret that, not as two characters, but as the
Unicode character U+0414 or "Д" (appologies if that doesn't
display on your terminal, it's the CYRILLIC CAPITAL LETTER DE).
> > # by Tim Toady of perlmonks
> > #show-unicode.pl
> >
> > binmode STDOUT, ":utf8";
If you're running under windows, this might be needed (though I would
think that -C would have taken care of that).
> > $pat = "@ARGV";
This is the same as "$pat = join '', @ARGV", so we're combining the
comand-line arguments into one string.
> > if (ord $pat > 256) {
> > $pat = sprintf("%04x", ord $pat);
If the first character of the string from the command-line is a
Unicode character outside of the range 0..255, then transform $pat
into a string representation of the hex value of the first
character... honestly, I'm starting to lose it myself here...
> > }
> > elsif (ord $pat > 128) { # arg in sneaky UTF-8
> > $pat = sprintf("%04x", unpack("U0U",$pat));
Huh wa? You've turned on Unicode support with the -C, so ord(anything)
is going to return the correct ordinal value of the character... This
looks like it's assumed to be the first byte of a multi-byte
character, which cannot happen when you're using UTF-8 strings (you'll
see the whole, wide character as one value, and ord will return that
code-point).
> > }
> >
> > @names = split /^/, do 'unicore/Name.pl';
Here, we read in the content of a program called "unicore/Name.pl",
evaluate it as Perl code and split that returned string on line
breaks.
Ok, nuff said, that's not going to help you at all since you don't
even have "unicore/Name.pl", whatever that is.
What will help you is this: first, try turning off UTF8 on the input
channel. Do this by putting "-C0" at the beginning of your program
like so:
#!/usr/bin/perl -C0
Then see if you get better results. If that doesn't help, then go the
other way around:
#!/usr/bin/perl -CSD
If that doesn't work, I'm not sure what's going on, and you will want
to take up the previously mentioned tactic of talking to the sysadmin
of the remote machine and asking what the heck you're getting back.
------------------------------
Date: Sat, 23 Oct 2004 08:52:38 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Trouble understanding data structure
Message-Id: <cld2k8$b0u$1@slavica.ukpost.com>
Page wrote:
> I have some XML that I read in and print out using Data::Dumper which
> has helped me tremendously, but I'm struggling with some parts of it.
>
> Here is the sample Dumper output:
> $VAR1 = {
> 'detail' => [
> {
> 'table' => [
> {
> 'tr' => [
> {
> 'td' => [
> {
> 'content' => '2316692',
> 'form' => '$',
> 'm' => '1',
> 'type' => 'red'
> },
> ' ',
> ' ',
> ' '
> ]
> }
> ],
> 'tt' => [
> 'Daily'
> ],
> etc...
I don't think you've cut-and-pasted that literally.
>
> The problem is when I try to loop through the table. Sometimes the
> child is a tt and sometimes the child is a tr and in other cases it is
> a th.
>
> How do I check to see which one it is?
> for (@{$struct->{detail}->[0]->{table}}) {
> # I want to now loop through all the children but do different
> stuff dependinging on whether the child is a tr, tt, or th.
> }
I think you have an array of single element hashes.
You can find the key value of a single element hash using:
my ($tag) = keys %$_; # Note the list context
------------------------------
Date: Sat, 23 Oct 2004 08:47:41 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: using range gives warning
Message-Id: <cld2au$b0i$1@slavica.ukpost.com>
David K. Wall wrote:
> Paul Lalli <mritty@gmail.com> wrote:
>
>
>>"Brian McCauley" <nobull@mail.com> wrote in message
>>news:clbghd$hqd$1@sun3.bham.ac.uk...
>>
>>>You appear to be confused by the behaviour of the range operator.
>>>
>>>Have you considered the possibility of reading the explaination
>>>of the behaviour of the range operator in the reference manual?
>>>(At least as far as the end of the first sentence).
>>>
>>>Looking up the thing you are confused about in the reference
>>>manual should come earlier in you problem solving path than
>>>posting to Usenet.
>>
>>Yup. And in fact, I did read perldoc perlop prior to posting -
>>but because of the circumstance in which I found this error, I was
>>looking for an explanation regarding something that had to do with
>>assigning to an array element. It simply didn't occur to me that
>>I was using scalar context.
>>
>>My apologies again
>
>
> This simply won't do, Paul. Haven't you learned anything here? You're
> supposed to flame Brian for being rude to you and demand that he
> parrot the documentation to you rather than reading it for yourself.
And now I am going to mess things up further by apologising that my
response was not clearly enough tounge-in-cheek - it really could have
done with a few smilies. I didn't really think that Paul hadn't RTFM.
------------------------------
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 7290
***************************************