<?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 Use of uninitialized value $_ in split in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249164#M658532</link>
    <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I have created the attached script to check to see if a connection to a port can be made.&lt;BR /&gt;Basically the script runs like this - &lt;BR /&gt;&lt;BR /&gt;script1.pl -f filename.conf&lt;BR /&gt;&lt;BR /&gt;where filename.conf has the following content - &lt;BR /&gt;&lt;BR /&gt;host:port&lt;BR /&gt;&lt;BR /&gt;but when I am running the script I am getting "Use of uninitialized value $_ in split".&lt;BR /&gt;&lt;BR /&gt;Can you help here?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan</description>
    <pubDate>Mon, 26 Jul 2010 22:20:27 GMT</pubDate>
    <dc:creator>Allanm</dc:creator>
    <dc:date>2010-07-26T22:20:27Z</dc:date>
    <item>
      <title>Use of uninitialized value $_ in split</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249164#M658532</link>
      <description>Hi!&lt;BR /&gt;&lt;BR /&gt;I have created the attached script to check to see if a connection to a port can be made.&lt;BR /&gt;Basically the script runs like this - &lt;BR /&gt;&lt;BR /&gt;script1.pl -f filename.conf&lt;BR /&gt;&lt;BR /&gt;where filename.conf has the following content - &lt;BR /&gt;&lt;BR /&gt;host:port&lt;BR /&gt;&lt;BR /&gt;but when I am running the script I am getting "Use of uninitialized value $_ in split".&lt;BR /&gt;&lt;BR /&gt;Can you help here?&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan</description>
      <pubDate>Mon, 26 Jul 2010 22:20:27 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249164#M658532</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2010-07-26T22:20:27Z</dc:date>
    </item>
    <item>
      <title>Re: Use of uninitialized value $_ in split</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249165#M658533</link>
      <description>I'm thinking that you can't use $_ with pulling data from an array.  You opened the file, but you didn't read it into any structure for processing.&lt;BR /&gt;&lt;BR /&gt;----------------------&lt;BR /&gt;Yours:&lt;BR /&gt;open (FILE, $filename) or die "Unable to open $filename";&lt;BR /&gt;until (eof FILE){&lt;BR /&gt;&lt;BR /&gt; $FS = ':';&lt;BR /&gt; ($Fld1,$Fld2) = split($FS, $_);&lt;BR /&gt;   my $hostname = $Fld1;&lt;BR /&gt;   my $portnumber = $Fld2;&lt;BR /&gt;}&lt;BR /&gt;close (FILE);&lt;BR /&gt;&lt;BR /&gt;-----------------&lt;BR /&gt;Untested, but I suggest something like the following, which always seems to get $_ working with a foreach loop.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;open (FILE, $filename) or die "Unable to open $filename";&lt;BR /&gt;@array=&lt;FILE&gt;;&lt;BR /&gt;close (FILE);&lt;BR /&gt;&lt;BR /&gt;$FS = ':';&lt;BR /&gt;foreach (@array) {&lt;BR /&gt; ($hostname,$portnumber) = split($FS, $_);&lt;BR /&gt;}&lt;BR /&gt;&lt;/FILE&gt;</description>
      <pubDate>Mon, 26 Jul 2010 22:49:56 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249165#M658533</guid>
      <dc:creator>TwoProc</dc:creator>
      <dc:date>2010-07-26T22:49:56Z</dc:date>
    </item>
    <item>
      <title>Re: Use of uninitialized value $_ in split</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249166#M658534</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;Allan :&lt;BR /&gt;&lt;BR /&gt;You never read the configuration file, and hence '$_' is undefined.  Try:&lt;BR /&gt;&lt;BR /&gt;#!/usr/bin/perl&lt;BR /&gt;use strict;&lt;BR /&gt;use warnings;&lt;BR /&gt;use Socket;&lt;BR /&gt;use Getopt::Std;&lt;BR /&gt;# set time until connection attempt times out&lt;BR /&gt;my $timeout = 3;&lt;BR /&gt;if ($#ARGV != 1) {&lt;BR /&gt;  print "usage: script.pl -f filename.conf \n";&lt;BR /&gt;  exit 2;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;our $opt_f;&lt;BR /&gt;getopts("f:");&lt;BR /&gt;my $filename = $opt_f;&lt;BR /&gt;&lt;BR /&gt;open (FILE, $filename) or die "Unable to open $filename";&lt;BR /&gt;my ($hostname, $portnumber) = split(/:/, &lt;FILE&gt;);&lt;BR /&gt;&lt;BR /&gt;close (FILE);&lt;BR /&gt;&lt;BR /&gt;my $host = shift || $hostname;&lt;BR /&gt;my $port = shift || $portnumber;&lt;BR /&gt;my $proto = getprotobyname('tcp');&lt;BR /&gt;my $iaddr = inet_aton($host);&lt;BR /&gt;my $paddr = sockaddr_in($port, $iaddr);&lt;BR /&gt;&lt;BR /&gt;socket(SOCKET, PF_INET, SOCK_STREAM, $proto) || die "socket: $!";&lt;BR /&gt;# socket opened&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, $paddr) || error();&lt;BR /&gt;  alarm(0);&lt;BR /&gt;};&lt;BR /&gt;if ($@) {&lt;BR /&gt;  close SOCKET || die "close: $!";&lt;BR /&gt;  print "$hostname is NOT listening on tcp port $portnumber.\n";&lt;BR /&gt;  exit 1;&lt;BR /&gt;}&lt;BR /&gt;else {&lt;BR /&gt;  close SOCKET || die "close: $!";&lt;BR /&gt;  print "$hostname is listening on tcp port $portnumber.\n";&lt;BR /&gt;  exit 0;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...&lt;/FILE&gt;</description>
      <pubDate>Mon, 26 Jul 2010 23:09:39 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249166#M658534</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-07-26T23:09:39Z</dc:date>
    </item>
    <item>
      <title>Re: Use of uninitialized value $_ in split</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249167#M658535</link>
      <description>Hi Allan:&lt;BR /&gt;&lt;BR /&gt;You have a large number of questions with unassigned points (159 of 278 responses).  It would be appreciated if you could evaluate the help you received.&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums.itrc.hp.com/service/forums/pageList.do?userId=CA1505975&amp;amp;listType=unassigned&amp;amp;forumId=1" target="_blank"&gt;http://forums.itrc.hp.com/service/forums/pageList.do?userId=CA1505975&amp;amp;listType=unassigned&amp;amp;forumId=1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Tue, 27 Jul 2010 10:48:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249167#M658535</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2010-07-27T10:48:26Z</dc:date>
    </item>
    <item>
      <title>Re: Use of uninitialized value $_ in split</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249168#M658536</link>
      <description>Sorry I have provided the points for this thread. WIll work on some of the older ones now.&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Allan</description>
      <pubDate>Fri, 13 Aug 2010 02:56:05 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/use-of-uninitialized-value-in-split/m-p/5249168#M658536</guid>
      <dc:creator>Allanm</dc:creator>
      <dc:date>2010-08-13T02:56:05Z</dc:date>
    </item>
  </channel>
</rss>

