``use Data::Locations::Shell;'' INSTEAD of ``use Data::Locations;'' and replace all occurrences of ``Data::Locations'' in your program by ``Data::Locations::Shell''.
The advantage of using ``Data::Locations::Shell'' instead of ``Data::Locations'' is that you don't need TWO object references for the SAME location anymore: One for the location itself and one for the file handle the location has been tied to.
Instead, you have only ONE object reference you can do everything with: Use it as a file handle in Perl's built-in functions for dealing with files, AND use it to invoke methods from the ``Data::Locations'' class, at the same time!
Note also that this module is fully compatible with ``Data::Locations'',
i.e., if you change all occurrences of ``Data::Locations'' in your program
to ``Data::Locations::Shell'', your program should work exactly as before -
with the added benefit that you don't need to ``tie()'' your locations to a
file handle explicitly anymore in order to be able to use ``print $location @items;'' and ``$item = <$location>;'', for instance, as shown below (for a more detailed description of these
methods, see Data).
Note however that ``Data::Locations::Shell'' needs Perl version 5.004 (or higher) in order to run (whereas ``Data::Locations'' can do with previous versions of Perl).
use Data::Locations::Shell;
$filehandle = Data::Locations::Shell->new();
$filehandle = Data::Locations::Shell->new($filename);
$subfilehandle = $filehandle->new();
$subfilehandle = $filehandle->new($filename);
$filehandle->filename($filename);
$filename = $filehandle->filename();
$filehandle->print(@items);
$filehandle->println(@items);
$filehandle->printf($format,@items);
print $filehandle @items;
printf $filehandle $format, @items;
$ok = Data::Locations::Shell->dump();
$ok = $filehandle->dump();
$ok = $filehandle->dump($filename);
$item = $filehandle->read();
@list = $filehandle->read();
$item = <$filehandle>;
@list = <$filehandle>;
Data::Locations::Shell->reset();
$filehandle->reset();
Data::Locations::Shell->traverse(\&callback_function);
$filehandle->traverse(\&callback_function);
Data::Locations::Shell->delete();
$filehandle->delete();
$filehandle->tie('FILEHANDLE');
Note that you can ``tie()'' the same location to several file handles at the same time, hence the existence of the ``tie()'' method in this module as well.
Note further that once you did ``use Data::Locations::Shell;'' you can also use all the methods of the module ``Data::Locations'' (because ``Data::Locations'' is loaded implicitly and automatically by ``Data::Locations::Shell''), i.e., you can have ``Data::Locations'' and ``Data::Locations::Shell'' objects at the same time, but there is no way of converting an object of the class ``Data::Locations'' into one of the class ``Data::Locations::Shell''!
perl(1),
perldata(1), perlfunc(1),
perlsub(1), perlmod(1), perlref(1),
perlobj(1), perlbot(1), perltoot(1),
perltie(1), printf(3), sprintf(3).