http://www.perlmonks.org?node_id=1009235


in reply to Making Cue Scripts with Perl

open PLAY, $mit_shakes || die "Could not open file: $!\n";

You are testing whether $mit_shakes is true or false, not whether open succeeded or failed.    You need to either use parentheses:

open( PLAY, $mit_shakes ) || die "Could not open file: $!\n";

Or use the low precedence or operator:

open PLAY, $mit_shakes or die "Could not open file: $!\n";


until ($line =~ m/<\/head>/) { if ($line =~ m/<title>(.*)<\/title>/) { $title_of_play = $1; } print "$line\n"; $line = <PLAY>; }

That is usually written as:

while ( my $line = <PLAY> ) { last if $line =~ m/<\/head>/; if ( $line =~ m/<title>(.*)<\/title>/ ) { $title_of_play = $1; } print "$line\n"; }


my $i = 0; foreach (@ARGV) { if ($i == 0) { print "$_"; $i = 1; } else { print ", $_"; } } print ". </h2>\n";

That is usually written as:

print join ', ', @ARGV, "</h2>\n";


while (<PLAY>) { $line = $_;

That is usually written as:

while ( my $line = <PLAY> ) {


foreach (@ARGV) { my $character = $_;

That is usually written as:

foreach my $character ( @ARGV ) {