#!/usr/bin/perl # $Id: XXX.plx; # $Revision: 1 $ # $HeadURL: 1 $ # $Source: /Perl/XXX.plx $ # $Date: 10.30.2012 $ # $Author: daugh016 $ use 5.014; #this enables strict use warnings; use vars qw/ $VERSION /; $VERSION = '1.00'; use English qw(-no_match_vars); use Readonly; my $print_err = "Cannot print:\t"; my $var_test = 'This is a test variable'; print_var_with_err( "\$var_test", "\$print_err" ); my @list_test = qw(This is a test list); print_list_with_err( "\@list_test", "\$print_err" ); # Print variable with error messages sub print_var_with_err { my ( $a, $b ) = @_; my $a_eval = eval $a; my $b_eval = eval $b; print $a . qq{:\n} . $a_eval . qq{\n} or croak( $b_eval . $ERRNO ); return; } # Print list with error messages sub print_list_with_err { my ( $c, $d ) = @_; my @c_eval = eval "$c"; my $d_eval = eval $d; while ( my ( $index, $elem ) = each @c_eval ) { say $c . q{[} . $index . qq{]:\n} . $elem . qq{\n} or croak( $d_eval . $ERRNO ); } return; }