Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

Mwahahahaha! It can be done!

use 5.010; use Acme::UseStrict; use Acme::What; use Web::Magic; sub WHAT { 'use strict'; my @args = $_[0] =~ m{\w+}g; my $woeid = pop @args; $woeid = do { warn "If you want to know the weather $woeid, " . "define the YAHOO_WOEID environment variable. " . "Assuming you live where TOBYINK lives" unless exists $ENV{YAHOO_WOEID} && defined $ENV{YAHOO_WOEID}; ($ENV{YAHOO_WOEID} // 26191) } if $woeid =~ m{^(outside|here)$}i; my $unit = $^F==1 ? 'F' : 'C'; # if $^F == 2 then detect unit by locale. Belize and US use Fahren +heit. if ($^F > 1 and $ENV{LC_MEASUREMENT} =~ /^.._(US|BZ)/i) { $unit = 'F'; } my %opts = ( 'w' => $woeid, 'u' => lc $unit, ); my ($temperature) = Web::Magic -> new(q<http://weather.yahooapis.com/forecastrss>, %opts) -> findnodes('//yweather:condition/@temp') -> map(sub { $_->value }); return "$temperature $unit"; } local $^F = 1; my $temperature=what? (i mean outside); say "The temperature is $temperature";

In reply to Re: Measure temperature outside in Perl by tobyink
in thread Measure temperature outside in Perl by chessgui

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (9)
    As of 2014-10-01 19:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      What is your favourite meta-syntactic variable name?














      Results (38 votes), past polls