How can I detect and/or error on undefined barewords in perl subroutines?

I receive data files in perl, and I'd like to read them into Matlab.  Some of 
the files contain barewords that I don't have an implementation for.  When I 
process these files using the do command, the undefined barewords are silently 
treated as 0.  This is undesirable because I'd have to look through all files 
provided to me, detect undefined barewords. And if I miss one, my data is 
invalid.

>From what I can tell, Matlab's perl command returns a character array that's 
>printed to the terminal in perl.  So my process is: run the provided file with 
>do, encode the result as json, print the result for use in Matlab, and convert 
>the json string into a Matlab struct.

So is there something different I can do to cause an error when provided files 
contain undefined barewords?

#start Received file====================
$someVar = [map {$_ - 250 * FT2M} 1,2,3,];  #FT2M is undef
{
  variable => "SomethingCool",
  data => $ someVar
}

#end Received file=====================

#start my script ====================
use strict;
use warnings;
use JSON;

my $json = JSON->new;
my $return = do $ARGV[0];  #using ARGV to get file from user
print encode_json $return;

#end my script =====================

Thanks,
Dustin

Reply via email to