[28936] in Perl-Users-Digest
Perl-Users Digest, Issue: 180 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Feb 28 06:09:58 2007
Date: Wed, 28 Feb 2007 03:09:03 -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 Wed, 28 Feb 2007 Volume: 11 Number: 180
Today's topics:
Re: Alan J. Flavell RIP <ben@morrow.me.uk>
change chr(9) ? <max@xxx.tovle.ct>
Re: change chr(9) ? <abigail@abigail.be>
Re: change chr(9) ? <ben@morrow.me.uk>
decode a string to "Perl's internal form" without Encod <gypark@gmail.com>
Re: decode a string to "Perl's internal form" without E anno4000@radom.zrz.tu-berlin.de
Re: decode a string to "Perl's internal form" without E <ben@morrow.me.uk>
Re: DocumentHTML ? <1usa@llenroc.ude.invalid>
Expect and xterm <stahl.karl@gmail.com>
new CPAN modules on Wed Feb 28 2007 (Randal Schwartz)
Re: new method to test Perl code <DJStunks@gmail.com>
perl bug with references <ppc@cheapbooks.com>
Re: perl bug with references <1usa@llenroc.ude.invalid>
Re: perl bug with references <ben@morrow.me.uk>
Re: sysread & eof <ben@morrow.me.uk>
Re: using a list <someone@example.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 28 Feb 2007 10:49:29 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Alan J. Flavell RIP
Message-Id: <pa3gb4-uq7.ln1@osiris.mauzo.dyndns.org>
Quoth anno4000@radom.zrz.tu-berlin.de:
> Alan J. Flavell, an esteemed poster also on clpm, has died in late 2006.
In the all-too-short time I knew Alan here in clpmisc, he was
invariably kind, courteous, knowledgeable and helpful.
He will be sorely missed.
Ben
--
don't get my sympathy hanging out the 15th floor. you've changed the locks 3
times, he still comes reeling though the door, and soon he'll get to you, teach
you how to get to purest hell. you do it to yourself and that's what really
hurts is you do it to yourself just you, you and noone else ** ben@morrow.me.uk
------------------------------
Date: Wed, 28 Feb 2007 11:32:46 +0100
From: "max" <max@xxx.tovle.ct>
Subject: change chr(9) ?
Message-Id: <es3lo6$n7r$1@ss408.t-com.hr>
Help
I have txt file with chr(9) in text, how to change chr(9) - horizontal tab
to chr(32)"space"
------------------------------
Date: 28 Feb 2007 10:47:58 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: change chr(9) ?
Message-Id: <slrneuaneu.eh.abigail@alexandra.abigail.be>
max (max@xxx.tovle.ct) wrote on MMMMCMXXIX September MCMXCIII in
<URL:news:es3lo6$n7r$1@ss408.t-com.hr>:
!! Help
!!
!! I have txt file with chr(9) in text, how to change chr(9) - horizontal tab
!! to chr(32)"space"
I'd use 'tr'. But that isn't Perl. Go read its manual.
Abigail
--
perl -wle 'eval {die ["Just another Perl Hacker"]}; print ${$@}[$#{@${@}}]'
------------------------------
Date: Wed, 28 Feb 2007 10:46:50 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: change chr(9) ?
Message-Id: <q53gb4-uq7.ln1@osiris.mauzo.dyndns.org>
Quoth "max" <max@xxx.tovle.ct>:
> Help
>
> I have txt file with chr(9) in text, how to change chr(9) - horizontal tab
> to chr(32)"space"
perl -i~ -pe'tr/\t/ /' txtfile
Ben
--
'Deserve [death]? I daresay he did. Many live that deserve death. And some die
that deserve life. Can you give it to them? Then do not be too eager to deal
out death in judgement. For even the very wise cannot see all ends.'
ben@morrow.me.uk
------------------------------
Date: 27 Feb 2007 21:56:12 -0800
From: "Raymundo" <gypark@gmail.com>
Subject: decode a string to "Perl's internal form" without Encode module?
Message-Id: <1172642172.459621.62790@t69g2000cwt.googlegroups.com>
Hello,
At first, I'm sorry that I'm not good at English. :-)
There is a string which is encoded with UTF-8, EUC-KR(Korean), EUC-JP,
or any other encoding scheme.
I want to decode it so that it become a string in "Perl's internal
form" (that is, unicode form.. is it so called "utf8"?).
For example,
$octets =3D "=B0=A1=B3=AA"; # 2 Korean characters, sequence of 6 Byt=
es
according to UTF-8
$string =3D "\x{AC00}\x{B098}"; # 2 Unicode characters. I want to get
this from $octets
It can be done easily using Encode module:
use Encode qw(decode);
$string =3D decode("UTF-8", $octets);
My question is, if I don't have Encode module in my server and I have
Text::Iconv module instead, Can I do the same thing using it? If I
can, how?
use Text::Iconv;
$converter =3D Text::Iconv->new("UTF-8", to-ENCODING);
$string =3D $converter->convert($octets);
What do I have to write for "to-ENCODING"?
I tried to "UNICODE" but Text::Iconv seemed to regard "UNICODE" as
"UCS-2LE"...
Any advice would be appreciated,
Raymundo at South Korea.
------------------------------
Date: 28 Feb 2007 08:17:23 GMT
From: anno4000@radom.zrz.tu-berlin.de
Subject: Re: decode a string to "Perl's internal form" without Encode module?
Message-Id: <54ks4jF21hrrvU1@mid.dfncis.de>
Raymundo <gypark@gmail.com> wrote in comp.lang.perl.misc:
> Hello,
>
> At first, I'm sorry that I'm not good at English. :-)
>
> There is a string which is encoded with UTF-8, EUC-KR(Korean), EUC-JP,
> or any other encoding scheme.
>
> I want to decode it so that it become a string in "Perl's internal
> form" (that is, unicode form.. is it so called "utf8"?).
>
> For example,
> $octets = "°¡³ª"; # 2 Korean characters, sequence of 6 Bytes
> according to UTF-8
> $string = "\x{AC00}\x{B098}"; # 2 Unicode characters. I want to get
> this from $octets
>
> It can be done easily using Encode module:
> use Encode qw(decode);
>
> $string = decode("UTF-8", $octets);
>
> My question is, if I don't have Encode module in my server and I have
You have the Encode module, it is part of every complete Perl
installation.
> Text::Iconv module instead, Can I do the same thing using it? If I
> can, how?
I don't know the Text::Iconv module, so I can't answer that. If Encode
works for you, use that.
Anno
------------------------------
Date: Wed, 28 Feb 2007 10:34:32 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: decode a string to "Perl's internal form" without Encode module?
Message-Id: <oe2gb4-5m7.ln1@osiris.mauzo.dyndns.org>
Quoth anno4000@radom.zrz.tu-berlin.de:
> Raymundo <gypark@gmail.com> wrote in comp.lang.perl.misc:
> > Hello,
> >
> > At first, I'm sorry that I'm not good at English. :-)
> >
> > There is a string which is encoded with UTF-8, EUC-KR(Korean), EUC-JP,
> > or any other encoding scheme.
> >
> > I want to decode it so that it become a string in "Perl's internal
> > form" (that is, unicode form.. is it so called "utf8"?).
> >
> > For example,
> > $octets = "°¡³ª"; # 2 Korean characters, sequence of 6 Bytes
> > according to UTF-8
> > $string = "\x{AC00}\x{B098}"; # 2 Unicode characters. I want to get
> > this from $octets
> >
> > It can be done easily using Encode module:
> > use Encode qw(decode);
> >
> > $string = decode("UTF-8", $octets);
> >
> > My question is, if I don't have Encode module in my server and I have
>
> You have the Encode module, it is part of every complete Perl
> installation.
...from 5.8 onwards. If you are stuck with 5.6, you should be aware that
that version of Perl did not handle Unicode at all internally, and you
really ought to upgrade.
Ben
--
Every twenty-four hours about 34k children die from the effects of poverty.
Meanwhile, the latest estimate is that 2800 people died on 9/11, so it's like
that image, that ghastly, grey-billowing, double-barrelled fall, repeated
twelve times every day. Full of children. [Iain Banks] ben@morrow.me.uk
------------------------------
Date: Wed, 28 Feb 2007 03:15:02 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: DocumentHTML ?
Message-Id: <Xns98E4E25F1661Dasu1cornelledu@127.0.0.1>
"~greg" <g_m@remove-comcast.net> wrote in
news:ceidndaqk4ODRHnYnZ2dnUVZ_tqnnZ2d@comcast.com:
>> [ snip TOFU.
>> Please don't do that either.
>> ]
>>
>> --
>> Tad McClellan SGML consulting
>> tadmc@augustmail.com Perl programming
>> Fort Worth, Texas
>
>
> please don't spam.
>
Greg:
I don't know what to make of you. What is the point of that remark? Tad's
signature is just that: A standard sig which is separated from the body of
the post with the proper sequence of characters so that any reasonable
newsreader can automatically snip it in replies.
If you haven't read the posting guidelines yet, you should read them and
follow them so as to maximize the chances of getting useful responses.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: 27 Feb 2007 20:13:39 -0800
From: "Ishmael" <stahl.karl@gmail.com>
Subject: Expect and xterm
Message-Id: <1172636019.747994.165040@m58g2000cwm.googlegroups.com>
I would like to automate the following sequence:
1) Open xterm via Expect script.
2) Run a program in the new terminal.
3) 'Let go' of the new terminal, leaving it running (!).
4) Exit Expect script.
I can get as far as 1) with Perl's implementation of Expect, and as
far as 2) with TCL Expect (using the hocus pocus described in Don
Libes' book). Any ideas? (P.S. Using xterm's '-e' option won't work
in this case).
Thanks for your help!
------------------------------
Date: Wed, 28 Feb 2007 05:42:13 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Feb 28 2007
Message-Id: <JE5ruD.1Izp@zorch.sf-bay.org>
The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN). You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.
Acme-Lingua-EN-Inflect-Modern-0.002
http://search.cpan.org/~rjbs/Acme-Lingua-EN-Inflect-Modern-0.002/
modernize Lingua::EN::Inflect rule's
----
Alvis-QueryFilter-0.3
http://search.cpan.org/~wbuntine/Alvis-QueryFilter-0.3/
Perl module providing SRU query filtering
----
Authen-PluggableCaptcha-0.05
http://search.cpan.org/~jvanasco/Authen-PluggableCaptcha-0.05/
A pluggable Captcha framework for Perl
----
Authen-PluggableCaptcha-KeyManagerDB-0.02
http://search.cpan.org/~jvanasco/Authen-PluggableCaptcha-KeyManagerDB-0.02/
A sample DB backed KeyManger for Authen::PluggableCaptcha that is compatible with Authen::PluggableCaptcha::KeyManager
----
Brick-0.2183_01
http://search.cpan.org/~bdfoy/Brick-0.2183_01/
This is the description
----
Bundle-Email-0.043
http://search.cpan.org/~rjbs/Bundle-Email-0.043/
a bundle to install the main set of Email:: modules
----
CGI.pm-3.27
http://search.cpan.org/~lds/CGI.pm-3.27/
----
Catalyst-Controller-FormBuilder-MultiForm-0.02
http://search.cpan.org/~dwarren/Catalyst-Controller-FormBuilder-MultiForm-0.02/
Multiple forms per template with Catalyst::Controller::FormBuilder
----
Catalyst-Engine-HTTP-POE-0.06
http://search.cpan.org/~agrundma/Catalyst-Engine-HTTP-POE-0.06/
Single-threaded multi-tasking Catalyst engine
----
Catalyst-Model-DBIC-0.15
http://search.cpan.org/~bricas/Catalyst-Model-DBIC-0.15/
(DEPRECATED) DBIC Model Class
----
Config-Basic-1.8
http://search.cpan.org/~fdulau/Config-Basic-1.8/
----
Config-General-Validate-1.02
http://search.cpan.org/~tlinden/Config-General-Validate-1.02/
Validate Config Hashes
----
Config-General-Validate-1.03
http://search.cpan.org/~tlinden/Config-General-Validate-1.03/
Validate Config Hashes
----
Config-JSON-1.0.0
http://search.cpan.org/~rizen/Config-JSON-1.0.0/
A JSON based config file system.
----
Config-JSON-1.0.1
http://search.cpan.org/~rizen/Config-JSON-1.0.1/
A JSON based config file system.
----
Crypt-ECDSA-0.041
http://search.cpan.org/~billh/Crypt-ECDSA-0.041/
Elliptical Cryptography Digital Signature Algorithm
----
DBIx-Class-Loader-ADO-0.07
http://search.cpan.org/~bricas/DBIx-Class-Loader-ADO-0.07/
DBIx::Class::Loader ADO Implementation.
----
DBM-Deep-1.0000
http://search.cpan.org/~rkinyon/DBM-Deep-1.0000/
A pure perl multi-level hash/array DBM that supports transactions
----
Data-Compare-0.16
http://search.cpan.org/~dcantrell/Data-Compare-0.16/
compare perl data structures
----
DateTime-TimeZone-0.62
http://search.cpan.org/~drolsky/DateTime-TimeZone-0.62/
Time zone object base class and factory
----
DublinCore-Record-0.03
http://search.cpan.org/~bricas/DublinCore-Record-0.03/
Container for Dublin Core metadata elements
----
Easy-Options-0.01_01
http://search.cpan.org/~dirt/Easy-Options-0.01_01/
Easy to use, feature rich general purpose option processing using Getopt::Long as the underlying options processing package. Contrary to the Getopt::Long package, and despite the fact that this refers
----
Egg-Model-DBIC-0.01
http://search.cpan.org/~lushe/Egg-Model-DBIC-0.01/
DBIx::Class for Egg.
----
File-Copy-Recursive-0.31
http://search.cpan.org/~dmuey/File-Copy-Recursive-0.31/
Perl extension for recursively copying files and directories
----
File-Find-Rule-DIZ-0.06
http://search.cpan.org/~bricas/File-Find-Rule-DIZ-0.06/
Rule to match the contents of a FILE_ID.DIZ
----
File-Find-Rule-SAUCE-0.06
http://search.cpan.org/~bricas/File-Find-Rule-SAUCE-0.06/
Rule to match on title, author, etc from a file's SAUCE record
----
File-Mirror-0.10
http://search.cpan.org/~jwu/File-Mirror-0.10/
Perl extension for recursive directory copy
----
File-Util-3.176
http://search.cpan.org/~tommy/File-Util-3.176/
Easy, versatile, portable file handling
----
File-Util-3.18
http://search.cpan.org/~tommy/File-Util-3.18/
Easy, versatile, portable file handling
----
GD-Image-Scale2x-0.03
http://search.cpan.org/~bricas/GD-Image-Scale2x-0.03/
Implementation of the Scale2x algorithm for the GD library
----
Games-NES-ROM-0.04
http://search.cpan.org/~bricas/Games-NES-ROM-0.04/
View information about an NES game from a ROM file
----
Google-Adwords-v1.1.2
http://search.cpan.org/~rohan/Google-Adwords-v1.1.2/
an interface which abstracts the Google Adwords SOAP API
----
IO-Async-0.01
http://search.cpan.org/~pevans/IO-Async-0.01/
a collection of modules that implement asynchronous filehandle IO
----
IO-Mark-v0.0.1
http://search.cpan.org/~andya/IO-Mark-v0.0.1/
Read unseekable filehandles non-destructively.
----
IPC-PubSub-0.24
http://search.cpan.org/~jesse/IPC-PubSub-0.24/
Interprocess Publish/Subscribe channels
----
Imager-QRCode-0.01
http://search.cpan.org/~kurihara/Imager-QRCode-0.01/
Generate QR Code with Imager using libqrencode
----
MP4-Info-1.12
http://search.cpan.org/~jhar/MP4-Info-1.12/
Fetch info from MPEG-4 files (.mp4, .m4a, .m4p, .3gp)
----
Mail-Audit-2.216
http://search.cpan.org/~rjbs/Mail-Audit-2.216/
Library for creating easy mail filters
----
Mail-LocalDelivery-0.304
http://search.cpan.org/~rjbs/Mail-LocalDelivery-0.304/
Deliver mail to a local mailbox
----
Mediawiki-Spider-0.31
http://search.cpan.org/~cselt/Mediawiki-Spider-0.31/
Perl extension for flat mirror of mediawikis
----
Net-DHCPClientLive-0.01
http://search.cpan.org/~mingzhang/Net-DHCPClientLive-0.01/
stateful DHCP client object
----
Net-SIP-0.22
http://search.cpan.org/~sullr/Net-SIP-0.22/
Framework SIP (Voice Over IP, RFC3261)
----
Net-Z3950-ZOOM-1.18
http://search.cpan.org/~mirk/Net-Z3950-ZOOM-1.18/
Perl extension for invoking the ZOOM-C API.
----
POE-Component-CPAN-YACSmoke-0.15
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-0.15/
bringing the power of POE to CPAN smoke testing.
----
POE-Component-CPAN-YACSmoke-0.16
http://search.cpan.org/~bingos/POE-Component-CPAN-YACSmoke-0.16/
bringing the power of POE to CPAN smoke testing.
----
POE-Component-Client-HTTP-0.82
http://search.cpan.org/~rcaputo/POE-Component-Client-HTTP-0.82/
a HTTP user-agent component
----
POE-Component-Client-Keepalive-0.1000
http://search.cpan.org/~rcaputo/POE-Component-Client-Keepalive-0.1000/
manage connections, with keep-alive
----
POE-Component-Client-Pastebot-0.03
http://search.cpan.org/~bingos/POE-Component-Client-Pastebot-0.03/
interact with Bot::Pastebot web services.
----
Perl-Version-v0.0.6
http://search.cpan.org/~andya/Perl-Version-v0.0.6/
Parse and manipulate Perl version strings
----
Perl-Version-v0.0.7
http://search.cpan.org/~andya/Perl-Version-v0.0.7/
Parse and manipulate Perl version strings
----
Pod-AxPoint-0.02
http://search.cpan.org/~tlinden/Pod-AxPoint-0.02/
----
Pod-S5-0.02
http://search.cpan.org/~tlinden/Pod-S5-0.02/
Generate S5 slideshow from POD source file.
----
Pod-Xhtml-1.52_01
http://search.cpan.org/~jrockway/Pod-Xhtml-1.52_01/
Generate well-formed XHTML documents from POD format documentation
----
RPC-Object-0.31
http://search.cpan.org/~jwu/RPC-Object-0.31/
A lightweight implementation for remote procedure calls
----
RRD-Simple-1.42
http://search.cpan.org/~nicolaw/RRD-Simple-1.42/
Simple interface to create and store data in RRD files
----
RT-Extension-RT2toRT3-1.25
http://search.cpan.org/~falcone/RT-Extension-RT2toRT3-1.25/
----
SRU-0.96
http://search.cpan.org/~bricas/SRU-0.96/
Search and Retrieval by URL
----
Test-YAML-Meta-0.01
http://search.cpan.org/~barbie/Test-YAML-Meta-0.01/
Validation of the META.yml file in a distribution.
----
Test-YAML-Meta-0.02
http://search.cpan.org/~barbie/Test-YAML-Meta-0.02/
Validation of the META.yml file in a distribution.
----
Text-CSV-Separator-0.13
http://search.cpan.org/~enell/Text-CSV-Separator-0.13/
Determine the field separator of a CSV file
----
Text-Hatena-0.20
http://search.cpan.org/~jkondo/Text-Hatena-0.20/
Perl extension for formatting text with Hatena Style.
----
Text-Restructured-0.003025
http://search.cpan.org/~nodine/Text-Restructured-0.003025/
Perl implementation of reStructuredText parser
----
Time-HiRes-1.9707
http://search.cpan.org/~jhi/Time-HiRes-1.9707/
High resolution alarm, sleep, gettimeofday, interval timers
----
Tk-Pod-0.9933
http://search.cpan.org/~srezic/Tk-Pod-0.9933/
Pod browser toplevel widget
----
Tk-Wizard-Bases-1.952
http://search.cpan.org/~mthurn/Tk-Wizard-Bases-1.952/
----
WWW-EmpireTheatres-0.05
http://search.cpan.org/~bricas/WWW-EmpireTheatres-0.05/
Get film listings for the Empire Theatres cinema chain
----
WWW-TV-0.06
http://search.cpan.org/~tigris/WWW-TV-0.06/
Parse TV.com for information about TV shows.
----
XML-API-0.11
http://search.cpan.org/~mlawren/XML-API-0.11/
Perl extension for creating XML documents
----
XML-MyXML-0.076
http://search.cpan.org/~karjala/XML-MyXML-0.076/
A simple XML module
----
XML-MyXML-0.0761
http://search.cpan.org/~karjala/XML-MyXML-0.0761/
A simple XML module
----
XML-Tiny-1.05
http://search.cpan.org/~dcantrell/XML-Tiny-1.05/
simple lightweight parser for a subset of XML
----
sapnwrfc-0.06
http://search.cpan.org/~piers/sapnwrfc-0.06/
SAP Netweaver RFC support for Perl
If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.
This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
http://www.stonehenge.com/merlyn/LinuxMag/col82.html
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: 27 Feb 2007 18:28:01 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: new method to test Perl code
Message-Id: <1172629681.077399.218110@8g2000cwh.googlegroups.com>
On Feb 26, 6:05 am, dnikola...@gmail.com wrote:
> This is out of the border of your mind after 33 years of programming..
> sorry :)
> As I wrote earlier, CodeIDE.com will support many standart modules
> soon.
> We started from few basic (pragmas also) and CGI.
> Hope, you will try to visit us in few motnhs to check the difference
> in perl working :)
> Thanks and cya.
your site sucks.
I thought I'd test something mentioned in another thread and I was
hoping you were running Perl 5.6 so:
PROGRAM
printf "version is v%vd\n", $^V;
RESULT
Can't locate object method "new" via package "Benchmark"
(perhaps you forgot to load "Benchmark"?) at
/var/www/basic/lib/WPLib.pm line 304.
which I'm sure is great information if I was going to try to hack your
crappy site, but unfortunately is of no use to my original question.
-jp
------------------------------
Date: 27 Feb 2007 18:13:57 -0800
From: "dt" <ppc@cheapbooks.com>
Subject: perl bug with references
Message-Id: <1172628837.171444.221380@p10g2000cwp.googlegroups.com>
I found an odd behavior.
when I have a reference, let's say it is an array, it seems to pad the
value differently in perl 5.6 vs 5.8:
this worked in perl 5.8 but not perl 5.6:
$ref =~ /^ARRAY/;
for 5.6, I had to change to =~ /^\s*ARRAY/;
could not find anything mentioning this behavior anywhere. I doubt it
is a "feature"
------------------------------
Date: Wed, 28 Feb 2007 03:17:17 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: perl bug with references
Message-Id: <Xns98E4E2C113347asu1cornelledu@127.0.0.1>
"dt" <ppc@cheapbooks.com> wrote in news:1172628837.171444.221380
@p10g2000cwp.googlegroups.com:
> I found an odd behavior.
>
> when I have a reference, let's say it is an array, it seems to pad the
> value differently in perl 5.6 vs 5.8:
>
> this worked in perl 5.8 but not perl 5.6:
>
> $ref =~ /^ARRAY/;
>
> for 5.6, I had to change to =~ /^\s*ARRAY/;
>
> could not find anything mentioning this behavior anywhere. I doubt it
> is a "feature"
Don't use regexes when the humble eq operator would suffice.
Please post a short but complete script that demonstrates the behavior.
Sinan
--
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
------------------------------
Date: Wed, 28 Feb 2007 04:29:02 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: perl bug with references
Message-Id: <e1dfb4-vcc.ln1@osiris.mauzo.dyndns.org>
Quoth "dt" <ppc@cheapbooks.com>:
> I found an odd behavior.
>
> when I have a reference, let's say it is an array, it seems to pad the
> value differently in perl 5.6 vs 5.8:
>
> this worked in perl 5.8 but not perl 5.6:
>
> $ref =~ /^ARRAY/;
>
> for 5.6, I had to change to =~ /^\s*ARRAY/;
>
> could not find anything mentioning this behavior anywhere. I doubt it
> is a "feature"
Works for me:
~% perl -v
This is perl, v5.8.8 built for i686-linux
...
~% perl -le'print [] =~ /^ARRAY/ ? "match" : "no match"'
match
~%
You shouldn't be doing this anyway. Use Scalar::Util::reftype.
Ben
--
All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk Kurt Vonnegut
------------------------------
Date: Wed, 28 Feb 2007 04:24:09 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: sysread & eof
Message-Id: <9ocfb4-vcc.ln1@osiris.mauzo.dyndns.org>
Quoth lstouder@teksavvy.com:
> I'm use IO::Socket on linux to read from a webpage. I don't want to use
> LWP::Simple. How would I find the EOF when the web server is finished
> sending me the webpage? Here's what I'm using right now:
>
> while (my $res = sysread($sock_in,$buf,$bufsize)) {
> syswrite($sock_out,$buf,length($buf));
> last if ($res < $bufsize);
> }
>
> It works, but obviously, if a webpage has a size that is a multiple of
> $bufsize, this will loop forever.
I don't know what makes you think that. Did you try it? sysread returns
0 on EOF.
Note that you should also be checking defined($res), as sysread returns
undef on errors. Depending on how you've opened the socket and your
system, some errors (EINTR and EAGAIN, specifically) are not in fact
errors, but indications that you need to retry the read.
I think you need to read
perldoc -f sysread
and
man 2 read
before you go much further (the latter assumes you are on Unix; this is
the documentation for the C read function which is what Perl's sysread
calls. If you are on some other system you will need to find the
appropriate documentation for yourself).
Ben
--
I must not fear. Fear is the mind-killer. I will face my fear and
I will let it pass through me. When the fear is gone there will be
nothing. Only I will remain.
ben@morrow.me.uk Frank Herbert, 'Dune'
------------------------------
Date: Wed, 28 Feb 2007 08:36:57 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: using a list
Message-Id: <JabFh.1911$IE4.1164@edtnps82>
corefile@gmail.com wrote:
> On Feb 27, 2:36 pm, "John W. Krahn" <some...@example.com> wrote:
>>
>> #!/usr/bin/perl
>> use warnings;
>> use strict;
>> use Socket;
>>
>> my $ip = unpack 'N', inet_aton '192.168.100.1'; #first ip
>> my $number = 254; #number of ips
>> my @allports = ( 25, 110, 443, 179 ); #listening ports
>> my $forward = '10.100.100.1'; # static ip everything get forwarded to
>> my $fport = 10001; # starting port that @allports will
>> # forward to running on fip
>> my $file = 'somefile.txt';
>>
>> open my $FD, '>>', $file or die "Cannot open '$file' $!";
>>
>> for ( 1 .. $number ) {
>> my $addr = inet_ntoa pack 'N', $ip;
>> for my $port ( @allports ) {
>> print $FD "$addr $port maps to $forward $fport\n";
>> ++$fport;
>> }
>> ++$ip;
>> }
>>
>> close $FD;
>>
>> __END__
>
> perfect that worked great, one thing I forgot. I need to also have a
> variable that takes the date command and makes a name for it.
> I need to use the month/date/time/year + a incrementing number, so
> building on what we have:
>
>
> rule 022715362007_1 192.168.100.1 25 maps to 10.100.100.1 20001
> rule 022715362007_2 192.168.100.1 110 maps to 10.100.100.1 20002
> rule 022715362007_3 192.168.100.1 443 maps to 10.100.100.1 20003
> rule 022715362007_4 192.168.100.1 179 maps to 10.100.100.1 20004
> rule 022715362007_5 192.168.100.2 25 maps to 10.100.100.1 20005
> rule 022715362007_6 192.168.100.2 110 maps to 10.100.100.1 20006
> rule 022715362007_7 192.168.100.2 443 maps to 10.100.100.1 20007
> rule 022715362007_8 192.168.100.2 179 maps to 10.100.100.1 20008
> rule 022715362007_9 192.168.100.3 25 maps to 10.100.100.1 20009
#!/usr/bin/perl
use warnings;
use strict;
use Socket;
my ( $min, $hour, $day, $mon, $year ) = ( localtime )[ 1 .. 5 ];
my $date = sprintf '%02d%02d%02d%02d%04d_', $mon + 1, $day, $hour, $min,
$year + 1900;
my $ip = unpack 'N', inet_aton '192.168.100.1'; #first ip
my $number = 254; #number of ips
my @allports = ( 25, 110, 443, 179 ); #listening ports
my $forward = '10.100.100.1'; # static ip everything get forwarded to
my $fport = 10000; # starting port that @allports will
# forward to running on fip
my $incr = 1;
my $file = 'somefile.txt';
open my $FD, '>>', $file or die "Cannot open '$file' $!";
for ( 1 .. $number ) {
my $addr = inet_ntoa pack 'N', $ip;
for my $port ( @allports ) {
print $FD "rule $date$incr $addr $port maps to $forward ", $fport +
$incr, "\n";
++$incr;
}
++$ip;
}
close $FD;
__END__
John
--
Perl isn't a toolbox, but a small machine shop where you can special-order
certain sorts of tools at low cost and in short order. -- Larry Wall
------------------------------
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 V11 Issue 180
**************************************