Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Array Manipulation

by Jalcock501 (Sexton)
on Oct 08, 2013 at 08:53 UTC ( #1057382=note: print w/ replies, xml ) Need Help??


in reply to Array Manipulation

For some reason I keep getting the following

syntax error at ./new.pl line 6, near ") {" Execution of ./new.pl aborted due to compilation errors.
When running this bit of script:
#! /usr/bin/perl -w my @files= <*.in> for (@files) { s/[.]in//g } say $_ for @files;


Comment on Re: Array Manipulation
Select or Download Code
Re^2: Array Manipulation
by Corion (Pope) on Oct 08, 2013 at 09:03 UTC

    The detection of the real error location is not always precise (and it unfortunately cannot be). When you are looking at an obviously valid construct and Perl still insists on finding a fault there, look at the preceding statements - most likely it's a missing semicolon there that "extends" that statement further and leads to an error somewhere further down the code.

    In your case, it's a missing semicolon in the statement right before your for statement:

    my @files= <*.in>
      Hi Corion

      You know what... I literally spotted that just before reading this post, feel like an absolute muppet.

      Thanks for your help mate.

      Jim

Re^2: Array Manipulation
by Anonymous Monk on Oct 08, 2013 at 09:06 UTC
    Beware of whitespace in shebang (line 1), and beware of missing semicolons (line 3)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (11)
As of 2014-09-16 19:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (44 votes), past polls