I would like to build a module that will contain full paths to frequently used system commands (e.g., cp), so I could 'use' it in the beginning of my Perl scripts.
Has someone created such a module already (I couldn't find it on either CPAN or in google) ?
My (obviously flawed) attempt is as follows:
The (abbreviated) module:
And the testing script:$ cat LinuxCommandsPaths.pm package LinuxCommandsPaths ; use strict ; require Exporter; my @ISA = qw(Exporter); my @EXPORT_OK = qw( $cat $cleartool $chkconfig ) ; our $cat = '/bin/cat' ; our $cleartool = '/usr/atria/bin/cleartool' ; our $chkconfig = '/sbin/chkconfig' ; 1;
The problem, as you can see, is that I couldn't find the correct way to import the '$cat' variable so I could just write:#!/usr/bin/perl -iw # use LinuxCommandsPaths qw(:DEFAULT $cat $cleartool $chkconfig) ; my $cat=$LinuxCommandsPaths::cat ; print "\$cat == |$cat|\n"; __END__
but I have to have the horrid:print "$cat \n" ;
which defeats the whole idea of the module.my $cat=$LinuxCommandsPaths::cat ;
Any help would be appreciated.
Ron.
In reply to How to correctly import variables to a module ? by ronbarak
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |