in reply to choping a word!

You could use substr or unpack

use strict; my $filename="0092042095432.dat"; #get this in as desired #THEN with substr my $fourchars=substr($filename,0,4); # OR with unpack my $fourchars=unpack("A4",$filename); #THEN if you want each character you can my @chars=split('',$fourchars);

Now you have an array chars with the values (0, 0, 9, 2);