[24555] in Perl-Users-Digest
Perl-Users Digest, Issue: 6733 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jun 26 14:05:41 2004
Date: Sat, 26 Jun 2004 11: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 Sat, 26 Jun 2004 Volume: 10 Number: 6733
Today's topics:
complex data structure <jeff@whitehouse.gov>
Re: complex data structure <invalid-email@rochester.rr.com>
Re: complex data structure <xx087@freenet.carleton.ca>
Re: complex data structure <jeff@whitehouse.gov>
Re: complex data structure <spamtrap@dot-app.org>
Re: Help getting into HTML file. <ken_sington@nospam_abcdefg.com>
Re: Help getting into HTML file. <jimsimpson@cox.net>
monitoring changing web pages <rsnyder95@comcast.net>
Re: monitoring changing web pages <usenet@morrow.me.uk>
Re: PAR with active state: Compress::Zlib object versio <Graham.T.removethis.Wood@oracle.andthis.com>
Re: password change <krahnj@acm.org>
Re: Printing a hash question <tadmc@augustmail.com>
Re: Regexp for ls -l listing <david@tvis.co.uk>
Request for comments on a JPEG metadata Perl module <stefano_bettelli@yahoo.fr>
Re: Splitting a file <tadmc@augustmail.com>
Re: Trim Multiple Dirs to Max Total Space Used - by Dat <bik.mido@tiscalinet.it>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sat, 26 Jun 2004 16:29:50 GMT
From: Jeff <jeff@whitehouse.gov>
Subject: complex data structure
Message-Id: <2whDc.7656$Xn.3422@nwrdny03.gnilink.net>
I've created a beast! Here is my data structure:
$VAR1 = 'bunkers';
$VAR2 = {
'items' => [
\[
{
'archie' => 'conservative'
}
],
\[
{
'meathead' => 'liberal'
}
]
]
};
$VAR3 = 'simpsons';
$VAR4 = {
'items' => [
\[
{
'haha' => 'nelson munce'
}
],
\[
{
'whoohoo' => 'homer simpson'
}
]
]
};
How do I access the hash key value pairs? This fails at runtime:
(Not a HASH reference at haha line 22.)
foreach $key (keys %hash){
print "[".$key."]\n";
for $who (@{$hash{$key}{items}}){
foreach $item (keys %{$who}){
print $item . " => " . $who->{$item} . "\n";
}
}
}
TIA,
Jeff
------------------------------
Date: Sat, 26 Jun 2004 17:48:07 GMT
From: Bob Walton <invalid-email@rochester.rr.com>
Subject: Re: complex data structure
Message-Id: <40DDB6D4.3010002@rochester.rr.com>
Jeff wrote:
> I've created a beast! Here is my data structure:
>
> $VAR1 = 'bunkers';
> $VAR2 = {
> 'items' => [
> \[
> {
> 'archie' => 'conservative'
> }
> ],
> \[
> {
> 'meathead' => 'liberal'
> }
> ]
> ]
> };
> $VAR3 = 'simpsons';
> $VAR4 = {
> 'items' => [
> \[
> {
> 'haha' => 'nelson munce'
> }
> ],
> \[
> {
> 'whoohoo' => 'homer simpson'
> }
> ]
> ]
> };
>
> How do I access the hash key value pairs? This fails at runtime:
> (Not a HASH reference at haha line 22.)
>
> foreach $key (keys %hash){
> print "[".$key."]\n";
> for $who (@{$hash{$key}{items}}){
> foreach $item (keys %{$who}){
> print $item . " => " . $who->{$item} . "\n";
> }
> }
> }
...
> Jeff
That *is* a beast of a structure. I'll take your word for it that that
is really the structure you want (scalar references to array references
included). I also assume that your *original* data structure was a hash
containing $VAR1 through $VAR4 as keys/values, and that you didn't
properly dump a reference to that outside hash, but rather independently
dumped the keys/values to that hash. If so, here you go...
use warnings; #let Perl help you all it can
use strict; #let Perl help you all it can
my $VAR1 = 'bunkers';
my $VAR2 = {
'items' => [
\[
{
'archie' => 'conservative'
}
],
\[
{
'meathead' => 'liberal'
}
]
]
};
my $VAR3 = 'simpsons';
my $VAR4 = {
'items' => [
\[
{
'haha' => 'nelson munce'
}
],
\[
{
'whoohoo' => 'homer simpson'
}
]
]
};
#reconstitute assumed original structure:
my %hash=($VAR1,$VAR2,$VAR3,$VAR4);
=item
How do I access the hash key value pairs? This fails at runtime:
(Not a HASH reference at haha line 22.)
=cut
foreach my $key (keys %hash){
print "[".$key."]\n";
for my $who (@{$hash{$key}->{items}}){
foreach my $item (keys %{${$$who}[0]}){
print $item . " => " . $$who->[0]->{$item} . "\n";
}
}
}
HTH. You didn't show enough of your intended data structure for me to
know if you actually intend to have one-element arrays where I show them
in the code -- if they will actually have more than one element, you
will need to introduce another foreach loop to iterate over them. My
guess this isn't the data structure you really want.
--
Bob Walton
Email: http://bwalton.com/cgi-bin/emailbob.pl
------------------------------
Date: 26 Jun 2004 17:52:00 GMT
From: Glenn Jackman <xx087@freenet.carleton.ca>
Subject: Re: complex data structure
Message-Id: <slrncdrdu0.r3b.xx087@smeagol.ncf.ca>
Jeff <jeff@whitehouse.gov> wrote:
> I've created a beast! Here is my data structure:
[...]
> $VAR4 = {
> 'items' => [
> \[
> {
> 'haha' => 'nelson munce'
> }
> ],
> \[
> {
> 'whoohoo' => 'homer simpson'
> }
> ]
> ]
> };
The problem is that $hash{items}[0] is a reference to an array reference.
This is due to the backslashed brace ( \[ ). Why do you do that?
%hash=(simpsons=>{items=>[\[{haha=>'nelsonmunce'}],\[{whoohoo=>'homersimpson'}]]});
$homer = ${ $hash{simpsons}{items}[1] }->[0]{whoohoo};
>
> How do I access the hash key value pairs? This fails at runtime:
> (Not a HASH reference at haha line 22.)
>
> foreach $key (keys %hash){
> print "[".$key."]\n";
> for $who (@{$hash{$key}{items}}){
> foreach $item (keys %{$who}){
> print $item . " => " . $who->{$item} . "\n";
> }
> }
> }
>
> TIA,
> Jeff
Why are you mixing 'for' and 'foreach'?
foreach $key (keys %hash) {
foreach $ref (@{$hash{$key}{$items}}) {
foreach $who (@$$ref) {
# ^^^^^^
foreach $item (keys %$who) {
print "$item => $who->{$item}\n";
}
}
}
}
--
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca
------------------------------
Date: Sat, 26 Jun 2004 18:00:30 GMT
From: Jeff <jeff@whitehouse.gov>
Subject: Re: complex data structure
Message-Id: <2RiDc.3136$x9.106@nwrddc02.gnilink.net>
Bob Walton wrote:
> Jeff wrote:
>
>> I've created a beast! Here is my data structure:
>>
>> $VAR1 = 'bunkers';
>> $VAR2 = {
>> 'items' => [
>> \[
>> {
>> 'archie' => 'conservative'
>> }
>> ],
>> \[
>> {
>> 'meathead' => 'liberal'
>> }
>> ]
>> ]
>> };
>> $VAR3 = 'simpsons';
>> $VAR4 = {
>> 'items' => [
>> \[
>> {
>> 'haha' => 'nelson munce'
>> }
>> ],
>> \[
>> {
>> 'whoohoo' => 'homer simpson'
>> }
>> ]
>> ]
>> };
>>
>> How do I access the hash key value pairs? This fails at runtime:
>> (Not a HASH reference at haha line 22.)
>>
>> foreach $key (keys %hash){
>> print "[".$key."]\n";
>> for $who (@{$hash{$key}{items}}){
>> foreach $item (keys %{$who}){
>> print $item . " => " . $who->{$item} . "\n";
>> }
>> }
>> }
>
> ...
>
>> Jeff
>
>
> That *is* a beast of a structure. I'll take your word for it that that
> is really the structure you want (scalar references to array references
> included). I also assume that your *original* data structure was a hash
> containing $VAR1 through $VAR4 as keys/values, and that you didn't
> properly dump a reference to that outside hash, but rather independently
> dumped the keys/values to that hash. If so, here you go...
>
> use warnings; #let Perl help you all it can
> use strict; #let Perl help you all it can
> my $VAR1 = 'bunkers';
> my $VAR2 = {
> 'items' => [
> \[
> {
> 'archie' => 'conservative'
> }
> ],
> \[
> {
> 'meathead' => 'liberal'
> }
> ]
> ]
> };
> my $VAR3 = 'simpsons';
> my $VAR4 = {
> 'items' => [
> \[
> {
> 'haha' => 'nelson munce'
> }
> ],
> \[
> {
> 'whoohoo' => 'homer simpson'
> }
> ]
> ]
> };
> #reconstitute assumed original structure:
> my %hash=($VAR1,$VAR2,$VAR3,$VAR4);
> =item
> How do I access the hash key value pairs? This fails at runtime:
> (Not a HASH reference at haha line 22.)
> =cut
> foreach my $key (keys %hash){
> print "[".$key."]\n";
> for my $who (@{$hash{$key}->{items}}){
> foreach my $item (keys %{${$$who}[0]}){
> print $item . " => " . $$who->[0]->{$item} . "\n";
> }
> }
> }
>
> HTH. You didn't show enough of your intended data structure for me to
> know if you actually intend to have one-element arrays where I show them
> in the code -- if they will actually have more than one element, you
> will need to introduce another foreach loop to iterate over them. My
> guess this isn't the data structure you really want.
>
I'm certainly open to suggestions. Here is the method that creates the
hash:
sub getHashes()
{
my $this = shift;
my ($sep,$bad_programmer) = @_;
my (%hash, $hash);
my $lines = "";
my (@list, @cols);
my ($left,$right);
my ($prefix, $items);
if(open(FILE, "<" . $this->{"file"})){
flock(FILE, $LOCK_EX);
while(<FILE>){
next if /^$/;
next if /^\s*#/;
$lines .= $_;
}
flock(FILE, $LOCK_UN);
close(FILE);
}
$prefix = 'default';
$items = 'items';
foreach my $thing ( split( /\n/, $lines ) ){
if($thing =~ m/^\[([^\]]+)\]$/){
$prefix = $1;
print "PREFIX: $prefix\n";
next;
}
($left,$right) = split( /$sep/, $thing );
# Trim begnining and trailing whitespace
$left=~s/^\s+//;
$right=~s/^\s+//;
$left=~s/\s+$//;
$right=~s/\s+$//;
#$hash{$prefix}{$items} = [{ $left => $right, }];
push(@{$hash{$prefix}{$items}}, \[{ $left => $right, }]);
}
return %hash;
}
I had really wanted to push arrays (not refs) on $hash{$prefix}{$items}
Jeff
------------------------------
Date: Sat, 26 Jun 2004 14:04:15 -0400
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: complex data structure
Message-Id: <572dnaOJx4E8J0DdRVn-vg@adelphia.com>
> foreach $item (keys %{$who}){
The major problem in the above is that $who is neither a Simpsons reference
nor a Bunkers reference, it's a Dr. Seuss reference.
Okay, seriously... Like the error says, $who is not a hash ref, it's an
array ref, so the above should be:
foreach $item (@{$who}) {
Also, the array referred to by $who contains two items - each is a reference
to a reference (not a typo - note the backslash in the Data::Dumper output)
to an array. The inner array contains a single item, which is a reference
to a hash containing a single item.
To work with the code as given, your data structure would need to look in
part like this:
$VAR4 = {
'items' => {
'haha' => 'nelson munce',
'whoohoo' => 'homer simpson'
}
};
If the data is correct as given, then the code will need to be restructured
to correctly deal with the additional layers of array references.
To help deal with these issues, I suggest reading 'perldoc
perlreftut' (References Tutorial), 'perldoc perldsc' (Data Structures
Cookbook), and 'perldoc perllol' (Lists of Lists), in that order.
sherm--
--
Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
------------------------------
Date: Sat, 26 Jun 2004 03:45:21 -0400
From: Ken Sington <ken_sington@nospam_abcdefg.com>
Subject: Re: Help getting into HTML file.
Message-Id: <M82dnY0o45wbtEDdRVn-gw@speakeasy.net>
Jim Simpson wrote:
> I have the following line of code:
>
> <my $response = $ua->post(whatever)>
>
> The $response which is returned contains HTML code and is now printing on
> the DOS screen. How can I get it into an .html file so I can see it on my
> computer screen?
>
> Thanks,
>
> Jim
>
>
perhaps:
perl myprog.pl > mypage.html
in DOS command prompt.
and opening it in your browser.
that may be simpler
------------------------------
Date: Sat, 26 Jun 2004 13:07:56 -0400
From: "Jim Simpson" <jimsimpson@cox.net>
Subject: Re: Help getting into HTML file.
Message-Id: <V3iDc.610$Rr2.445@lakeread03>
Thanks to all who responded - very helpful.
Jim
"Ken Sington" <ken_sington@nospam_abcdefg.com> wrote in message
news:M82dnY0o45wbtEDdRVn-gw@speakeasy.net...
> Jim Simpson wrote:
>
> > I have the following line of code:
> >
> > <my $response = $ua->post(whatever)>
> >
> > The $response which is returned contains HTML code and is now printing
on
> > the DOS screen. How can I get it into an .html file so I can see it on
my
> > computer screen?
> >
> > Thanks,
> >
> > Jim
> >
> >
> perhaps:
> perl myprog.pl > mypage.html
> in DOS command prompt.
> and opening it in your browser.
> that may be simpler
------------------------------
Date: Sat, 26 Jun 2004 10:05:24 -0400
From: "Rod Snyder" <rsnyder95@comcast.net>
Subject: monitoring changing web pages
Message-Id: <SdmdnZIHbMNIH0Dd4p2dnA@comcast.com>
I am looking to try to build a program that monitors a specific page and
emails a group when the page changes. Any suggestions on modules to use or a
general description of how to build this would be appreciated.
Rod
------------------------------
Date: 26 Jun 2004 16:16:07 +0100
From: Ben Morrow <usenet@morrow.me.uk>
Subject: Re: monitoring changing web pages
Message-Id: <40dd9337_1@mk-nntp-2.news.uk.tiscali.com>
Quoth "Rod Snyder" <rsnyder95@comcast.net>:
> I am looking to try to build a program that monitors a specific page and
> emails a group when the page changes. Any suggestions on modules to use or a
> general description of how to build this would be appreciated.
LWP
Net::SMTP or Mail::Mailer or MIME::Lite
Investigate your system's facilities for running programs on a schedule,
e.g. cron on unix, Scheduled Tasks on Win32.
Ben
--
All persons, living or dead, are entirely coincidental.
ben@morrow.me.uk Kurt Vonnegut
------------------------------
Date: Sat, 26 Jun 2004 11:16:24 +0100
From: Graham Wood <Graham.T.removethis.Wood@oracle.andthis.com>
Subject: Re: PAR with active state: Compress::Zlib object version 1.22 does not match bootstrap parameter 1.16
Message-Id: <40DD4CF8.3060506@oracle.andthis.com>
Alan Stewart wrote:
> You could download the zip file copy of ActiveState build 635 and
> extract just site\lib\Compress\ and site\lib\auto\Compress\ to
> downgrade to version 1.16.
Thanks Allen, I'll try the binary 635 build option.
Graham
------------------------------
Date: Sat, 26 Jun 2004 07:19:46 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: password change
Message-Id: <40DD237F.93162225@acm.org>
Patrick wrote:
>
> On unix system is it possibble to change the password of a user from a
> var?
>
> like:
>
> system("passwd $user");
> print("$password\n");
> print("$password\n");
>
> But this doesnt work. Passwd is waiting for a input.
>
> It's hpux so --stdin doesnt work also.
Perhaps this posting from Randal will help:
http://groups.google.ca/groups?selm=86pthdysya.fsf%40blue.stonehenge.com
John
--
use Perl;
program
fulfillment
------------------------------
Date: Sat, 26 Jun 2004 00:24:55 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Printing a hash question
Message-Id: <slrncdq257.36h.tadmc@magna.augustmail.com>
scadav <dkscaccia@yahoo.com> wrote:
> print out all of the items
> but sort on the values?
>
> any help would be appreciated.
Any checking of the Perl FAQ *before* posting to the
Perl newsgroup appreciated.
perldoc -q hash
perldoc -q sort
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 26 Jun 2004 18:23:16 +0100
From: zzapper <david@tvis.co.uk>
Subject: Re: Regexp for ls -l listing
Message-Id: <a0crd0lee0p4e7b3a2l71p1emi3dthuir4@4ax.com>
On Fri, 25 Jun 2004 16:50:38 +0200, wrote:
>>
>>$_=qq|-rwxrwxrwx+ 1 davidr None 186 Mar 3 16:36 Application.cfm|;
>
>
>>@res2=split /\s+/;
>
>This is just as
>
> @res2=split;
>
>>print "\nsize = $res2[4] : \n";
>
> print "\nsize = ", (split)[4], " : \n";
Nico one, the ls actually comes from an Net::FTP command, so I can't use stat.
$ftp->dir("$file"); I'm also concerned that size won't always be the th element.
zzapper (vim, cygwin, wiki & zsh)
--
vim -c ":%s.^.CyrnfrTfcbafbeROenzSZbbyranne.|:%s/[R-T]/ /Ig|:normal ggVGg?"
http://www.vim.org/tips/tip.php?tip_id=305 Best of Vim Tips
------------------------------
Date: Sat, 26 Jun 2004 19:57:26 +0200
From: Stefano Bettelli <stefano_bettelli@yahoo.fr>
Subject: Request for comments on a JPEG metadata Perl module
Message-Id: <pan.2004.06.26.17.57.26.885135@yahoo.fr>
Hi,
I got recently interested in the possibility of designing a Perl
library for reading and modifying JPEG image metadata (with Exif
info, IPTC info, comments, thumbnails and so on). This kind of
additional data stored in the image itself is very useful for
organising digital photo collections. For various reasons, the
existing Perl libraries and programs do not fully satisfy me,
so I decided to enter the arena and write a Perl module (this is
also a good way to learn the language better ...).
I would like to ask you some suggestions
on how to design this module:
1) Do you think that submitting this module to CPAN is worth of,
or do you think that what is available is already sufficient?
2) What is the best name for the module?
I am currently using Image::MetaInfo::JPEG.
3) How can I decide what is the minimum Perl version
for running the module?
4) Do you have any idea on how it could be extended? Whether
there are interesting functionalities I did not think about?
Do you have any suggestion on code style?
Every other suggestion is of course welcome. You can download
(FOR THE TIME BEING, let's say for next two weeks) the module
at the following address:
http://82.229.136.165/IMJ/
In the following I am listing the main functionalities supplied
by my module. The purpose of this module is to read/modify/
rewrite meta-data segments in JPEG files, which can contain
comments, thumbnails, Exif information (photographic parameters),
IPTC information (editorial parameters) and similar data.
Each JPEG file is made of consecutive segments (data blocks
prefixed by a 2 byte segment code and a 2 byte segment length),
exception made for the actual picture data (the so called entropy
coded segment(s), which are indeed row data). Most of these
segments specify parameters for decoding the picture data into a
bitmap; some of them, namely the COMment and APPlication segments,
contain however meta-data, i.e., information about how the photo
was shot (usually added by a digital camera) and additional notes
from the photograph. These additional pieces of information are
especially valuable for picture databases, since the meta-data
can be saved together with the picture without resorting to
additional database structures.
This module works by breaking a JPEG file into individual segments.
Each file is associated to an Image::MetaInfo::JPEG structure
object, which contains one Image::MetaInfo::JPEG::Segment object
for each segment. Segments with a known format are then parsed,
and their content can be accessed in a structured way for display.
Some of them can even be modified and then rewritten to disk.
The current state is the following:
Segment Possible content Status
------------------------------------------
COM User comments parse/read/write
APP0 JFIF data (+ thumbnail) parse/read
APP1 Exif or XMP data parse
APP2 FPXR data or ICC profiles parse
APP3 additional EXIF-like data parse
APP4 HPSC nothing
APP12 PreExif ASCII meta parse[devel.]
APP13 IPTC and PhotoShop data parse/read/(write IPTC [devel.])
APP14 Adobe tags parse
"Parse" means that the segment content is decoded and stored
in low-level records. "Read" means that these data are available
in a more organised way at a higher level. The package contains
a quite detailed perldoc page, which you can read for further
info. This is the index:
1) STRUCTURE OF JPEG PICTURES
2) MANAGING A JPEG STRUCTURE OBJECT
3) MANAGING A JPEG SEGMENT OBJECT
4) MANAGING A JPEG RECORD OBJECT
5) COMMENTS ("COM" segments)
6) JFIF data ("APP0" segments)
7) IPTC DATA (from "APP13" segments)
8) CURRENT STATUS
-) Known Problems
-) References
-) OTHER PACKAGES (the "competitors")
I plan to add read/write support for Exif data in a few weeks.
The module contains already a test suite with 67 tests.
Thank you in advance for every suggestions,
best regards,
Stefano Bettelli
------------------------------
Date: Sat, 26 Jun 2004 00:26:43 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Splitting a file
Message-Id: <slrncdq28j.36h.tadmc@magna.augustmail.com>
Gianni <pincopallo_it@yahoo.it> wrote:
> I have a file done like this
[snip]
> how can I create a new file after the || ??
Show us what you have tried so far, and we will help you fix it.
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 26 Jun 2004 12:25:04 +0200
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Trim Multiple Dirs to Max Total Space Used - by Date
Message-Id: <8beqd01hrqf6tfkgh2t5h08pvtgrc5fh4n@4ax.com>
On Sat, 26 Jun 2004 03:39:40 GMT, Ron Heiby <heiby_u@falkor.chi.il.us>
wrote:
>Michele's script was very close to what I was looking for, so I started with it (before
>seeing Randal's version, which I'll now have to study).
Well, I've always used File::Find for my needs of "this kind", and it
has always revealed to be perfectly suited for them, though I must say
that Randal's script is cool in that his module already provides what
I am doing manually.
>Michele Dondi <bik.mido@tiscalinet.it> wrote:
>> use constant MAXSPACE => 0xA00_000; # 10Mb
>
>I needed to be able to get the maximum space value from a configuration file, so this
>line was replaced in my version with:
>
>my $image_megs = `cat /path/to/config_file 2>/dev/null`;
>$image_megs = 250 unless $image_megs;
This is good in that it's only one line. Personally I'm a bit
idiosicratic with backticks, but that's definitely a personal thing,
so don't mind!
However you may want to do some more checks by adopting something
along the lines of this (untested):
my $image_megs = do {
open my $fh, '<', 'path/to/config_file' or die
"Can't open config file: $!\n";
local $_=<$fh>;
chomp; # not necessary IIRC, but no harm done...
/^\d+$/ or
warn "config file not in the expected format" and
return 0;
$_; } || 250;
OTOH have you considered using an environment variable instead?
my $image_megs = $ENV{IMAGEMEGS} || 250;
>> find { no_chdir => 1,
>> wanted => sub {
>> return unless -f;
>
>I hadn't mentioned it, but all of the files of interest have the same extension, and
>there are other files in the directories, so at this point, I added:
> return unless /.extension$/;
I suspected that: of course yours is the obvious workaround. Only you
may want to be really fussy and write
return unless /\.extension$/;
^
instead, althoug I doubt that there would be many "false positives"...
>> push @files, [ $_, (stat _)[7,9] ];
>
>This is cool. I hadn't really seen an example of this that I had understood. I think
It's a standard Perl(5) construct.
>that what is happening is that the outer [] contains an unnamed array and returns a
>reference to it, and that reference is pushed onto the @files array. I've seen this
Yes, it's a reference to an anonymous array.
>Along the way, I had added a bunch of additional "print" statements, to show me what
>was going on at different points, to make sure I understood it. I commented out the
>"unlink" statement during most of my investigation and early testing. I confused myself
A Very Good Thing(TM)! As a totally minor side note, the code as
written:
unlink $_->[0] and
print "Removing `$_->[0]'" or
warn "Can't remove `$_->[0]': $!\n";
makes it easy to comment out just the line with unlink() and having
the statement still working for debugging/tersting purposes:
# unlink $_->[0] and
print "Removing `$_->[0]'" or
warn "Can't remove `$_->[0]': $!\n";
This is why I often format it this way, BTW...
Michele
--
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
"perl bug File::Basename and Perl's nature"
------------------------------
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 6733
***************************************