Thank you everyone for your responses. Sorry for my delayed response.

I've looked at your examples and I have tried a few different things.

I think I am going to go with a bit simpler approach looking at some other similar code, that so far in testing seems to be working for what I need.

# Remove leading url $icon =~ s/https:\/\/api.weather.gov\/icons\/land\///; # Split at / my @iconSplit = split(/\//, $icon); my $dayNight = $iconSplit[0]; # Split at ? to remove size info $icon = $iconSplit[1]; my @iconSplit2 = split(/\?/, $icon); $icon = $iconSplit2[0]; # Split at , for % of precip if present my @iconSplit3 = split(/\,/, $icon); $icon = $iconSplit3[0]; my $poP = $iconSplit3[1]; if (not defined $poP) { $poP = 0; # null } my %newIcons= ( 'skc' => "clear-day.png", 'few' => "partly-cloudy-day.png", 'sct' => "partly-cloudy-day.png", 'bkn' => "cloudy.png", 'ovc' => "cloudy.png", 'wind_skc' => "wind.png", 'wind_few' => "wind.png", 'wind_sct' => "wind.png", 'wind_bkn' => "wind.png", 'wind_ovc' => "wind.png", 'snow' => "snow.png", 'rain_snow' => "sleet.png", 'rain_sleet' => "sleet.png", 'snow_sleet' => "sleet.png", 'fzra' => "sleet.png", 'rain_fzra' => "sleet.png", 'snow_fzra' => "sleet.png", 'sleet' => "sleet.png", 'rain' => "rain.png", 'rain_showers' => "rain.png", 'rain_showers_hi' => "rain.png", 'tsra' => "thunderstorm.png", 'tsra_sct' => "thunderstorm.png", 'tsra_hi' => "thunderstorm.png", 'tornado' => "tornado.png", 'hurricane' => "thunderstorm.png", 'tropical_storm' => "thunderstorm.png", 'dust' => "fog.png", 'smoke' => "fog.png", 'haze' => "fog.png", 'hot' => "clear-day.png", 'cold' => "clear-day.png", 'blizzard' => "snow.png", 'fog' => "fog.png" ); $icon = $newIcons{$icon};

With DarkSky shutting down their API later this year, I need to move over to NWS API, and match current build parameters and icon sets as close as possible.

Then later I can go back and add more icons to the existing sets, and clean up some of the other smaller details that are changing because of this move.

Thanks again!


In reply to Re: Regex to Array lookup question by johnfl68
in thread Regex to Array lookup question by johnfl68

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.