[28164] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9528 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 27 00:05:49 2006

Date: Wed, 26 Jul 2006 21:05:05 -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           Wed, 26 Jul 2006     Volume: 10 Number: 9528

Today's topics:
    Re: Count values in multi dimensional array <tadmc@augustmail.com>
    Re: counting number of uniques in a multidimensional ar <tadmc@augustmail.com>
    Re: counting number of uniques in a multidimensional ar <benmorrow@tiscali.co.uk>
    Re: DNS with bind9 sucks, what is an easier tool for fu <syscjm@gwu.edu>
    Re: FAQ 4.60 How can I always keep my hash sorted? <brian.d.foy@gmail.com>
    Re: How to send utf-8 data using LWP::UserAgent? <benmorrow@tiscali.co.uk>
        Please confirm bug in SHLOMIF >  Error-0.17 > Error <dbasch@yahoo.com>
    Re: Please confirm bug in SHLOMIF >  Error-0.17 > Error <1usa@llenroc.ude.invalid>
        Properly setting my PERL5LIB for CPAN modules vfoley@gmail.com
        Uninitialized value errors <archimede@linby.net>
    Re: Uninitialized value errors axel@white-eagle.invalid.uk
    Re: Uninitialized value errors <ksamp@vp_removeit_.pl>
    Re: Uninitialized value errors <archimede@linby.net>
    Re: Uninitialized value errors <archimede@linby.net>
    Re: Uninitialized value errors <syscjm@gwu.edu>
    Re: Uninitialized value errors axel@white-eagle.invalid.uk
    Re: Use MSXML in perl without registration <benmorrow@tiscali.co.uk>
    Re: Using an input/csv file to rename files <someone@example.com>
    Re: Using an input/csv file to rename files <benmorrow@tiscali.co.uk>
    Re: What is the right syntax? <ksamp@vp_removeit_.pl>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 26 Jul 2006 18:42:26 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Count values in multi dimensional array
Message-Id: <slrnecfvf2.3e4.tadmc@magna.augustmail.com>

Oliver Meister <oli.meister@gmail.com> wrote:

> Unfortunately I haven't figured out how i can count the number of
> values in the array "Exchange".


There *is no* array "Exchange"!

That is going to make counting things in the array extremely difficult...


> With this example [1], I am expecting to have a count of 3 for the Key
> "Exchange".


*Why* are you expecting a count of 3?

It looks like there are 4 of them to me...


> May I ask for a helping hand?


May we ask for a comprehensible question?


> $VAR1 = {
>           'InputList' => {
>                            'InputListAction' => 'Replace',
>                            'Instrument' => [
>                                              {
>                                                'Exchange' => 'SWX',


The value associated with key 'Exchange' is a string, not an array.

There is only *one* array in your entire data structure, and it
is associated with the 'Instrument' key, not the 'Exchange' key...


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 26 Jul 2006 18:30:53 -0500
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: counting number of uniques in a multidimensional array column
Message-Id: <slrnecfupd.3e4.tadmc@magna.augustmail.com>

Tad McClellan <tadmc@augustmail.com> wrote:
> Jack <jack_posemsky@yahoo.com> wrote:
> 
>> I want to exclude
>> from the counting any null values, 
> 
>> sub uniques
>> {
>>  my %unique = ();
>>  if (@_ != /^\z/) { $unique{$_}++ foreach @_ }  ;


Or, if you meant values rather than keys:

   $unique{$_}++ foreach grep length, @_;


>>  return keys %unique; 
> 
> 
>    return grep length, keys %unique;
> 
> or, since there can only be one anyway:
> 
>    delete $unique{''};
>    return keys %unique;
> 
> 
>> }


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Wed, 26 Jul 2006 16:27:19 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: counting number of uniques in a multidimensional array column
Message-Id: <n7ekp3-lvj.ln1@osiris.mauzo.dyndns.org>


Quoth Ted Zlatanov <tzz@lifelogs.com>:

> Interestingly, length(undef) is also 0, which makes Tad's length()
> test eliminate undef values as well.  For extra credit and fun, figure
> out why length(undef) is 0

 ... with a warning...

Ben

-- 
It will be seen that the Erwhonians are a meek and long-suffering people,
easily led by the nose, and quick to offer up common sense at the shrine of
logic, when a philosopher convinces them that their institutions are not based 
on the strictest morality. [Samuel Butler, paraphrased] benmorrow@tiscali.co.uk


------------------------------

Date: Wed, 26 Jul 2006 19:35:30 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: DNS with bind9 sucks, what is an easier tool for full DNS?
Message-Id: <12cfv26hln8io4c@corp.supernews.com>

gavino wrote:
> anyone?
> 

Bueller?


Chris Mattern


------------------------------

Date: Wed, 26 Jul 2006 17:11:17 -0700
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 4.60 How can I always keep my hash sorted?
Message-Id: <260720061711173663%brian.d.foy@gmail.com>

In article <J2zGCG.73y@news.boeing.com>, Charles DeRykus
<ced@blv-sam-01.ca.boeing.com> wrote:

> > 4.60: How can I always keep my hash sorted?
> > 
> >     You can look into using the DB_File module and tie() using the $DB_BTREE
> >     hash bindings as documented in "In Memory Databases" in DB_File. The
> >     Tie::IxHash module from CPAN might also be instructive.
> > 
> 
> While not wanting to heap on calories, I think mention of Tie's speed 
> penalty is warranted:

I think I can do that in a sentence. :)

-- 
Posted via a free Usenet account from http://www.teranews.com



------------------------------

Date: Wed, 26 Jul 2006 16:24:14 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: How to send utf-8 data using LWP::UserAgent?
Message-Id: <u1ekp3-lvj.ln1@osiris.mauzo.dyndns.org>


Quoth Gert Brinkmann <g111@netcologne.de>:
> Gert Brinkmann wrote:
> 
> > Why does the is_utf8($text,1) routine tells me, that the utf-8 String is
> > correct utf-8 even if there is an iso-latin "ö" in the string?
> 
> Ok. The string is completely correct. It is tagged as utf8 and it contains
> utf8. But the question ist: Why is utf8 converted to iso-latin again, when
> writing it into the "binmode'd" file?
> 
> Here is a test-script:
> -----------------------------------------------
> #!/usr/bin/perl
> 
> use strict;
> use warnings;
> use Encode;
> 
> my $x = 'gört';
> $x = Encode::encode("utf-8", $x);

This is wrong. (I'm surprised you didn't get an error.) encode converts
from characters to bytes; you want to convert from bytes (in whatever
your source file is in, probably iso8859-1) into characters, so you want

$x = Encode::decode iso8859_1 => $x;

An alternative to this would be to use the encoding pragma to tell Perl
what charset your source file uses.

> Encode::_utf8_on($x);

NO! You should never need to call the _utf8_o{n,ff} functions.

> open (my $fh, ">foo.log") or die "could not open foo.log";

open my $fh, '>:encoding(utf8)', 'foo.log' or die...;

Tell Perl what you want, or it doesn't know what to give you.
:encoding(utf8) is (IMHO) preferable to :utf8 as you get better error
handling.

> binmode $fh;

This says '$fh is for binary data'. That means that each character
printed to $fh will be written out as a single byte if possible, IOW
the string will be printed in ISO8859-1. Characters above \xff will give
a 'wide character in print' warning, and (I think, but this situation is
Wrong anyway) utf8 output.

Ben

> print $fh "isutf8=",    (Encode::is_utf8($x,0)?1:0), 
>           "; correct=", (Encode::is_utf8($x,1)?1:0),";\n";

Again, you don't need to care about the state of the internal utf8 flag.
Just tell Perl you want $x to be characters, not bytes.

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.
benmorrow@tiscali.co.uk                                   Frank Herbert, 'Dune'


------------------------------

Date: 26 Jul 2006 16:21:36 -0700
From: "Derek Basch" <dbasch@yahoo.com>
Subject: Please confirm bug in SHLOMIF >  Error-0.17 > Error
Message-Id: <1153956096.203534.125890@m79g2000cwm.googlegroups.com>

Hello Everyone,

I was hoping someone could confirm a bug for me. I believe I have found
a bug in the Error module. The Synopsis section shows this example:

throw Error::Simple -text => "Oops!" if $other_condition;

However, this style of instantiating a Error::Simple object is broken.
The constructor for Error::Simple does not convert the parameters array
into a hash as expected:

    265 sub new {
    266     my $self  = shift;
    267     my $text  = "" . shift;
    268     my $value = shift;
    269     my(@args) = ();

I believe it should be:

    265 sub new {
    266     my (%params) = @_;

and the parameters should be dereferenced as hash elements throughout.
Can anyone confirm?

Thanks,
Derek Basch



------------------------------

Date: Thu, 27 Jul 2006 03:44:23 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Please confirm bug in SHLOMIF >  Error-0.17 > Error
Message-Id: <Xns980CF1962A218asu1cornelledu@127.0.0.1>

"Derek Basch" <dbasch@yahoo.com> wrote in news:1153956096.203534.125890
@m79g2000cwm.googlegroups.com:

> I was hoping someone could confirm a bug for me.

You have the wrong attitude. You should hope to learn something by 
asking people, instead of wanting to find a bug.

It is OK that you do not know Perl. It is not OK to assume that 
everything you do not understand is a bug.

> throw Error::Simple -text => "Oops!" if $other_condition;

I have never used this module. However, when you claim to have found a 
bug, it is customary to come up with a test case that actually 
illustrates unexpected behavior. That allows other people to replicate 
the problem and potentially fix the bug.

> However, this style of instantiating a Error::Simple object is broken.

You do not show that it is broken,

> The constructor for Error::Simple does not convert the parameters
> array into a hash as expected:

Why should it?

Besides, the excerpt above shows the constructor named 'throw' being 
invoked, not 'new'.

> 
>     265 sub new {
>     266     my $self  = shift;
>     267     my $text  = "" . shift;
>     268     my $value = shift;
>     269     my(@args) = ();
> 
> I believe it should be:
> 
>     265 sub new {
>     266     my (%params) = @_;

Then, you would be trying to construct a hash using an odd number of 
elements.
 
> and the parameters should be dereferenced as hash elements throughout.

Why?

Show us a test case where things don't work. Otherwise, I do not have 
the slightest motivation to go install the aformentioned module, and try 
to come up with a test case to demonstrate a bug you are fantasizing 
about.

-- 
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: 26 Jul 2006 17:16:09 -0700
From: vfoley@gmail.com
Subject: Properly setting my PERL5LIB for CPAN modules
Message-Id: <1153959369.204524.94930@i42g2000cwa.googlegroups.com>

Hello,

I am a new Perl programmer and I would need some help with CPAN
modules.  During the configuration part of CPAN, I asked that the
modules be installed in ~/perl.  This gave me a directory structure,
however I am not sure which directory/ies I should put in my PERL5LIB
variable.  This is the current setup:

perl/
     lib/
         perl/
              5.8.7/
                    auto/
                         Term/
                              ReadKey/
                         Date/
                              Manip/
                    Term/
     share/
           perl/
                5.8.7/
                      Date/
     man/
         man3/

Should I add only the top-most perl directory and Perl will recursively
check down that directory, or do I need to specify something like
"~/perl/lib/perl/5.8.7" ?

I'm also curious on the difference between lib and share.

Thank you for you time,

Vincent.



------------------------------

Date: Thu, 27 Jul 2006 00:50:46 +0200
From: Archimede Pitagorico <archimede@linby.net>
Subject: Uninitialized value errors
Message-Id: <r3sfc2hopt14b5dr2uc67fk46oo68ioj7u@4ax.com>

This code give me many errors:

http://nopaste.info/6ec866c6ea.html

1) Use of uninitialized value in numeric gt (>) ....

Why? Thanks.


------------------------------

Date: Wed, 26 Jul 2006 23:17:34 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Uninitialized value errors
Message-Id: <iKSxg.7258$5K2.6072@fed1read03>

Archimede Pitagorico <archimede@linby.net> wrote:
> This code give me many errors:
 
> http://nopaste.info/6ec866c6ea.html
 
> 1) Use of uninitialized value in numeric gt (>) ....
 
> Why? Thanks.

If you cannot be bothered to actually post your code, why should we
bother to look it up on the web?

Axel



------------------------------

Date: Thu, 27 Jul 2006 01:21:25 +0100
From: ks <ksamp@vp_removeit_.pl>
Subject: Re: Uninitialized value errors
Message-Id: <ma1gc21hdmpr2cmtatm0cf4tbq1ol07boa@4ax.com>

On Thu, 27 Jul 2006 00:50:46 +0200, Archimede Pitagorico
<archimede@linby.net> wrote:

>This code give me many errors:
>
>http://nopaste.info/6ec866c6ea.html
>
>1) Use of uninitialized value in numeric gt (>) ....

beceuse you haven't read any values into $num1 and $num2 variables.
they remain uninitialized. i haven't used String::Scanf module before
but you don't have to use it to solve your problem. instead of using
sscanf try this:

my $line = <>;
($num1, $num2) = $line =~ /(\d+).*?(\d+)/;

you can also remove $input variable and put some tests after above 2
lines to ensure that both, $num1 and $num2 are defined - contain some
values. be aware that the user can provide any input line - even the
one you aren't expecting.

best regards,
ks


------------------------------

Date: Thu, 27 Jul 2006 01:26:05 +0200
From: Archimede Pitagorico <archimede@linby.net>
Subject: Re: Uninitialized value errors
Message-Id: <seufc2ti8rgm1jah8ho0t1b514g1be2471@4ax.com>

On Wed, 26 Jul 2006 23:17:34 GMT, axel@white-eagle.invalid.uk wrote:

>Archimede Pitagorico <archimede@linby.net> wrote:
>> This code give me many errors:
> 
>> http://nopaste.info/6ec866c6ea.html
> 
>> 1) Use of uninitialized value in numeric gt (>) ....
> 
>> Why? Thanks.
>
>If you cannot be bothered to actually post your code, why should we
>bother to look it up on the web?
>
>Axel

Sorry but I have  think that long code can be a problem in newsgroups.
:(



------------------------------

Date: Thu, 27 Jul 2006 01:26:36 +0200
From: Archimede Pitagorico <archimede@linby.net>
Subject: Re: Uninitialized value errors
Message-Id: <qgufc2111sgp3q4c85jqhl34f37j9lqch3@4ax.com>

On Thu, 27 Jul 2006 01:21:25 +0100, ks <ksamp@vp_removeit_.pl> wrote:

>On Thu, 27 Jul 2006 00:50:46 +0200, Archimede Pitagorico
><archimede@linby.net> wrote:
>
>>This code give me many errors:
>>
>>http://nopaste.info/6ec866c6ea.html
>>
>>1) Use of uninitialized value in numeric gt (>) ....
>
>beceuse you haven't read any values into $num1 and $num2 variables.
>they remain uninitialized. i haven't used String::Scanf module before
>but you don't have to use it to solve your problem. instead of using
>sscanf try this:
>
>my $line = <>;
>($num1, $num2) = $line =~ /(\d+).*?(\d+)/;
>
>you can also remove $input variable and put some tests after above 2
>lines to ensure that both, $num1 and $num2 are defined - contain some
>values. be aware that the user can provide any input line - even the
>one you aren't expecting.
>
>best regards,
>ks


Ok thanks :)


------------------------------

Date: Wed, 26 Jul 2006 19:39:49 -0400
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: Uninitialized value errors
Message-Id: <12cfva9f8oongf5@corp.supernews.com>

Archimede Pitagorico wrote:
> On Wed, 26 Jul 2006 23:17:34 GMT, axel@white-eagle.invalid.uk wrote:
> 
> 
>>Archimede Pitagorico <archimede@linby.net> wrote:
>>
>>>This code give me many errors:
>>
>>>http://nopaste.info/6ec866c6ea.html
>>
>>>1) Use of uninitialized value in numeric gt (>) ....
>>
>>>Why? Thanks.
>>
>>If you cannot be bothered to actually post your code, why should we
>>bother to look it up on the web?
>>
>>Axel
> 
> 
> Sorry but I have  think that long code can be a problem in newsgroups.
> :(
> 

Which is why you make it *short* code.  The rule is: "Reduce your
script down to the absolute minimum required to replicate
the error you are seeing.  Then post that short *but complete*
script."  This is not only courteous to the group but is an
essential debugging method.  Much of the time you will find that
simply attempting to so reduce your script will make the cause
of the error obvious to you.  Have you read the posting guidelines?
If not, you should.


Chris Mattern


------------------------------

Date: Thu, 27 Jul 2006 02:15:29 GMT
From: axel@white-eagle.invalid.uk
Subject: Re: Uninitialized value errors
Message-Id: <5lVxg.7261$5K2.4761@fed1read03>

Archimede Pitagorico <archimede@linby.net> wrote:
> On Wed, 26 Jul 2006 23:17:34 GMT, axel@white-eagle.invalid.uk wrote:
 
>>Archimede Pitagorico <archimede@linby.net> wrote:
>>> This code give me many errors:
 
>>> http://nopaste.info/6ec866c6ea.html
 
>>> 1) Use of uninitialized value in numeric gt (>) ....
 
>>> Why? Thanks.

>>If you cannot be bothered to actually post your code, why should we
>>bother to look it up on the web?

> Sorry but I have  think that long code can be a problem in newsgroups.
> :(

Long code is a problem anyway... the Posting Guidelines give guidance as
to providing the best means of receiving help.

Besides that, posting the code to the newsgroup is much less of a problem
than putting it on a web site.

- People need to start a browser to view the code instead of just
  reading it in context with the problem.

- Answers relating to the code are not very meaningful unless those
  reading the follow-ups also go to the effort of visiting the web page.
  Which manages to destroy guidelines about posting replies in context
  unless the replier is willing to cut and paste. 

- The web page will no doubt be ephemeral and thus the archives of the
  group will contain posts with little meaning since essential
  information is lacking (the same as posting material with an
  X-No-Archive header).

- In general it just involves a great deal more work for everyone with
  no gain whatsoever.

Sorry to go on at length, but it is something which does annoy me... you
are certainly not the only person to do this and doubtless will not be
the last.

Axel



------------------------------

Date: Wed, 26 Jul 2006 16:13:34 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Use MSXML in perl without registration
Message-Id: <uddkp3-lvj.ln1@osiris.mauzo.dyndns.org>


Quoth "Sisyphus" <sisyphus1@nomail.afraid.org>:
> 
> "Ben Morrow" <benmorrow@tiscali.co.uk> wrote in message
> news:eo8gp3-rh.ln1@osiris.mauzo.dyndns.org...
> >
> > Quoth "Sisyphus" <sisyphus1@nomail.afraid.org>:
> > >
> > > "Vinay" <shah.vinay@gmail.com> wrote in message
> > > news:1153782403.410656.21810@75g2000cwc.googlegroups.com...
> > > > I would like to use MSXML4.0 in my perl script, but not have it
> > > > register on my machine. The way to do that is explained for C++ at
> this
> > > > link:
> > > > http://www.perfectxml.com/articles/msxml/TipsAugust02.asp
> 
<snip>
> > > Otherwise you can use the Win32::API module.
> > >
> > > With Win32::API, I envisage that there's no need to call LoadLibrary,
> > > GetProcessAddress, and FreeLibrary. Instead you just access the
> functions
> > > from the dll directly. (However, I'm not sure if that's correct - given
> that
> > > you're dealing with COM objects.)
> >
> > That is correct insofar as calling Win32 APIs (or: C functions in DLLs
> > with the __stdcall calling convention) goes: the Win32::API
> > instantiation process does the LoadLibrary for you. However, you can't
> > call C++ member functions at all, so you can't translate that code.
> >
> 
> Oh .... bummer. Wasn't aware of that - thanks for correcting. (I try to
> avoid Win32::API - usually go the XS route.) Is there some C-style way of
> accessing those member functions with Win32::API ? Or does "you can't
> translate the code" really *mean* "you can't translate the code" :-)

I believe there is no way. You may be able to create a dll that does the
work for you (which you can then call with W32:API), but I'm having a
hard time seeing how you could specify the method names.

To the OP: if you're really into some pain :), you could see if you can
find a way to adapt that code into something that returns a real COM
instance, and then grovel around in the guts of W32::OLE to find a way
to bind your instance to a W32::OLE object....

Ben

-- 
You poor take courage, you rich take care:
The Earth was made a common treasury for everyone to share
All things in common, all people one.
'We come in peace'---the order came to cut them down.[benmorrow@tiscali.co.uk]


------------------------------

Date: Thu, 27 Jul 2006 00:34:39 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: Using an input/csv file to rename files
Message-Id: <zSTxg.174696$771.116861@edtnps89>

Terry wrote:
> I am a few hours into my life after Perl.
> 
> I need to rename approximately 5000 .jpg files, which I think I have
> figured out thanks to "Learning Perl" 3rd. Ed. (pg. 176).
> 
> Unlike that example, I would like to compare/match the file names to a
> table/field in a csv file and once matched rename the file to the
> second table/field in the csv file so that ABCDEFG.jpg becomes
> 1111111.jpg and ABCDEFH.jpg becomes 1111112.jpg and so on.
> 
> I've been searching my perldoc, comp.lang.perl.misc and "Learning Perl"
> most of the day and haven't found anything that looks like what I want
> to do, but I'm chalking that up to not knowing where to look.
> 
> Any suggestions of howto: or where to look would be greatly
> appreciated.

UNTESTED:


open my $csv, '<', 'csv_file' or die "Cannot open 'csv_file' $!";

while ( <$csv> ) {
    chomp;
    my ( $from, $to ) = split /,/;
    if ( -e $from and not -e $to ) {
        rename $from, $to or warn "Cannot rename '$from' $!";
        }
    }

close $csv;




John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Thu, 27 Jul 2006 03:30:27 +0100
From: Ben Morrow <benmorrow@tiscali.co.uk>
Subject: Re: Using an input/csv file to rename files
Message-Id: <33llp3-nae.ln1@osiris.mauzo.dyndns.org>


Quoth "John W. Krahn" <krahnj@telus.net>:
> Terry wrote:
> > I am a few hours into my life after Perl.
> > 
> > I need to rename approximately 5000 .jpg files, which I think I have
> > figured out thanks to "Learning Perl" 3rd. Ed. (pg. 176).
> > 
> > Unlike that example, I would like to compare/match the file names to a
> > table/field in a csv file and once matched rename the file to the
> > second table/field in the csv file so that ABCDEFG.jpg becomes
> > 1111111.jpg and ABCDEFH.jpg becomes 1111112.jpg and so on.
> > 
> > I've been searching my perldoc, comp.lang.perl.misc and "Learning Perl"
> > most of the day and haven't found anything that looks like what I want
> > to do, but I'm chalking that up to not knowing where to look.
> > 
> > Any suggestions of howto: or where to look would be greatly
> > appreciated.
> 
> UNTESTED:

And wrong.

> open my $csv, '<', 'csv_file' or die "Cannot open 'csv_file' $!";
> 
> while ( <$csv> ) {
>     chomp;
>     my ( $from, $to ) = split /,/;

CSV is actually quite complicated for such a simple format, and this is
not the right way to parse it. Use a module, such as Text::CSV_XS.

>     if ( -e $from and not -e $to ) {
>         rename $from, $to or warn "Cannot rename '$from' $!";
>         }
>     }
> 
> close $csv;

If you're not going to check the return value, there's no point doing an
explicit close.

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 'Alcestis')        [ flame, and falls out of sight. ]  benmorrow@tiscali.co.uk


------------------------------

Date: Thu, 27 Jul 2006 00:23:19 +0100
From: ks <ksamp@vp_removeit_.pl>
Subject: Re: What is the right syntax?
Message-Id: <15ufc2p0hvprps9p28jlb3g27q25p3fkv7@4ax.com>


>@names = {"a","b","c"};
>
>@occup = {"d","e","f'};

do you really know what above means? both arrays have one element
which is a hash reference. you probably wanted to do that:

@occup = ('d', 'e', 'f');

or

@occup = qw(d e f);

best regards,
ks


------------------------------

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 9528
***************************************


home help back first fref pref prev next nref lref last post