
tacitoregis
(usa Ubuntu)
Enviado em 24/10/2013 - 19:09h
Senhores,
Estou aprendendo perl e parei em um problema que aconteceu quando eu estudava referencias e ponteiros. Será que alguém pode me ajudar? O erro foi o seguinte.
#!/usr/bin/perl
use warnings;
$idade = 25;
@nomes = qw(Frodo Sam Fred Vilma) ;
%conta = ( banco => "Perl Bank" ,
correntista => "Willy Kitty",
saldo => 1500 ,
);
# Criando Ponteiros:
$pointer1 = \$idade;
$pointer2 = \@nomes;
$pointer3 = \%conta;
$pointer4 = [ qw(céu árvore mar) ] ;
$pointer5 = { SP => "São Paulo", RS=>"Rio Grande do Sul", MA => "Maranhão" };
# Removando a referência:
say $$pointer1;
say @$pointer2;
say %$pointer3;
say $pointer2->[1] ;
say $pointer3->{"correntista"};
say "@{$pointer4}";
say %{$pointer5};
Este foi o erro apresentado..
chaves-laptop perl # ./exemplo2.4.pl
Unquoted string "say" may clash with future reserved word at ./exemplo2.4.pl line 25.
Array found where operator expected at ./exemplo2.4.pl line 25, at end of line
(Missing operator before ?)
Unquoted string "say" may clash with future reserved word at ./exemplo2.4.pl line 26.
Unquoted string "say" may clash with future reserved word at ./exemplo2.4.pl line 29.
String found where operator expected at ./exemplo2.4.pl line 29, near "say "@{$pointer4}""
(Do you need to predeclare say?)
Unquoted string "say" may clash with future reserved word at ./exemplo2.4.pl line 30.
syntax error at ./exemplo2.4.pl line 25, near "say @"
syntax error at ./exemplo2.4.pl line 29, near "say "@{$pointer4}""
Execution of ./exemplo2.4.pl aborted due to compilation errors.
Se alguém puder, por favor, me ajudem..