Hi --
I've read some explanations in the Camel book, but this error is puzzling me:
------------------------------
code
-----------------------------
#!/usr/bin/perl
use warnings;
use strict;
system("clear");
our $FileName;
our @File;
our @Card;
_enterCard();
my $hex = _transformToHex(@Card);
print "$hex\n";
sub _enterCard
{ #write the biblographic card
print "AUTHOR(S)= "; my $authors = <>;
print "TITLE= "; my $title = <>;
print "KEYWORDS= "; my $keywords = <>;
print "SOURCE/JOURNAL= "; my $source = <>;
print "VOL= "; my $vol = <>;
print "YEAR= "; my $year = <>;
print "PAGES= "; my $pages = <>;
print "EDITOR= "; my $editor = <>;
print "ETC= "; my $etc = <>;
print "X-REF= "; my $xref = <>;
$authors = "AUTHOR(S)= $authors";
$title = "TITLE= $title";
$keywords = "KEYWORDS= $keywords";
$source = "SOURCE/JOURNAL= $source";
$vol = "VOL= $vol";
$year = "YEAR= $year";
$pages = "PAGES= $pages";
$editor = "EDITOR= $editor";
$etc = "ETC= $etc";
$xref = "X-REF= $xref";
@Card=($authors, $title, $keywords, $source, $vol, $year, $pages, $editor, $etc, $xref);
print "\n\n@Card\n";
}
sub _transformToHex {
my @data = @_
my $hex = unpack("H*", join('_', @data));
#print "$hex\n";
return $hex;
}
----------------------
end code
----------------------
----------------------
error
----------------------
$ perl writeFile.pl
syntax error at writeFile.pl line 51, near "@_
my "
Global symbol "@data" requires explicit package name at writeFile.pl line 51.
Execution of writeFile.pl aborted due to compilation errors.
----------------------
end error
---------------------
The data (@Card) was passed to the argument stack (@_) via a subroutine and
it was bound locally (that is, in the block lexical scope) to @data.
Of course, simply appending "my @data;" at the beginning of the script
(next to "our (etc..)") would resolve the error.
But why do you have to do that, since we declare "my @data" inside a sub
routine block?
I don't understand this...
Any comment on what the issue is is appreciated.
TIA.
Henry Lenzi