use strict; my ($this, $that, $tother, $twix); my $fname = "0092042095432.dat"; if ($fname =~ /^(\d{4})(\d{3})(\d{3})(\d{3})/) { ($this, $that, $tother, $twix) = ($1,$2,$3,$4); } print "$this $that $tother $twix\n"; # ...or whatever #### ($this, $that, $tother, $twix) = $fname =~ /^(\d{4})(\d{3})(\d{3})(\d{3})/; print "$this $that $tother $twix\n"; # ...or whatever