Re: [Bug-gnupod] mktunes.pl creates corrupt iTunesDB ?

2009-06-18 Thread H. Langos

Hi Richard,

On Wed, Jun 17, 2009 at 10:00:16PM +0200, Richard van den Berg wrote:
 On 6/17/09 10:41 AM, H. Langos wrote:
 -   $mktunes-WriteItunesDB;
 +   $mktunes-WriteItunesDB(Keep=$opts{'keepattr'});
 

 Shouldn't that be :

 $mktunes-WriteItunesDB( {Keep = $opts{'keepattr'}} );
   

 It turns out it depends on your usage. The form I chose you can used as:

 ($self,%args) = @_;
 @keep=split(/[ ,]+/, $args{Keep});


This form passes the whole hash as a key/value list and creates a new one in
the sub. It will break if you add other parameters as the receiving %args
hash will try to suck up all he parameters that you pass.

$mktunes-WriteItunesDB(Keep=$opts{'keepattr'},foo,bar); 
will let foo and bar end up in %args:

You might try to separate them but 

($self,%args,$localfoo,$localbar) = @_;
will end up
%args == ( Keep = value of $opts{'keepattr'},
  foo  = bar )
$localfoo == undef
$localbar == undef

 While the form with the {} can be used as:

 ($self,$args) = @_;
 @keep=split(/[ ,]+/, $args-{Keep});


This form only passed a single hash reference.

thus 
($self,$args,$localfoo,$localbar) = @_;
will assign a single scalar to $args and $localfoo and $localbar will
get their values.

Did I mention before that I hate perl? :-)


 Both forms are in use in the gnupod code at the moment, I just picked  
 the first..

Check if they are used for the same purpose. :-)

 Here is a new patch with your suggestions and the tunes2pod code. The  
 diff for XMLhelper.pm looks a bit weird, but all I did was move the  
 reset code to a new resetxml() sub. The reset is needed because the  
 playlists are stored in XDAT by doxml() and won't be overwritten by the  
 playlists from the iTunesDB otherwise.

I'll take a look at a revised patch later ... got to hurry to work.

-henrik



___
Bug-gnupod mailing list
Bug-gnupod@nongnu.org
http://lists.nongnu.org/mailman/listinfo/bug-gnupod


Re: [Bug-gnupod] mktunes.pl creates corrupt iTunesDB ?

2009-06-18 Thread Richard van den Berg
On Thu, June 18, 2009 08:22, H. Langos wrote:
 Did I mention before that I hate perl? :-)

In about every other post to this list. ;-) To me, the things about perl
that I sometimes hate let me very quickly write code that does what I want
at other times. When I started with the tunes2pod code I thought damn,
this is going to be very hard to do. Then one hour later I was done and
it worked. :-)

 Both forms are in use in the gnupod code at the moment, I just picked
 the first..

 Check if they are used for the same purpose. :-)

They are. I'm very good at copy-and-paste and mimicking other people's
style. I realize that most of the gnupod code is not yours, so don't blame
me for using Adrian's coding style. :-)

Cheers,

Richard



___
Bug-gnupod mailing list
Bug-gnupod@nongnu.org
http://lists.nongnu.org/mailman/listinfo/bug-gnupod