And here is my 'module':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;
Thanks in advance.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;
In reply to Making/Using a module. by Andrew_Levenson
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |