curtisb has asked for the wisdom of the Perl Monks concerning the following question:
OK, here is my function for splitting text at commas. However it is not working. Could someone please help? The script is to take one file, strip the commas out and copy to a new file.
There are four columns that will be split on commas.
Thanks,$file = 'u:\curtisbl\test\text.dbf'; $file0 = 'u:\curtisbl\test\output.dbf'; $warn = "Unable to open file: $file\n"; $warn0 = "Unable to create output file: $file0\n"; $warn1 = "Unable to close file: $file\n"; $warn2 = "Unable to close output file: $file0\n"; open(FILE, "$file") || die $warn; open(TEXT, ">$file0") || die $warn0; while (<FILE>) { ($description, $UIC1, $UIC2, $UIC3) = split(/,+/); print TEXT; } close(FILE) || die $warn1; close(TEXT) || die $warn2;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(jeffa) Re: split function
by jeffa (Bishop) on Nov 12, 2001 at 22:05 UTC | |
|
Re: split function
by arhuman (Vicar) on Nov 12, 2001 at 22:10 UTC | |
by belg4mit (Prior) on Nov 12, 2001 at 22:16 UTC | |
|
Re: split function
by belg4mit (Prior) on Nov 12, 2001 at 22:13 UTC |