in reply to split string by character count

Have you thought of using unpack? Then each time you wish to split the $string into $subStrings you can just change the unpack code list.

I'm not sure how you're representing @list - is each line an element that needs parsing into $var and $noChar or individual elements?

Assuming the structure you have above you could do something like:

my $string = '21090412500011 209 070279501 9047 +0 1111'; my $f = "A6A4A4A15A18A4A1A5A13"; # Dynamically construct from list val +ues. my @subStrings = unpack("A6A4A4A15A18A4A1A5A13",$string);

Then the @subStrings list would hold all the substrings you require.

All you have to do each time you read it is parse the @list and create the $f pack list. Each substring is represented by an "A" (alphanumeric) followed by the length of the substring - i.e. "A6" is a 6 char substring.