in reply to FileOperation.pl

There's some room for improvement here. First, I have to confess that I don't know what "MO" refers to, and I don't think I'll ever have a set of directories called "inboundd", "DN_Dump" and "MO_Dump" with files called "*.dat" that have the particular arrangement of comma-separated values that your code expects. I don't want to discourage you, but in order for people to find this useful, there needs to be more explanation about how and why it might be useful.

As for things that could be improved:

Here's an alternative version that shows what I'm talking about (and a few other adjustments):

#!/usr/bin/perl -- use strict; die "We don't seem to be in the right directory.\n" unless ( -d 'inboundd' and -d 'DN_Dump' and -d 'MO_Dump' ); my @datfiles = <inboundd/*.dat>; die "No inboundd/*.dat files were found. We must be done.\n" unless ( @datfiles ); local $/; # set input record separator to "undef" for my $GetFile ( @datfiles ) { ( my $PutFile = $GetFile ) =~ s{inboundd/}{}; if ( $PutFile =~ /^DN_/ ) { rename $GetFile, "DN_Dump/$PutFile" or die "Can't move $GetFil +e to DN_Dump: $!"; next; } open( CHECKBOOK, $GetFile ) || die "$GetFile: $!"; my $InString = <CHECKBOOK>; close CHECKBOOK; rename $GetFile, "MO_Dump/$PutFile" or die "Can't move $GetFile to + MO_Dump: $!"; # GETTING THE FILE OUT AND FORM MO if (( my @InArrData = split( /,/, $InString )) >= 9 ) { my ( $Mobile, $Msg, $Short, $Vendor, $Inbound ) = @InArrData[1,5,6,7,9]; $Msg =~ s/[0-9a-f]{2}/chr(hex($1))/egi; print "mo:$Mobile:$Short:$Inbound:$Vendor:$Msg\n"; } }
(updated to add "die" traps on the "rename" calls)

I don't really know what those *.dat files contain. I'm taking your word for it that applying "split /,/" to the file content will always produce exactly the set of values, in the exact order, required by your list of assignments: no unexpected commas within quoted CSV fields, no extra lines of commentary (with commas) before the expected data, no leading or trailing whitespace that would mess up the output string, and so on. (Usually, I'd be less trustful of data file contents.)