mido45 has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks

I want some help in the following code:

for (my $i=1; $i<=$#array1;$i++){ `curl -G -x $array1[$i]:$array2[$i] http://www.google.com`; }

The error

curl: no URL specified!

curl: try 'curl --help' for more information

sh: line 1: :8080: command not found

sh: line 2: http://www.google.com: No such file or directory

So how can I execute curl in the right way?

Thank You in advance

Update

Hello Monks

It worked as jwkrahn suggested

I am trying now to check the output of the curl for certain conditions

What do you think is better for graping the output of the curl $variable OR @array OR in any other way you see it wright

20100219 Janitored by Corion: Restored original content, as per Writeup Formatting Tips

Replies are listed 'Best First'.
Re: Help using curl command
by jwkrahn (Abbot) on Feb 16, 2010 at 04:08 UTC
Re: Help using curl command
by Corion (Patriarch) on Feb 16, 2010 at 08:52 UTC

    As a general debugging approach, print out the lines before giving them to the shell, so you see whether your values in @array have the values you think they should have:

    # don't use a C-style loop for my $i (0..$#array1) { my $cmd = "curl -G -x $array1[$i]:$array2[$i] http://www.google.co +m"; print "Running [$cmd]\n"; system( $cmd ) == 0 or warn "Couldn't run [$cmd]: $!/$?"; };
Re: Help using curl command
by InfiniteSilence (Curate) on Feb 16, 2010 at 04:36 UTC
    Strange, I don't have a proxy available but the string is formatted correctly:
    perl -e @array1 = qw|localhost|; @array2 = qw|8080|; print `echo curl +-G -x $array1[0]:$array2[0] http://www.google.com`;
    === shows === curl -G -x localhost:8080 http://www.google.com

    Celebrate Intellectual Diversity

Re: Help using curl command
by FunkyMonk (Bishop) on Feb 16, 2010 at 10:28 UTC
    Your strings have newlines in them?
Re: Help using curl command Update
by mido45 (Novice) on Feb 16, 2010 at 15:23 UTC

    Hello Monks

    for (my $i=1; $i<=$#array1;$i++){ print"$i\n"; `curl -G -x $array1[$i]:$array2[$i] http://www.google.com`; }

    It worked as jwkrahn suggested

    I am trying now to check the output of the curl for certain conditions

    What do you think is better for graping the output of the curl $variable OR @array OR in any other way you see it wright