Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl syntax error: Bareword found where operator expected

Tags:

perl

As the title suggests how could I accomplish this?

I have been following a tutorial, but I get a syntax error:

Bareword found where operator expected at arrays_and_variables.pl line
26, near "$2names"
        (Missing operator before names?) syntax error at
arrays_and_variables.pl line 26, near "$2names " Execution of
arrays_and_variables.pl aborted due to compilation errors.

The code I have so far is:

@names = ('james','dylan','max');

# join elements of array into a schalar variable.
$2names = join ('', @names);
print $s2names;
like image 767
Ben Thorsby Avatar asked Jul 01 '26 11:07

Ben Thorsby


1 Answers

2names is an invalid variable name. Names can't start with a number—they have to begin with a letter or an underscore.

like image 181
Samir Talwar Avatar answered Jul 03 '26 21:07

Samir Talwar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!