PERL @ (at sign) and ARRAY

commandline session

$cat array.pl
#!/usr/bin/perl
use strict;
use warnings;


my @colors = ("red","green","blue");
print "@colors";
print "n";
$perl array.pl
red green blue
$vim array.pl
$cat array.pl
#!/usr/bin/perl
use strict;
use warnings;


my @colors = ("red","green","blue");
print "@colors";
print "n";
print $color[0];
print "n";

$perl array.pl
Global symbol "@color" requires explicit package name at array.pl line 9.
Execution of array.pl aborted due to compilation errors.
$vim array.pl
$cat array.pl
#!/usr/bin/perl
use strict;
use warnings;


my @colors = ("red","green","blue");
print "@colors";
print "n";
print $colors[0];
print "n";

$perl array.pl
red green blue
red
$

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s