bug-fileutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: fileutils/textutils LC_COLLATE support


From: Bob Proulx
Subject: Re: fileutils/textutils LC_COLLATE support
Date: Fri, 19 Oct 2001 05:48:11 -0600

> Also because it's easier to call from perl (because that's what I'm
> doing) without changing LC_ALL for the whole process.

Perl seems able to handle this fine.  You don't need to change it for
the entire process.  Just for sort.

  use IO::File;
  use strict;
  
  sub perlsort {
      my $filename = shift;
      my $cmd = "LC_COLLATE=en_US.UTF-8 sort $filename |";
      my $file = IO::File->new();
      if (!$file->open($cmd)) {
          die "Error: Could not run sort: $!\n";
      }
      while (defined($_ = $file->getline())) {
          print $_;
      }
      if (!$file->close()) {
          die "Error: Could not sort: $!\n";
      }
  }

  if (length($ARGV[0])) {
      &perlsort($ARGV[0]);
  }

Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]