There aren't many pitfalls. Any modules that you might encounter that you have doubts about can be checked against testing information.
The "\n" character cleanly prints CRLF. So you don't need to change your previous code. Perl is smart like that.
Windows 9x is less reliable than NT flavors, but that's just my observation.
Quick and Dirty newline fixer-uper (there's more than one better way to do this:)
#!/usr/bin/perl
use strict 'vars';
use vars qw( @stuff $i @ARGV $fh );
$/ = undef;
if (-e "$ARGV[0]"){
open ($fh, "+>>$ARGV[0]");
seek $fh,0,0;
@stuff = <$fh>;
foreach (@stuff){
$_ =~ s/\r/\n/mig;
}
seek $fh,0,0;
truncate $fh,0;
print $fh @stuff;
close $fh;
print "Done.\n";
}
else{
print "Select a file that's actually there.\n";
}
Hope this helps.
John J Reiser
newrisedesigns.com
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|