Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: Making Cue Scripts with Perl

by jwkrahn (Monsignor)
on Dec 17, 2012 at 21:19 UTC ( #1009235=note: print w/ replies, xml ) Need Help??


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 ) {


Comment on Re: Making Cue Scripts with Perl
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1009235]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-12-25 16:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (160 votes), past polls