[32030] in Perl-Users-Digest
Perl-Users Digest, Issue: 3294 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 21 14:09:24 2011
Date: Mon, 21 Feb 2011 11:09:10 -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 Mon, 21 Feb 2011 Volume: 11 Number: 3294
Today's topics:
Re: arithmetic persistence <marc.girod@gmail.com>
books on perl <k4monk@gmail.com>
Re: books on perl <cartercc@gmail.com>
Re: books on perl (DF4OR)
Re: books on perl <justin.1011@purestblue.com>
Re: books on perl <sherm.pendley@gmail.com>
Re: Please help me how is easiest way to extract text b <tadmc@seesig.invalid>
Re: Please help me how is easiest way to extract text b <cartercc@gmail.com>
Re: really need all the %{ ${ ${$_}{x} }{y} } jazz? jidanni@jidanni.org
Re: really need all the %{ ${ ${$_}{x} }{y} } jazz? <peter@makholm.net>
Re: really need all the %{ ${ ${$_}{x} }{y} } jazz? <bugbear@trim_papermule.co.uk_trim>
Re: really need all the %{ ${ ${$_}{x} }{y} } jazz? <marc.girod@gmail.com>
Re: really need all the %{ ${ ${$_}{x} }{y} } jazz? <uri@StemSystems.com>
Re: really need all the %{ ${ ${$_}{x} }{y} } jazz? <sherm.pendley@gmail.com>
Telnet to cisco <bogus@address.to.nowhere.com>
Re: Telnet to cisco <m@rtij.nl.invlalid>
Re: Telnet to cisco <notvalid@cox.net.invalid>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 21 Feb 2011 07:01:43 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: arithmetic persistence
Message-Id: <d175da93-500b-46b1-bee3-69f4bc81139e@g10g2000vbv.googlegroups.com>
On Feb 21, 12:48=A0am, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
> On my machine what is below is almost an order of magnitude better.
Just want to acknowledge.
Thanks.
Marc
------------------------------
Date: Mon, 21 Feb 2011 07:16:29 -0800 (PST)
From: K4 Monk <k4monk@gmail.com>
Subject: books on perl
Message-Id: <e677e207-4046-47f6-b0b4-117254ac5fc1@u24g2000prn.googlegroups.com>
can someone be so kind to point out some good perl books? I've
programmed in perl for a few years now but only to write small scripts
etc. and never went deep down to even find out stuff like proper use
of regex or parsing long strings for repeat patterns etc. Any help
would be appreciated.
------------------------------
Date: Mon, 21 Feb 2011 08:02:41 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: books on perl
Message-Id: <2dcf1367-cde1-453e-bbed-52fc4f5f756e@y35g2000prc.googlegroups.com>
On Feb 21, 10:16=A0am, K4 Monk <k4m...@gmail.com> wrote:
> can someone be so kind to point out some good perl books? I've
> programmed in perl for a few years now but only to write small scripts
> etc. and never went deep down to even find out stuff like proper use
> of regex or parsing long strings for repeat patterns etc. Any help
> would be appreciated.
In my opinion, the best book not on a beginner level is 'Higher Order
Perl' by Mark Jason Dominus. You can get it for free at
http://hop.perl.plover.com/
but I strongly recommend buying it, not least because it encourages
others to write such books.
You can also obtain books for special topics, like the Perl DBI, Perl
CGI, networking, object oriented Perl, data munging, best practices,
Perl and TK, and so on. Speaking for myself, the two most important
books in my Perl development are data munging by Cross, and Perl and
MySQL by Dubois, although both of these books are regarded poorly by
the Perl community as a whole.
Finally, the most essential 'book' is the Perl documentation. I
constantly keep this open on my computer, and have been known to
actually print dead tree copies of particular sections and study them.
You really can't consider this as a text -- the purpose isn't (in most
cases) to instruct -- but the documentation is the one thing that
every Perl developer should know and love.
CC.
------------------------------
Date: Mon, 21 Feb 2011 17:53:28 +0100
From: "Ekki (DF4OR) Plicht" <ekki@plicht.de>
Subject: Re: books on perl
Message-Id: <iju5a8$pek$01$1@news.t-online.com>
K4 Monk wrote:
> can someone be so kind to point out some good perl books? I've
> programmed in perl for a few years now but only to write small scripts
> etc. and never went deep down to even find out stuff like proper use
> of regex or parsing long strings for repeat patterns etc. Any help
> would be appreciated.
a) this is an FAQ, see perlfaq2, Perl Books
b) I just finished "Modern Perl" by 'chromatic', ISBN 978-0-9779201-5-0.
Although available online I bought the paper edition (easier to read in the
tub) to support the author(s).
Highly recommended, even or especially if you already have some Perl
experience. Gives an excellent overview of modern Do's and Don'ts, a solid
refresh of my knowledge and a bagful of useful hints and tricks.
YMMV.
Cheers,
Ekki
------------------------------
Date: Mon, 21 Feb 2011 16:31:03 +0000
From: Justin C <justin.1011@purestblue.com>
Subject: Re: books on perl
Message-Id: <7jga38-ecj.ln1@zem.masonsmusic.co.uk>
On 2011-02-21, K4 Monk <k4monk@gmail.com> wrote:
> can someone be so kind to point out some good perl books? I've
> programmed in perl for a few years now but only to write small scripts
> etc. and never went deep down to even find out stuff like proper use
> of regex or parsing long strings for repeat patterns etc. Any help
> would be appreciated.
Ask perl: `perldoc -q book`
Justin.
--
Justin C, by the sea.
------------------------------
Date: Mon, 21 Feb 2011 14:02:44 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: books on perl
Message-Id: <m2d3ml1a97.fsf@sherm.shermpendley.com>
K4 Monk <k4monk@gmail.com> writes:
> can someone be so kind to point out some good perl books?
There's a page about it on my CamelBones site - in essence, what it says
is "O'Reilly rules!" :-)
<http://www.camelbones.org/books.html>
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Mon, 21 Feb 2011 07:38:33 -0600
From: Tad McClellan <tadmc@seesig.invalid>
Subject: Re: Please help me how is easiest way to extract text between some variable text
Message-Id: <slrnim4qcr.h08.tadmc@tadbox.sbcglobal.net>
sharma__r@hotmail.com <sharma__r@hotmail.com> wrote:
> On Feb 20, 11:33 pm, "Mladen" <mlade...@gmail.com> wrote:
>> Please help me how is easiest way to extract text between some variable text
[really wants to know: ...way to extract text between HTML tags]
> $np =
> qr{
> [<]
> (?:
> (?> [^<>]+ )
> |
> (??{ $np })
> )*
> [>]
> }xms
^^
^^
^^
> ;
The "m" modifier affects only the "^" and "$" anchors.
It is a no-op if your pattern does not contain those anchors.
The "s" modifier affects only the "." metacharacter.
It is a no-op if your pattern does not contain that character.
You should not enable special treatment if you are not going
to make use of that special treatment.
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.liamg\100cm.j.dat/"
The above message is a Usenet post.
I don't recall having given anyone permission to use it on a Web site.
------------------------------
Date: Mon, 21 Feb 2011 06:38:47 -0800 (PST)
From: ccc31807 <cartercc@gmail.com>
Subject: Re: Please help me how is easiest way to extract text between some variable text
Message-Id: <4471de92-0832-4f2d-ac65-4a888def914d@w9g2000prg.googlegroups.com>
On Feb 20, 1:33=A0pm, "Mladen" <mlade...@gmail.com> wrote:
> Please help me how is easiest way to extract text between some variable t=
ext
> <TH class=3Dname width=3D100>New name</TH> =A0 =A0 =A0 need to extract: N=
ew name
A couple of weeks back, hymie! posted a thread enditled 'table -->
pre'. He wanted to extract the content of an HTML table to preformat
it. I posted the following script and output.
Perl gives you a number of ways to do what you want, many of them
simple minded and primitive, others pretty sophisticated. I generally
prefer the former, the more simple minded and primitive the better.
You probably should approach a problem like this in an incremental
fashion, by first matching the least possible amount of what you want,
and adding to it little by little until you get what you want. You
don't need to use a regular expression, index() and substr() will do
the same kind of thing.
Other technologies will do the same kind of thing. I routinely do this
in vi (vim), when I want to transfer some content from one function to
another function, for instance, converting a SQL query to a hash
declaration.
CC.
SCRIPT
#! perl
use strict;
use warnings;
my $content =3D '';
while (<DATA>)
{
next unless /\w/;
chomp;
if ($_ =3D~ m!<(\/?)table!)
{
$content .=3D "<$1pre>";
next;
}
elsif ($_ =3D~ m!<\/?tr!)
{
$content .=3D "
\n";
next;
}
elsif ($_ =3D~ m!<t[dh]>([^<]*)<\/t[dh]>!)
{
$content .=3D sprintf("%-20s", $1);
next;
}
else
{
warn "ERROR: $_\n";
}
}
print $content;
exit(0);
__DATA__
<table>
<tr>
<td>George</td>
<td>Washington</td>
<td>Virginia</td>
<td>1788</td>
</tr>
<tr>
<td>George</td>
<td>Washington</td>
<td>Virginia</td>
<td>1792</td>
</tr>
<tr>
<td>John</td>
<td>Adams</td>
<td>Massachesetts</td>
<td>1796</td>
</tr>
<tr>
<td>Thomas</td>
<td>Jefferson</td>
<td>Virginia</td>
<td>1800</td>
</tr>
<tr>
<td>Thomas</td>
<td>Jefferson</td>
<td>Virginia</td>
<td>1804</td>
</tr>
</table>
OUTPUT'
<pre>
George Washington Virginia 1788
George Washington Virginia 1792
John Adams Massachesetts 1796
Thomas Jefferson Virginia 1800
Thomas Jefferson Virginia 1804
</pre>
------------------------------
Date: Mon, 21 Feb 2011 21:27:39 +0800
From: jidanni@jidanni.org
Subject: Re: really need all the %{ ${ ${$_}{x} }{y} } jazz?
Message-Id: <ijtpar$b74$1@news.datemas.de>
Gentlemen, this is harder than taxes. My only question remaining is
as just having found out
$v->{status}, $$v{status}, ${$v}{status}
all mean the same thing, why doesn't perl warn me to use one instead
of another? I mean it warns
Scalar value @x[4] better written as $x[4]
so why not on these?
> So which is it?
(One was location, one was location_type, so they were different, else
the program would die anyway.)
------------------------------
Date: Mon, 21 Feb 2011 14:46:16 +0100
From: Peter Makholm <peter@makholm.net>
Subject: Re: really need all the %{ ${ ${$_}{x} }{y} } jazz?
Message-Id: <87ei711own.fsf@vps1.hacking.dk>
jidanni@jidanni.org writes:
> all mean the same thing, why doesn't perl warn me to use one instead
> of another? I mean it warns
> Scalar value @x[4] better written as $x[4]
Bacause there are a subtle difference between these two and supposedly
you would very rarely mean the former. But the different ways to handle
references is a matter of style and context. (Hint: @x[4] is not a
scalar value as such).
Not sure that it is a good answer, but I think it is the explanation for
this warning and not having a warning for a multiplitude of other
stylistic uses of perl.
//Makholm
------------------------------
Date: Mon, 21 Feb 2011 13:55:41 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: really need all the %{ ${ ${$_}{x} }{y} } jazz?
Message-Id: <OfWdncdRjJlA8__QnZ2dnUVZ8o6dnZ2d@brightview.co.uk>
jidanni@jidanni.org wrote:
> Gentlemen, this is harder than taxes. My only question remaining is
> as just having found out
> $v->{status}, $$v{status}, ${$v}{status}
> all mean the same thing, why doesn't perl warn me to use one instead
> of another?
Since they all mean the same thing, and the implementor(s)
presumably meant them all to be used, why would it?
BugBear
------------------------------
Date: Mon, 21 Feb 2011 06:56:56 -0800 (PST)
From: Marc Girod <marc.girod@gmail.com>
Subject: Re: really need all the %{ ${ ${$_}{x} }{y} } jazz?
Message-Id: <58284307-aa52-4eb4-ac33-6ae552a0c40e@k38g2000vbn.googlegroups.com>
On Feb 21, 1:27=A0pm, jida...@jidanni.org wrote:
> so why not on these?
Is it that the (supposedly) preferred one, $v->{status},
has not always been supported, so that there are a lot
of the other two in existing code, and warning about
them would uselessly annoy a lot of people.
Not 100% sure, though.
Marc
------------------------------
Date: Mon, 21 Feb 2011 11:33:34 -0500
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: really need all the %{ ${ ${$_}{x} }{y} } jazz?
Message-Id: <87hbbxmjoh.fsf@quad.sysarch.com>
>>>>> "j" == jidanni <jidanni@jidanni.org> writes:
j> Gentlemen, this is harder than taxes. My only question remaining is
j> as just having found out
j> $v->{status}, $$v{status}, ${$v}{status}
j> all mean the same thing, why doesn't perl warn me to use one instead
j> of another? I mean it warns
j> Scalar value @x[4] better written as $x[4]
j> so why not on these?
>> So which is it?
j> (One was location, one was location_type, so they were different, else
j> the program would die anyway.)
you need to understand the roots of why they all exist.
$$v{status} and ${$v}{status} are the same but for the {}. you can
always dereference a scalar with a bare sigil but if you need to isolate
that from the neighboring text {} is allowed around the ref for
that. this is similar to using {} around the name of a variable so these
are different:
"$foobar" and "${foo}bar"
so that case is covered and is needed for isolation.
the -> form is prefered when dereferencing a single value via a ref in a
scalar. it is clearer and similar to the object calls use of ->. it
can't be used when dereferencing a slice (not being discussed here). so
it doesn't replace the sigil in front of a reference syntax so that is
still needed. it is useful is a large subset of those cases so it is the
most popular style of dereferencing when it can be used. it is
encouraged to be used when it can be used.
so all three have their reasons and purposes and this is not a random
set of related features.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
------------------------------
Date: Mon, 21 Feb 2011 13:59:18 -0500
From: Sherm Pendley <sherm.pendley@gmail.com>
Subject: Re: really need all the %{ ${ ${$_}{x} }{y} } jazz?
Message-Id: <m2hbbx1aex.fsf@sherm.shermpendley.com>
jidanni@jidanni.org writes:
> Gentlemen, this is harder than taxes. My only question remaining is
> as just having found out
> $v->{status}, $$v{status}, ${$v}{status}
> all mean the same thing, why doesn't perl warn me to use one instead
> of another?
Because they all mean the same thing, meaning that which one to use is
a question of style.
> I mean it warns
> Scalar value @x[4] better written as $x[4]
Because that's *not* a question of style - it's a common error that Perl
just happens to be able to diagnose well enough to figure out what you
really meant.
sherm--
--
Sherm Pendley
<http://camelbones.sourceforge.net>
Cocoa Developer
------------------------------
Date: Mon, 21 Feb 2011 13:01:53 +0100
From: Bogus <bogus@address.to.nowhere.com>
Subject: Telnet to cisco
Message-Id: <ijtk7h$ei7$1@node2.news.atman.pl>
Hi,
I need to write a telnet client through which I will connect to cisco
(router/switch) but it must be as much similar to normal telnet client
as possible - right now I wrote very simple telnet client but it doesn't
work like I want e.g. when I send command "show ip bgp" which shows
whole bgp table normal telnet wait for space to show next page of
prefixes but my script doesn't work in this place
I need to use this script like a normal telnet client - is it possible?
Reason: I need to format some data which is send to console
This is the code which I found:
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr=> "remote-ip",
PeerPort=> "23",
) or die "cannot connect to remote-ip";
$remote->autoflush(1);
print STDERR "[Connected to $host:$port]\n";
die "can't fork: $!" unless defined($kidpid = fork());
if ($kidpid) {
while (defined ($line = <$remote>)) {
print STDOUT $line;
}
kill("TERM", $kidpid); # send SIGTERM to child
}
else {
while (defined ($line = <STDIN>)) {
print $remote $line;
}
}
Thanks
------------------------------
Date: Mon, 21 Feb 2011 16:21:28 +0100
From: Martijn Lievaart <m@rtij.nl.invlalid>
Subject: Re: Telnet to cisco
Message-Id: <ogca38-53b.ln1@news.rtij.nl>
On Mon, 21 Feb 2011 13:01:53 +0100, Bogus wrote:
> Hi,
>
> I need to write a telnet client through which I will connect to cisco
> (router/switch) but it must be as much similar to normal telnet client
> as possible - right now I wrote very simple telnet client but it doesn't
> work like I want e.g. when I send command "show ip bgp" which shows
> whole bgp table normal telnet wait for space to show next page of
> prefixes but my script doesn't work in this place I need to use this
> script like a normal telnet client - is it possible?
Use clogin from the rancid package, much easier.
M4
------------------------------
Date: Mon, 21 Feb 2011 13:01:44 -0500
From: John Mason Jr <notvalid@cox.net.invalid>
Subject: Re: Telnet to cisco
Message-Id: <iju9a9$n6p$1@news.eternal-september.org>
On 2/21/2011 7:01 AM, Bogus wrote:
> Hi,
>
> I need to write a telnet client through which I will connect to cisco
> (router/switch) but it must be as much similar to normal telnet client
> as possible - right now I wrote very simple telnet client but it doesn't
> work like I want e.g. when I send command "show ip bgp" which shows
> whole bgp table normal telnet wait for space to show next page of
> prefixes but my script doesn't work in this place
> I need to use this script like a normal telnet client - is it possible?
>
> Reason: I need to format some data which is send to console
>
> This is the code which I found:
> use IO::Socket;
> $remote = IO::Socket::INET->new(
> Proto => "tcp",
> PeerAddr=> "remote-ip",
> PeerPort=> "23",
> ) or die "cannot connect to remote-ip";
>
> $remote->autoflush(1);
> print STDERR "[Connected to $host:$port]\n";
> die "can't fork: $!" unless defined($kidpid = fork());
> if ($kidpid) {
> while (defined ($line = <$remote>)) {
> print STDOUT $line;
> }
> kill("TERM", $kidpid); # send SIGTERM to child
> }
> else {
> while (defined ($line = <STDIN>)) {
> print $remote $line;
> }
> }
>
> Thanks
http://search.cpan.org/~joshua/Net-Telnet-Cisco-1.10/Cisco.pm
John
------------------------------
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:
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests.
#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 V11 Issue 3294
***************************************