open(NEW,"<","new.txt"); while ( my $line = ) { chomp $line; process_line($line); } close(NEW); sub process_line { my $line = shift; my @chars = split//,$line; print ord($chars[0]),$/; # print the character number of the first character of $line print $line,$/; }