in reply to Re^4: Unable to run or troubleshoot a script...
in thread Unable to run or troubleshoot a script...
Regarding that comment about "old or oddball" mac files: since macosx is built atop BSD UNIX, it's entirely likely (and normal) for text files on current macs to use LF rather than CR line termination (i.e. when they've been created by perl or unix shell operations). But there are some "legacy style" operations and tools still operating in macosx that may create CR-terminated text files as well.my $infile = "some_indeterminate_kindof.txt"; open( IN, "<", $infile ) or die "$infile: $!\n"; my @raw_lines = <IN>; close IN; s/[\r\n]+$// for ( @raw_lines ); # "chomp" for both dos and unix my @text_lines = map { split /\r+/ } @raw_lines; # for (old or oddbal +l) mac files
That snippet should also work as intended in case you happen to get "hybrid" input (e.g. in cases where a single text stream is really a "raw" concatenation of files with different line-termination patterns).
|
|---|