in reply to Format file

[ Please include computer text (code, data, output) in <c>..</c> tags. It will preserve the layout. It'll even handle escaping special character for you. ]

Every time I try to run this code I get a syntax error at my.

$SELECT.DAT2 is not a valid variable name.

my $SELECT.DAT2

means

(my $SELECT) . "DAT2"

Contrary to what you said, it's not a syntax error, but it's obviously not what you want. That's why you should always use use strict;. That would have made it a syntax error. It catches so many errors.

There is a syntax error in your code, though.

$ perl a.pl String found where operator expected at a.pl line 4, near ""NO" "\n"" (Missing operator before "\n"?) syntax error at a.pl line 4, near ""NO" "\n"" a.pl had compilation errors.

This is caused by a missing comma.

Replies are listed 'Best First'.
Re^2: Format file
by cdarke (Prior) on Jan 22, 2011 at 05:56 UTC
    Just to clarify, except for the leading sigil ($,@,%, etc.), variable names may only consist of alphanumerics or an underscore. The first character must not be a numeric.

    You will see certain special variables which break this rule (see perlvar) but these are used to control, or get information about, perl behaviour. You cannot create them yourself.