Just use it. In Perl, a string that looks like a number is a number.
Now, if you want to be sure that the thing is the number before using it, then there is a utility method in Scalar::Util
that does this:
use Scalar::Util qw/looks_like_number/; $input=substr($line,1,index($line,",")-1); if (looks_like_number($input)) { $input += 1;
Based on the input of the sample that you left in the comments, a more reliable way to extract the number:
$line =~ /([^\[\],]+)/;
source share