Because you named your variable $tar_obj then you try and call a method on $tar. You mistyped the variable names which is exactly what those warnings and errors are telling you if you'd bother to read them.
| [reply] [d/l] [select] |
Name "main::tar" used only once: possible typo at u.pl line 4
That's not an error - it's a warning to alert you to the fact that the variable "$tar" appears only once in the script. That's worthy of a warning because, generally, there's no point in mentioning a variable only once in a script. If you had been on the ball (so to speak) you would then have realised that the Archive::Tar object you created was called $tar_obj, not $tar. (If you had coded in a 'use strict;' you would not have needed to be "on the ball".)
Anyway ... as I'm sure you now realise, you can only call the get_files method on Archive::Tar objects, and whereas $tar_obj is one such Archive::Tar object, $tar is not :-)
Cheers, Rob | [reply] |