[31163] in Perl-Users-Digest
Perl-Users Digest, Issue: 2408 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon May 11 06:09:41 2009
Date: Mon, 11 May 2009 03:09:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Mon, 11 May 2009 Volume: 11 Number: 2408
Today's topics:
Re: "print $variable" gives me REF(0x8fdc2d4) instead o <scottalorda@libello.com>
Re: "print $variable" gives me REF(0x8fdc2d4) instead o <peter@makholm.net>
Re: Console output (or anything) on Win32? <RedGrittyBrick@spamweary.invalid>
Help with regexp <mikaelpetterson@hotmail.com>
Re: Help with regexp sln@netherlands.com
Re: Help with regexp sln@netherlands.com
Re: Help with regexp <devnull4711@web.de>
Re: IO::Socket::INET on OSX or TCP stack problem <rvtol+usenet@xs4all.nl>
new CPAN modules on Mon May 11 2009 (Randal Schwartz)
Re: OOP to standard <noreply@gunnar.cc>
Re: OOP to standard <tadmc@seesig.invalid>
Re: OOP to standard <spamtrap@dot-app.org>
Re: writing get_script() <frank@example.invalid>
Re: writing get_script() <jurgenex@hotmail.com>
Re: writing get_script() <frank@example.invalid>
Re: writing get_script() <frank@example.invalid>
Re: writing get_script() <hjp-usenet2@hjp.at>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 11 May 2009 01:14:58 -0700 (PDT)
From: =?ISO-8859-1?Q?S=E9bastien_Cottalorda?= <scottalorda@libello.com>
Subject: Re: "print $variable" gives me REF(0x8fdc2d4) instead of HASH(0x....)
Message-Id: <6ac27009-b750-4041-9e13-9d5f08c01715@e23g2000vbe.googlegroups.com>
On 8 mai, 17:07, smallpond <smallp...@juno.com> wrote:
> On May 8, 8:31=A0am, S=E9bastien Cottalorda <scottalo...@libello.com>
> wrote:
>
>
>
> > Hi all,
>
> > I'm trying to add Hash::Flatten functionality to the IPC::Shareable
> > module.
>
> > In IPC::Shareable, I've that function:
> > sub _freeze {
> > =A0 =A0 my $s =A0=3D shift;
> > =A0 =A0 my $water =3D shift;
> > ...
> > =A0 =A0 my $ice =3D freeze $water;
> > ...
> > =A0 =A0 $s->shmwrite($ice);
>
> > }
>
> > I'm trying to add Hash::Flatten like this:
> > sub _freeze {
> > =A0 =A0 my $s =A0=3D shift;
> > =A0 =A0 my $water =3D shift;
> > ...
> > =A0 =A0 $water =3D flatten($water, { HashDelimiter =3D> '->', ArrayDeli=
miter
> > =3D> '=3D>', });
> > =A0 =A0 my $ice =3D freeze $water;
> > ...
> > =A0 =A0 $s->shmwrite($ice);
>
> > }
>
> > unfortunately, sometimes, i obtains:
> > "Not a SCALAR reference at /home/workspace/panneau/modules/IPC/
> > Shareable.pm line 717."
> > and the module crashes.
> > When I print $water just before flatten(...), I get REF(0x8fdc2d4)
> > instead of HASH(0x...)
>
> > With the Data::Dumper module, I obtains:
> > $water =3D \{
> > =A0 =A0 'key' =3D> 'value',
> > =A0 =A0 'another_key =3D> {
> > =A0 =A0 =A0 =A0 'key1' =3D> 'value1',
> > =A0 =A0 =A0 =A0 ....
> > =A0 =A0 },
>
> > }
>
> > How can I transform $water from REF(0x....) to HASH(0x....)
>
> > Thanks in advance for any kind of help.
>
> > Sebastien
>
> Is the ref to a ref to a hash? =A0ie. $water =3D \\%h?
> $rapids =3D ref $water eq "REF" ? %$water : $water;
Sorry, I obtain :
Not a HASH reference at /blah_blah../Shareable.pm line 681
It seems not to be only a ref to a ref to a hash.
I do not explain how Data::Dumper manage to dump it like this:
$VAR=3D\{ .... }
I try to look into the Dumper package but I lost me ....
------------------------------
Date: Mon, 11 May 2009 10:48:18 +0200
From: Peter Makholm <peter@makholm.net>
Subject: Re: "print $variable" gives me REF(0x8fdc2d4) instead of HASH(0x....)
Message-Id: <87my9k6n59.fsf@vps1.hacking.dk>
Sébastien Cottalorda <scottalorda@libello.com> writes:
>> Is the ref to a ref to a hash? ie. $water = \\%h?
>> $rapids = ref $water eq "REF" ? %$water : $water;
> I do not explain how Data::Dumper manage to dump it like this:
> $VAR=\{ .... }
Because that in a correct syntax for making a reference to a
hash-reference. See 'perldoc perlref'.
The outer ref is made by Rule 1: "By using the backslash operator on a
variable, subroutine, or value.". Here it is used on a value, which
happens to be a reference (byt rule 3) itself.
So Data::Dumper dumps it correct.
//Makholm
------------------------------
Date: Mon, 11 May 2009 10:42:13 +0100
From: RedGrittyBrick <RedGrittyBrick@spamweary.invalid>
Subject: Re: Console output (or anything) on Win32?
Message-Id: <4a07f2f7$0$2537$da0feed9@news.zen.co.uk>
Ben Morrow wrote:
> Quoth RedGrittyBrick <RedGrittyBrick@SpamWeary.foo>:
>> (Followup set)
>>
>> Ilya Zakharevich wrote:
>>> On 2009-05-08, Ben Morrow <ben@morrow.me.uk> wrote:
>>>>> Is it possible to use `binmode($fh, SOMETHING)' in Win32 to get "the
>>>>> expected console-like behaviour" on the handle? Something other API?
>>>> I don't think so. There doesn't appear to be any way to call
>>>> WriteConsoleW from perl without wrapping it yourself: AFAICT,
>>>> Win32::Console only allows you to call WriteConsoleA, which won't do
>>>> what you want.
>>> I knew already that the win32 port of Perl cannot read command-line
>>> arguments, cannot get contents of directories, or open files (as in
>>> http://groups.google.com/group/comp.lang.perl.misc/msg/1fc326742ab7deb2).
>> Didn't Sinan answer that?
>>
>>
>> I find the Win32 port I use does all those things (if I understand
>> correctly):
>>
>> C:\> mkdir t
>> C:\> cd t
>> C:\t> echo aaa > a.txt
>> C:\t> echo bbb > b.txt
>>
>> C:\t> perl -e "print qq(ARGV[0] is '$ARGV[0]'\n)" a.txt
>> ARGV[0] is 'a.txt'
>>
>> C:\t> perl -e "opendir $d, '.'; @f = readdir($d); print join ' ', @f"
>> . .. a.txt b.txt
>>
>> C:\t> perl -e "open $fh, '<', $ARGV[0]; while(<$fh>) {print}" a.txt
>> aaa
>>
>> What have I missed?
>
> None of those files have names that require Unicode. Try it again with
> some that do, including names with characters not in your current
> codepage.
>
>>> Now it is also that it cannot even output to terminal...
>>>
>>> I would say that this is a strange state for a >10-years old
>>> commertially-supported port...
>>>
>> One of your goals was to get "full Unicode text on the console", do you
>> mean this sort of thing:
>>
>> C:\> chcp 65001
>> Active code page: 65001
>>
>> C:\> perl -e "binmode(STDOUT, ':utf8'); print qq(abc\x{2116}def\n)"
>> abcâ„–def
>>
>
> Ilya's aim was to get full Unicode output on the console *without*
> changing the codepage. This is possible by calling WriteConsoleW, but
> perl doesn't provide any way to call that.
>
Thanks for clarifying, I now see there are problems as Ilya suggested.
--
RGB
------------------------------
Date: Sun, 10 May 2009 23:47:23 -0700 (PDT)
From: mike <mikaelpetterson@hotmail.com>
Subject: Help with regexp
Message-Id: <dc12ffd4-9c02-44ed-9743-c35bb9dc55c4@u10g2000vbd.googlegroups.com>
Hi,
I have the following string that I need to check the following:
CXP_1212232_R1A01
It starts with CXP and has seven digits after first underscore and
that after second underscore it begins with an cap R followed by a
cap letter and a digit. Then the last digits in the string can be any
number of digits ( it is like an index).
I have ttried the following regexp:
if($name !~ m/^[CXP]_\d{7}_[R]{1}\d{1}[A-Z]{1}\d+/){
print "String should be something like, CXP_1233445_R1A01\n";
print "You had the following, $name\n";
exit 1;
}
I tried the following,CXP_1212232_R1A01, but I seem to go into the if
statement. However this should be an acceptable name. Any hints?
br,
//mike
------------------------------
Date: Mon, 11 May 2009 00:04:17 -0700
From: sln@netherlands.com
Subject: Re: Help with regexp
Message-Id: <iejf0595dabvof815uft45u1himpol0nk4@4ax.com>
On Sun, 10 May 2009 23:47:23 -0700 (PDT), mike <mikaelpetterson@hotmail.com> wrote:
>It starts with CXP and has seven digits after first underscore and
>that after second underscore it begins with an cap R followed by a
>cap letter and a digit. Then the last digits in the string can be any
>number of digits ( it is like an index).
>
/^CXP.*?\d{7}.*?_R[A-Z]\d\d*?$/
-sln
------------------------------
Date: Mon, 11 May 2009 00:06:27 -0700
From: sln@netherlands.com
Subject: Re: Help with regexp
Message-Id: <3hjf05pe0elg793fhnq875ft1ttc07hgk0@4ax.com>
On Mon, 11 May 2009 00:04:17 -0700, sln@netherlands.com wrote:
>On Sun, 10 May 2009 23:47:23 -0700 (PDT), mike <mikaelpetterson@hotmail.com> wrote:
>
>>It starts with CXP and has seven digits after first underscore and
>>that after second underscore it begins with an cap R followed by a
>>cap letter and a digit. Then the last digits in the string can be any
>>number of digits ( it is like an index).
>>
>/^CXP.*?\d{7}.*?_R[A-Z]\d\d*?$/
>
/^CXP.*?_\d{7}.*?_R[A-Z]\d\d*?$/
-sln
------------------------------
Date: Mon, 11 May 2009 11:14:13 +0200
From: Frank Seitz <devnull4711@web.de>
Subject: Re: Help with regexp
Message-Id: <76q8iqF1dqthqU1@mid.individual.net>
mike wrote:
>
> CXP_1212232_R1A01
[...]
> I have ttried the following regexp:
>
> if($name !~ m/^[CXP]_\d{7}_[R]{1}\d{1}[A-Z]{1}\d+/){
The square brackets around "CXP" and "R" are wrong ([...] means
character class) and the "{1}" are useless, the rest is ok.
/^CXP_\d{7}_R\d[A-Z]\d+/
Frank
--
Dipl.-Inform. Frank Seitz; http://www.fseitz.de/
Anwendungen für Ihr Internet und Intranet
Tel: 04103/180301; Fax: -02; Industriestr. 31, 22880 Wedel
------------------------------
Date: Mon, 11 May 2009 03:39:55 +0200
From: "Dr.Ruud" <rvtol+usenet@xs4all.nl>
Subject: Re: IO::Socket::INET on OSX or TCP stack problem
Message-Id: <4a0781eb$0$182$e4fe514c@news.xs4all.nl>
derykus@gmail.com wrote:
> eval { local $SIG{ALRM} = sub { die 'socket t/o';
> alarm(...);
> $socket->read($r, 6) };
> alarm(0);
> };
> if ( $@ =~ m{socket t/o} and not $socket->connected ) {
> ... reopen socket etc.
> }
That template looks wrong. My go at it:
eval {
local $SIG{ALRM} = sub { die 'socket t/o' };
alarm 8;
$socket->read($r, 6);
alarm 0;
1; # success
}
or do {
my $err = $@ || "unknown";
alarm 0;
if ( $err =~ m{socket t/o} and not $socket->connected ) {
... reopen socket etc.
}
};
--
Ruud
------------------------------
Date: Mon, 11 May 2009 04:42:27 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon May 11 2009
Message-Id: <KJGqEr.1o2F@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.
Alien-wxWidgets-0.43
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.43/
building, finding and using wxWidgets binaries
----
Apache2-AuthCASSimple-0.10
http://search.cpan.org/~yvesago/Apache2-AuthCASSimple-0.10/
Apache2 module to authentificate through a CAS server
----
Array-Diff-0.05001
http://search.cpan.org/~typester/Array-Diff-0.05001/
Find the differences between two arrays
----
CPAN-Mini-Inject-0.24
http://search.cpan.org/~andya/CPAN-Mini-Inject-0.24/
Inject modules into a CPAN::Mini mirror.
----
CPANTS-Weight-0.13
http://search.cpan.org/~adamk/CPANTS-Weight-0.13/
Graph based weights for CPAN Distributions
----
Catalyst-Controller-AllowDisable-0.07
http://search.cpan.org/~taro/Catalyst-Controller-AllowDisable-0.07/
Use when you want to disable your controller.
----
Catalyst-Devel-1.13
http://search.cpan.org/~flora/Catalyst-Devel-1.13/
Catalyst Development Tools
----
Catalyst-Devel-1.14_01
http://search.cpan.org/~flora/Catalyst-Devel-1.14_01/
Catalyst Development Tools
----
Catalyst-Plugin-Log-Colorful-0.15
http://search.cpan.org/~taro/Catalyst-Plugin-Log-Colorful-0.15/
Catalyst Plugin for Colorful Log
----
Catalyst-Plugin-Session-Store-File-0.17
http://search.cpan.org/~mramberg/Catalyst-Plugin-Session-Store-File-0.17/
File storage backend for session data.
----
Chemistry-Bond-Find-0.23
http://search.cpan.org/~itub/Chemistry-Bond-Find-0.23/
Detect bonds in a molecule from atomic 3D coordinates and assign formal bond orders
----
Chemistry-Canonicalize-0.11
http://search.cpan.org/~itub/Chemistry-Canonicalize-0.11/
Number the atoms in a molecule in a unique way
----
Chemistry-File-MDLMol-0.21
http://search.cpan.org/~itub/Chemistry-File-MDLMol-0.21/
MDL molfile reader/writer
----
Chemistry-File-PDB-0.22
http://search.cpan.org/~itub/Chemistry-File-PDB-0.22/
Protein Data Bank file format reader/writer
----
Chemistry-File-PDB-0.23
http://search.cpan.org/~itub/Chemistry-File-PDB-0.23/
Protein Data Bank file format reader/writer
----
Chemistry-File-SMILES-0.46
http://search.cpan.org/~itub/Chemistry-File-SMILES-0.46/
SMILES linear notation parser/writer
----
Chemistry-Mol-0.37
http://search.cpan.org/~itub/Chemistry-Mol-0.37/
Molecule object toolkit
----
Chemistry-Pattern-0.27
http://search.cpan.org/~itub/Chemistry-Pattern-0.27/
Chemical substructure pattern matching
----
Chemistry-Ring-0.20
http://search.cpan.org/~itub/Chemistry-Ring-0.20/
Represent a ring as a substructure of a molecule
----
DBIx-Class-ResultSet-Void-0.01
http://search.cpan.org/~fayland/DBIx-Class-ResultSet-Void-0.01/
improve DBIx::Class::ResultSet with void context
----
DBIx-Class-ResultSet-Void-0.02
http://search.cpan.org/~fayland/DBIx-Class-ResultSet-Void-0.02/
improve DBIx::Class::ResultSet with void context
----
Dansguardian-0.6
http://search.cpan.org/~mogaal/Dansguardian-0.6/
Simple module for administer dansguardian's control files.
----
DateTime-Format-CLDR-1.08
http://search.cpan.org/~maros/DateTime-Format-CLDR-1.08/
Parse and format CLDR time patterns
----
DateTime-TimeZone-HPUX-0.07
http://search.cpan.org/~dolmen/DateTime-TimeZone-HPUX-0.07/
Handles timezones defined at the operating system level on HP-UX
----
Devel-PerlySense-0.0179
http://search.cpan.org/~johanl/Devel-PerlySense-0.0179/
Perl IDE backend with Emacs frontend
----
Dist-Zilla-Plugin-ReadmeFromPod-0.03
http://search.cpan.org/~fayland/Dist-Zilla-Plugin-ReadmeFromPod-0.03/
Automatically convert POD to a README for Dist::Zilla
----
File-AptFetch-0.0.7
http://search.cpan.org/~whynot/File-AptFetch-0.0.7/
perl interface onto APT-Methods.
----
File-ChangeNotify-0.02
http://search.cpan.org/~drolsky/File-ChangeNotify-0.02/
Watch for changes to files, cross-platform style
----
File-Strmode-0.01
http://search.cpan.org/~salva/File-Strmode-0.01/
Converts a file mode into a symbolic string
----
File-Strmode-0.02
http://search.cpan.org/~salva/File-Strmode-0.02/
Converts a file mode into a symbolic string
----
GD-SVG-0.33
http://search.cpan.org/~twh/GD-SVG-0.33/
Seamlessly enable SVG output from scripts written using GD
----
Geo-Cloudmade-0.1
http://search.cpan.org/~gdm/Geo-Cloudmade-0.1/
An extended interface to Cloudmade's Geo API
----
HTML-FormFu-Model-DBIC-0.04003
http://search.cpan.org/~cfranks/HTML-FormFu-Model-DBIC-0.04003/
Integrate HTML::FormFu with DBIx::Class
----
HTML-Truncate-0.18
http://search.cpan.org/~ashley/HTML-Truncate-0.18/
(beta software) truncate HTML by percentage or character count while preserving well-formedness.
----
Inline-Files-0.63
http://search.cpan.org/~ambs/Inline-Files-0.63/
Multiple virtual files at the end of your code
----
KSx-Analysis-StripAccents-0.05
http://search.cpan.org/~sprout/KSx-Analysis-StripAccents-0.05/
Remove accents and fold to lowercase
----
KSx-Highlight-Summarizer-0.05
http://search.cpan.org/~sprout/KSx-Highlight-Summarizer-0.05/
KinoSearch Highlighter subclass that provides more comprehensive summaries
----
Mail-Lite-0.1002
http://search.cpan.org/~davinchi/Mail-Lite-0.1002/
----
Mail-Lite-0.1003
http://search.cpan.org/~davinchi/Mail-Lite-0.1003/
----
Mail-Lite-0.1004
http://search.cpan.org/~davinchi/Mail-Lite-0.1004/
----
Module-Install-Repository-0.04
http://search.cpan.org/~miyagawa/Module-Install-Repository-0.04/
Automatically sets repository URL from svn/svk/Git checkout
----
Net-ParSCP-0.12
http://search.cpan.org/~casiano/Net-ParSCP-0.12/
Secure transfer of files between clusters via SSH
----
NetHack-Item-0.10
http://search.cpan.org/~sartak/NetHack-Item-0.10/
parse and interact with a NetHack item
----
PPI-1.204_02
http://search.cpan.org/~adamk/PPI-1.204_02/
Parse, Analyze and Manipulate Perl (without perl)
----
PPI-PowerToys-0.13
http://search.cpan.org/~adamk/PPI-PowerToys-0.13/
A handy collection of small PPI-based utilities
----
PPI-PowerToys-0.14
http://search.cpan.org/~adamk/PPI-PowerToys-0.14/
A handy collection of small PPI-based utilities
----
PathTools-3.30
http://search.cpan.org/~smueller/PathTools-3.30/
----
RSSycklr-0.11
http://search.cpan.org/~ashley/RSSycklr-0.11/
(beta) Highly configurable recycling of syndication (RSS/Atom) feeds into tailored, guaranteed XHTML fragments.
----
Simo-0.1109
http://search.cpan.org/~kimoto/Simo-0.1109/
Very simple framework for Object Oriented Perl.
----
SmokeRunner-Multi-0.16
http://search.cpan.org/~drolsky/SmokeRunner-Multi-0.16/
Manage smoke tests across multiple branches/checkouts/projects
----
StupidMarkov-0.002
http://search.cpan.org/~jtgans/StupidMarkov-0.002/
A stupid Markov chain implementation.
----
Test-Command-0.03
http://search.cpan.org/~danboo/Test-Command-0.03/
Test routines for external commands
----
Test-Command-0.04
http://search.cpan.org/~danboo/Test-Command-0.04/
Test routines for external commands
----
Tk-TextVi-0.015
http://search.cpan.org/~jstrom/Tk-TextVi-0.015/
Tk::Text widget with Vi-like commands
----
URI-Amazon-APA-0.01
http://search.cpan.org/~dankogai/URI-Amazon-APA-0.01/
URI to access Amazon Product Advertising API
----
WWW-Alexa-TrafficRank-1.3
http://search.cpan.org/~guruperl/WWW-Alexa-TrafficRank-1.3/
Query Alexa.com Traffic Rank of website.
----
WWW-Modbot-0.02
http://search.cpan.org/~michael/WWW-Modbot-0.02/
Tools to automoderate Web-based spam
----
Wx-0.90
http://search.cpan.org/~mbarbon/Wx-0.90/
interface to the wxWidgets cross-platform GUI toolkit
----
Yoyo-0.00001_00
http://search.cpan.org/~yamakura/Yoyo-0.00001_00/
It is a tool that confirms the command result to various hosts connected with ssh.
----
rpm-build-perl-0.70
http://search.cpan.org/~atourbin/rpm-build-perl-0.70/
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/>
Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
------------------------------
Date: Mon, 11 May 2009 03:36:39 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: OOP to standard
Message-Id: <76pdq0F1du6vmU1@mid.individual.net>
Guy wrote:
> I was refering to O'Reilly's "CGI Programming with Perl 2e", by Guelich...,
> p87 says:
> CGI.pm like Perl is powerful yet flexible.
> It supports two styles of usage:
> a standard interface
> and an OO interface...
>
> further on p88:
> Here is an example. The OO syntax:
> use strict;
> use CGI;
> my $q = new CGI;
> my $name = $q->param( "name" );
> print $q->header( "text/html" );
> The standard Syntax looks like this:
> use strict;
> use CGI qw ( :standard );
> my $name = param( "name" );
> print header( "text/html" );
>
> So I just figured that when you have [use CGI;] instead of [use CGI qw(
> :standard )] it meant it was OO. I guess that's not quite right.
You can always use the OO interface.
use CGI qw( :standard );
means that you import a bunch of subroutine names into your script,
which makes it possible to use the standard interface as well. You are
then free to mix them to your liking.
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Sun, 10 May 2009 21:59:17 -0500
From: Tad J McClellan <tadmc@seesig.invalid>
Subject: Re: OOP to standard
Message-Id: <slrnh0f545.e7v.tadmc@tadmc30.sbcglobal.net>
Guy <someone@somewhere.nb.ca> wrote:
> "Tad J McClellan" <tadmc@seesig.invalid> wrote ...:
> slrnh0enr8.ctk.tadmc@tadmc30.sbcglobal.net...
>> Guy <someone@somewhere.nb.ca> wrote:
>>> What would be the standard way of writing the following object oriented
>>> perl
>>> code?
>>>
>>> use CGI;
>>> $CGI::DISABLE_UPLOADS = 1;
>>> $CGI::POST_MAX=102_400; # 100KB ex: 1024 x 100
>>
>>
>> There is no object orientation in any of that code.
>>
>> If you think that there is, then you have a conceptual misunderstanding
>> somewhere.
>>
>> If you can explain why you think that that code is object-oriented
>> then we could probably help to clear up your misunderstanding.
>>
>> So, why do you think that the above is object-oriented?
>>
>
> I was refering to O'Reilly's "CGI Programming with Perl 2e", by Guelich...,
> p87 says:
> CGI.pm like Perl is powerful yet flexible.
> It supports two styles of usage:
> a standard interface
> and an OO interface...
>
> further on p88:
> Here is an example. The OO syntax:
> use strict;
> use CGI;
> my $q = new CGI;
> my $name = $q->param( "name" );
> print $q->header( "text/html" );
> The standard Syntax looks like this:
> use strict;
> use CGI qw ( :standard );
> my $name = param( "name" );
> print header( "text/html" );
>
> So I just figured that when you have [use CGI;] instead of [use CGI qw(
>:standard )] it meant it was OO. I guess that's not quite right.
^^^^^^^^^^^^^^^
It is not right at all.
There must exist an object for it to be object oriented!
i.e. there must be a bless() somewhere (often buried in a constructor
as with CGI->new() above) to create an object in Perl.
You appear to not yet have a handle on what a "package" is in Perl.
perldoc perlmod
should help with that. Packages are used for both functional and
object-oriented modules.
All the
use CGI qw ( :standard );
does it to import some symbols (function names) into your program's
namespace. You can use a functional style *without* importing
anything too, but then you need to use the fully qualified name
of the function. eg:
use CGI;
my $name = CGI::param( "name" );
--
Tad McClellan
email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"
------------------------------
Date: Mon, 11 May 2009 03:29:00 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: OOP to standard
Message-Id: <m1skjccd37.fsf@dot-app.org>
"Guy" <someone@somewhere.nb.ca> writes:
> "Tad J McClellan" <tadmc@seesig.invalid> wrote ...:
> slrnh0enr8.ctk.tadmc@tadmc30.sbcglobal.net...
>> Guy <someone@somewhere.nb.ca> wrote:
>>> What would be the standard way of writing the following object oriented
>>> perl
>>> code?
>>>
>>> use CGI;
>>> $CGI::DISABLE_UPLOADS = 1;
>>> $CGI::POST_MAX=102_400; # 100KB ex: 1024 x 100
>>
>> There is no object orientation in any of that code.
>>
>
> I was refering to
Tad was referring to the code you posted here. There is no OOP in the
above code.
> O'Reilly's "CGI Programming with Perl 2e", by Guelich...,
> p87 says:
> CGI.pm like Perl is powerful yet flexible.
> It supports two styles of usage:
> a standard interface
> and an OO interface...
>
> further on p88:
> Here is an example. The OO syntax:
> use strict;
> use CGI;
> my $q = new CGI;
> my $name = $q->param( "name" );
> print $q->header( "text/html" );
> The standard Syntax looks like this:
> use strict;
> use CGI qw ( :standard );
> my $name = param( "name" );
> print header( "text/html" );
>
> So I just figured that when you have [use CGI;] instead of [use CGI qw(
> :standard )] it meant it was OO. I guess that's not quite right.
It's not right at all. It's not the use() that makes it OOP, it's using
an object - the $q object in the above.
Have you read 'perldoc perlboot', or 'perldoc perltoot'?
sherm--
--
My blog: http://shermspace.blogspot.com
Cocoa programming in Perl: http://camelbones.sourceforge.net
------------------------------
Date: Sun, 10 May 2009 21:22:22 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script()
Message-Id: <3zam2vcguevw.hpxdug0x6vk.dlg@40tude.net>
In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:
>>What I want it to do is join the first through the ultimate words in s.
>
> If you don't know what $#s means, then maybe you could ask? If you don't
> know what (1..$#s) means, then maybe you could ask? Using code fragments
> that you picked up somewhere without knowing their meaning an throwing
> them together rarely produces useful code.
>
> $@s is the highest index in the array @s, i.e. a number.
> (1..$#s) is the list of numbers from 1 to the highest index of @s.
> Nowhere does it relate to the content of @s.
>
> What you want is maybe
> @s[1..$#s]
> which is a slice of the array @s, containing the elements from index 1
> to the highest index. However I would probably use shift() instead to
> remove the first element from an array.
C:\MinGW\source>perl m9.pl
44:005:017 Then the high priest rose up, and all they that were with him,
(which
is the sect of the Sadducees,) and were filled with indignation,
44:005:018 And laid their hands on the apostles, and put them in the common
pris
on.
44:005:019 But the angel of the Lord by night opened the prison doors, and
broug
ht them forth, and said,
44:005:020 Go, stand and speak in the temple to the people all the words of
this
life.
C:\MinGW\source>type m9.pl
#!/usr/bin/perl
# perl m9.pl
use warnings;
use strict;
local $/="";
while ( <DATA> ) {
my @s = split /\s+/, $_;
my $verse = $s[0];
my $script = join(' ', @s[1..$#s]);
print "$verse $script\n";
}
__DATA__
44:005:017 Then the high priest rose up, and all they that were with him,
(which is the sect of the Sadducees,) and were filled with
indignation,
44:005:018 And laid their hands on the apostles, and put them in the
common prison.
44:005:019 But the angel of the Lord by night opened the prison doors,
and brought them forth, and said,
44:005:020 Go, stand and speak in the temple to the people all the words
of this life.
C:\MinGW\source>
Thanks, jü, this is looking better. The last thing I think this needs
before insertion into a tree is having the newlines of $verse adiosed
unless it's the ultimate one.
Is it the case that with perl, in verse 18, s[?] has 4 characters for the
word 'the', where the ultimate is newline, or six characters for 'words' in
verse 20?
--
Frank
Oh, What Doesn't Kill You Can Have Lingering Aftereffects!
~~ Al Franken,
------------------------------
Date: Sun, 10 May 2009 21:38:07 -0700
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: writing get_script()
Message-Id: <3laf051qcvrqvipr527miv96pc839s6v65@4ax.com>
Franken Sense <frank@example.invalid> wrote:
[...[
> my @s = split /\s+/, $_;
> my $verse = $s[0];
> my $script = join(' ', @s[1..$#s]);
As I wrote before you can replace those three lines above with a single
my ($verse, $script) = split /\s+/, $_, 2;
>[...]
>The last thing I think this needs
>before insertion into a tree is having the newlines of $verse adiosed
>unless it's the ultimate one.
I have no idea what you mean by this sentence.
>Is it the case that with perl, in verse 18, s[?] has 4 characters for the
>word 'the', where the ultimate is newline, or six characters for 'words' in
>verse 20?
And neither with this sentence.
jue
------------------------------
Date: Mon, 11 May 2009 00:38:25 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script()
Message-Id: <1kl96ouz4njot.1cryzp5q6396y$.dlg@40tude.net>
In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:
> Franken Sense <frank@example.invalid> wrote:
> [...[
>> my @s = split /\s+/, $_;
>> my $verse = $s[0];
>> my $script = join(' ', @s[1..$#s]);
>
> As I wrote before you can replace those three lines above with a single
>
> my ($verse, $script) = split /\s+/, $_, 2;
When I print $verse and $script at the end of this loop, I get a faithful
copy of the original, and I'm glad to have that as an option.
split /PATTERN/,EXPR,LIMIT
Since EXPR would default to $_, I have to wonder how general this syntax
could be. What would happen if limit weren't 2? (Perldoc perlfunc doesn't
have a lot on this.)
>
>>[...]
>>The last thing I think this needs
>>before insertion into a tree is having the newlines of $verse adiosed
>>unless it's the ultimate one.
>
> I have no idea what you mean by this sentence.
>
>>Is it the case that with perl, in verse 18, s[?] has 4 characters for the
>>word 'the', where the ultimate is newline, or six characters for 'words' in
>>verse 20?
>
> And neither with this sentence.
>
> jue
It doesn't help that I also don't really know what I'm getting at here.
Here's what these data look like in a hex editor:
http://lomas-assault.net/usenet/z30.jpg
About halfway down on the screen dump the F0 line begins with
74 68 65
, which is the 'the'
, followed by
OD OA
, cr-lf, the newline on my implementation,
then
twelve '20''s, which is whitespace.
I want to get rid of the cr-lf's in the middle of a verse. I think with
the more verbose version, I get rid of newlines that don't immediately
precede the next verse.
#!/usr/bin/perl
# perl m21.pl
use strict;
use warnings;
local $/="";
my $len = 5;
while( my $line = <DATA> ) {
chomp($line);
my @s = split /\s+/, $line;
for my $i (0..$#s) {
$len = length($s[$i]);
print "s[$i] = $s[$i] $len \n";
}
}
__DATA__
44:005:017 Then the high priest rose up, and all they that were with him,
(which is the sect of the Sadducees,) and were filled with
indignation,
44:005:018 And laid their hands on the apostles, and put them in the
common prison.
44:005:019 But the angel of the Lord by night opened the prison doors,
and brought them forth, and said,
44:005:020 Go, stand and speak in the temple to the people all the words
of this life.
# end script begin abridged output
s[12] = the 3
s[13] = common 6
s[14] = prison. 7
It looks like the 'the' has no newlines attached. Tja.
--
Frank
The irony upon irony of this lawsuit was great. First, Fox having the
trademark 'fair and balanced' -- a network which is anything but fair and
balanced. Then there's the irony of a news organization trying to suppress
free speech.
~~ Al Franken, CNN interview
------------------------------
Date: Mon, 11 May 2009 01:45:57 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: writing get_script()
Message-Id: <1c5abzipwpcoh.o86r9mf3tw6r.dlg@40tude.net>
In Dread Ink, the Grave Hand of Jürgen Exner Did Inscribe:
>>> True. However there is no reason why not to build a binary tree in Perl.
>>
>>Is there a module for it?
>
> A quick search for 'Binary Tree" on CPAN returns several hundred
> results, the very first on being "Tree::Binary" with many more
> interesting modules on the same and the next page.
I've got a new problem here. I've installed Tree::Binary using
activestate's ppm. To test, I've run a script with the line
use Tree::Binary;
. I find no Binary.pm in the Tree folder where I would expect it:
http://lomas-assault.net/usenet/z31.jpg
I wouldn't know how to proceed.
--
Frank
Oh, What Doesn't Kill You Can Have Lingering Aftereffects!
~~ Al Franken,
------------------------------
Date: Mon, 11 May 2009 09:54:24 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: writing get_script()
Message-Id: <slrnh0fmdh.9m4.hjp-usenet2@hrunkner.hjp.at>
On 2009-05-11 04:38, Jürgen Exner <jurgenex@hotmail.com> wrote:
> Franken Sense <frank@example.invalid> wrote:
> [...[
>> my @s = split /\s+/, $_;
>> my $verse = $s[0];
>> my $script = join(' ', @s[1..$#s]);
>
> As I wrote before you can replace those three lines above with a single
>
> my ($verse, $script) = split /\s+/, $_, 2;
That's not the same. Franken's version splits the script into
white-space separated words and then joins them with a single space. In
other words, it replaces all sequences of whitespace with a single
space. Your version doesn't. This should be equivalent:
my ($verse, $script) = split /\s+/, $_, 2;
$script =~ s/\s+/ /g;
(except that this will also preserve whitespace at the end).
>>[...]
>>The last thing I think this needs before insertion into a tree is
>>having the newlines of $verse adiosed unless it's the ultimate one.
>
> I have no idea what you mean by this sentence.
I think he means that he wants to remove (adios = tschüß) all but the
last newline from each verse. But he already does that, so maybe I'm
wrong.
hp
------------------------------
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 2408
***************************************