scot's Journal
http://use.perl.org/~scot/journal/
scot's use Perl Journalen-ususe Perl; is Copyright 1998-2006, Chris Nandor. Stories, comments, journals, and other submissions posted on use Perl; are Copyright their respective owners.2012-01-25T02:38:00+00:00pudgepudge@perl.orgTechnologyhourly11970-01-01T00:00+00:00scot's Journalhttp://use.perl.org/images/topics/useperl.gif
http://use.perl.org/~scot/journal/
Automated downloading of NOAA radar images
http://use.perl.org/~scot/journal/33516?from=rss
Inspired by <a href="http://perlmonks.org/?node_id=620033">Develop your own weather maps and alerts with Perl and GD</a>, I have put together a script which downloads the base radar image from a specific site at a specified interval.<blockquote><div><blockquote><div><p> <tt>use strict;<br>use LWP::Simple;<br>use POSIX;<br>my $refresh = 1800;<br>do {<br> my $base="http://radar.weather.gov/ridge/RadarImg/N0R/MTX_N0R_0.gif";<br>my $timestring = strftime( "%Y%m%d_%H%M%S", gmtime() );<br>my $savefilename = "SLCRadar_".$timestring.".gif"; my $status = getstore($base,$savefilename);<br>print $status."\n"<nobr> <wbr></nobr>;<br>sleep $refresh;<br> } while ($refresh);<br><blockquote></tt></p></div> </blockquote><p>See my <a href="http://perlmonks.org/?node_id=508209">Standard Code Disclaimer</a></p></div></blockquote>scot2007-06-13T21:47:15+00:00internetAutomated extraction of NOAA weather satellite images
http://use.perl.org/~scot/journal/33367?from=rss
<blockquote><div><p>NOAA updates its weather satellite images on the GOES website every 30 minutes, with images in infrared, visible light, and water vapor wavelengths; for both the eastern and western halves of the US. The script below grabs those images and saves them to a local file with a timestamp. Could prove useful for doing your own weather forecasting or whatever....I have updated the script to use the "strftime" function from the POSIX module,and the filenames now are very precise (for example "eastconusir20070530_074348.jpg"). I also updated the script to timestamp the images with Greenwich Mean Time...thanks to graff and jasonk over at Perlmonks for their feedback...</p></div></blockquote><blockquote><div><p> <tt>use strict;<br>use LWP::Simple;<br>use POSIX;<br> <br>my $image;<br>my $url;<br>my %images = (<br>"eastconusir" => "http://www.goes.noaa.gov/GIFS/ECIR.JPG",<br>"eastconusvis" => "http://www.goes.noaa.gov/GIFS/ECVS.JPG",<br>"eastconuswv" => "http://www.goes.noaa.gov/GIFS/ECWV.JPG",<br>"westconusir" => "http://www.goes.noaa.gov/GIFS/WCIR.JPG",<br>"westconusvis" => "http://www.goes.noaa.gov/GIFS/WCVS.JPG",<br>"westconusvwv" => "http://www.goes.noaa.gov/GIFS/WCWV.JPG",<br>);<br> <br>foreach my $key (keys %images) {<br>print $key."\n";<br>my $epoch = ( head( $images{$key} ) )[ 2 ] || next;<br>my $timestring = strftime( "%Y%m%d_%H%M%S", gmtime( $epoch ) );<br>print $timestring."\n";<br>print $images{$key}."\n";<br>my $status = getstore($images{$key},$key.$timestring.".jpg");<br>print $status."\n"<nobr> <wbr></nobr>;<br>};</tt></p></div> </blockquote>scot2007-05-29T22:45:27+00:00journalSun's Java Web Server superior to Apache?
http://use.perl.org/~scot/journal/33081?from=rss
<a href="http://serverwatch.com/">Serverwatch</a> has posted a review of Sun's Java Web Server which is very positive. My summary of the review is <a href="http://redcloudresearch.blogspot.com/2007/04/suns-java-web-server-superior-to-apache.html">here</a>.scot2007-04-23T18:42:03+00:00internetMethod for extracting urls for filetypes + auto-retrieval
http://use.perl.org/~scot/journal/32911?from=rss
<p> <a href="http://perlmonks.org/?node_id=559293">This post</a> reminded me of a problem which I have been trying to solve involving extracting URL's pointing to a specific filetype (say a gz archive) from a web page. It turns out that at <a href="http://cpan.org/">CPAN</a> there is a <a href="http://cpan.org/modules/01modules.index.html">page </a>which contains an alphabetical list of all modules, with a hyperlink to the tar.gz file of each module.</p><p>The following code (given appropriate substitution of the command line input; ie gz for pdf) will create a text file with all of the URL's for the tar.gz files:</p><blockquote><div><p> <tt>use strict;<br>use LWP::Simple;<br>use HTML::SimpleLinkExtor;<br>#usage getfileoftype http://www.example.com pdf > urllist.txt<br>my $url = shift;<br>my $filetype = shift;<br>my $filetypelen = length($filetype);<br>my $offset = -$filetypelen;<br>#print $filetypelen."\n";<br>#print $offset."\n";<br>my $fileget = getstore($url,"tempfile.html");<br>my $extor = HTML::SimpleLinkExtor->new(); $extor->parse_file("tempfile.html");<br>my @a_hrefs = $extor->a;<br>for my $element (@a_hrefs) {<br># print $element;<br># print "\n";<br>my $suffix = substr($element,$offset,$filetypelen);<br># print $suffix;<br># print "\n"; if ($suffix =~ m/$filetype/){<br>print $element;<br>print "\n";<br>}<br>}</tt></p></div> </blockquote><p>Once you have that, you can then use the following code to automatically download all of the modules if you so choose, or whatever subset of the modules you wish to extract from the text file created by the above code:</p><blockquote><div><p> <tt>use strict;<br>use LWP::Simple;<br>use File::Basename;<br>open (DATA, "urllist.txt") || die "File open failure!";<br>while (my $downloadurl = <DATA>){<br>(my $name, my $path, my $suffix) = fileparse($downloadurl);<br>my $finurl = $downloadurl;<br>print $finurl."\n";<br>my $savefilename = $name.$suffix;<br>print $savefilename;<br>print "\n";<br>my $status = getstore($finurl,$savefilename); print $status."\n"<br>}</tt></p></div> </blockquote><p>Both pieces of code work nicely on my WinXP box. Yes, I know that "tempfile.html" gets clobbered, but I was just glad to get this code working, and WinXP doesn't seem to care. In any case, one can now generate a local repository of modules. Suggestions for improvement in my code are welcome!</p>scot2007-04-04T22:51:12+00:00toolsuse.perl posts hit google quickly
http://use.perl.org/~scot/journal/32890?from=rss
use.perl posts frequently make it into the top hits of a google search.scot2007-04-03T19:11:12+00:00journalRemote computing with a Linux app server farm
http://use.perl.org/~scot/journal/32390?from=rss
IBM Developerworks writes up a <a href="http://www-128.ibm.com/developerworks/linux/library/l-server-farm.html">slick setup</a> at the University of California where they replaced Windows XP boxes with ITX Mini-boxes in a couple of computer labs and got positive feedback from the endusers plus significant cost savings.scot2007-02-13T16:44:01+00:00linuxScript to calculate digits of pi
http://use.perl.org/~scot/journal/32248?from=rss
Introducing my blog on Perl, <a href="http://redcloudresearch.blogspot.com/">Red Cloud Research</a>, with this <a href="http://redcloudresearch.blogspot.com/2007/01/calculate-digits-of-pi-gaussian.html">entry</a>.scot2007-01-24T21:31:51+00:00journalDev language poll
http://use.perl.org/~scot/journal/32123?from=rss
From <a href="http://www.ddj.com/dept/java/196600578">here:</a>
Developers Embrace Java, Drop Visual Basic<br> <br>
By Gregg Keizer<br> <br>
Use of Visual Basic has dropped 35% since the spring, says a poll of more than 430 North American developers done by research company Evans Data Corp.
Developers have abandoned Microsoft's Visual Basic in droves during the last six months, and they're using Java more than any other development language, according to a recently published survey.<br>
Use of Visual Basic has dropped 35% since the spring, says a poll of more than 430 North American developers done by research company Evans Data. "Microsoft has dominated languages since the early 90s, but we are seeing much more parity now," said John Andrews, president of Evans Data, in a statement. "The use of scripting languages, as well as Java, appears to have limited VB's future market potential."<br>
Developers aren't only leaving Visual Basic, they're also less likely to work in the Visual Basic.Net environment; VB.Net use is down 26%, the survey shows.<br>
Java now holds the top spot, with 45% of the polled developers saying they used Java during some part of the last six months. C/C++, meanwhile, was used by 40% of the coders, and C# was used by 32%.<br>
The survey also indicates that use of Ajax, short for Asynchronous JavaScript and XML, is up 10% since the spring 2006 poll, with 28% of the developers involved in Ajax-style Web interface development at some point during the last six months.scot2007-01-11T21:11:09+00:00news"A Java Front-End To CGI/Perl "
http://use.perl.org/~scot/journal/32106?from=rss
<p>Found this <a href="http://www.extropia.com/presentations/birznieks/JavaCGI/index.html">JavaCGI Bridge Presentation</a> which based on a cursory read looks like an alternative to AJAX. The gist is this:<br>
<br>
</p><p><div class="quote"><p>JavaCGIBridge Solution</p><p>
CGI/Perl advantages</p><p>
* CGI/Perl can provide database connectivity more easily<br>
* Application related "business-rules" are centrally maintained and executed in CGI/Perl scripts<br>
* Browsers that don't support Java can still use the application<br>
* Leverage existing "legacy" CGI/Perl code<br>
* Many Internet Service Providers only allow CGI/Perl access (no daemons)</p><p>
Java advantages</p><p>
* Java applet becomes a truly thin client<br>
- only requires GUI code and GUI logic<br>
- JavaCGIBridge class adds ~5k overhead<br>
- No need to learn the entire Java class library.<br>
- You can get by with AWT (Forms) and some utility classes<br>
* Java applet can maintain state between all CGI script calls<br>
* Java applet can cache retrieved data<br>
- eliminates the need to constantly get redundant data from the server</p></div><p>Check the date of the presentation: 1997<nobr> <wbr></nobr>:) !!</p>scot2007-01-09T18:48:28+00:00javaSimple extraction of links from web page
http://use.perl.org/~scot/journal/32052?from=rss
<p>It took me far longer than I thought it would to come up with this code that grabs a web page and stuffs all the page's hyperlinks into a text file.<br>
<br>Updated...</p><p><code><br>use strict;<br>use WWW::Mechanize;<br>#usage perl linkextractor.pl http://www.example.com/ > output.txt<br>
my $url = shift;<br>
my $mech = WWW::Mechanize->new();<br>
$mech->get($url);<br>
my $status=$mech->status();<br>
print $status." OK-URL request succeeded."."\n";<br>
my @links = $mech->links;<br>
print STDOUT ($_->url, $/) foreach $mech->links;</code></p>scot2007-01-02T21:35:02+00:00toolsSimple automated file retriever
http://use.perl.org/~scot/journal/32046?from=rss
<p>I whipped this together to grab web pages on a daily basis:</p><p><code><br>use strict;<br>use LWP::Simple;<br>use Time::localtime;<br>use File::Basename;</code></p><p><code>open (DATA, "urllist.txt") || die "File open failure!";<br>while (my $downloadurl = <DATA>){<br>
(my $name, my $path, my $suffix) = fileparse($downloadurl);<br>
my $finurl = $downloadurl;<br>
print $finurl."\n";<br>
my $lt = localtime();<br>
my $now_string = $lt->mon." ".$lt->mday;</code></p><p><code>
my $savefilename = $now_string.$name.$suffix;<br>
print $savefilename;<br>
print "\n";<br>
my $status = getstore($finurl,$savefilename);<br>
print $status."\n"<br>}</code></p>scot2007-01-02T18:27:24+00:00toolsJava + Perl = Good stuff
http://use.perl.org/~scot/journal/31992?from=rss
This <a href="http://www.perl.com/pub/a/2006/12/21/using-java-classes.html">article</a> is definitely worth a look. From the article: "The key to using JCR from Perl is Inline::Java. This library allows a Perl program to call Java methods with very little effort."scot2006-12-22T23:37:43+00:00javaToday's quote from St. Larry
http://use.perl.org/~scot/journal/31917?from=rss
Much as I hate to say it, the Computer Science view of language design
has gotten too inbred in recent years. The Computer Scientists should
pay more attention to the Linguists, who have a much better handle on
how people prefer to communicate. --Larry Wall<br> <br>
Amen!scot2006-12-14T18:17:37+00:00othersPugs-Perl6 on Windows is impressive
http://use.perl.org/~scot/journal/31916?from=rss
I've been meaning to take a look at Perl 6 and Pugs and found <a href="http://jnthn.net/perl6/">Jonathon Worthington's site</a>. Installing and running Perl6-Pugs on my Windows box from Jonathan's binary was astoundingly quick and easy. He's got a nice "Quick Start" tutorial as well. ++JW.scot2006-12-14T18:09:26+00:00perl6Review of "Perl in a Nutshell" 2nd edition
http://use.perl.org/~scot/journal/31901?from=rss
This journal entry is my working draft for eventually submitting a review as a story. My thesis is that this book is a solid addition for any Perl coder's bookshelf. Why?<br>
-someone with experience in another language could pick this book and be productive fairly quickly<br>
-plenty of useful code snippets<br>
-section with usage summary for all of the standard modules<br>
-sections on CGI gives you more than just what's in CGI.pm but form a good intro to CGI in general<br>
Book details<br>
Title: Perl in a Nutshell<br>
by
Stephen Spainhour, Ellen Siever, Nathan Patwardhan
Second Edition: June 2002<br>
Series: In a Nutshell<br>
ISBN 10: 0-596-00241-6<br>
ISBN 13: 9780596002411<br>
Pages: 760<br>
Current price at oreilly.com: $39.95scot2006-12-13T19:49:19+00:00booksThis site's daily Wall quote
http://use.perl.org/~scot/journal/31769?from=rss
This morning's quote from Larry got me chuckling: "Let's say the docs present a simplified view of reality...<nobr> <wbr></nobr>:-)". I created myself a little file to paste these quotes into for future enjoyment. Nice site feature!scot2006-11-30T16:15:34+00:00useperlSmart move by Sun Microsystems
http://use.perl.org/~scot/journal/31759?from=rss
The <a href="http://www2.sun.de/dc/forms/reg_us_2211_391.jsp">following </a> popped up on the Sun Developer Network RSS feed a few days ago:<br> <br>
"For a limited time, Sun is offering a free DVD media kit which includes the Solaris 10 Operating System for both SPARC and x86 platforms as well as Sun Studio 11 software.<br>
Take this opportunity to get familiar with the most advanced operating system on the planet and the tools which enable the highest optimizations and best runtime performance on the Solaris Operating System, bar-none.<br>
Sun Studio software provides optimizing C, C++ and Fortan compilers, visual performance tools, and high performance libraries to enhance your Solaris development environment."<br> <br>
The cost to Sun to distribute DVD's will be minimal compared to the potential increase in market share for/usage of Solaris. There's no question that Solaris has always been a rock-solid *nix, and if Sun can get the open source community using Solaris the benefits to Sun are obvious.scot2006-11-29T21:55:53+00:00unixEnterpriseDB-PostGreSQL rebranded
http://use.perl.org/~scot/journal/31758?from=rss
I stumbled onto the website of <a href="http://www.enterprisedb.com/">EnterpriseDB</a> which markets a product called EnterpriseDB which appears to be essentially a re-branded PostGreSQL. I will be very interested to see if CPAN modules targeted to PostGreSQL work out of the box with this database. Presumably, they would. My super search of Perlmonks.org turned up exactly zero references to EnterpriseDB, which was mildly surprising.<br> <br>
The biggest roadblock to more widespread adoption of PostGreSQL in my opinion has been its horrible name. Any branding or marketing consultant worth their salt would blanch in horror if a client suggested giving a product such a hard to spell, difficult to pronounce name. I don't know how any CIO could sell switching to PostGreSQL; you can just imagine the CEO saying "you want us to switch to Post-what? post-grrsklll? post grease-kill? Forget it."scot2006-11-29T19:47:15+00:00others