Andrew_Levenson has asked for the wisdom of the Perl Monks concerning the following question:
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;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Making/Using a module.
by davidrw (Prior) on Mar 09, 2006 at 01:21 UTC | |
by Andrew_Levenson (Hermit) on Mar 09, 2006 at 01:26 UTC | |
by runrig (Abbot) on Mar 09, 2006 at 01:50 UTC | |
by Andrew_Levenson (Hermit) on Mar 09, 2006 at 01:55 UTC | |
by Andrew_Levenson (Hermit) on Mar 09, 2006 at 01:40 UTC | |
by davidrw (Prior) on Mar 09, 2006 at 02:41 UTC | |
by Andrew_Levenson (Hermit) on Mar 09, 2006 at 03:30 UTC | |
by TGI (Parson) on Mar 09, 2006 at 06:10 UTC | |
by Andrew_Levenson (Hermit) on Mar 09, 2006 at 03:13 UTC |