in reply to split problem...

If you're starting with a multi-line string (1^a^x\r\n2^b^y\r\n3^c^z\r\n...) stored in a scalar variable ($itDetail), then the easier way would be:
open( FH, ">/some/path/debug.txt" ) or die "can't write debug.txt: $!" +; for my $_line ( split /[\r\n]+/, $itDetail ) { my ( $Num, $Qt, $_trashit ) = split /\^/, $_line; print FH "Num = $Num\n"; # do other things... }