<?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: Problem in running perl script in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159760#M319823</link>
    <description>use strict;&lt;BR /&gt;my %nv;&lt;BR /&gt;my $fn = "$currentenvroot/load.config";&lt;BR /&gt;open my $fh, "&amp;lt;", $fn or die "cannot open config file '$fn': $!";&lt;BR /&gt;while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my ($name, $value) = split m/=/;&lt;BR /&gt;    print "NAME $name VAL $value \n" ;&lt;BR /&gt;    $nv{$name} = $value;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Several issues addressed.&lt;BR /&gt;&lt;BR /&gt;1. while ($line = &lt;F&gt;) {&lt;BR /&gt;&lt;BR /&gt;this will stop is the line consists of a single 0. If you want to assign to a variable, use something like&lt;BR /&gt;&lt;BR /&gt; while (defined (my $line = &lt;F&gt;)) {&lt;BR /&gt;&lt;BR /&gt;2. On modern perls, it is better to use lexical file handles. They have a better (more restricted) scope, and are way more easy to pass to functions and methods that take handles. Compare&lt;BR /&gt;&lt;BR /&gt; $csv-&amp;gt;getline ($fh);&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt; $csv-&amp;gt;getline (*FH);&lt;BR /&gt;&lt;BR /&gt;3. split ("=", $line)&lt;BR /&gt;&lt;BR /&gt;Does NOT do what you expect. Besides some exceptions, the first argument to split is a regex, not a string.&lt;BR /&gt;&lt;BR /&gt;4. chomp on a variable&lt;BR /&gt;&lt;BR /&gt;When needing to chomp lines, do that as soon as possible for readability. First reject the lines you don't want, then chomp, then parse.&lt;BR /&gt;&lt;BR /&gt;5. use strict;&lt;BR /&gt;&lt;BR /&gt;Use strict; Always. And thus also use lexical variables. When you now make a typo or use a variable out of it' scope, it'll warn.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;/F&gt;&lt;/F&gt;</description>
    <pubDate>Wed, 12 Mar 2008 08:28:01 GMT</pubDate>
    <dc:creator>H.Merijn Brand (procura</dc:creator>
    <dc:date>2008-03-12T08:28:01Z</dc:date>
    <item>
      <title>Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159755#M319818</link>
      <description>Hi all, &lt;BR /&gt;&lt;BR /&gt;I have a problem in running the perl script. Its throwing these error.&lt;BR /&gt;&lt;BR /&gt;"Use of uninitialized value in scalar chomp at"&lt;BR /&gt;&lt;BR /&gt;and &lt;BR /&gt;&lt;BR /&gt;Name "main::OUT" used only once: possible typo &lt;BR /&gt;&lt;BR /&gt;can u pls help me resolve these errors.</description>
      <pubDate>Wed, 12 Mar 2008 06:33:48 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159755#M319818</guid>
      <dc:creator>chinnaga</dc:creator>
      <dc:date>2008-03-12T06:33:48Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159756#M319819</link>
      <description>&amp;gt; Name "main::OUT" used only once: possible typo&lt;BR /&gt;&lt;BR /&gt;probably you meant STDOUT where you have something like&lt;BR /&gt;&lt;BR /&gt;print OUT "Warning\n";&lt;BR /&gt;&lt;BR /&gt;&amp;gt; "Use of uninitialized value in scalar chomp at"&lt;BR /&gt;&lt;BR /&gt;in your code you have either&lt;BR /&gt;&lt;BR /&gt;chomp;&lt;BR /&gt;&lt;BR /&gt;or&lt;BR /&gt;&lt;BR /&gt;chomp $foo;&lt;BR /&gt;&lt;BR /&gt;the default arg to chomp is $_. The variable that chomp is seeing has no value, or is undef, which causes the warning.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Mar 2008 06:59:58 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159756#M319819</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2008-03-12T06:59:58Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159757#M319820</link>
      <description>Thanks a lot Merijn,&lt;BR /&gt;&lt;BR /&gt;This is the part of the script. I have assigned the $value to chomp, and I am printing the value also , can u please tell me wht is wrong in this .&lt;BR /&gt;&lt;BR /&gt;open(F,"$currentenvroot/load.config") or die "cannot open&lt;BR /&gt;       $currentenvroot/load.config config  file";&lt;BR /&gt;    while($line = &lt;F&gt;) {&lt;BR /&gt;     ($name,$value) = split("=",$line);&lt;BR /&gt;      chomp ($value);&lt;BR /&gt;   print "NAME $name   VAL  $value \n" ;&lt;BR /&gt;&lt;BR /&gt;     $nv{$name} = $value;&lt;BR /&gt;    }&lt;/F&gt;</description>
      <pubDate>Wed, 12 Mar 2008 07:47:43 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159757#M319820</guid>
      <dc:creator>chinnaga</dc:creator>
      <dc:date>2008-03-12T07:47:43Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159758#M319821</link>
      <description>&amp;gt;I have assigned the $value to chomp&lt;BR /&gt;&lt;BR /&gt;Only if you go through the while loop.</description>
      <pubDate>Wed, 12 Mar 2008 07:58:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159758#M319821</guid>
      <dc:creator>Dennis Handly</dc:creator>
      <dc:date>2008-03-12T07:58:49Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159759#M319822</link>
      <description>It is inside the while loop.</description>
      <pubDate>Wed, 12 Mar 2008 08:02:08 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159759#M319822</guid>
      <dc:creator>chinnaga</dc:creator>
      <dc:date>2008-03-12T08:02:08Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159760#M319823</link>
      <description>use strict;&lt;BR /&gt;my %nv;&lt;BR /&gt;my $fn = "$currentenvroot/load.config";&lt;BR /&gt;open my $fh, "&amp;lt;", $fn or die "cannot open config file '$fn': $!";&lt;BR /&gt;while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    my ($name, $value) = split m/=/;&lt;BR /&gt;    print "NAME $name VAL $value \n" ;&lt;BR /&gt;    $nv{$name} = $value;&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Several issues addressed.&lt;BR /&gt;&lt;BR /&gt;1. while ($line = &lt;F&gt;) {&lt;BR /&gt;&lt;BR /&gt;this will stop is the line consists of a single 0. If you want to assign to a variable, use something like&lt;BR /&gt;&lt;BR /&gt; while (defined (my $line = &lt;F&gt;)) {&lt;BR /&gt;&lt;BR /&gt;2. On modern perls, it is better to use lexical file handles. They have a better (more restricted) scope, and are way more easy to pass to functions and methods that take handles. Compare&lt;BR /&gt;&lt;BR /&gt; $csv-&amp;gt;getline ($fh);&lt;BR /&gt;&lt;BR /&gt;to&lt;BR /&gt;&lt;BR /&gt; $csv-&amp;gt;getline (*FH);&lt;BR /&gt;&lt;BR /&gt;3. split ("=", $line)&lt;BR /&gt;&lt;BR /&gt;Does NOT do what you expect. Besides some exceptions, the first argument to split is a regex, not a string.&lt;BR /&gt;&lt;BR /&gt;4. chomp on a variable&lt;BR /&gt;&lt;BR /&gt;When needing to chomp lines, do that as soon as possible for readability. First reject the lines you don't want, then chomp, then parse.&lt;BR /&gt;&lt;BR /&gt;5. use strict;&lt;BR /&gt;&lt;BR /&gt;Use strict; Always. And thus also use lexical variables. When you now make a typo or use a variable out of it' scope, it'll warn.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn&lt;/F&gt;&lt;/F&gt;</description>
      <pubDate>Wed, 12 Mar 2008 08:28:01 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159760#M319823</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2008-03-12T08:28:01Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159761#M319824</link>
      <description>Thanks, &lt;BR /&gt;&lt;BR /&gt;I have modified the changes u have told me ...but still I am getting error. I have declared my %nv; &lt;BR /&gt;&lt;BR /&gt;Global symbol "$nv" requires explicit package name at /opt_apps/comcat_itg/r_curr/be/loads/patsy_discount/driver/ftp_patsy.pl.&lt;BR /&gt;&lt;BR /&gt;I am sending u the script.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;#!usr/bin/perl&lt;BR /&gt;use warnings;&lt;BR /&gt;use strict;&lt;BR /&gt;&lt;BR /&gt;my $var;&lt;BR /&gt;my $inpath;&lt;BR /&gt;my $value;&lt;BR /&gt;my $line;&lt;BR /&gt;my @line;&lt;BR /&gt;my $name;&lt;BR /&gt;#############################################################&lt;BR /&gt;# FTP Script to transfer data files from 649 to hpcc547&lt;BR /&gt;#Ramkumar Balasubramanian&lt;BR /&gt;#############################################################&lt;BR /&gt;my $currentenvroot=`/opt_apps/comcat_root/bin/getEnvRootPath.sh SH`;&lt;BR /&gt;$currentenvroot =~ s/[\n\r]//g;&lt;BR /&gt;my $currentftpenvroot=`/opt_apps/comcat_root/bin/getEnvRootPath.sh FTP`;&lt;BR /&gt;$currentftpenvroot =~ s/[\n\r]//g;&lt;BR /&gt;my $cmd;&lt;BR /&gt;my $cmdprd;&lt;BR /&gt;my $lcddir;&lt;BR /&gt;my $cdir;&lt;BR /&gt;my %nv;&lt;BR /&gt;my $fn = "$currentenvroot/r_curr/be/loads/load.config";&lt;BR /&gt;&lt;BR /&gt;#Now Start FTP to Send the PATSY Data to htx6048 #&lt;BR /&gt;&lt;BR /&gt;$lcddir="lcd $currentftpenvroot/data/output/patsy_discount\n";&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;open my $fh, "&amp;lt;", $fn or die "cannot open config file '$fn': $!";&lt;BR /&gt;while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;chomp;&lt;BR /&gt;my ($name, $value) = split m/=/;&lt;BR /&gt;print "NAME $name VAL $value \n" ;&lt;BR /&gt;$nv{$name} = $value;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;ANd this is the error I am getting &lt;BR /&gt;&lt;BR /&gt;Global symbol "$nv" requires explicit package name at /opt_apps/comcat_itg/r_curr/be/loads/patsy_discount/driver/ftp_patsy.pl line 57.&lt;BR /&gt;Execution of /opt_apps/comcat_itg/r_curr/be/loads/patsy_discount/driver/ftp_patsy.pl aborted due to compilation errors.</description>
      <pubDate>Wed, 12 Mar 2008 08:50:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159761#M319824</guid>
      <dc:creator>chinnaga</dc:creator>
      <dc:date>2008-03-12T08:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159762#M319825</link>
      <description>&lt;!--!*#--&gt;There is nothing to add to Merijn's recommendations.&lt;BR /&gt;&lt;BR /&gt;Maybe, you could change the split criteria to include possible whitespace around the equals sign, as to have stripped it off from you key value pairs?&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;my ($key, $val) = split /\s*=\s*/, $line;&lt;BR /&gt;&lt;BR /&gt;$nv{$key} = $val if defined $key;&lt;BR /&gt;&lt;BR /&gt;As this looks like parsing one of those notorious Win ini files,&lt;BR /&gt;there plenty of modules on CPAN for those&lt;BR /&gt;(probably too bewildering not to have it parsed by ones own parsing)</description>
      <pubDate>Wed, 12 Mar 2008 09:28:28 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159762#M319825</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2008-03-12T09:28:28Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159763#M319826</link>
      <description>Is this the whole script?&lt;BR /&gt;Looks these are fewer than 57 lines.&lt;BR /&gt;There must be another occurrence of $nv.</description>
      <pubDate>Wed, 12 Mar 2008 09:38:32 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159763#M319826</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2008-03-12T09:38:32Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159764#M319827</link>
      <description>probably another typo somewhere. There error is about the SCALAR $nv, whereas in the code you've sown us so far, you were only using the HASH %nv. Addressing elements in the hash is&lt;BR /&gt;&lt;BR /&gt; $nv{$key}&lt;BR /&gt;&lt;BR /&gt;Look for occurances of $nv that are not followed by an opening brace.&lt;BR /&gt;&lt;BR /&gt;And I bet the warning/error comes with a line numer. Should be clear enough.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Mar 2008 10:23:06 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159764#M319827</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2008-03-12T10:23:06Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159765#M319828</link>
      <description>&lt;!--!*#--&gt;Are you still seeing the original error?&lt;BR /&gt;&lt;BR /&gt;Clearly that means that the 'split' line did not produce a $values, which probably means there was no '=' on the line.&lt;BR /&gt;&lt;BR /&gt;&amp;gt;&amp;gt; my ($name, $value) = split m/=/;&lt;BR /&gt;&lt;BR /&gt;A simply debugging for that suspected problem would be a print line like&lt;BR /&gt;&lt;BR /&gt;print STDERR "Bad input line # $. : $_\n" unless defined($value);&lt;BR /&gt;&lt;BR /&gt;And, as indicated the split uses a regular expression which you may want to exploit, for example to suck up whitespace around the '='&lt;BR /&gt;my ($name, $value) = split m/\s*=\s*/;&lt;BR /&gt;&lt;BR /&gt;Depending on the exact parsing requirements You may also want to consider NOT to use a split but a match. For example, you may want to skip lines which start with a # or find new sections in the input, or skip leading whitespace&lt;BR /&gt;&lt;BR /&gt;while (&amp;lt;$fh&amp;gt;) {&lt;BR /&gt;   if (/\s*(\S+)\s*=\s*(.*)$/) {&lt;BR /&gt;      $name = $l;&lt;BR /&gt;      $values = $2;&lt;BR /&gt;      :&lt;BR /&gt;   } else {&lt;BR /&gt;      if (other acceptable input) {&lt;BR /&gt;         ...&lt;BR /&gt;      } else {&lt;BR /&gt;        print STDERR "Bad input line # $. : $_\n";&lt;BR /&gt;      }&lt;BR /&gt;   }&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;fwiw,&lt;BR /&gt;Hein.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Mar 2008 10:54:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159765#M319828</guid>
      <dc:creator>Hein van den Heuvel</dc:creator>
      <dc:date>2008-03-12T10:54:57Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159766#M319829</link>
      <description>Thanks a lot to everybody , its working fine now.</description>
      <pubDate>Wed, 12 Mar 2008 11:32:18 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159766#M319829</guid>
      <dc:creator>chinnaga</dc:creator>
      <dc:date>2008-03-12T11:32:18Z</dc:date>
    </item>
    <item>
      <title>Re: Problem in running perl script</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159767#M319830</link>
      <description>Thanks can be expressed in assigning points to the given answers. This will help future readers in finding the answers.&lt;BR /&gt;&lt;BR /&gt;An anser the "solved" your problem is usually rated 9..10, and answer that helped greatle 5..8, an informative answer that didn't bring you closer but helped you understand things better 2..4 and all else 0..1&lt;BR /&gt;&lt;BR /&gt;&lt;A href="http://forums11.itrc.hp.com/service/forums/pageList.do?userId=CA1462614&amp;amp;listType=unassigned&amp;amp;forumId=1" target="_blank"&gt;http://forums11.itrc.hp.com/service/forums/pageList.do?userId=CA1462614&amp;amp;listType=unassigned&amp;amp;forumId=1&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Mar 2008 13:36:33 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/problem-in-running-perl-script/m-p/4159767#M319830</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2008-03-12T13:36:33Z</dc:date>
    </item>
  </channel>
</rss>

