用perl从文本中获取部分内容

时间:2013-04-07 09:50:42

标签: json perl

我怎么能用perl从这个文本中获取一些内容......我认为它的解码json ...现在我需要以此为例:

星期日

阴天下午有可能下雨。高达18C。凉风习习。东北风速为10至20公里/小时。下雨的几率为50%。“

{
    "response": {
        "version": "0.1"
        ,"termsofService": "http://www.wunderground.com/weather/api/d/terms.html"
        ,"features": {
        "forecast10day": 1
        }
    }
        ,
    "forecast":{
        "txt_forecast": {
        "date":"2:00 PM CEST",
        "forecastday": [
        {
        "period":0,
        "icon":"chancerain",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif",
        "title":"Sunday",
        "fcttext":"Overcast with a chance of rain in the afternoon. High of 64F. Winds from the NE at 5 to 15 mph. Chance of rain 50%.",
        "fcttext_metric":"Overcast with a chance of rain in the afternoon. High of 18C. Breezy. Winds from the NE at 10 to 20 km/h. Chance of rain 50%.",
        "pop":"50"
        }
        ,
        {
        "period":1,
        "icon":"chancerain",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif",
        "title":"Sunday Night",
        "fcttext":"Overcast with a chance of rain. Low of 50F. Winds from the NNE at 5 to 10 mph. Chance of rain 50%.",
        "fcttext_metric":"Overcast with a chance of rain. Low of 10C. Winds from the NNE at 10 to 15 km/h. Chance of rain 50%.",
        "pop":"50"
        }
        ,
        {
        "period":2,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Monday",
        "fcttext":"Partly cloudy with a chance of rain. High of 64F. Winds from the SE at 5 to 10 mph. Chance of rain 20%.",
        "fcttext_metric":"Partly cloudy with a chance of rain. High of 18C. Winds from the SE at 10 to 15 km/h.",
        "pop":"20"
        }
        ,
        {
        "period":3,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Monday Night",
        "fcttext":"Partly cloudy with a chance of rain after midnight. Low of 48F. Winds less than 5 mph.",
        "fcttext_metric":"Partly cloudy with a chance of rain after midnight. Low of 9C. Winds less than 5 km/h.",
        "pop":"20"
        }
        ,
        {
        "period":4,
        "icon":"chancerain",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif",
        "title":"Tuesday",
        "fcttext":"Overcast with a chance of rain. High of 59F. Winds from the SSE at 5 to 10 mph. Chance of rain 70%.",
        "fcttext_metric":"Overcast with a chance of rain. High of 15C. Winds from the SSE at 10 to 15 km/h. Chance of rain 70%.",
        "pop":"70"
        }
        ,
        {
        "period":5,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Tuesday Night",
        "fcttext":"Partly cloudy. Low of 48F. Winds less than 5 mph.",
        "fcttext_metric":"Partly cloudy. Low of 9C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":6,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Wednesday",
        "fcttext":"Partly cloudy. High of 63F. Winds from the South at 5 to 10 mph.",
        "fcttext_metric":"Partly cloudy. High of 17C. Winds from the South at 5 to 15 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":7,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Wednesday Night",
        "fcttext":"Partly cloudy. Low of 46F. Winds less than 5 mph.",
        "fcttext_metric":"Partly cloudy. Low of 8C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":8,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Thursday",
        "fcttext":"Partly cloudy. High of 66F. Winds from the SSE at 5 to 10 mph.",
        "fcttext_metric":"Partly cloudy. High of 19C. Winds from the SSE at 10 to 15 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":9,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Thursday Night",
        "fcttext":"Partly cloudy. Low of 52F. Winds less than 5 mph.",
        "fcttext_metric":"Partly cloudy. Low of 11C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":10,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Friday",
        "fcttext":"Partly cloudy. High of 66F. Winds from the SSE at 5 to 10 mph.",
        "fcttext_metric":"Partly cloudy. High of 19C. Winds from the SSE at 10 to 15 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":11,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Friday Night",
        "fcttext":"Partly cloudy. Low of 48F. Winds less than 5 mph.",
        "fcttext_metric":"Partly cloudy. Low of 9C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":12,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Saturday",
        "fcttext":"Clear. High of 66F. Winds from the South at 5 to 10 mph.",
        "fcttext_metric":"Clear. High of 19C. Winds from the South at 10 to 15 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":13,
        "icon":"clear",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif",
        "title":"Saturday Night",
        "fcttext":"Clear. Low of 50F. Winds less than 5 mph.",
        "fcttext_metric":"Clear. Low of 10C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":14,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Sunday",
        "fcttext":"Clear. High of 66F. Winds less than 5 mph.",
        "fcttext_metric":"Clear. High of 19C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":15,
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "title":"Sunday Night",
        "fcttext":"Partly cloudy. Low of 52F. Winds less than 5 mph.",
        "fcttext_metric":"Partly cloudy. Low of 11C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":16,
        "icon":"clear",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif",
        "title":"Monday",
        "fcttext":"Clear. High of 68F. Winds less than 5 mph.",
        "fcttext_metric":"Clear. High of 20C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":17,
        "icon":"clear",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif",
        "title":"Monday Night",
        "fcttext":"Clear. Low of 52F. Winds less than 5 mph.",
        "fcttext_metric":"Clear. Low of 11C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":18,
        "icon":"mostlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif",
        "title":"Tuesday",
        "fcttext":"Mostly cloudy. High of 68F. Winds less than 5 mph.",
        "fcttext_metric":"Mostly cloudy. High of 20C. Winds less than 5 km/h.",
        "pop":"0"
        }
        ,
        {
        "period":19,
        "icon":"chancerain",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif",
        "title":"Tuesday Night",
        "fcttext":"Mostly cloudy with a chance of rain. Low of 52F. Winds less than 5 mph. Chance of rain 30%.",
        "fcttext_metric":"Mostly cloudy with a chance of rain. Low of 11C. Winds less than 5 km/h. Chance of rain 30%.",
        "pop":"30"
        }
        ]
        },
        "simpleforecast": {
        "forecastday": [
        {"date":{
    "epoch":"1365368400",
    "pretty":"11:00 PM CEST on April 07, 2013",
    "day":7,
    "month":4,
    "year":2013,
    "yday":96,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Sun",
    "weekday":"Sunday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":1,
        "high": {
        "fahrenheit":"64",
        "celsius":"18"
        },
        "low": {
        "fahrenheit":"50",
        "celsius":"10"
        },
        "conditions":"Chance of Rain",
        "icon":"chancerain",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif",
        "skyicon":"cloudy",
        "pop":50,
        "qpf_allday": {
        "in": 0.08,
        "mm": 2.0
        },
        "qpf_day": {
        "in": 0.04,
        "mm": 1.0
        },
        "qpf_night": {
        "in": 0.06,
        "mm": 1.5
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 11,
        "kph": 18,
        "dir": "NE",
        "degrees": 38
        },
        "avewind": {
        "mph": 8,
        "kph": 13,
        "dir": "NE",
        "degrees": 44
        },
        "avehumidity": 55,
        "maxhumidity": 67,
        "minhumidity": 46
        }
        ,
        {"date":{
    "epoch":"1365454800",
    "pretty":"11:00 PM CEST on April 08, 2013",
    "day":8,
    "month":4,
    "year":2013,
    "yday":97,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Mon",
    "weekday":"Monday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":2,
        "high": {
        "fahrenheit":"64",
        "celsius":"18"
        },
        "low": {
        "fahrenheit":"48",
        "celsius":"9"
        },
        "conditions":"Chance of Rain",
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "skyicon":"partlycloudy",
        "pop":20,
        "qpf_allday": {
        "in": 0.04,
        "mm": 1.0
        },
        "qpf_day": {
        "in": 0.01,
        "mm": 0.3
        },
        "qpf_night": {
        "in": 0.04,
        "mm": 1.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 8,
        "kph": 13,
        "dir": "NNE",
        "degrees": 32
        },
        "avewind": {
        "mph": 5,
        "kph": 8,
        "dir": "South",
        "degrees": 182
        },
        "avehumidity": 60,
        "maxhumidity": 69,
        "minhumidity": 42
        }
        ,
        {"date":{
    "epoch":"1365541200",
    "pretty":"11:00 PM CEST on April 09, 2013",
    "day":9,
    "month":4,
    "year":2013,
    "yday":98,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Tue",
    "weekday":"Tuesday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":3,
        "high": {
        "fahrenheit":"59",
        "celsius":"15"
        },
        "low": {
        "fahrenheit":"48",
        "celsius":"9"
        },
        "conditions":"Chance of Rain",
        "icon":"chancerain",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/chancerain.gif",
        "skyicon":"cloudy",
        "pop":70,
        "qpf_allday": {
        "in": 0.20,
        "mm": 5.1
        },
        "qpf_day": {
        "in": 0.17,
        "mm": 4.3
        },
        "qpf_night": {
        "in": 0.00,
        "mm": 0.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 7,
        "kph": 11,
        "dir": "South",
        "degrees": 171
        },
        "avewind": {
        "mph": 4,
        "kph": 6,
        "dir": "South",
        "degrees": 172
        },
        "avehumidity": 60,
        "maxhumidity": 67,
        "minhumidity": 56
        }
        ,
        {"date":{
    "epoch":"1365627600",
    "pretty":"11:00 PM CEST on April 10, 2013",
    "day":10,
    "month":4,
    "year":2013,
    "yday":99,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Wed",
    "weekday":"Wednesday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":4,
        "high": {
        "fahrenheit":"63",
        "celsius":"17"
        },
        "low": {
        "fahrenheit":"46",
        "celsius":"8"
        },
        "conditions":"Partly Cloudy",
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "skyicon":"partlycloudy",
        "pop":0,
        "qpf_allday": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_day": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_night": {
        "in": 0.00,
        "mm": 0.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 7,
        "kph": 11,
        "dir": "SW",
        "degrees": 219
        },
        "avewind": {
        "mph": 5,
        "kph": 8,
        "dir": "SSW",
        "degrees": 195
        },
        "avehumidity": 60,
        "maxhumidity": 66,
        "minhumidity": 51
        }
        ,
        {"date":{
    "epoch":"1365714000",
    "pretty":"11:00 PM CEST on April 11, 2013",
    "day":11,
    "month":4,
    "year":2013,
    "yday":100,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Thu",
    "weekday":"Thursday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":5,
        "high": {
        "fahrenheit":"66",
        "celsius":"19"
        },
        "low": {
        "fahrenheit":"52",
        "celsius":"11"
        },
        "conditions":"Partly Cloudy",
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "skyicon":"partlycloudy",
        "pop":0,
        "qpf_allday": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_day": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_night": {
        "in": 0.00,
        "mm": 0.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 8,
        "kph": 13,
        "dir": "South",
        "degrees": 187
        },
        "avewind": {
        "mph": 6,
        "kph": 10,
        "dir": "South",
        "degrees": 175
        },
        "avehumidity": 61,
        "maxhumidity": 66,
        "minhumidity": 47
        }
        ,
        {"date":{
    "epoch":"1365800400",
    "pretty":"11:00 PM CEST on April 12, 2013",
    "day":12,
    "month":4,
    "year":2013,
    "yday":101,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Fri",
    "weekday":"Friday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":6,
        "high": {
        "fahrenheit":"66",
        "celsius":"19"
        },
        "low": {
        "fahrenheit":"48",
        "celsius":"9"
        },
        "conditions":"Partly Cloudy",
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "skyicon":"partlycloudy",
        "pop":0,
        "qpf_allday": {
        "in": 0.01,
        "mm": 0.3
        },
        "qpf_day": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_night": {
        "in": 0.01,
        "mm": 0.3
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 8,
        "kph": 13,
        "dir": "South",
        "degrees": 182
        },
        "avewind": {
        "mph": 6,
        "kph": 10,
        "dir": "South",
        "degrees": 172
        },
        "avehumidity": 72,
        "maxhumidity": 85,
        "minhumidity": 50
        }
        ,
        {"date":{
    "epoch":"1365886800",
    "pretty":"11:00 PM CEST on April 13, 2013",
    "day":13,
    "month":4,
    "year":2013,
    "yday":102,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Sat",
    "weekday":"Saturday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":7,
        "high": {
        "fahrenheit":"66",
        "celsius":"19"
        },
        "low": {
        "fahrenheit":"50",
        "celsius":"10"
        },
        "conditions":"Partly Cloudy",
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "skyicon":"mostlysunny",
        "pop":0,
        "qpf_allday": {
        "in": 0.01,
        "mm": 0.3
        },
        "qpf_day": {
        "in": 0.01,
        "mm": 0.3
        },
        "qpf_night": {
        "in": 0.00,
        "mm": 0.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 8,
        "kph": 13,
        "dir": "South",
        "degrees": 181
        },
        "avewind": {
        "mph": 6,
        "kph": 10,
        "dir": "South",
        "degrees": 188
        },
        "avehumidity": 66,
        "maxhumidity": 82,
        "minhumidity": 61
        }
        ,
        {"date":{
    "epoch":"1365973200",
    "pretty":"11:00 PM CEST on April 14, 2013",
    "day":14,
    "month":4,
    "year":2013,
    "yday":103,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Sun",
    "weekday":"Sunday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":8,
        "high": {
        "fahrenheit":"66",
        "celsius":"19"
        },
        "low": {
        "fahrenheit":"52",
        "celsius":"11"
        },
        "conditions":"Partly Cloudy",
        "icon":"partlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/partlycloudy.gif",
        "skyicon":"sunny",
        "pop":0,
        "qpf_allday": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_day": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_night": {
        "in": 0.00,
        "mm": 0.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 6,
        "kph": 10,
        "dir": "SW",
        "degrees": 232
        },
        "avewind": {
        "mph": 2,
        "kph": 3,
        "dir": "SW",
        "degrees": 236
        },
        "avehumidity": 61,
        "maxhumidity": 69,
        "minhumidity": 44
        }
        ,
        {"date":{
    "epoch":"1366059600",
    "pretty":"11:00 PM CEST on April 15, 2013",
    "day":15,
    "month":4,
    "year":2013,
    "yday":104,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Mon",
    "weekday":"Monday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":9,
        "high": {
        "fahrenheit":"68",
        "celsius":"20"
        },
        "low": {
        "fahrenheit":"52",
        "celsius":"11"
        },
        "conditions":"Clear",
        "icon":"clear",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/clear.gif",
        "skyicon":"sunny",
        "pop":0,
        "qpf_allday": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_day": {
        "in": 0.00,
        "mm": 0.0
        },
        "qpf_night": {
        "in": 0.00,
        "mm": 0.0
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 4,
        "kph": 6,
        "dir": "East",
        "degrees": 81
        },
        "avewind": {
        "mph": 2,
        "kph": 3,
        "dir": "South",
        "degrees": 172
        },
        "avehumidity": 65,
        "maxhumidity": 75,
        "minhumidity": 53
        }
        ,
        {"date":{
    "epoch":"1366146000",
    "pretty":"11:00 PM CEST on April 16, 2013",
    "day":16,
    "month":4,
    "year":2013,
    "yday":105,
    "hour":23,
    "min":"00",
    "sec":0,
    "isdst":"1",
    "monthname":"April",
    "weekday_short":"Tue",
    "weekday":"Tuesday",
    "ampm":"PM",
    "tz_short":"CEST",
    "tz_long":"Europe/Belgrade"
},
        "period":10,
        "high": {
        "fahrenheit":"68",
        "celsius":"20"
        },
        "low": {
        "fahrenheit":"52",
        "celsius":"11"
        },
        "conditions":"Mostly Cloudy",
        "icon":"mostlycloudy",
        "icon_url":"http://icons-ak.wxug.com/i/c/k/mostlycloudy.gif",
        "skyicon":"mostlycloudy",
        "pop":0,
        "qpf_allday": {
        "in": 0.09,
        "mm": 2.3
        },
        "qpf_day": {
        "in": 0.01,
        "mm": 0.3
        },
        "qpf_night": {
        "in": 0.15,
        "mm": 3.8
        },
        "snow_allday": {
        "in": 0,
        "cm": 0
        },
        "snow_day": {
        "in": 0,
        "cm": 0
        },
        "snow_night": {
        "in": 0,
        "cm": 0
        },
        "maxwind": {
        "mph": 5,
        "kph": 8,
        "dir": "SSW",
        "degrees": 193
        },
        "avewind": {
        "mph": 4,
        "kph": 6,
        "dir": "South",
        "degrees": 174
        },
        "avehumidity": 69,
        "maxhumidity": 77,
        "minhumidity": 56
        }
        ]
        }
    }
}

1 个答案:

答案 0 :(得分:1)

您可以轻松使用JSON模块将此字符串加载到perl哈希引用中:

use JSON qw( decode_json );

my $jsonString = "{ ... }"; #Your JSON string
my $decoded = decode_json($jsonString);

现在$ decoding变量包含哈希和数组形式的数据。 您可以轻松访问'sunday',例如:

say $decoded->{forecast}{txt_forecast}{forecastday}[0]{title};  #will print'sunday'

say $decoded->{forecast}{txt_forecast}{forecastday}[0]{"fcttext"}; #will return sunday's weather text