[Canberra-pm] here document perl script

Kim Holburn kim at holburn.net
Thu Jun 8 18:59:31 PDT 2006


Thanks, that works.  Now how do I put the results in an environment var?

This doesn't work:
i=`/usr/bin/perl - `<<EOP
use Socket;

my \$ip = "$1";
my \$addr = inet_aton(\$ip);
my \$name = gethostbyaddr(\$addr,AF_INET);
my \$ip2 = sprintf "%-20s", "[\$ip]";
if (\$name eq "") { \$name = "not found"; }
my \$begin .= \$ip2 . \$name;
print "\$begin\n";
EOP

echo "\"$i\""

putting the backtick after the end of the here doesn't appear to work  
either.


On 2006 Jun 09, at 11:21 AM, James Ring wrote:

> Hi Kim,
>
>> I want to put a here document fragment of perl in a shell script.
>> I'm sure I've done something like this before but I can't get it to
>> work.  Anyone got any ideas?
>>
>> #!/bin/sh
>>
>>
>> /usr/bin/perl -e -- <<EOP
>
> The stuff between <<EOP and EOP will be passed into Perl's standard  
> input,
> so you don't need the -e. I think this works:
>
> /usr/bin/perl - <<EOP
>
>> Kim Holburn
>
> Regards,
> James
> -- 
> James Ring
>
>

-- 
Kim Holburn
Security Manager, National ICT Australia Ltd.
Ph: +61 2 61258620 M: +61 417820641  F: +61 2 6230 6121
mailto:kim.holburn at nicta.com.au  aim://kimholburn
skype://kholburn - PGP Public Key on request
Cacert Root Cert: http://www.cacert.org/cacert.crt
Aust. Spam Act: To stop receiving mail from me: reply and let me know.
Use ISO 8601 dates [YYYY-MM-DD] http://www.saqqara.demon.co.uk/ 
datefmt.htm

Democracy imposed from without is the severest form of tyranny.
                           -- Lloyd Biggle, Jr. Analog, Apr 1961





More information about the Canberra-pm mailing list