my $comment_count; my $share_count; if($lines =~m/\"comment_count\"\:.*?(\d+?)/gc){ $comment_count = $1; } if($lines =~m/\"share_count\"\:.*?(\d+?)/gc){ $share_count = $1; }