[33001] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4277 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 25 05:17:18 2014

Date: Mon, 25 Aug 2014 02:17:05 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 25 Aug 2014     Volume: 11 Number: 4277

Today's topics:
    Re: perl6 too much pointless functionality <rweikusat@mobileactivedefense.com>
    Re: porting bash curl command into perl <jurgenex@hotmail.com>
    Re: porting bash curl command into perl <vilain@NOspamcop.net>
    Re: porting bash curl command into perl <gamo@telecable.es>
    Re: porting bash curl command into perl <news@lawshouse.org>
    Re: porting bash curl command into perl <hjp-usenet3@hjp.at>
    Re: porting bash curl command into perl <gamo@telecable.es>
    Re: porting bash curl command into perl <gamo@telecable.es>
    Re: porting bash curl command into perl <hjp-usenet3@hjp.at>
    Re: porting bash curl command into perl <hjp-usenet3@hjp.at>
    Re: porting bash curl command into perl <gamo@telecable.es>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 23 Aug 2014 19:12:08 +0100
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: perl6 too much pointless functionality
Message-Id: <87bnrbcbyf.fsf@sable.mobileactivedefense.com>

gamo <gamo@telecable.es> writes:
> El 22/08/14 a las 17:29, Rainer Weikusat escribi:
>>> @newlist = @list.pick(*);
>>> >
>>> >is the same as doing a shuffle from List::Util.
>> That's not really an example for 'new syntax' as the core is about
>> calling a builtin method on a list object. And writing
>
> Of course it is new syntax.
>
> 1) The dot changes it's function

That's a syntactical change compared to Perl,  OTOH, C has used . in
this way for an eternity and the same is also true for C++. Java got it
from there but dropped the separate 'dereferencing access' operator (->)
Perl adopted after some time for 'dereferencing accesses'. In this
respect (and in a few others), Perl6 is more like Java than Perl and one
of the justifications for that was actually "why use -> when everyone
else uses .".  But "what everyone else does" can obviously not be
regarded as new and in any case, you wrote about 'shuffling a list'
which would be the method call and possibly also the adoption of
'everything is an object' as design principile, thus enabling method
calls on arrays. And neither 'design principles' nor 'standard library
routine' are 'syntax'.

As to using the . as 'subordinate component access operator'
(suggestions for a better term very much welcome), that's actually a
nice demonstration of the ultimate irrelevance of 'syntax', some
people's apparent obsession with that notwithstanding: Object and method
call have to be associated with each other in some way so that a
compiler or interpreter can locate both. Usually, an in itself
meaningless operator symbol will be used for that, but if this ends up
as

list.pick
list->pick
pick(list)
list[pick]
pick@list
/list\_/pick\

really doesn't matter: It's gotta be something and someone using the
language has to learn it but ultimatively, it exists to enable a machine
to disambiguitate the text.

To a degree, it also exists to facilitate communication about
algorithms among humans but considering that programming languages are
plenty and new arrangments of non-alphanumerical characters in order to
accomplish the same thing are constantly being invented, forgotten and
re-invented, programming languages can't really serve that purpose,
especially considering that they - in addition to the funny character
combination rules - usually also come with their own terminology for
talking about funny character combinations.


------------------------------

Date: Sat, 23 Aug 2014 13:17:35 -0700
From: Jrgen Exner <jurgenex@hotmail.com>
Subject: Re: porting bash curl command into perl
Message-Id: <kbthv9pna0r77goul3jt3ado8lvi82mfkm@4ax.com>

chaos.lord@gmx.net wrote:

[Please limit your line lenght to <75 characters as has been customary
in Usenet for decades. Thank you]

>i'm a little stucked about using curl with perl. 

What is 'curl'? 

>I have an working bash command which controlls a powersply. 

What is 'powersply'?

>now i need to port my script into pern 

what is 'pern'?

>and i so not understend, how to pass multiple commands in one command.

What do you mean by 'multiple commands in one command'?

>My bash command looks like this:
>
>dummy=`curl -s --data "login=p:admin:beta30" --data "port=list" http://192.168.8.12/tgi/control.tgi`;
>
>all data i found on the web only descripbes that the perl module only can send one data in one request, or do i anderstand the wiki wrong?

You don't have any Perl module. What Perl module are you talking about?
And what do you mean by "can send one data in one request"?

jue


------------------------------

Date: Sat, 23 Aug 2014 13:29:44 -0700
From: Michael Vilain <vilain@NOspamcop.net>
Subject: Re: porting bash curl command into perl
Message-Id: <vilain-4F9AFB.13294423082014@news.individual.net>

In article <adb3f3a3-b41d-4fd0-942e-a2f092a414fc@googlegroups.com>,
 chaos.lord@gmx.net wrote:

> Hello every one,
> 
> i'm a little stucked about using curl with perl. I have an working bash 
> command which controlls a powersply. now i need to port my script into pern 
> and i so not understend, how to pass multiple commands in one command.
> 
> My bash command looks like this:
> 
> dummy=`curl -s --data "login=p:admin:beta30" --data "port=list" 
> http://192.168.8.12/tgi/control.tgi`;
> 
> all data i found on the web only descripbes that the perl module only can 
> send one data in one request, or do i anderstand the wiki wrong?
> 
> TNX
> 
> Chaos

Aside from all the typos from someone who's obviously not an english 
speaker, I wonder if you've wanted through the Perl CPAN library.  The 
curl interface is duplicated in the libwww CPAN module with varying 
degrees of complexity.  

The syntax above looks like you're trying to send a HTTP GET request to 
something.  Have you tried doing it just in native perl instead of 
bothering with curl?

-- 
DeeDee, don't press that button!  DeeDee!  NO!  Dee...
[I filter all Goggle Groups posts, so any reply may be automatically ignored]




------------------------------

Date: Sun, 24 Aug 2014 00:16:39 +0200
From: gamo <gamo@telecable.es>
Subject: Re: porting bash curl command into perl
Message-Id: <ltb3t8$132$1@speranza.aioe.org>

El 23/08/14 a las 22:29, Michael Vilain escribi:
> i'm a little stucked about using curl with perl. I have an working bash
>>command which controlls a powersply. now i need to port my script into pern
>>and i so not understend, how to pass multiple commands in one command.
>>
>>My bash command looks like this:
>>
>>dummy=`curl -s --data "login=p:admin:beta30" --data "port=list"
>>http://192.168.8.12/tgi/control.tgi`;
>>
>>all data i found on the web only descripbes that the perl module only can
>>send one data in one request, or do i anderstand the wiki wrong?
>>

You don't need a module to replicate a working bash script in Perl.

So, it simply must work with something like

#!/usr/bin/perl -w

$var1 = `curl -s --data "login=p:admin:beta30" --data "port=list" 
http://etc`;

print "$var";

__END__

The comand is only one (curl) but the tranfered data are two,
each string after --data and one space. Problems could arise
if the program lisening 'control.tgi' doesn't handle it as
expected.

If you wish to put more commands in a single script you only
have to replicate the $var2=`curl ...`; line.

It is expected that you do something with output collected
in $var1, $var2 in Perl, but you don't give a clue.

Good luck


-- 
http://www.telecable.es/personales/gamo/


------------------------------

Date: Sun, 24 Aug 2014 08:10:56 +0100
From: Henry Law <news@lawshouse.org>
Subject: Re: porting bash curl command into perl
Message-Id: <25SdncpNX_qeDWTOnZ2dnUVZ8mOdnZ2d@giganews.com>

On 23/08/14 20:42, chaos.lord@gmx.net wrote:
> now i need to port my script into pern and i so not understend, how to pass multiple commands in one command.
>
> My bash command looks like this:
>
> dummy=`curl -s --data "login=p:admin:beta30" --data "port=list"http://192.168.8.12/tgi/control.tgi`;
>
> all data i found on the web only descripbes that the perl module only can send one data in one request, or do i anderstand the wiki wrong?

The Curl man page makes it clear that multiple usage of the --data 
option still only sends ONE post; the different data elements are joined 
in one string thus: login=p:admin:beta30&port=list.  So you are not 
sending more than one request.

I hacked a little code, using the Perl LWP::Curl module in case it helps 
you.  I have not tested or checked it for syntax errors.

#!/usr/bin/perl
use warnings;
use strict;

use LWP::Curl;

my $url = 'http://192.168.8.12/tgi/control.tgi';
my %data = (
   login => 'p:admin:beta30',
   port  => 'list'
);

my $curl = LWP::Curl->new();
my $dummy = $curl->post( $url, \%data );
print "Here is \$dummy, whatever it is: $dummy\n";



-- 

Henry Law            Manchester, England


------------------------------

Date: Sun, 24 Aug 2014 09:21:28 +0200
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: porting bash curl command into perl
Message-Id: <slrnlvj4jo.frt.hjp-usenet3@hrunkner.hjp.at>

On 2014-08-23 22:16, gamo <gamo@telecable.es> wrote:
> El 23/08/14 a las 22:29, Michael Vilain escribió:
>>>i'm a little stucked about using curl with perl. I have an working
>>>bash command which controlls a powersply. now i need to port my
>>>script into pern and i so not understend, how to pass multiple
>>>commands in one command.
>>>
>>>My bash command looks like this:
>>>
>>>dummy=`curl -s --data "login=p:admin:beta30" --data "port=list"
>>>http://192.168.8.12/tgi/control.tgi`;
>>>
>>>all data i found on the web only descripbes that the perl module only can
>>>send one data in one request, or do i anderstand the wiki wrong?
>
> You don't need a module to replicate a working bash script in Perl.
>
> So, it simply must work with something like
>
> #!/usr/bin/perl -w
>
> $var1 = `curl -s --data "login=p:admin:beta30" --data "port=list" 
> http://etc`;
>
> print "$var";

I have probably seen too many scripts which do something like

    $now=`date`;
    chomp $now;

or worse

    $foo= $cgi->param('foo');
    $bar=`/usr/bin/something $foo`;

but I get slightly edgy when I see code like this. There are situations
where calling an external program is the best or sometimes even the only
solution. But if there is a Perl function which achieves the same thing
(either builtin or from a module), I prefer to use that, because:

 * It returns an appropriate Perl data type (often an object)
   instead of some string which I have to parse.
 * It's safer (Here the command seems to be a constant string, but
   somebody will interpolate some user input into it eventually)
 * It's often faster.
 * It is less system dependent.


> The comand is only one (curl) but the tranfered data are two,
> each string after --data and one space.

What space? There is neither a space passed from the shell to curl nor
from curl to the web server. According to curl(1):

|      -d, --data <data>
|         (HTTP) Sends the specified data in a POST request  to  the  HTTP
|         server,  in  the  same  way  that a browser does when a user has
|         filled in an HTML form and presses the submit button. This  will
|         cause curl to pass the data to the server using the content-type
|         application/x-www-form-urlencoded.  Compare to -F, --form.
[...]
|         If any of these options is used more than once on the same  com‐
|         mand  line,  the  data  pieces specified will be merged together
|         with a separating  &-symbol.  Thus,  using  '-d  name=daniel  -d
|         skill=lousy'  would  generate  a  post  chunk  that  looks  like
|         'name=daniel&skill=lousy'.

Or, in other words, a standard HTTP POST request
So, in Perl this would be:

my $ua = LWP::UserAgent->new();

my $response = $ua->post('http://192.168.8.12/tgi/control.tgi',
                         [ 'login' => 'p:admin:beta30',
                           'port'  => 'list',
                         ]);
my $content = $response->content;

(untested)

        hp


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel


------------------------------

Date: Sun, 24 Aug 2014 10:03:32 +0200
From: gamo <gamo@telecable.es>
Subject: Re: porting bash curl command into perl
Message-Id: <ltc69j$udo$1@speranza.aioe.org>

El 24/08/14 a las 09:21, Peter J. Holzer escribió:
> What space? There is neither a space passed from the shell to curl nor
> from curl to the web server. According to curl(1):
>
> |      -d, --data <data>
                    ^this space!

There are commands that don't expect a space between an option
and its parameter, others do. I only want to be specific.

-- 
http://www.telecable.es/personales/gamo/


------------------------------

Date: Sun, 24 Aug 2014 11:40:52 +0200
From: gamo <gamo@telecable.es>
Subject: Re: porting bash curl command into perl
Message-Id: <ltcc04$b5r$1@speranza.aioe.org>

El 24/08/14 a las 09:21, Peter J. Holzer escribió:
>   * It returns an appropriate Perl data type (often an object)
>     instead of some string which I have to parse.
>   * It's safer (Here the command seems to be a constant string, but
>     somebody will interpolate some user input into it eventually)
>   * It's often faster.
>   * It is less system dependent.

That are the pros. Now the contra: curl is a CLI against libcurl. It is
reasonable to suppose that curl command match the version of libcurl, 
because they are installed joined.
So, you can trust curl. Can you do the same with a module that builds
against some version of libcurl? You need to investigate to.

-- 
http://www.telecable.es/personales/gamo/


------------------------------

Date: Sun, 24 Aug 2014 16:52:36 +0200
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: porting bash curl command into perl
Message-Id: <slrnlvjv1k.afe.hjp-usenet3@hrunkner.hjp.at>

On 2014-08-24 08:03, gamo <gamo@telecable.es> wrote:
> El 24/08/14 a las 09:21, Peter J. Holzer escribi:
>> What space? There is neither a space passed from the shell to curl nor
>> from curl to the web server. According to curl(1):
>>
>> |      -d, --data <data>
>                     ^this space!
>
> There are commands that don't expect a space between an option
> and its parameter,

There is no space here which is passed to curl. Curl gets two parameters
"--data" and "<data>", neither contains a space.

> others do. I only want to be specific.

You are unclear.

        hp

-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpat. -- Ralph Babel


------------------------------

Date: Sun, 24 Aug 2014 17:04:17 +0200
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: porting bash curl command into perl
Message-Id: <slrnlvjvnh.afe.hjp-usenet3@hrunkner.hjp.at>

On 2014-08-24 09:40, gamo <gamo@telecable.es> wrote:
> El 24/08/14 a las 09:21, Peter J. Holzer escribi:
>>   * It returns an appropriate Perl data type (often an object)
>>     instead of some string which I have to parse.
>>   * It's safer (Here the command seems to be a constant string, but
>>     somebody will interpolate some user input into it eventually)
>>   * It's often faster.
>>   * It is less system dependent.
>
> That are the pros. Now the contra: curl is a CLI against libcurl. It is
> reasonable to suppose that curl command match the version of libcurl, 
> because they are installed joined.

It may not be installed at all. Or it may not be in the path.

> So, you can trust curl.

Even if I can trust curl, that isn't a reason against using standard
perl module.

> Can you do the same with a module that builds against some version of
> libcurl? You need to investigate to.

LWP::UserAgent doesn't depend on libcurl. 

        hp


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpat. -- Ralph Babel


------------------------------

Date: Sun, 24 Aug 2014 17:46:00 +0200
From: gamo <gamo@telecable.es>
Subject: Re: porting bash curl command into perl
Message-Id: <ltd1cm$ua5$1@speranza.aioe.org>

El 24/08/14 a las 17:04, Peter J. Holzer escribi:
>> Can you do the same with a module that builds against some version of
>> >libcurl? You need to investigate to.

> LWP::UserAgent doesn't depend on libcurl.

So, you have a working solution and one or more experiments.
Ok, it's up to the OP to do what he can. It's fine to tell
as much as possible of solutions.

-- 
http://www.telecable.es/personales/gamo/


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 4277
***************************************


home help back first fref pref prev next nref lref last post