in reply to Re: Question about MP3::Tag and undef id3v2
in thread Question about MP3::Tag and undef id3v2

Hmm, no, it's commented because there is no id3v2 :
$VAR1 = \undef; Can't call method "get_frame_ids" on an undefined value at ./test.pl l +ine 26.
That's why I do my $id3v2 = exists $mp3->{ID3v2} ? $mp3->{ID3v2} : $mp3->new_tag("ID3v2");

Replies are listed 'Best First'.
Re^3: Question about MP3::Tag and undef id3v2
by kcott (Archbishop) on Sep 06, 2017 at 06:12 UTC

    G'day DecMoon,

    Welcome to the Monastery.

    These are lines 25 and 26 in the code you posted:

    print Dumper(\$id3v2); print Dumper(\$id3v2->get_frame_ids);

    The first line of output you show ($VAR1 = \undef;) is telling you that $id3v2 is undef (i.e. it's undefined).

    So, "$id3v2->get_frame_ids" (in line 26) is equivalent to "undef->get_frame_ids". That's effectively what the second line of output you show is telling you.

    You'll need to do something with your assignment to $id3v2. I'm unfamiliar with the MP3::Tag module, so I'm not really in a position to advise you what that "something" might be. Options could include: checking for definedness; setting a default value; skipping some part of the code if it's not defined; or something completely different.

    — Ken