Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 29 Apr 2019 21:09:11 +0100
From:      Steve Roome <me@stephenroome.com>
To:        ports@freebsd.org
Subject:   gnupod - can't use hash as reference.
Message-ID:  <CAMrSzCUfOYcoB2QLVo2DLvu9coOHHtbmbam8YrSshXPewcDKPw@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
Hi all, sorry for the noise here, my pkg installed gnupod is apparently
maintained by ports@

It is: gnupod-0.99.8_3 on: 12.0-RELEASE-p3 GENERIC  amd64

Perl for me is: v5.28.1

For the last few years any use of gnupod_addsong.pl has always immediately
crashed like so:

Can't use 'defined(@array)' (Maybe you should just omit the defined()?) at
/usr/local/lib/perl5/site_perl/GNUpod/XMLhelper.pm line 362.
Compilation failed in require at /usr/local/bin/gnupod_addsong.pl line 25.
BEGIN failed--compilation aborted at /usr/local/bin/gnupod_addsong.pl line
25.

As suggested, I do remove the wrapping defined() from XMLhelper.pm:

--- /usr/local/lib/perl5/site_perl/GNUpod/XMLhelper.pm.orig     2019-04-29
20:45:40.054385000 +0100
+++ /usr/local/lib/perl5/site_perl/GNUpod/XMLhelper.pm  2019-04-29
20:45:50.724704000 +0100
@@ -359,7 +359,7 @@
                        print OUT " </smartplaylist>\n";
                }
                elsif(my $phr = get_plpref($current_plname)) { #plprefs
found..
-                       if
(defined(@{$XDAT->{playlists}->{data}->{$current_plname}})) { #the playlist
is not empty
+                       if
(@{$XDAT->{playlists}->{data}->{$current_plname}}) { #the playlist is not
empty
                                print OUT "\n ".mkfile({playlist=>$phr},
{return=>1,noend=>1})."\n";

foreach(@{$XDAT->{playlists}->{data}->{$current_plname}}) {
                                        print OUT "   $_\n";


It then fails with:

Can't use a hash as a reference at
/usr/local/lib/perl5/site_perl/GNUpod/FileMagic.pm line 365.
Compilation failed in require at /usr/local/bin/gnupod_addsong.pl line 27.
BEGIN failed--compilation aborted at /usr/local/bin/gnupod_addsong.pl line
27.

There are three other similar hashes as references issues, and so I patch
FileMagic as follows:

--- /usr/local/lib/perl5/site_perl/GNUpod/FileMagic.pm.orig     2018-04-25
23:49:44.587365000 +0100
+++ /usr/local/lib/perl5/site_perl/GNUpod/FileMagic.pm  2019-04-29
20:50:27.565552000 +0100
@@ -362,7 +362,7 @@
                foreach (keys(%{$in})) {
                        my $kvp = __flatten($_, $exclude); # key
                        next if !defined($kvp);
-                       my $v = __flatten(%{$in}->{$_}, $exclude); # value
+                       my $v = __flatten(%{{$in}->{$_}}, $exclude); # value
                        $kvp .= " : ".$v     if (defined($v) && ("$v" ne
""));
                        push @out, $kvp;
                }
@@ -418,9 +418,10 @@
        my $case = "check";

        if (ref($options) eq "HASH") {
-               $joinby = %{$options}->{joinby}        if
defined(%{$options}->{joinby});
-               $wspace = lc(%{$options}->{wspace})    if
defined(%{$options}->{wspace});
-               $case   = lc(%{$options}->{case})      if
defined(%{$options}->{case});
+               my %hh = %$options;
+               $joinby = $hh{joinby}        if $hh{joinby};
+               $wspace = lc($hh{wspace})    if $hh{wspace};
+               $case   = lc($hh{case})      if $hh{case};
        }
        my $merged = "";



This then makes gnupod work for me, and I can put music on my ipod once
again.

This problem has hampered me for a while, but I've not supplied a patch
sooner
and I've not done them as attachments either as I'm no longer sure of my
perl-fu
and I've a feeling that possibly this ought to be fixed differently.

Hope this is useful,

Steve Roome



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAMrSzCUfOYcoB2QLVo2DLvu9coOHHtbmbam8YrSshXPewcDKPw>