Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ARGV syntax issue 2

Status
Not open for further replies.

vbrookslv

ISP
Joined
Apr 18, 2005
Messages
2
Location
US
Greetings Perl Pro's,

I am an long time admin, but a novice when it comes to Perl. I have a canned script from a CC auth provider, and am trying to modify it to make it a bit more useful. Below is the sample code, (sanitized, of course). I'm sure I just need a quote somewhere or something. I have googled my brains out trying to find a sample of something that looks like this that I could learn from, but I am just coming up empty. I really do plan on sitting down with a good book one day and learning Perl.. I just have too many things on my plate right now. :) Anyway, any suggestions would be much appreciated.

# This script is the second half of a two-parter.
# The first script uploads credit card info (over SSL, of course)
# to the processor. This second script will then retrieve the
# results of the batch, using the batchId provided as output
# from the first script. The default script has you putting the
# batchId into the actual code. While this would work, it just
# doesn't seem quite as clean as it should be. In intend to
# tie these scripts to an internally developed application,
# written in another language. That app will just call the
# first script for processing, pick up the output, then call
# this second script to get the results of the batch.

require HTTP::Request;
require LWP::UserAgent;
use HTTP::Request::Common;




$ua = LWP::UserAgent->new;
$url = '$url .= 'echo_id=<your_merchant_id_here>&';
$url .= 'merchant_pin=<your_merchant_pin_here>&';
$url .= 'batchId=<batch_number_to_retrieve_here>';
#$url .= 'batchId=$ARGV[0]'; #This is what I was attempting instead, with no luck
$response = $ua->request((GET $url), 'results.txt');
if ($response->is_success)
{
print $response->content;
}
else
{
print $response->error_as_HTML;
}
print "Command-line arguments: @ARGV"; #I added this line to prove that the ARGV is getting populated properly
 
Try that line using double quotes rather than single ones. Single quotes don't interpolate variables, so your $url would be, literally, `batchId=$ARGV[0]'. If you use double quotes instead, it'll replace $ARGV[0] with the first command-line argument.

See this link for a quick article on different types of quoting in Perl.
 
If I understand you correctly, the script does not run?
Put a '#' at the start of each line.
Remove them one at a time and run the script after each removal.
Good Luck

Keith
 
audiopro,

I should have been more clear. The script runs, it just wasn't properly evaluating ARGV in that line.

ishnid,

That fixed it. I knew it would be something along those lines, but without knowing the rules of Perl... :)

Anyway, thanks guys. I can't believe how quick that got solved!
 
Status
Not open for further replies.

Similar threads

Replies
2
Views
346
  • Locked
  • Question Question
Replies
3
Views
385
Replies
1
Views
299
Replies
4
Views
392

Part and Inventory Search

Sponsor

Back
Top