Re: [MacPerl-WebCGI] I'm out standing in my field, duh!
[email protected] Tue, 6 Mar 2001 15:32:39 +0900
| Newsgroups | perl.macperl.webcgi |
|---|---|
| Message-ID | <v04011705b6ca2e19d533@[211.19.92.57]> |
tedd<[email protected]> wrote: >I'm trying to open and read a data file on a server....... >Everything gets dumped (assigned) into the first variable... here's a script I use for parsing an Apple works data base which is TAB delimited - It splits on TABS to get the fields, then splits on the space in the first field so I can separate the name and surname. This script works, I use it a lot and, as you can see, it's not much different from your script, except (maybe) the source file was created under MacOS. In other words if the source file you're using wasn't created under Mac OS you may be getting some kind of conflict caused by different end of line markers: OS Perl Escape Char Octal -- ---------------- ----- Mac \r \015 UNIX \n \012 DOS/WIN \r\n \015\012 Perl uses \n to localize the end of line to whatever system it's running on, but only when it writes the file, so try adding this to your script $line =~ s/\015\012|\012|\015/\n/g; (or if you want to use it on $_) s/\015\012|\012|\015/\n/g; ===example script=== #! perl -w use strict; use diagnostics-verbose; my($path,@name,@data); $path='Macintosh HD:Desktop Folder:DB.txt'; open (IN, $path); while(<IN>){ @data=split(/\t/); @name=split(/\s/,$data[0]); print "$name[0] $name[1] Uname: $data[9] pass: $data[10]\n"; } ===example script=== HTH Robin