[EMAIL PROTECTED] wrote:
> 
> I have tried the below perl script to modify the major version number in a
> Unicode text file.

Well, a script that just prints one line if it matches won't edit a file
properly.
You probably want a print for every line, anyhow.

> 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:

>                my $number = $1;
>                $number = tr/\x00//d;

You probably wanted =~ as an operator in the tr/// line.

>                $number++;
>                join '',
>                map "$_\x00",
>                split //,
>                'ExeVerMajor\\=' . $number . '\\;'

That's pretty baroque. Better to make a tounicode() function and use
regular Perl
expressions (assuming you don't have anything other than 8-bit
characters)
(note that these are much faster than your map/split/etc):

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

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

Or am I missing something about your data? Has it always got NUL chars
as the second
byte?

-- 
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