Upgrade to Pro — share decks privately, control downloads, hide ads and more …

初めてのPerl

Sponsored · Your Podcast. Everywhere. Effortlessly. Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.

 初めてのPerl

Avatar for arvelt

arvelt

May 21, 2015
Tweet

More Decks by arvelt

Other Decks in Programming

Transcript

  1. 1-1.コード例 open(IN, 'perform.csv'); while(<IN>){ #改行除去、カンマ区切りで配列へ chomp ($_); my @data =

    split(/,/, $_); #クォーテーション除を for (my $i=0; $i<@data; $i++) { $data[$i] =~ s/(")+//g; } #値の取得 $value1 = $data[1]; $value2 = $data[2]; $value3 = $data[3]; } close(IN);
  2. 1-2.コード例 #------------------------------------------------------------------------- # Usage:command path [-r] # Usage:command path [--recursive]

    #------------------------------------------------------------------------- use Getopt::Long; #コマンドオプション my $opt_recursive = 0; #サブディレクトリを検索するかどうか GetOptions( 'recursive' => \$opt_recursive ); my $directory = $ARGV[0]; if ( ! $directory ) { print "No Args ! Usage:command PATH" ; exit(1); } searchDirectory( $directory ); #指定したディレクトリを走査する再帰処理
  3. 1-3.コード例 use Net::FTP; use Config::Tiny; my $config = Config::Tiny->new->read('setting.ini'); my

    $ftp=$config->{_}->{FTP_SERVER} ; my $ftp_id=$config->{_}->{FTP_ID } ; my $ftp_pass=$config->{_}->{FTP_PASS } ; my $ftp = Net::FTP->new($FTP_SERVER) or die "Cannot connect to $FTP_SERVER: $!"; $ftp->login( $ftp_id, $ftp_pass); # ログイン $ftp->put( $uploadfile ) ; # アップロード $ftp->quit;
  4. 1-4.コード例 use Win32::OLE qw(in with); use Win32::OLE::Const 'Microsoft Excel'; my

    $excel = Win32::OLE->GetActiveObject('Excel.Application') || Win32::OLE->new('Excel.Application', 'Quit') || die 'cannot get active excel! interupted.'; my $book = $excel->Workbooks->Open( 'test.xlsx' ) || die "no File. interupted. :$!"; # ファイルを開く my $sheet = $book->Worksheets( 'sheet1' ) || die 'No sheet! Interupted.'; #シートを取得する my $data = $sheet->Range("A1")->{Value} || die 'No ref. Interupted.'; print "$data\n"; #値を取得する #ブックを閉じる $book->Close(); #エクセルを閉じる $excel->quit();