[EMAIL PROTECTED] wrote:
> 
> I have tried the below perl script to modify the major version number in a
> Unicode text file. It seems that the substitution never happens as the
> 'print' statement in the script below simple echoe the contents of the line.
> Any ideas as to what I am doing wrong? The Unicode file looks something
> like:

I looked at your data. You'll have to handle the magic number
("\xff\xfe")
at the beginning of the file, and change the input separator string:

#!/usr/bin/perl -w
use strict;
use IO::File;

sub tounicode { my $s = shift; pack('v*', unpack('c*', $s)) }
sub fromunicode { my $s = shift; pack('c*', unpack('v*', $s)) }

my $input = IO::File->new("HelloJava.vjp", "r") or die "Can't open
input: $!";
binmode($input);
$/ = "\x0a\x00";

my $output = IO::File->new("output.vjp", "w") or die "Can't open output:
$!";
binmode($output);

my $magic;
$input->read($magic, 2);
$output->print($magic);

while (my $line = $input->getline())
{
        $line = fromunicode($line);
        # do processing as normal with Perl here:
        # $line =~ s/whatever/whateverelse/;
        $output->print(tounicode($line));
}

-- 
Ned Konz
currently: Stanwood, WA
email:     [EMAIL PROTECTED]
homepage:  http://www.bike-nomad.com

---
You are currently subscribed to perl-win32-users as: [archive@jab.org]
To unsubscribe, forward this message to
         [EMAIL PROTECTED]
For non-automated Mailing List support, send email to  
         [EMAIL PROTECTED]

Reply via email to