<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Perl script help needed in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790786#M641241</link>
    <description>OK&lt;BR /&gt;I have no idea how to do this.&lt;BR /&gt;Some example based on the code above please ?&lt;BR /&gt;Regards&lt;BR /&gt;Peter</description>
    <pubDate>Mon, 23 May 2011 13:57:59 GMT</pubDate>
    <dc:creator>Piotr Kirklewski</dc:creator>
    <dc:date>2011-05-23T13:57:59Z</dc:date>
    <item>
      <title>Perl script help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790783#M641238</link>
      <description>Hi there&lt;BR /&gt;&lt;BR /&gt;Could you guys help me to figure out how can I set a timeout value smaller that 1 sec ? I tried 0.3 but it didn't work. The program actually does stuff longer then if the value is set to 1.&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl -w&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;&lt;BR /&gt;use Socket;&lt;BR /&gt;my $timeout = 1;&lt;BR /&gt;&lt;BR /&gt;open (MYFILE, '/home/x/robot/ips.txt');&lt;BR /&gt;&lt;BR /&gt; while (&lt;MYFILE&gt;) {&lt;BR /&gt;     chomp;&lt;BR /&gt;    $a="$_";&lt;BR /&gt; &lt;BR /&gt; socket SOCKET, PF_INET, SOCK_STREAM, getprotobyname('tcp') or die;&lt;BR /&gt; my $ip = inet_aton( $a );&lt;BR /&gt; my $address = sockaddr_in( 80, $ip );&lt;BR /&gt; &lt;BR /&gt; eval {&lt;BR /&gt;    local $SIG{ALRM} = sub { die "timeout" };&lt;BR /&gt;    alarm($timeout);&lt;BR /&gt;    connect (SOCKET, $address) || error();&lt;BR /&gt;    alarm(0);&lt;BR /&gt; };&lt;BR /&gt; if ($@) {&lt;BR /&gt;    close SOCKET || die "close: $!";&lt;BR /&gt;    #print "$a is NOT listening on tcp port 80.\n";&lt;BR /&gt;  }&lt;BR /&gt;  else {&lt;BR /&gt;    close SOCKET || die "close: $!";&lt;BR /&gt;    open (OUTFILE, '/home/x/robot/ip80ok.txt');&lt;BR /&gt;    print "$a\n";&lt;BR /&gt;    print OUTFILE "$a\n";&lt;BR /&gt;    close (OUTFILE);&lt;BR /&gt;  }&lt;BR /&gt;&lt;BR /&gt;}&lt;BR /&gt;close(MYFILE);&lt;BR /&gt;&lt;BR /&gt;&lt;/MYFILE&gt;</description>
      <pubDate>Mon, 23 May 2011 01:38:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790783#M641238</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2011-05-23T01:38:42Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790784#M641239</link>
      <description>The number of seconds value for the "alarm" function must be an integer.&lt;BR /&gt;&lt;BR /&gt;The description of "alarm" in perlfunc(1) man page says:&lt;BR /&gt;&lt;BR /&gt;-----&lt;BR /&gt;[...]&lt;BR /&gt;For delays of finer granularity than one second, the Time::HiRes module (from CPAN, and starting from Perl 5.8 part of the standard distribution) provides ualarm().  You may also use Perl's four-argument version of select() leaving the first three arguments undefined, or you might be able to use the "syscall" interface to access setitimer(2) if your system supports it. See perlfaq8 for details.&lt;BR /&gt;[...]&lt;BR /&gt;-----&lt;BR /&gt;&lt;BR /&gt;Information about Time::HiRes can of course be found at the cpan.org website:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://search.cpan.org/~zefram/Time-HiRes-1.9722/HiRes.pm" target="_blank"&gt;http://search.cpan.org/~zefram/Time-HiRes-1.9722/HiRes.pm&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;MK</description>
      <pubDate>Mon, 23 May 2011 04:41:44 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790784#M641239</guid>
      <dc:creator>Matti_Kurkela</dc:creator>
      <dc:date>2011-05-23T04:41:44Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790785#M641240</link>
      <description>HI:&lt;BR /&gt;&lt;BR /&gt;You don't need the '-w' switch on the shebang line *and* the 'warnings' pragma.  Use the pragma.&lt;BR /&gt;&lt;BR /&gt;The '-w' switch applies globally whereas the pragma allows much finer control over what you want to be warned about and where you might want to temporarily turn off warnings.&lt;BR /&gt;&lt;BR /&gt;As Matti noted,  use the 'Time::HiRes' module for working with times less than one-second.  This module is part of the core Perl distribution so you can immediately deploy it.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;BR /&gt;</description>
      <pubDate>Mon, 23 May 2011 12:10:14 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790785#M641240</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-05-23T12:10:14Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790786#M641241</link>
      <description>OK&lt;BR /&gt;I have no idea how to do this.&lt;BR /&gt;Some example based on the code above please ?&lt;BR /&gt;Regards&lt;BR /&gt;Peter</description>
      <pubDate>Mon, 23 May 2011 13:57:59 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790786#M641241</guid>
      <dc:creator>Piotr Kirklewski</dc:creator>
      <dc:date>2011-05-23T13:57:59Z</dc:date>
    </item>
    <item>
      <title>Re: Perl script help needed</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790787#M641242</link>
      <description>Hi (again):&lt;BR /&gt;&lt;BR /&gt;I have no idea how to do this.&lt;BR /&gt;Some example based on the code above please ?&lt;BR /&gt;&lt;BR /&gt;Homework, eh?&lt;BR /&gt;&lt;BR /&gt;Start by adding the 'Time::HiRes' module:&lt;BR /&gt;&lt;BR /&gt;use Time::HiRes qw(ualarm);&lt;BR /&gt;&lt;BR /&gt;Now, change 'alarm()' to 'ualarm()'&lt;BR /&gt;&lt;BR /&gt;Remember, the 'ualarm' runs in *micro*seconds.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Mon, 23 May 2011 14:02:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/perl-script-help-needed/m-p/4790787#M641242</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2011-05-23T14:02:38Z</dc:date>
    </item>
  </channel>
</rss>

