Results 1 to 4 of 4
Code:
package file_handler_funcs;
sub legal($) {
my $file_name = shift;
$file_name =~ s/\s/\ /g;
$file_name =~ s/\(/\(/g;
$file_name =~ s/\)/\)/g;
$file_name =~ s/'/\'/g;
return ($file_name);
}
1;
Code:
#!/usr/bin/perl
use ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 06-24-2003 #1Linux User
- Join Date
- Apr 2003
- Location
- TEXAS
- Posts
- 314
Am I missing something in this code
Code:package file_handler_funcs; sub legal($) { my $file_name = shift; $file_name =~ s/\s/\\ /g; $file_name =~ s/\(/\\(/g; $file_name =~ s/\)/\\)/g; $file_name =~ s/'/\\'/g; return ($file_name); } 1;
this gives me a compile error saying legal doesnt exist.[/code]Code:#!/usr/bin/perl use file_handler_funcs; @dirs = `ls -lR $ARGV[0]`; $sum = 0; foreach $dir (@dirs) { chomp($dir); if($dir =~ /^-/) { @info = split /\s+/,$dir,9; $sum+=$info[4]; $file=legal($info[$#info]); print("$file\n"); } }The computer made me do it!! Slackware
and SUSE too Gig\'em WHOOOOP!!
\"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)
- 06-25-2003 #2Linux Engineer
- Join Date
- Jan 2003
- Location
- Lebanon, pa
- Posts
- 994
You must either add something like this to your module:
or call legal like this:Code:require Exporter; @ISA = qw(Exporter); @EXPORT = qw(legal);
Code:file_handler_funcs::legal
- 06-25-2003 #3Linux Engineer
- Join Date
- Jan 2003
- Location
- Lebanon, pa
- Posts
- 994
Oh yeah I forgot you call call it like this
BTW you might want to add my $self =shift; in your subs in your module since it passes the package name to it first.Code:file_handler_funcs->legal
- 06-25-2003 #4Linux User
- Join Date
- Apr 2003
- Location
- TEXAS
- Posts
- 314
thanx for the help
The computer made me do it!! Slackware
and SUSE too Gig\'em WHOOOOP!!
\"God put me on this earth to accomplish a certain amount of tasks, At the rate I\'m going I will never die.\" (I don\'t know)


Reply With Quote
