#!/bin/perl
# lib_url.pl
# AIM: Load a URL file into a line array, return line count
use strict;
use warnings;
use LWP::Simple;

## my $url = "http://static.fgx.ch/js/OpenLayers-2.12/theme/default/style.css";
## sub prt($) { print shift; }

sub fetch_url($$$) {
	my ($url,$ra,$dbg) = @_;
    my $ret = 0;
	prt( "Fetching: $url\n" ) if ($dbg & 0x01);
	my $txt = get($url);
	if ($txt && length($txt)) {
		# prt( "$txt\n" );
        @{$ra} = split("\n",$txt);
        $ret = scalar @{$ra};
    } else {
        prt("URL: $url FAILED!\n");
    }
    return $ret;
}

## my @arr = ();
## my $cnt = fetch_url($url,\@arr);
# prt("Got $cnt lines...\n");

1;
# eof
