Perl で第一引数のファイルを取り出すルーチン の変更点 - アールメカブ

アールメカブ


Perl で第一引数のファイルを取り出すルーチン の変更点


Perl で第一引数のファイルを取り出すルーチン
// main
$input = &argcut($ARGV[0]);
//
Perl で第一引数のファイルを取り出すルーチンをパッケージ化


 #!/usr/bin/perl
 package ishida;

 sub argcut{
  my($file) = @_;
  if(-e $file){
    if($file =~ /(\w+)\.(\w+)$/){
      $newfile = $1.".csv";
    }
    else{x
      $newfile = $file.".csv";
    }
 
  
  }
  else {
    print "cant find $file\n";
  }
  return $newfile;
 }

呼出し側では

 #!/usr/bin/perl
 require "ishida.pl";
 $input = ishida::argcut($ARGV[0]);