Re: Perl equivalent to unix script
- From: usenet@xxxxxxxxxxxxxxx
- Date: 30 Oct 2006 11:00:13 -0800
Mike wrote:
cat tempfile1 | sort > newfile2;
That's rather convoluted even for UNIX scripting. Why not:
sort tempfile1 > newfile2;
You cannot do this as a pure-Perl approach (ie, no shell redirects,
etc) any more simply. You could do something like this:
#!/usr/bin/perl
use strict; use warnings;
open (my $in, '<', '/tmp/tempfile1') or die "oops - $!\n";
open (my $out, '>', '/tmp/newfile2') or die "oops - $!\n";
print $out sort(<$in>);
close $in;
close $out;
unlink $in;
__END__
--
The best way to get a good answer is to ask a good question.
David Filmer (http://DavidFilmer.com)
.
- Prev by Date: Re: How do I do full access logging including HTTP headers?
- Next by Date: Re: Interesting behaviour with lexical variable
- Previous by thread: Re: Perl equivalent to unix script
- Next by thread: FAQ 4.64 How can I get the unique keys from two hashes?
- Index(es):