Link to home
Start Free TrialLog in
Avatar of dwcronin
dwcroninFlag for United States of America

asked on

hopefully a simple hash error

i'm new to perl so this is hopefully simple.  i keep getting the following error:

------------------------------------------------------------------------------------------------------------
syntax error at /home/dwcronin/programs/ex4_1 line 7, near "$family_name{"
Execution of /home/dwcronin/programs/ex4_1 aborted due to compilation errors.
--------------------------------------------------------------------------------------------------------------

specifically. i'm trying to learn hashes by following the o'reilly book 'learning perl" by randal schwartz.
Avatar of dwcronin
dwcronin
Flag of United States of America image

ASKER

here is the code that would not upload:
#!/usr/bin/perl;                                           # ex5_1
######################################################################################
use warnings;
use strict;
use 5.010;

my $family_name{"fred"} = "flintstone";

~                                                                                                                                                                        
~                                                                                                                                                                        
~                                                                                                                                                                        
~                                                                                                                                                                        
~                                                                                                                                                                        
~
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Alternatively, you can initialize the variable inline:

use warnings;
use strict;
use 5.010;

my %family_name = ("fred", "flintstone");

Open in new window