in reply to Re^2: File Manipulation - Need Advise!
in thread File Manipulation - Need Advise!

file1.txt output is the following:- COMPUTER DISTRIBUTION_ID STATUS 30F-WKS `1781183799.xxx11' IC--- 30F-WKS `1781183799.xxxx1' IC--- ADM34A3F9 `1781183799.41455' IC---
I want COMPUTER DISTRIBUTION_ID STATUS 30F-WKS `1781183799.xxx11' IC--- ADM34A3F9 `1781183799.41455' IC---

Replies are listed 'Best First'.
Re^4: File Manipulation - Need Advise!
by bart (Canon) on Jan 03, 2008 at 18:32 UTC
    Like someone said in the Chatterbox: your data may not separated by tabs. Therefore, the whole record (line) would be treated as the id.

    Replace split /\t/ in my code, with split /\s+/.

    If it still won't work, then use the following code at the end, to test what's in the hash:

    use Data::Dumper; print Dumper \%data;
    and see what makes it fail.

      Bart, Its working now!!! How can open file2.txt and print to file1.txt WITHIN THE SCRIPT? Is this possible with your solution???

            How can open file2.txt and print to file1.txt WITHIN THE SCRIPT? I

        Consider:

        | | Hand waving.... | | # be sure to close the files before re-opening them if they have been +opened in the script # prior to this point open(F1,"> file1.txt") or die "file1.txt: $!"; open(F2,"< file2.txt") or die "file2.txt: $1"; | | More hand waving.... $line=<F2>; # read a line from file2.txt print F1 $line; #write that line to file1.txt


        Peter L. Berghold -- Unix Professional
        Peter -at- Berghold -dot- Net; AOL IM redcowdawg Yahoo IM: blue_cowdawg