I'm trying to write a script to send an email containing a traffic monitoring graph from some network management software (MRTG).
Could anyone help me with passing a hash by reference please?
This is my code:
[red]
[/red]
The line in red above is where Perl chokes and I see this error:
[red]
[/red]
Line 140 is where I try to read the values in the hash table which I have just passed by ref.
Could anyone show me how to read arrays of hashes after they have been passed by reference please? I can paste the whole program if necessary.
Many thanks,
James.
Could anyone help me with passing a hash by reference please?
This is my code:
Code:
#Main#
#Get info
@mails = get_info()
#Mails is an array of hashes
#Pass by ref
get_html ( \$mails[$i]{'html'} );
sub get_info{
...etc...
#store the filepath of the html page to send
$mail{'html'}{'file_loc'} = $content;
...etc...
}
#Open HTML file#
sub get_html{
my ( $html_hash ) = @_;
#Open HTML file specified in hash table
Code:
open ( HTML, [red]${$html_hash{'file_loc'}} );
Code:
...etc...
}
The line in red above is where Perl chokes and I see this error:
[red]
Code:
"Global symbol "%html_hash" requires explicit package name at email2.pl line 140."
Line 140 is where I try to read the values in the hash table which I have just passed by ref.
Could anyone show me how to read arrays of hashes after they have been passed by reference please? I can paste the whole program if necessary.
Many thanks,
James.