I was told that to create a routine that any program can use, I need to make a module, so I tried my hand at that. But for the life of my, I can't get it to work. Can anyone glance over my scripts to tell me what it is i'm doing wrong?
This is the script:
use strict;
use warnings;
my @file;
my $file1;
my $file2;
print "Please enter the name of the file to copy.\n";
use FileNamePrep qw(&func1);
open FILE, "<$file1";
while(<FILE>){
push @file, $_;
}
close FILE;
print "\nPlease enter the name of the copy destination.\n";
use FileNamePrep qw(&func2);
if($file2 eq "\n"){
$file2='C:\Documents and Settings\Copy Destination.txt';
print "\nIf you did not give a destination, your new file
will be found under C:\ Documents and Settings, with the name Copy
Destination.txt\n";
}
open LOG, ">$file2";
print LOG @file;
close LOG;
And here is my 'module':
package FileNamePrep;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 0.1;
@ISA = qw(Exporter);
@EXPORT = ();
@EXPORT_OK = qw(func1 func2);
%EXPORT_TAGS = ( DEFAULT => [qw(&func1)],
Both => [qw(&func1 &func2)]);
sub func1 {
for(my $file1=<>){
chomp($file1);
if(m/\"/){
chop($file1);
$file1=reverse($file1);
chop($file1);
$file1=reverse($file1);
}
}
}
sub func2 {
for(my $file2=<>){
chomp($file2);
if(m/\"/){
chop($file2);
$file2=reverse($file2);
chop($file2);
$file2=reverse($file2);
}
}
}
1;
Thanks in advance.