[28277] in Perl-Users-Digest
Perl-Users Digest, Issue: 9641 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 24 03:05:58 2006
Date: Thu, 24 Aug 2006 00:05:10 -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 Thu, 24 Aug 2006 Volume: 10 Number: 9641
Today's topics:
Re: how can I find the driver list in perl <jurgenex@hotmail.com>
Re: how can I find the driver list in perl <1usa@llenroc.ude.invalid>
Indirectly called code <bol@adv.magwien.gv.at>
IO::Select::select() says no readable data even if ther jari.eskelinen@iki.fi
new CPAN modules on Thu Aug 24 2006 (Randal Schwartz)
Re: Question about UNIVERSAL <benmorrow@tiscali.co.uk>
readdir the directory name and file name separately? <zhushenli@gmail.com>
Re: readdir the directory name and file name separately <1usa@llenroc.ude.invalid>
Re: readdir the directory name and file name separately <zhushenli@gmail.com>
Re: readdir the directory name and file name separately <emschwar@pobox.com>
simple hash of arrays, I cant see the trees for the for <bpatton@ti.com>
Re: simple hash of arrays, I cant see the trees for the <xicheng@gmail.com>
Re: simple hash of arrays, I cant see the trees for the <xicheng@gmail.com>
Re: simple hash of arrays, I cant see the trees for the <bpatton@ti.com>
Re: simple hash of arrays, I cant see the trees for the <uri@stemsystems.com>
Re: variable with empty space <benmorrow@tiscali.co.uk>
Re: variable with empty space <josef.moellers@fujitsu-siemens.com>
Re: warnings (was Re: Most useful standard module?) <BLOCKSPAMfishfry@your-mailbox.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 24 Aug 2006 02:24:35 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: how can I find the driver list in perl
Message-Id: <D58Hg.14784$hP6.1736@trnddc04>
Over G wrote:
> not the list of drviers that insall in my computer, but the names of
> the HD installed , so if for example I have western digital installed
> on my computer and I call it drive C: I want some command to tell me
> that you have C: and D: and F: and so on...
>
> I hope this is clear now, altough I can not really understand how can
> you understand my original question diffrently ,asside from the one
> that call himself DR.
OMG. Maybe by just reading what _you_ wrote?
- "how can I find the driver list in perl" [This is still the subject of
this thread]
- "what should I write in perl in order t get the driver list in my
computer?"
I think it's pretty clear that you wrote _driver_. And not once but twice.
Now, if you wish us to read _drives_ instead then maybe it would have been a
lot easier if you had written _drives_?
jue
------------------------------
Date: Thu, 24 Aug 2006 04:08:07 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: how can I find the driver list in perl
Message-Id: <Xns9829179A365Easu1cornelledu@127.0.0.1>
"Over G" <odperry@gmail.com> wrote in news:1156336639.199134.223500@
75g2000cwc.googlegroups.com:
[ Please do not top-post. Please do not quote signatures.
Oh, why bother, I am going to plonk you anyway. ]
> Dr.Ruud wrote:
>> Over G schreef:
>>
>> > [W]hat should I write in [P]erl in order t[o] get
>> > the driver list in my computer?
>>
>> I assume that you share a car. You don't need Perl if you remember
>> part of the name, or of the contents, of the file with the driver
>> list, just use (example for Windows computer follows) [Start],
>> Search.
>>
>> If you prefer to do it in Perl, then start by reading the Posting
>> Guidelines that are posted here twice a week.
> that was a very rude answer. instead of answering my question stright
> away you are using low sarcasm of the worst kind.
Oh, why do I always miss all the fun? I wonder what constitutes high
sarcasm of the best kind.
> pathetic, don't bother to answer.
Why not? He obviously put more thought into his response than you put
into your original post. And, you are the person who is asking others to
use their time to help you. Do read the posting guidelines. They help
you help yourself and learn to help others help you.
> Are you sure that your name Start with DR.
> which university gave you this ?!
>
> (probably gaza strip university.)
*PLONK*
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: Thu, 24 Aug 2006 09:02:52 +0200
From: "Ferry Bolhar" <bol@adv.magwien.gv.at>
Subject: Indirectly called code
Message-Id: <1156402973.122611@proxy.dienste.wien.at>
Hi,
I try to find out, where Perl may run code besides the "main script" and
the modules and methods it will use (lets' call it "indirectly called
code").
Currently, I know about these ways (Perl 5.8.8):
o) Tying
o) BEGIN/CHECK/INIT/END blocks
o) AUTOLOAD subroutines and DESTROY methods
o) Operator overloading
o) User attributes
o) I/O layers
o) Source filters
o) Import facility (@INC)
o) Debugger hooks
Are there some more?
Greetings, Ferry
--
Ing. Ferry Bolhar
Municipality of Vienna, Department 14
A-1010 Vienna / AUSTRIA
E-mail: bol@adv.magwien.gv.at
------------------------------
Date: 23 Aug 2006 23:53:31 -0700
From: jari.eskelinen@iki.fi
Subject: IO::Select::select() says no readable data even if there are
Message-Id: <1156402411.852101.136040@m73g2000cwd.googlegroups.com>
Hi there,
I am having wirting simple server-client program with
ActiveState ActivePerl 5.8.7 in Win32, but having some
weird problems with reading from sockets. I have googled
for a day now and have found no solution.
I am using line-based communication in order to keep
reading and writing to sockets easy and to avoid buffering
problems. However, buffering problems I have:
When I write two lines from server to socket and do
IO::Select::select (or can_read()) in client, select()
returns handle that can be read. I read first line from
socket using <$socket> and then select() again. Select should
return again handle because there are unread second line.
However, it wil not return anything. If I read from socket
despite of select()'s reutrn, I get second line just like
expected.
So behaviour of select() is unexpected. Or should select()
behave like that? Returning filehandle that can be read only
once, even if there are more data? I read select()'s
documentation, but got an image that it should return handles
ALWAYS if there are data available.
What I am doing wrong? Thank you very much in advance if
somebody can give answer to me!
Ps. Code for reproducing problem:
--------- server.pl -----------
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use IO::Select;
my $socket = new IO::Socket::INET(
LocalAddr=>'localhost',
LocalPort=>'1234',
Proto=>'TCP',
Listen =>1);
binmode($socket);
$socket->autoflush(1);
my $select = new IO::Select();
$select->add($socket);
while (1) {
my @readable = $select->can_read(0);
foreach my $rsock (@readable) {
if ($rsock == $socket) {
my $ns = $rsock->accept();
binmode($ns);
$ns->autoflush(1);
$select->add($ns);
print {$ns} "Hello there, I am your server.\r\n";
print {$ns} "Ready to obey?.\r\n";
} elsif (eof($rsock)) {
$select->remove($rsock);
close($rsock);
} else {
my $buffer = <$rsock>;
print "Client said: $buffer\n";
}
}
sleep(1);
}
----------------------------------
----------- client.pl ------------
#!/usr/bin/perl -w
use strict;
use IO::Socket;
use IO::Select;
use Data::Dumper;
my $socket = new IO::Socket::INET(
PeerAddr=>'localhost',
PeerPort=>'1234',
Proto=>'TCP',
);
binmode($socket);
$socket->autoflush(1);
my $select = new IO::Select();
$select->add($socket);
while (1) {
my @readable = $select->can_read(0);
print Dumper \@readable;
foreach my $rsock (@readable) {
my $buffer = <$rsock>;
print "Server said: $buffer\n";
}
sleep(1);
}
----------------------------------
When running server.pl and client.pl, client prints following:
$VAR1 = [];
$VAR1 = [
bless( \*Symbol::GEN0, 'IO::Socket::INET' )
];
Server said: Hello there, I am your server.
$VAR1 = [];
$VAR1 = [];
Etc. It is cleary seen that select() (or in this case can_read())
indicates that there are nothing more to read, even when there are.
Best regards,
Jari Eskelinen
------------------------------
Date: Thu, 24 Aug 2006 04:42:08 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Thu Aug 24 2006
Message-Id: <J4HJq8.1qF6@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.
App-SimpleScan-1.20
http://search.cpan.org/~mcmahon/App-SimpleScan-1.20/
simple_scan's core code
----
CGI.pm-3.22
http://search.cpan.org/~lds/CGI.pm-3.22/
----
Cache-Simple-TimedExpiry-0.25
http://search.cpan.org/~jesse/Cache-Simple-TimedExpiry-0.25/
----
Catalyst-Example-InstantCRUD-v0.0.14
http://search.cpan.org/~zby/Catalyst-Example-InstantCRUD-v0.0.14/
----
Crypt-Tea-2.10
http://search.cpan.org/~pjb/Crypt-Tea-2.10/
The Tiny Encryption Algorithm in Perl and JavaScript
----
Crypt-Tea_JS-2.16
http://search.cpan.org/~pjb/Crypt-Tea_JS-2.16/
The Tiny Encryption Algorithm in Perl and JavaScript
----
Data-Reuse-0.05
http://search.cpan.org/~elizabeth/Data-Reuse-0.05/
share constant values with Data::Alias
----
Devel-Cover-0.59
http://search.cpan.org/~pjcj/Devel-Cover-0.59/
Code coverage metrics for Perl
----
GD-2.35
http://search.cpan.org/~lds/GD-2.35/
Interface to Gd Graphics Library
----
Games-Mastermind-0.02
http://search.cpan.org/~book/Games-Mastermind-0.02/
A simple framework for MasterMind games
----
Module-Install-0.64
http://search.cpan.org/~audreyt/Module-Install-0.64/
Standalone, extensible Perl module installer
----
Net-Whois-Raw-1.14
http://search.cpan.org/~despair/Net-Whois-Raw-1.14/
Get Whois information for domains
----
Number-Phone-1.52
http://search.cpan.org/~dcantrell/Number-Phone-1.52/
base class for Number::Phone::* modules
----
Number-Phone-1.53
http://search.cpan.org/~dcantrell/Number-Phone-1.53/
base class for Number::Phone::* modules
----
Number-Phone-UK-DetailedLocations-1.0
http://search.cpan.org/~dcantrell/Number-Phone-UK-DetailedLocations-1.0/
more detailed location information for Nu mber::Phone::UK
----
PAR-Dist-0.17
http://search.cpan.org/~smueller/PAR-Dist-0.17/
Create and manipulate PAR distributions
----
SVN-Web-0.49
http://search.cpan.org/~nikc/SVN-Web-0.49/
Subversion repository web frontend
----
Senna-0.50_04
http://search.cpan.org/~dmaki/Senna-0.50_04/
Perl Interface To Senna Fulltext Search Engine
----
Test-Pod-Snippets-0.01
http://search.cpan.org/~yanick/Test-Pod-Snippets-0.01/
Generate tests from pod code snippets
----
Text-Migemo-0.01
http://search.cpan.org/~jiro/Text-Migemo-0.01/
Migemo library module for Perl
----
WWW-Google-SiteMap-1.09
http://search.cpan.org/~jasonk/WWW-Google-SiteMap-1.09/
Perl extension for managing Google SiteMaps
----
WWW-phpBB-0.02
http://search.cpan.org/~stefant/WWW-phpBB-0.02/
phpBB forum scraper
----
Win32-GuiTest-1_50.5
http://search.cpan.org/~ctrondlp/Win32-GuiTest-1_50.5/
Perl GUI Test Utilities.
----
YAML-Tiny-0.10
http://search.cpan.org/~adamk/YAML-Tiny-0.10/
Read/Write YAML files with as little code as possible
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: Wed, 23 Aug 2006 21:34:40 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Question about UNIVERSAL
Message-Id: <0oqur3-atd.ln1@osiris.mauzo.dyndns.org>
Quoth "Ferry Bolhar" <bol@adv.magwien.gv.at>:
> First, thanks to all who replied.
>
> Ben Morrow:
>
> > No. Perl already handles cycles in the @ISA hierarchy (with an error);
>
> Is this what "Regexp::DESTROY" is for?
WTF??? *NO*.
Regexp::DESTROY does nothing. It's defined in perl/universal.c .
What on earth made you think it had *anything* to do with cycles in the
@ISA hierarchy?
> > I would respectfully suggest that if you can't figure this out for
> > yourself, you're probably better off staying out of the guts of Deep
> > Magic modules like Attribute::Handlers.
>
> You may be right but if I do not attempt to learn somewhat new
> from time to time (and often other code contains some very useful
> techniques), I will never use Perl in all the ways it is useable. The
> more one knows about a language, the better he can use it.
I couldn't agree more.
> Where your experience come from?
perldocs/Camel/here/perl source. And, most importantly, applying some
common sense to all of the above.
I don't wish to be mean, but I really think you would be better off
learning rather more about programming in general, including how to find
the answers to questions such as these yourself, before you tackle the
deeper aspects of how perl is implemented.
Ben
--
"Awww, I'm going to miss her."
"Don't you hate her?"
"Yes, with a fiery vengeance."
[benmorrow@tiscali.co.uk]
------------------------------
Date: 23 Aug 2006 18:47:02 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: readdir the directory name and file name separately?
Message-Id: <1156384021.984979.325110@b28g2000cwb.googlegroups.com>
Hi all,
I found readdir generate list contain ".", "..", "directory name",
"file name".
How can I readdir only the "directory name" and only the "file name"?
Thanks!
Davy
------------------------------
Date: Thu, 24 Aug 2006 03:58:03 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: readdir the directory name and file name separately?
Message-Id: <Xns9828F3E8FF1C3asu1cornelledu@127.0.0.1>
"Davy" <zhushenli@gmail.com> wrote in news:1156384021.984979.325110
@b28g2000cwb.googlegroups.com:
> I found readdir generate list contain ".", "..", "directory name",
> "file name".
> How can I readdir only the "directory name" and only the "file name"?
Have you considered reading the documentation for the function you are
using?
perldoc -f readdir
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: 23 Aug 2006 21:19:02 -0700
From: "Davy" <zhushenli@gmail.com>
Subject: Re: readdir the directory name and file name separately?
Message-Id: <1156393142.153763.122070@75g2000cwc.googlegroups.com>
A. Sinan Unur wrote:
> "Davy" <zhushenli@gmail.com> wrote in news:1156384021.984979.325110
> @b28g2000cwb.googlegroups.com:
>
> > I found readdir generate list contain ".", "..", "directory name",
> > "file name".
> > How can I readdir only the "directory name" and only the "file name"?
>
> Have you considered reading the documentation for the function you are
> using?
>
> perldoc -f readdir
[snip]
Shall I use
#--------
opendir(DIR, $some_dir);
@dir_list = grep{-d "$some_dir/$_"} readdir(DIR);
@file_list = grep{-f "$some_dir/$_"} readdir(DIR);
closedir(DIR);
#--------
Thanks!
Davy
>
> 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: 23 Aug 2006 20:35:35 -0600
From: Eric Schwartz <emschwar@pobox.com>
Subject: Re: readdir the directory name and file name separately?
Message-Id: <87fyfmeu88.fsf@localhost.localdomain>
"Davy" <zhushenli@gmail.com> writes:
> I found readdir generate list contain ".", "..", "directory name",
> "file name".
> How can I readdir only the "directory name" and only the "file name"?
You can't. But you can ignore the files:
my $dirname="/path/to/dir";
opendir my $dirhandle, $dirname or die "Couldn't open [$dirname]: $!";
while(my $entry = readdir($dirhandle)) {
next unless -d "$dirname/$entry"; # perldoc -f -X
# perldoc -f readdir (2nd paragraph)
# do other stuff here
}
-=Eric
------------------------------
Date: 23 Aug 2006 18:26:15 -0700
From: "bpatton" <bpatton@ti.com>
Subject: simple hash of arrays, I cant see the trees for the forest
Message-Id: <1156382775.024165.242120@p79g2000cwp.googlegroups.com>
I'm trying to get something on the order of
$VAR1 = {
'cell' => {
'1A' => {
'pass' => {
'ACTIVE' => {
[ 0 , 0 , 0 , 240 , 240 , 240 , ... ] ,
[ 1 , 2 , 3 , 4 , 5 , 6 , ... ] ,
},
},
'fail'=> {
'ACTIVE'=>{
...
This shoudl be very easy to do, but I've been working on my AC and had
a beer on an empty
stomach.
Here's some sample sode that soes not work.
#!/usr/local/bin/perl
use strict;
use warnings;
use Data::Dumper; $Data::Dumper::Indent = 1;
my $data;
my $x = 0;
my $y = 0;
my $dis = 240;
my $rule = '1A';
my $layer = 'ACTIVE';
$data->{cell}->{$rule}->{pass}->{$layer} =
( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
$x = $dis * 3;
$y = $dis * 3;
$data->{cell}->{$rule}->{pass}->{$layer} =
( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
$dis = int($dis / 2);
$data->{cell}->{$rule}->{fail}->{$layer} =
( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
$x = $dis * 3;
$y = $dis * 3;
$data->{cell}->{$rule}->{fail}->{$layer} =
( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
print Dumper($data);
------------------------------
Date: 23 Aug 2006 18:34:11 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: simple hash of arrays, I cant see the trees for the forest
Message-Id: <1156383251.104238.284960@h48g2000cwc.googlegroups.com>
bpatton wrote:
> I'm trying to get something on the order of
>
> $VAR1 = {
> 'cell' => {
> '1A' => {
> 'pass' => {
> 'ACTIVE' => {
> [ 0 , 0 , 0 , 240 , 240 , 240 , ... ] ,
> [ 1 , 2 , 3 , 4 , 5 , 6 , ... ] ,
> },
> },
> 'fail'=> {
> 'ACTIVE'=>{
> ...
>
>
> This shoudl be very easy to do, but I've been working on my AC and had
> a beer on an empty
> stomach.
> Here's some sample sode that soes not work.
> #!/usr/local/bin/perl
> use strict;
> use warnings;
>
> use Data::Dumper; $Data::Dumper::Indent = 1;
> my $data;
> my $x = 0;
> my $y = 0;
> my $dis = 240;
> my $rule = '1A';
> my $layer = 'ACTIVE';
> $data->{cell}->{$rule}->{pass}->{$layer} =
> ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> $x = $dis * 3;
> $y = $dis * 3;
> $data->{cell}->{$rule}->{pass}->{$layer} =
> ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> $dis = int($dis / 2);
> $data->{cell}->{$rule}->{fail}->{$layer} =
> ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> $x = $dis * 3;
> $y = $dis * 3;
> $data->{cell}->{$rule}->{fail}->{$layer} =
> ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> print Dumper($data);
you may want to change some braces into brackets, like:
$data->{cell}->{$rule}->{pass}->{$layer} =
[ $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y ];
Good luck,
Xicheng
------------------------------
Date: 23 Aug 2006 18:39:26 -0700
From: "Xicheng Jia" <xicheng@gmail.com>
Subject: Re: simple hash of arrays, I cant see the trees for the forest
Message-Id: <1156383566.076697.105970@74g2000cwt.googlegroups.com>
Xicheng Jia wrote:
> bpatton wrote:
> > I'm trying to get something on the order of
> >
> > $VAR1 = {
> > 'cell' => {
> > '1A' => {
> > 'pass' => {
> > 'ACTIVE' => {
> > [ 0 , 0 , 0 , 240 , 240 , 240 , ... ] ,
> > [ 1 , 2 , 3 , 4 , 5 , 6 , ... ] ,
> > },
> > },
> > 'fail'=> {
> > 'ACTIVE'=>{
> > ...
> >
> >
> > This shoudl be very easy to do, but I've been working on my AC and had
> > a beer on an empty
> > stomach.
> > Here's some sample sode that soes not work.
> > #!/usr/local/bin/perl
> > use strict;
> > use warnings;
> >
> > use Data::Dumper; $Data::Dumper::Indent = 1;
> > my $data;
> > my $x = 0;
> > my $y = 0;
> > my $dis = 240;
> > my $rule = '1A';
> > my $layer = 'ACTIVE';
> > $data->{cell}->{$rule}->{pass}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > $x = $dis * 3;
> > $y = $dis * 3;
> > $data->{cell}->{$rule}->{pass}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > $dis = int($dis / 2);
> > $data->{cell}->{$rule}->{fail}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > $x = $dis * 3;
> > $y = $dis * 3;
> > $data->{cell}->{$rule}->{fail}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > print Dumper($data);
>
> you may want to change some braces into brackets, like:
>
> $data->{cell}->{$rule}->{pass}->{$layer} =
> [ $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y ];
s/braces/parentheses/;
--
XC
------------------------------
Date: 23 Aug 2006 18:50:07 -0700
From: "bpatton" <bpatton@ti.com>
Subject: Re: simple hash of arrays, I cant see the trees for the forest
Message-Id: <1156384207.669775.37840@h48g2000cwc.googlegroups.com>
That did it , thanks :)
Xicheng Jia wrote:
> bpatton wrote:
> > I'm trying to get something on the order of
> >
> > $VAR1 = {
> > 'cell' => {
> > '1A' => {
> > 'pass' => {
> > 'ACTIVE' => {
> > [ 0 , 0 , 0 , 240 , 240 , 240 , ... ] ,
> > [ 1 , 2 , 3 , 4 , 5 , 6 , ... ] ,
> > },
> > },
> > 'fail'=> {
> > 'ACTIVE'=>{
> > ...
> >
> >
> > This shoudl be very easy to do, but I've been working on my AC and had
> > a beer on an empty
> > stomach.
> > Here's some sample sode that soes not work.
> > #!/usr/local/bin/perl
> > use strict;
> > use warnings;
> >
> > use Data::Dumper; $Data::Dumper::Indent = 1;
> > my $data;
> > my $x = 0;
> > my $y = 0;
> > my $dis = 240;
> > my $rule = '1A';
> > my $layer = 'ACTIVE';
> > $data->{cell}->{$rule}->{pass}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > $x = $dis * 3;
> > $y = $dis * 3;
> > $data->{cell}->{$rule}->{pass}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > $dis = int($dis / 2);
> > $data->{cell}->{$rule}->{fail}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > $x = $dis * 3;
> > $y = $dis * 3;
> > $data->{cell}->{$rule}->{fail}->{$layer} =
> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
> > print Dumper($data);
>
> you may want to change some braces into brackets, like:
>
> $data->{cell}->{$rule}->{pass}->{$layer} =
> [ $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y ];
>
> Good luck,
> Xicheng
------------------------------
Date: Wed, 23 Aug 2006 22:46:37 -0400
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: simple hash of arrays, I cant see the trees for the forest
Message-Id: <x78xleetpu.fsf@mail.sysarch.com>
>>>>> "b" == bpatton <bpatton@ti.com> writes:
b> That did it , thanks :)
regardless of the fix, your code leave much to be desired. perhaps you
should drink a better beer on an empty stomach?
>> > my $data;
>> > my $x = 0;
>> > my $y = 0;
>> > my $dis = 240;
>> > my $rule = '1A';
>> > my $layer = 'ACTIVE';
>> > $data->{cell}->{$rule}->{pass}->{$layer} =
>> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
you don't need -> between sets of [] or {}.
>> > $data->{cell}->{$rule}->{pass}->{$layer} =
>> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
all that redundancy is slow and very ugly. get a ref to the lowest level
that you are munging and use that:
my $rule_ref = \$data->{cell}{$rule} ;
my $coords = [$x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y] ;
$rule_ref->{pass}{$layer} = $coords ;
>> > $dis = int($dis / 2);
>> > $data->{cell}->{$rule}->{fail}->{$layer} =
>> > ( $x,$y , $x,$y+$dis , $dis,$dis , $dis,$y , $x,$y);
$rule_ref->{fail}{$layer} = $coords ;
i did that as it seems you are using the same coord stuff. if not,
create a new anon ref with the values you want. there is definitely
redundancy there that can be removed but i won't say exactly what it is
as i don't know your real data structure needs. my gut feeling is that
you are overdesigning this and it is more complex than you need.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 23 Aug 2006 21:38:06 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: variable with empty space
Message-Id: <euqur3-atd.ln1@osiris.mauzo.dyndns.org>
Quoth Josef Moellers <josef.moellers@fujitsu-siemens.com>:
>
> if ($username =~ /\s/)
>
> (ouch, ouch, don't hit me ... yes ... leaning toothpick ...)
>
> if ($username =~ m|\s|)
Or
if ($username =~ m{\s}) {
, as | is meta in a regex. :)
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] benmorrow@tiscali.co.uk
------------------------------
Date: Thu, 24 Aug 2006 09:00:12 +0200
From: Josef Moellers <josef.moellers@fujitsu-siemens.com>
Subject: Re: variable with empty space
Message-Id: <ecjit7$jac$1@nntp.fujitsu-siemens.com>
Ben Morrow wrote:
> Quoth Josef Moellers <josef.moellers@fujitsu-siemens.com>:
>=20
>> if ($username =3D~ /\s/)
>>
>>(ouch, ouch, don't hit me ... yes ... leaning toothpick ...)
>>
>> if ($username =3D~ m|\s|)
>=20
>=20
> Or=20
> if ($username =3D~ m{\s}) {
>=20
> , as | is meta in a regex. :)
=2E.. and so are '{' and '}':
\s{1,10)
matches 1 to 10 blanks
But you're right: if I use | as a delimiter, I won't be able to specify=20
alternations.
Never thought of that :-(
Thanks for pointing it out,
Josef
--=20
Josef M=F6llers (Pinguinpfleger bei FSC)
If failure had no penalty success would not be a prize
-- T. Pratchett
------------------------------
Date: Wed, 23 Aug 2006 22:58:02 -0700
From: fishfry <BLOCKSPAMfishfry@your-mailbox.com>
Subject: Re: warnings (was Re: Most useful standard module?)
Message-Id: <BLOCKSPAMfishfry-3529D4.22580223082006@comcast.dca.giganews.com>
In article <slrneepsnp.go5.tadmc@magna.augustmail.com>,
Tad McClellan <tadmc@augustmail.com> wrote:
> Jamie <nospam@geniegate.com> wrote:
>
> > I do make use of the -w switch now and then when trying to diagnose
> > something,
> > but I'm not to big on 'use warnings'.
>
>
> "use warnings" is far superior to the -w switch.
>
>
> > Data::Dumper is my friend and to me
> > anyway, far more useful when figuring out problems.
>
>
> Some people want a friend that helps them _discover_ problems too...
>
That's what endusers are for :-)
------------------------------
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 9641
***************************************