<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0">
  <channel>
    <title>'New to Perl and stuck...Help' Thread RSS Feed</title>
    <link>http://www.programmersheaven.com/</link>
    <description>Contains the latest posts from the thread 'New to Perl and stuck...Help' posted on the 'Perl' forum at Programmer's Heaven.</description>
    <language>en</language>
    <copyright>Copyright 2013 Programmers Heaven</copyright>
    <pubDate>Sat, 18 May 2013 16:32:37 -0700</pubDate>
    <lastBuildDate>Sat, 18 May 2013 16:32:37 -0700</lastBuildDate>
    <generator>Argotic Syndication Framework 2007.3.0.1, http://www.codeplex.com/Argotic</generator>
    <docs>http://www.rssboard.org/rss-specification</docs>
    <ttl>360</ttl>
    <image>
      <url>http://www.programmersheaven.com/images/ph.gif</url>
      <title>Programmers Heaven</title>
      <link>http://www.programmersheaven.com/</link>
      <width>88</width>
      <height>31</height>
    </image>
    <item>
      <title>New to Perl and stuck...Help</title>
      <link>http://www.programmersheaven.com/mb/perl/232358/232358/new-to-perl-and-stuckhelp/</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by mikeruth at  2003-12-18 13:12:55&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by mikeruth at  2003-12-18 13:12:10&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
I am on my second day of Perl programming and I am stuck.  The program&lt;br /&gt;
below will read a one line, 1 to 2 M file, test it, and, print some counts to another file.  I cannot get past the open...infile.&lt;br /&gt;
&lt;br /&gt;
Help!  I need to get this done soon (and with "use strict").&lt;br /&gt;
&lt;br /&gt;
Where did all of my spaces go???&lt;br /&gt;
&lt;br /&gt;
========================= The Code ===========================&lt;br /&gt;
&lt;br /&gt;
#!/opt/utils/5bin/perl5.001 -w&lt;br /&gt;
&lt;br /&gt;
# We have two versions.  Make sure to use the lastest.&lt;br /&gt;
&lt;br /&gt;
require 5.001;&lt;br /&gt;
use strict;&lt;br /&gt;
&lt;br /&gt;
if ( @ARGV &amp;lt; 2 )&lt;br /&gt;
    {&lt;br /&gt;
    die "\nUsage: $0 &amp;lt;infile&amp;gt;\n\nStopped";&lt;br /&gt;
    }&lt;br /&gt;
&lt;br /&gt;
my $infile = shift @ARGV;&lt;br /&gt;
my $outfile = shift @ARGV;&lt;br /&gt;
&lt;br /&gt;
open( my $infile_handle, "&amp;lt; $infile" ) or&lt;br /&gt;
    die "\nCan't open input file \"$infile\".\n",&lt;br /&gt;
        "Error: $!.\n",&lt;br /&gt;
        "Stopped";&lt;br /&gt;
&lt;br /&gt;
open( my $outfile_handle, "&amp;gt; $outfile" ) or&lt;br /&gt;
    die "\nCan't open output file \"$outfile\".\n",&lt;br /&gt;
        "Error: $!.\n",&lt;br /&gt;
        "Stopped";&lt;br /&gt;
&lt;br /&gt;
my $text = join( '', &amp;lt;$infile_handle&amp;gt; );&lt;br /&gt;
my $test_len = length( $test );&lt;br /&gt;
print "\n" , $test_len, "\n";&lt;br /&gt;
&lt;br /&gt;
close $infile_handle;&lt;br /&gt;
&lt;br /&gt;
chomp $text;&lt;br /&gt;
&lt;br /&gt;
#&lt;br /&gt;
# process the line and print results...&lt;br /&gt;
#&lt;br /&gt;
&lt;br /&gt;
close $outfile_handle;&lt;br /&gt;
&lt;br /&gt;
exit ( 0 );&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/232358/232358/new-to-perl-and-stuckhelp/</guid>
      <pubDate>Thu, 18 Dec 2003 13:11:13 -0700</pubDate>
      <category>Perl</category>
    </item>
    <item>
      <title>Re: New to Perl and stuck...Help</title>
      <link>http://www.programmersheaven.com/mb/perl/232358/232365/re-new-to-perl-and-stuckhelp/#232365</link>
      <description>: I am on my second day of Perl programming and I am stuck.  The ]&lt;br /&gt;
: program below will read a one line, 1 to 2 M file, test it, and, &lt;br /&gt;
: print some counts to another file.  I cannot get past the &lt;br /&gt;
: open...infile.&lt;br /&gt;
: &lt;br /&gt;
: Help!  I need to get this done soon (and with "use strict").&lt;br /&gt;
: &lt;br /&gt;
: Where did all of my spaces go???&lt;br /&gt;
: &lt;br /&gt;
: ========================= The Code ===========================&lt;br /&gt;
: &lt;br /&gt;
: #!/opt/utils/5bin/perl5.001 -w&lt;br /&gt;
: &lt;br /&gt;
: # We have two versions.  Make sure to use the lastest.&lt;br /&gt;
: &lt;br /&gt;
: require 5.001;&lt;br /&gt;
: use strict;&lt;br /&gt;
: &lt;br /&gt;
: if ( @ARGV &amp;lt; 2 )&lt;br /&gt;
:     {&lt;br /&gt;
:     die "\nUsage: $0 &amp;lt;infile&amp;gt;\n\nStopped";&lt;br /&gt;
:     }&lt;br /&gt;
: &lt;br /&gt;
: my $infile = shift @ARGV;&lt;br /&gt;
: my $outfile = shift @ARGV;&lt;br /&gt;
: &lt;br /&gt;
: open( my $infile_handle, "&amp;lt; $infile" ) or&lt;br /&gt;
:     die "\nCan't open input file \"$infile\".\n",&lt;br /&gt;
:         "Error: $!.\n",&lt;br /&gt;
:         "Stopped";&lt;br /&gt;
Don't see an immediate problem here, but you are using an older version of Perl.  This means it may like you to declare $infile_handle before the open statement, e.g.:-&lt;br /&gt;
&lt;br /&gt;
my $infile_handle;&lt;br /&gt;
open $infile_handle, "&amp;lt; $infile" or ...blah...;&lt;br /&gt;
&lt;br /&gt;
: open( my $outfile_handle, "&amp;gt; $outfile" ) or&lt;br /&gt;
:     die "\nCan't open output file \"$outfile\".\n",&lt;br /&gt;
:         "Error: $!.\n",&lt;br /&gt;
:         "Stopped";&lt;br /&gt;
And maybe the same there.&lt;br /&gt;
&lt;br /&gt;
: my $text = join( '', &amp;lt;$infile_handle&amp;gt; );&lt;br /&gt;
: my $test_len = length( $test );&lt;br /&gt;
Should that not be:-&lt;br /&gt;
my $test_len = length( $te&lt;span style="color: Red;"&gt;x&lt;/span&gt;t );&lt;br /&gt;
&lt;br /&gt;
: print "\n" , $test_len, "\n";&lt;br /&gt;
: &lt;br /&gt;
: close $infile_handle;&lt;br /&gt;
: &lt;br /&gt;
: chomp $text;&lt;br /&gt;
: &lt;br /&gt;
: #&lt;br /&gt;
: # process the line and print results...&lt;br /&gt;
: #&lt;br /&gt;
: &lt;br /&gt;
: close $outfile_handle;&lt;br /&gt;
: &lt;br /&gt;
: exit ( 0 );&lt;br /&gt;
&lt;br /&gt;
Looks OK besides that.  FYI, it's good to enclose code in code and /code tags - tags are put in square brackets.  Then the spacing is retained.  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Hope this helps, if not please post the output of perl -c thescript.pl, where thescript.pl is your script.  That or run it and post the warnings that you're given.&lt;br /&gt;
&lt;br /&gt;
Jonathan&lt;br /&gt;
&lt;br /&gt;
###&lt;br /&gt;
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&amp;amp;&amp;amp;&lt;br /&gt;
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;&lt;br /&gt;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/232358/232365/re-new-to-perl-and-stuckhelp/#232365</guid>
      <pubDate>Thu, 18 Dec 2003 13:53:08 -0700</pubDate>
      <category>Perl</category>
    </item>
    <item>
      <title>Re: New to Perl and stuck...Help</title>
      <link>http://www.programmersheaven.com/mb/perl/232358/232370/re-new-to-perl-and-stuckhelp/#232370</link>
      <description>&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by mikeruth at  2003-12-18 14:28:27&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
&lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by mikeruth at  2003-12-18 14:25:13&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
I made the changes that you suggested (thanks for catching the "test"&lt;br /&gt;
error).  The new code is:&lt;br /&gt;
&lt;br /&gt;
my $infile_handle;&lt;br /&gt;
open( $infile_handle, "&amp;lt; $infile" ) or ...&lt;br /&gt;
&lt;br /&gt;
When run I get:&lt;br /&gt;
&lt;br /&gt;
Can't use an undefined value as a symbol reference at edijd110.pl line 24. &amp;lt;--- the open above&lt;br /&gt;
&lt;br /&gt;
With -c I get:&lt;br /&gt;
&lt;br /&gt;
edijd110.pl syntax OK&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: : open( my $infile_handle, "&amp;lt; $infile" ) or&lt;br /&gt;
: :     die "\nCan't open input file \"$infile\".\n",&lt;br /&gt;
: :         "Error: $!.\n",&lt;br /&gt;
: :         "Stopped";&lt;br /&gt;
: Don't see an immediate problem here, but you are using an older version of Perl.  This means it may like you to declare $infile_handle before the open statement, e.g.:-&lt;br /&gt;
: &lt;br /&gt;
: my $infile_handle;&lt;br /&gt;
: open $infile_handle, "&amp;lt; $infile" or ...blah...;&lt;br /&gt;
: &lt;br /&gt;
: : open( my $outfile_handle, "&amp;gt; $outfile" ) or&lt;br /&gt;
: :     die "\nCan't open output file \"$outfile\".\n",&lt;br /&gt;
: :         "Error: $!.\n",&lt;br /&gt;
: :         "Stopped";&lt;br /&gt;
: And maybe the same there.&lt;br /&gt;
: &lt;br /&gt;
: Looks OK besides that.  FYI, it's good to enclose code in code and /code tags - tags are put in square brackets.  Then the spacing is retained.  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
: &lt;br /&gt;
: Hope this helps, if not please post the output of perl -c thescript.pl, where thescript.pl is your script.  That or run it and post the warnings that you're given.&lt;br /&gt;
: &lt;br /&gt;
: Jonathan&lt;br /&gt;
: &lt;br /&gt;
: ###&lt;br /&gt;
: for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&amp;amp;&amp;amp;&lt;br /&gt;
: (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;&lt;br /&gt;
: /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/232358/232370/re-new-to-perl-and-stuckhelp/#232370</guid>
      <pubDate>Thu, 18 Dec 2003 14:19:04 -0700</pubDate>
      <category>Perl</category>
    </item>
    <item>
      <title>Re: New to Perl and stuck...A solution??</title>
      <link>http://www.programmersheaven.com/mb/perl/232358/232371/re-new-to-perl-and-stucka-solution/#232371</link>
      <description>I found a solution but I do not know why it works.&lt;br /&gt;
&lt;br /&gt;
I deleted the line "my $infile_handle;".&lt;br /&gt;
I changed all occurences of "$infile_handle" to "INFILE_HANDLE".&lt;br /&gt;
&lt;br /&gt;
Why does this work?&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by mikeruth at  2003-12-18 14:28:27&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: &lt;strong&gt;&lt;span style="color: Red;"&gt;This message was edited by mikeruth at  2003-12-18 14:25:13&lt;/span&gt;&lt;/strong&gt;&lt;hr /&gt;&lt;br /&gt;
: I made the changes that you suggested (thanks for catching the "test"&lt;br /&gt;
: error).  The new code is:&lt;br /&gt;
: &lt;br /&gt;
: my $infile_handle;&lt;br /&gt;
: open( $infile_handle, "&amp;lt; $infile" ) or ...&lt;br /&gt;
: &lt;br /&gt;
: When run I get:&lt;br /&gt;
: &lt;br /&gt;
: Can't use an undefined value as a symbol reference at edijd110.pl line 24. &amp;lt;--- the open above&lt;br /&gt;
: &lt;br /&gt;
: With -c I get:&lt;br /&gt;
: &lt;br /&gt;
: edijd110.pl syntax OK&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: : : open( my $infile_handle, "&amp;lt; $infile" ) or&lt;br /&gt;
: : :     die "\nCan't open input file \"$infile\".\n",&lt;br /&gt;
: : :         "Error: $!.\n",&lt;br /&gt;
: : :         "Stopped";&lt;br /&gt;
: : Don't see an immediate problem here, but you are using an older version of Perl.  This means it may like you to declare $infile_handle before the open statement, e.g.:-&lt;br /&gt;
: : &lt;br /&gt;
: : my $infile_handle;&lt;br /&gt;
: : open $infile_handle, "&amp;lt; $infile" or ...blah...;&lt;br /&gt;
: : &lt;br /&gt;
: : : open( my $outfile_handle, "&amp;gt; $outfile" ) or&lt;br /&gt;
: : :     die "\nCan't open output file \"$outfile\".\n",&lt;br /&gt;
: : :         "Error: $!.\n",&lt;br /&gt;
: : :         "Stopped";&lt;br /&gt;
: : And maybe the same there.&lt;br /&gt;
: : &lt;br /&gt;
: : Looks OK besides that.  FYI, it's good to enclose code in code and /code tags - tags are put in square brackets.  Then the spacing is retained.  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
: : &lt;br /&gt;
: : Hope this helps, if not please post the output of perl -c thescript.pl, where thescript.pl is your script.  That or run it and post the warnings that you're given.&lt;br /&gt;
: : &lt;br /&gt;
: : Jonathan&lt;br /&gt;
: : &lt;br /&gt;
: : ###&lt;br /&gt;
: : for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&amp;amp;&amp;amp;&lt;br /&gt;
: : (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;&lt;br /&gt;
: : /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");&lt;br /&gt;
: : &lt;br /&gt;
: : &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/232358/232371/re-new-to-perl-and-stucka-solution/#232371</guid>
      <pubDate>Thu, 18 Dec 2003 14:43:31 -0700</pubDate>
      <category>Perl</category>
    </item>
    <item>
      <title>Re: New to Perl and stuck...A solution??</title>
      <link>http://www.programmersheaven.com/mb/perl/232358/232374/re-new-to-perl-and-stucka-solution/#232374</link>
      <description>: I found a solution but I do not know why it works.&lt;br /&gt;
: &lt;br /&gt;
: I deleted the line "my $infile_handle;".&lt;br /&gt;
: I changed all occurences of "$infile_handle" to "INFILE_HANDLE".&lt;br /&gt;
That was going to be my suggestion, but I went to grab some whisky before replying and you beat me to it.  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
: Why does this work?&lt;br /&gt;
In older versions of Perl 5 it was not possible to store a file handle in a scalar.  5.005 qualifies as "older".  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
&lt;br /&gt;
Jonathan&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
###&lt;br /&gt;
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&amp;amp;&amp;amp;&lt;br /&gt;
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;&lt;br /&gt;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");&lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/232358/232374/re-new-to-perl-and-stucka-solution/#232374</guid>
      <pubDate>Thu, 18 Dec 2003 14:56:47 -0700</pubDate>
      <category>Perl</category>
    </item>
    <item>
      <title>Re: New to Perl and stuck...A solution??</title>
      <link>http://www.programmersheaven.com/mb/perl/232358/232375/re-new-to-perl-and-stucka-solution/#232375</link>
      <description>Thank you for your help and time.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
: : I found a solution but I do not know why it works.&lt;br /&gt;
: : &lt;br /&gt;
: : I deleted the line "my $infile_handle;".&lt;br /&gt;
: : I changed all occurences of "$infile_handle" to "INFILE_HANDLE".&lt;br /&gt;
: That was going to be my suggestion, but I went to grab some whisky before replying and you beat me to it.  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
: &lt;br /&gt;
: : Why does this work?&lt;br /&gt;
: In older versions of Perl 5 it was not possible to store a file handle in a scalar.  5.005 qualifies as "older".  &lt;img src="http://www.programmersheaven.com/images/Community/smile.gif" width="15" height="15" alt="" /&gt;&lt;br /&gt;
: &lt;br /&gt;
: Jonathan&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
: ###&lt;br /&gt;
: for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&amp;amp;&amp;amp;&lt;br /&gt;
: (tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;&lt;br /&gt;
: /(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");&lt;br /&gt;
: &lt;br /&gt;
: &lt;br /&gt;
&lt;br /&gt;</description>
      <guid isPermaLink="true">http://www.programmersheaven.com/mb/perl/232358/232375/re-new-to-perl-and-stucka-solution/#232375</guid>
      <pubDate>Thu, 18 Dec 2003 15:01:57 -0700</pubDate>
      <category>Perl</category>
    </item>
  </channel>
</rss>