<?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: Another Perl CGI Question in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778624#M722500</link>
    <description>Hi Jason,&lt;BR /&gt;&lt;BR /&gt;Gregory is absolutely right.&lt;BR /&gt;Your code exhibits some obscurities, which I think are only due to some unfamiliarity with Perl.&lt;BR /&gt;First your open() call is strange indeed, but works because open() also accepts a list after its first argument which is a filehandle. (please read the open() POD, viz. "perldoc -f open").&lt;BR /&gt;The round parentheses depict a list, which in your case has as its only element the path to unixconcall.txt. &lt;BR /&gt;Since your or'ed the path string (which is always defined) to a die() call that never will be executed, your list has only this one element which is a valid filename.&lt;BR /&gt;Thus the Perl compiler won't complain even if you ran it with warnings enabled.&lt;BR /&gt;You have to choices.&lt;BR /&gt;Either you omit the parentheses altogether (which is a bit more like the sloppy Perlish style)&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;open ONCALL, '/usr/local/apache/cgi-bin/unixoncall.txt'&lt;BR /&gt; or die "cannot open: $!\n";&lt;BR /&gt;&lt;BR /&gt;or (as preferred by people coming from more strict languages), you embrace the two arguments with a pair of parentheses&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;open(ONCALL,  '/usr/local/apache/cgi-bin/unixoncall.txt')&lt;BR /&gt;&lt;BR /&gt;Then the assignment&lt;BR /&gt;&lt;BR /&gt;@oncall[$inx]="$_";&lt;BR /&gt;&lt;BR /&gt;actually is an assignment to a slice.&lt;BR /&gt;I really don't believe that you indended this, because it doesn't make much sense in this context.&lt;BR /&gt;Remember, Perl basically distinguishes between two "types", either list or scalar context.&lt;BR /&gt;Whenever you reference a single element of an array you address it in scalar context, thus requiring the '$'&lt;BR /&gt;&lt;BR /&gt;$oncall[$inx] = "$_";&lt;BR /&gt;&lt;BR /&gt;Apart from this, if you really afford to squeeze the whole file in an array you can have this much easier by enforcing list context with the diamond operator&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;@oncall = &lt;ONCALL&gt;;&lt;BR /&gt;&lt;BR /&gt;However, this is not very resource efficient, and you should rather loop through the lines of a file.&lt;BR /&gt;&lt;BR /&gt;If you mean to address the first element of a list, you will have to use the index 0 unless you redefined the special Perl variable '$[' (which is really deprecated)&lt;BR /&gt;Read the POD "perldoc perlvar".&lt;BR /&gt;&lt;BR /&gt;As far as CGI is concerned you'd better use the CGI.pm module (which is easier and *safer*)&lt;BR /&gt;Read "perldoc CGI".&lt;BR /&gt;&lt;BR /&gt;For tampering with files also read&lt;BR /&gt;"perldoc perlopentut"&lt;BR /&gt;&lt;BR /&gt;And finally, I'd strongly recommend to read the following:&lt;BR /&gt;&lt;BR /&gt;"perldoc perldata"&lt;BR /&gt;"perldoc perlsyn"&lt;/ONCALL&gt;</description>
    <pubDate>Tue, 06 Aug 2002 06:10:09 GMT</pubDate>
    <dc:creator>Ralph Grothe</dc:creator>
    <dc:date>2002-08-06T06:10:09Z</dc:date>
    <item>
      <title>Another Perl CGI Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778620#M722496</link>
      <description>Why is it that if I run the following code from the command prompt it will read the input file and output the array value at 1, but when I try to access it from my browser it won't show any value?&lt;BR /&gt;&lt;BR /&gt;#!/opt/perl/bin/perl&lt;BR /&gt;$inx=0;&lt;BR /&gt;&lt;BR /&gt;open ONCALL, ("/usr/local/apache/cgi-bin/unixoncall.txt" or die "Counld not open file!\n");&lt;BR /&gt;while (&lt;ONCALL&gt;) {&lt;BR /&gt;    chomp;&lt;BR /&gt;    @oncall[$inx]="$_";&lt;BR /&gt;    $inx++;&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;print "Content-type:text/html\n\n";&lt;BR /&gt;print "&lt;TITLE&gt;ONCALL&lt;/TITLE&gt;";&lt;BR /&gt;&lt;BR /&gt;print "&lt;H3&gt;$oncall[1]&lt;/H3&gt;&lt;BR /&gt;&lt;BR /&gt;";&lt;BR /&gt;&lt;BR /&gt;print "";&lt;BR /&gt;&lt;/ONCALL&gt;</description>
      <pubDate>Fri, 02 Aug 2002 15:13:25 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778620#M722496</guid>
      <dc:creator>Jason Berendsen</dc:creator>
      <dc:date>2002-08-02T15:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Another Perl CGI Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778621#M722497</link>
      <description>try it as user www&lt;BR /&gt;&lt;BR /&gt;Later,&lt;BR /&gt;Bill</description>
      <pubDate>Fri, 02 Aug 2002 15:18:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778621#M722497</guid>
      <dc:creator>Bill McNAMARA_1</dc:creator>
      <dc:date>2002-08-02T15:18:42Z</dc:date>
    </item>
    <item>
      <title>Re: Another Perl CGI Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778622#M722498</link>
      <description>I suppose it would help to look at what permissions the file you are reading in has!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;&lt;BR /&gt;Jason</description>
      <pubDate>Fri, 02 Aug 2002 15:40:20 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778622#M722498</guid>
      <dc:creator>Jason Berendsen</dc:creator>
      <dc:date>2002-08-02T15:40:20Z</dc:date>
    </item>
    <item>
      <title>Re: Another Perl CGI Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778623#M722499</link>
      <description>Your call to open() is very strange; perhaps you meant:&lt;BR /&gt;&lt;BR /&gt;open (ONCALL, "/usr/local/apache/cgi-bin/unixoncall.txt") or&lt;BR /&gt;    die "Counld not open file!\n";&lt;BR /&gt;&lt;BR /&gt;As you've written it, if open() fails the script continues&lt;BR /&gt;to execute.  The die() only gets called if the filename is&lt;BR /&gt;not true.&lt;BR /&gt;&lt;BR /&gt;Also, your use of:&lt;BR /&gt;&lt;BR /&gt;@oncall[$inx]="$_";&lt;BR /&gt;&lt;BR /&gt;should probably be:&lt;BR /&gt;&lt;BR /&gt;$oncall[$inx]="$_";&lt;BR /&gt;&lt;BR /&gt;Also note that Perl array indices (normally) start at zero&lt;BR /&gt;and not one.&lt;BR /&gt;</description>
      <pubDate>Fri, 02 Aug 2002 16:29:57 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778623#M722499</guid>
      <dc:creator>Gregory Fruth</dc:creator>
      <dc:date>2002-08-02T16:29:57Z</dc:date>
    </item>
    <item>
      <title>Re: Another Perl CGI Question</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778624#M722500</link>
      <description>Hi Jason,&lt;BR /&gt;&lt;BR /&gt;Gregory is absolutely right.&lt;BR /&gt;Your code exhibits some obscurities, which I think are only due to some unfamiliarity with Perl.&lt;BR /&gt;First your open() call is strange indeed, but works because open() also accepts a list after its first argument which is a filehandle. (please read the open() POD, viz. "perldoc -f open").&lt;BR /&gt;The round parentheses depict a list, which in your case has as its only element the path to unixconcall.txt. &lt;BR /&gt;Since your or'ed the path string (which is always defined) to a die() call that never will be executed, your list has only this one element which is a valid filename.&lt;BR /&gt;Thus the Perl compiler won't complain even if you ran it with warnings enabled.&lt;BR /&gt;You have to choices.&lt;BR /&gt;Either you omit the parentheses altogether (which is a bit more like the sloppy Perlish style)&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;open ONCALL, '/usr/local/apache/cgi-bin/unixoncall.txt'&lt;BR /&gt; or die "cannot open: $!\n";&lt;BR /&gt;&lt;BR /&gt;or (as preferred by people coming from more strict languages), you embrace the two arguments with a pair of parentheses&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;open(ONCALL,  '/usr/local/apache/cgi-bin/unixoncall.txt')&lt;BR /&gt;&lt;BR /&gt;Then the assignment&lt;BR /&gt;&lt;BR /&gt;@oncall[$inx]="$_";&lt;BR /&gt;&lt;BR /&gt;actually is an assignment to a slice.&lt;BR /&gt;I really don't believe that you indended this, because it doesn't make much sense in this context.&lt;BR /&gt;Remember, Perl basically distinguishes between two "types", either list or scalar context.&lt;BR /&gt;Whenever you reference a single element of an array you address it in scalar context, thus requiring the '$'&lt;BR /&gt;&lt;BR /&gt;$oncall[$inx] = "$_";&lt;BR /&gt;&lt;BR /&gt;Apart from this, if you really afford to squeeze the whole file in an array you can have this much easier by enforcing list context with the diamond operator&lt;BR /&gt;&lt;BR /&gt;e.g.&lt;BR /&gt;&lt;BR /&gt;@oncall = &lt;ONCALL&gt;;&lt;BR /&gt;&lt;BR /&gt;However, this is not very resource efficient, and you should rather loop through the lines of a file.&lt;BR /&gt;&lt;BR /&gt;If you mean to address the first element of a list, you will have to use the index 0 unless you redefined the special Perl variable '$[' (which is really deprecated)&lt;BR /&gt;Read the POD "perldoc perlvar".&lt;BR /&gt;&lt;BR /&gt;As far as CGI is concerned you'd better use the CGI.pm module (which is easier and *safer*)&lt;BR /&gt;Read "perldoc CGI".&lt;BR /&gt;&lt;BR /&gt;For tampering with files also read&lt;BR /&gt;"perldoc perlopentut"&lt;BR /&gt;&lt;BR /&gt;And finally, I'd strongly recommend to read the following:&lt;BR /&gt;&lt;BR /&gt;"perldoc perldata"&lt;BR /&gt;"perldoc perlsyn"&lt;/ONCALL&gt;</description>
      <pubDate>Tue, 06 Aug 2002 06:10:09 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/another-perl-cgi-question/m-p/2778624#M722500</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2002-08-06T06:10:09Z</dc:date>
    </item>
  </channel>
</rss>

