I just got done with this sort of thing. It looks like this.
my ($url, @rest, $url_rec, @url_keys);
($url, @rest)=split /\|/,$_;
if($#rest == 3) # We're re-building.
{
@url_keys= qw{url_last_checked_return_code url_cat_id url_descriptio
+n url_last_checked};
}
if($#rest == 1) # We're adding.
{
@url_keys = qw{url_cat_id url_description};
}
foreach my $key (@url_keys) {
$url_rec->{$key} = pop @rest;
}
I know that someone above adept-level could have done this more elegantly efficiently, but it works...so far. ;-)
kevin
Originally posted as a Categorized Answer. |