in reply to Re: Re: Re: Re: Re: Re: opening a file in a subroutine
in thread opening a file in a subroutine

Er, hold on there... Dont be too hasty.

$/ is the end of record seperator. It defaults to "\n".

What my code, which is in essence

my @list=split /\n/,do {local $/; <$fh>};
does is to read the whole file into a buffer then split it up by newlines and then return them, which should be more or less the same as
my @list=<$fh>;
(at least under default conditions) but obviously isn't on AS 5.6.

I hope you didnt do it naively as otherwise youll only have one entry in the array, which will contain the whole file.

--- demerphq
my friends call me, usually because I'm late....

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Re: Re: opening a file in a subroutine
by abhishes (Friar) on Feb 09, 2003 at 17:38 UTC
    Thanks again,
    I modified my code to
    local $/; open my $fh, "xml.log"; my $line = <$fh>; close ($fh);

    Now I have the whole file in $line and I extract all the data which I want from regular expressions. My code is working as expected and is very very fast.

    regards,
    Abhishek.