fivefiftyone has asked for the wisdom of the Perl Monks concerning the following question:
The desired result, when paired with the first part of the URL, would be XXXX-XXXX,XXXX-XXXX, not the XXXX-XXXXXXXX-XXXX I am left with.my $ref = $sth->fetchall_arrayref(); foreach my $result (@$ref) { $sn .= $result->[0]; } return $sn; $sth->finish(); $dbh->disconnect();
The LWP stuff itself will be simple. Running out of talent (or tutorials!) at a small hurdle like this is um, annoying :). A clue, a smack upside the head or a RTFM (please include a hyperlink) all welcome.#!/us/bin/perl + + + use strict; use warnings; use DBI; use LWP::UserAgent; sub get_serialno { my $dbh = DBI->connect("DBI:mysql:database=stuff;host=localhost", "w +oo", "hoo", {'RaiseError' => 1}) || die "Error: " . DBI->errstr; my $sth = $dbh->prepare("SELECT serialno FROM appliances"); $sth->execute(); my $sn; my $ref = $sth->fetchall_arrayref(); foreach my $result (@$ref) { $sn .= $result->[0]; } return $sn; $sth->finish(); $dbh->disconnect(); } my $asyncos = shift || die "Usage: imagefetch.pl <version number>-<bui +ld>\n"; my ($version, $build) = split /-/, $asyncos; (my $mversion = $version) =~ s/\./-/g; my $urlpart = "http://downloads.ironport.com/asyncos/upgrade/asyncos-$ +mversion.ipup?requested_version=phoebe-$mversion-$build&serial="; my $snpart = get_serialno; my $url = $urlpart . $snpart; print $url; print "\n\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Using join() on a MySQL arrayref
by jhourcle (Prior) on Jun 19, 2008 at 18:51 UTC | |
by fivefiftyone (Acolyte) on Jun 19, 2008 at 19:06 UTC |