perl
use strict; use warnings; sub openfile { my ($file_obj) = @_; open(FH,$file_obj); my @list = <FH>; return @list; } sub file_list { my @file_list = glob "*.txt"; return @file_list; } sub reg { my (@line,$fname) = @_; my $text; foreach my $i(@li</fh>…
以下を書いたらすごくよくわかった。 #!/usr/bin/perl my $reflist = [1,2,3]; my $reflist2 = $reflist; $reflist2->[0] = 0; print($reflist->[0]);#0 print('\n'); my @list = (1,2,3); my @list2 = @list; $list2[0] = 0; print($list[0]);#1 リファレン…
いまさらながら、perl -cw プログラムファイルと書くらしい。 これでプログラムの実行前に文法間違いがないかをチェックできる。 あとはMakefile.PLの書き方もよくわからない。 perlっていろいろ作法があるけど、 まとまった解説はどこを見たらいいんだろう。…
あー!ってなるけど、 まずは落ち着いて以下のことをチェックする。
#!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; package Tshop; sub new{ my $class = shift; my $self = {}; bless $self,$class; } sub shopname{ my $self = shift; my $cont = shift; my @list = $cont =~ /<h2><a\s.*>.*<\/a><\/h2>/g; my $data </a\s.*></h2>…
こんな感じ。 use warnings; use strict; open(FI,"ls|")||die; my @s = <FI>; close(FI); my $arg = $ARGV[0]; foreach my $i(@s){ chop($i); if($i =~ /$arg/){ print "$i.\n"; } } ユーザーとかプロセス見たりとか、 システム管理に使えるかも。 でもrmとかし</fi>…
my $num = [1,2,3]; print($num->[0]); my @num2 = (1,2,3); print($num2[0]); 上が配列のリファレンス、下が配列。 これって何が違うんだ。 アドレスを取得してるかどうかしかわかんないけど、 ほかに違いがあるのかな。 どっちがいいんだろうねー。
Perl doesn't reflect that I want to make dir and set permission. If I write like this mkdir('dir', 0777); but this way will be setting 755. How to solve this problem↓http://perl.g.hatena.ne.jp/Cress/20080611/1213184541 umask(0); mkdir('dir…
Post.pm package Post; use strict; use warnings; sub new{ my $class = shift; my $word = shift; return bless {'word'=>$word},$class; } sub wri{ my ($self,$arg) = @_; print $arg; } sub loop{ my $self = shift; for(my $i=0;$i<10;$i++){ print "$…
This is too awful code >
This script behaves like cat command. You input something file. And it will display list of files. use strict; use warnings; my $somefile = $ARGV[0]; sub read_dir { my $sef = shift; my @list; $sef =~/\./ || die "no dott!!\n"; opendir(DIR,'…
I wrote script to crawl web site by perl. It would collect A tag of html and repeat access in site to move another web site. But I can not understand reflexive, so it is inefficient. I have the second time to write perl script. This script…
I wrote perl for the first time. This is analyze logs of urchin if you input IP address what would know user action Result is url, it was seen pages and all of pages which user has seen it. Perl is useful when I have to spot job. Please yo…