【发布时间】:2013-08-17 12:07:42
【问题描述】:
所以我今天用 perl 制作了这个小脚本。
由于某种原因,它似乎没有下载任何东西,并且不断弹出错误提示
Use of uninitialized value $id in concatenation (.) or string at room.pl line 18.
Use of uninitialized value $id in concatenation (.) or string at room.pl line 18.
有人可以帮我修复此代码吗?
也正在使用 File::Path 好吗?这是 json http://media1.clubpenguin.com/play/en/web_service/game_configs/rooms.json
use strict;
use warnings;
use File::Path;
mkpath "rooms/";
use JSON;
use LWP::Simple qw(mirror);
open FILE, 'rooms.json' or die "Could not open file inputfile: $!";
sysread(FILE, my $result, -s FILE);
close FILE or die "Could not close file: $!";
my $json = decode_json($result);
foreach $item ($json) {
my $id = $item->{room_key};
mirror "http://media1.clubpenguin.com/play/v2/content/global/rooms/$id.swf" => "rooms/$id.swf";
}
【问题讨论】:
-
你可以在调用 mirror 之前添加一个 print $id 并在这里发布它的输出吗?
-
请将您的代码直接粘贴到问题中,而不是发布到 pastebin 或 prntscr.com 等外部服务。外部代码可以随时消失,并且没有像 SO 问题那样对其进行版本控制。因此,未来的读者可能无法看到外部代码,因此这个问题将毫无用处或没有多大意义。 StackOverflow 既关乎他人的未来参考,也关乎您今天的问题得到解答。
-
好的,我会的,对不起。我从来不知道。