: I am on my second day of Perl programming and I am stuck. The ]
: program 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.
:
: Help! I need to get this done soon (and with "use strict").
:
: Where did all of my spaces go???
:
: ========================= The Code ===========================
:
: #!/opt/utils/5bin/perl5.001 -w
:
: # We have two versions. Make sure to use the lastest.
:
: require 5.001;
: use strict;
:
: if ( @ARGV < 2 )
: {
: die "\nUsage: $0 <infile>\n\nStopped";
: }
:
: my $infile = shift @ARGV;
: my $outfile = shift @ARGV;
:
: open( my $infile_handle, "< $infile" ) or
: die "\nCan't open input file \"$infile\".\n",
: "Error: $!.\n",
: "Stopped";
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.:-
my $infile_handle;
open $infile_handle, "< $infile" or ...blah...;
: open( my $outfile_handle, "> $outfile" ) or
: die "\nCan't open output file \"$outfile\".\n",
: "Error: $!.\n",
: "Stopped";
And maybe the same there.
: my $text = join( '', <$infile_handle> );
: my $test_len = length( $test );
Should that not be:-
my $test_len = length( $te
xt );
: print "\n" , $test_len, "\n";
:
: close $infile_handle;
:
: chomp $text;
:
: #
: # process the line and print results...
: #
:
: close $outfile_handle;
:
: exit ( 0 );
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.
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.
Jonathan
###
for(74,117,115,116){$::a.=chr};(($_.='qwertyui')&&
(tr/yuiqwert/her anot/))for($::b);for($::c){$_.=$^X;
/(p.{2}l)/;$_=$1}$::b=~/(..)$/;print("$::a$::b $::c hack$1.");