Albert,
try this
while (<>)
{
s!header([^/>]+)/>!<header$1></header>!;
...
print;
}
Process a single line at a time, not the whole file.
___ _ ____ ___ __ __
/ _ )(_) / /_ __ / _ \___ _/ /_/ /____ ___
/ _ / / / / // / / ___/ _ `/ __/ __/ _ \/ _ \
/____/_/_/_/\_, / /_/ \_,_/\__/\__/\___/_//_/
/___/
Texas Instruments ASIC Circuit Design Methodlogy Group
Dallas, Texas, 214-480-4455, [EMAIL PROTECTED]
On Mon, 5 Jan 2004, Alberto Manuel Brand�o Sim�es wrote:
> but maybe you guys(hope this is the correct way :-/) know how to help
> me...
> I have this simple script:
>
> $/ = "</tu>";
>
> my $header = <>;
>
> # <header/> -> <header></header>
> $header =~ s!<header([^/>]+)/>!<header$1></header>!;
>
> # <body version...> -> <body>
> $header =~ s!<body[^>]+>!<body>!;
>
> # tmx version -> <tmx version="1.1">
> $header =~ s!<tmx version[^>]+>!<tmx version="1.1">!;
>
> # srclang -> srclang="foo"
> if ($header =~ m!(xml:)?lang=(["'])([^"']+)\2!) {
> $lang = $3;
> $header =~ s!srclang=(["'])[^"']+\1!srclang="$lang"!;
> }
>
> $header =~ s/xml:lang/lang/g;
> # xml:lang -> lang
> print $header;
>
> while(<>) {
> s/xml:lang/lang/g;
> print
> }
>
> Basically, a filter working on chunks (about 300bytes chunks).
> The problem is that I cannot process a 400MB file, because of
> out-of-memory.
> What is wrong? how can I solve it?
> Thanks a lot, and sorry for being a little OT.
>
> Alberto
>
>