#!/usr/bin/perl use strict; use warnings; while (<>) { chomp(); # Remove trailing newline my $checkvalue = substr($_, 0, 6); print("$checkvalue -130 -125\n") if ($checkvalue > -130 && $checkvalue <= -125); } __END__ ~> cat input.txt -123 -124 -125 -126 -127 -128 -129 -130 -131 -132 ~> ./prova.pl input.txt -125 -130 -125 -126 -130 -125 -127 -130 -125 -128 -130 -125 -129 -130 -125