所以我今天在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";
}
你能調用前添加打印$ id來反映並張貼在這裏它的輸出? – Himanshu
請將您的代碼直接粘貼到問題中,而不是發佈到像pastebin或prntscr.com這樣的外部服務。外部代碼可以隨時消失,並且不存在像SO問題那樣的版本控制。因此,未來的讀者可能無法看到外部代碼,因此這個問題將毫無用處或沒有多大意義。 ** StackOverflow與其他人一樣對未來的參考,因爲它是關於你今天得到你的問題的答案。** –
好吧,我會的,我很抱歉。我從來不知道這一點。 – user2524169