すいません WWW::Mechanizeをつかってlivedoorブログに投稿テストを しようとしているのですが、投稿ページ中のテキストフィールド名が title,tagまではエラーが出ないのですが本文の部分のテキストフィールド名 でエラーが出てしまいます。(ソースコードを見た所bodyと言う名前だったと思います。) no such field 'body' at /Library/Perl/5.8.8/WWW/Mechanize.pm line 1371
open IN, "<mydata.dat"; my @words_arr; foreach (<IN>) { push( @words_arr, $_ ); } chomp @words_arr; print "Content-type: text/html\n\n"; for ( my $i = 0 ; $i < 3 ; $i++ ) { print $words_arr[ int( rand(30) ) ]; }
ソースはこんな感じです。。
315 :デフォルトの名無しさん[sage]:2008/07/26(土) 18:32:59
>>314 open IN, "./mydata.dat" or die $!; chomp(my @words_arr = <IN>); print "Content-type: text/html\n\n"; print $words_arr[int(rand 30)] . " " for 1..3;
insert into Person (Id,Name) values ('1', '○○'); insert into Person (Id,Name) values ('2', '▲▲'); insert into Person (Id,Name) values ('3', '□□'); insert into Person (Id,Name) values ('4', '田中');
% perl -w -e '$a{$ika} = {}' Name "main::a" used only once: possible typo at -e line 1. Name "main::ika" used only once: possible typo at -e line 1. Use of uninitialized value $ika in hash element at -e line 1.
【文字列A'】 this is test of 0x48,0x65,0x6C,0x6C,0x6F,0x2C,0x77,0x6F,0x72,0x6C,0x64,0x21
ご多忙の中、誠に失礼いたしますが、ご教授お願いします。
602 :デフォルトの名無しさん[sage]:2008/08/01(金) 18:01:28
sub transform { my ($str) = @_; $str =~ s/"([^"]*)"/join(",",map{sprintf"0x%X",$_}unpack"C*",$1)/eg; $str; } print transform 'this is test of "Hello, World!"'
http://www.cpan.org/src/README.html > The first releases in each branch > Released > 5.10 December 2007 > 5.8 July 2002 > 5.6 March 2000 > 5.5 July 1998 > 5.4 May 1997
open(IN, '<After') or die "file open error: $!"; open(OUT, '<Before') or die "file open error: $!"; while( <IN> ){ @a = split(/,/, $_); @b = split(/,/, <OUT>); for($i =0; $i<13; $i++){ if ( $a[0] ne $b[$i] ){ print OUT "$a[$i]\t" } } print "\n"; }
for my $file ("更新前.csv", "更新用情報.csv") { open my $fh, "<", $file or die $!; while (my $line = readline $fh) { chomp $line; my ($id, @data) = split /,/, $line; $data{$id} = \@data; } close $fh; } { local $\ = "\n"; local $, = ","; open my $fh, ">", "更新後.csv" or die $!; while (my ($id, $data) = each(%data)) { print $fh $id, @$data; } close $fh; }
use utf8; use open IO => ":encoding(cp932)"; binmode STDIN => ":encoding(cp932)"; binmode STDOUT => ":encoding(cp932)"; binmode STDERR => ":encoding(cp932)"; use Encode;
use feature qw( :5.10 ); $|=1; #---------------------------------- say "スライムが現われた!";
857 :デフォルトの名無しさん[sage]:2008/08/07(木) 03:58:23
あれ? Perlはswitch caseでなくて、 given whenになるの?
858 :デフォルトの名無しさん[sage]:2008/08/07(木) 04:28:52
use warnings; use strict;
use utf8; use open IO => ":encoding(cp932)"; binmode STDIN => ":encoding(cp932)"; binmode STDOUT => ":encoding(cp932)"; binmode STDERR => ":encoding(cp932)"; use Encode;
use feature qw( :5.10 ); $|=1; #---------------------------------- my $foo;
given ($foo) {
when (/^abc/) { my $abc = 1; } when (/^def/) { my $def = 1; } when (/^xyz/) { my $xyz = 1; } default { my $nothing = 1; } }
↑これを実行すると、 Use of uninitialized value $_ in pattern match (m//) at untitled2.pl line 18. Use of uninitialized value $_ in pattern match (m//) at untitled2.pl line 19. Use of uninitialized value $_ in pattern match (m//) at untitled2.pl line 20. といわれます。$-の初期化なんてどうすればいいの?
>>875 >>857 に対しては有効だと思います。いわゆる switch を Perl で実現する構文についての説明そのもので、それが given () { when () {} } であること及びその詳細が明記されています。 >>858 に対しても同様で、"given(EXPR)" will assign the value of EXPR to $_ within the lexical scope of the block, から始まる部分に警告内容に関わる動作仕様について述べられています。 うまくいけば参考にして解決できますし、よしんば解決に至らなかったとしても、perldoc を引く練習にはなるはずです。 役に立っていてくれるとうれしいです。
以下のようにスレッドとネットワークの実験をしていたところ躓きました。port1にtelnetで接続後、port2に接続しても望んだ動作(接続後コマンド画面にすぐ戻る)をしません。どこを書き直せば良いのでしょうか。ご教授下さい。 use strict; use warnings; use threads; use IO::Socket; use IO::Select;
my $port1 = 7000; my $port2 = 7001;
my $sock1 = IO::Socket::INET->new(LocalPort => $port1, Listen => SOMAXCONN, Proto => 'tcp', Reuse => 1,); my $sock2 = IO::Socket::INET->new(LocalPort => $port2, Listen => SOMAXCONN, Proto => 'tcp', Reuse => 1,);
my $selecter = IO::Select->new; $selecter->add($sock1); $selecter->add($sock2);
910 :909の続きです[sage]:2008/08/08(金) 21:57:50
while( 1 ) { my ($active_socks) = IO::Select->select($selecter,undef,undef,undef);