Paul Corr <corr@voicenet.com>, who wrote: > Folks, > > I work with a variety of HTML source files (DOS, UNIX, Mac) and want > to prepend a DOCTYPE line. A previous script version worked well with > Mac files but put DOS/UNIX output all on one line after processing. > The goal is to have the script function as a droplet returning Mac > files for further editing. > <snip> > > Surely, there is a portable perl idiom for this task. I flip between > DOS, VMS, UNIX and Mac OSes to work with files. Some files are > dropped in a Windows directory for my VirtualPC pickup. Some arrive > in email zipped or attached, etc. Hmmm... In my experience in switching between Windows/Unix/MacPerl (here lately mainly between Unix and MacPerl) I have found that the "\n" does the same thing on both platforms, so you should only have to do a "\r\n" or some such for the special case in DOS... For example, this script: #!perl -wT use strict; use diagnostics; # Convert 'serial' Date to 'Sat Nov 16 20:20:00 1963'... my @months = qw(Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec); my @days = qw(Sun Mon Tue Wed Thu Fri Sat); # Split on two-character groups? $_ = "0020201610630619701"; my ($sec,$min,$hour,$mday,$mon,$year,$wday) = /\d\d/g; print "DATE: ", join(" ", /\d\d/g), " was the serial number given.\n"; # Ex: qw(00 20 20 16 10 63 06 197 01); # Last two not used... $year += 1900; # Damn, there goes Y2k again... print<<_EOF; The DATE TIME: $days[$wday] $months[$mon] $mday $hour:$min:$sec $year _EOF __END__ works the same whether MacOS or Unix, the point here being it uses HEREDOCS to write the data, so ftp'ing the script from one platform to the next automatically fixes any CR/LF problems for me... HTH, -Sneex- :] ____________________________________________________________________ Bill Jones * Data Security Specialist * http://jacksonville.pm.org/ FCCJ * 501 W State St * Jacksonville, FL 32202 * 1 (904) 632-3089 __ __ __ __ __ / // /__ ____ ___ __ __ / // /__ _____/ /_____ ____ / _ / _ `/ _ \/ _ \/ // / / _ / _ `/ __/ '_/ -_) __/ /_//_/\_,_/ .__/ .__/\_, / /_//_/\_,_/\__/_/\_\\__/_/ /_/ /_/ /___/ Running LinuxPPC RedHat 5.0 (Hurricane) __ _ http://www.linuxppc.org / /(_)_ __ _ ___ __ http://www.apache.org / / | | '_ \| | | \ \/ / http://www.redhat.com / /__| | | | | |_| |> < http://www.perl.com \____/_|_| |_|\__,_/_/\_\ http://www.gimp.org ==== Want to unsubscribe from this list? ==== Send mail with body "unsubscribe" to macperl-anyperl-request@macperl.org