develooper Front page | perl.beginners | Postings from March 2002

RE: Re: parsing a block

From:
al1912
Date:
March 30, 2002 18:29
Subject:
RE: Re: parsing a block
Message ID:
5883E203.0FC15731.0005C666@netscape.net
The code generates the following error message:
Missing $ on loop variable at line 17
which is the line that starts with
foreach my $line (split /\n/) {

Thanks

AL
"Jonathan E. Paton" <jonathanpaton@yahoo.com> wrote:

>> I want to be able to split data by using END delimiter but this didn't work! Here what I tried:
>> 
>> # to split lines by END delimiter
>> while ($line =<INPUT>) {
>>     @mylineBlock = split/END\n/, $line;
>> }
>
>Yay, your file format is $\ compatible, which is the input record separator.
>
>local $/ = "END\n";
>
>while (<INPUT>) {
>    #Do something with record.  e.g.
>
>    foreach my $line (split /\n/) {
>        foreach my $field (split /,/) {
>            # Do something with data.
>        }
>    }
>}
>
>There is alternatives to doing this, depending on what exactly you require from this.  The
>disadvantage of this approach is the blocksize... if you have TONS of data between the END tokens
>it will take an equal amount of memory to store it.  Rarely is that a problem in non-production
>scripts.
>
>Jonathan Paton
>
>__________________________________________________
>Do You Yahoo!?
>Everything you'll ever need on one web page
>from News and Sport to Email and Music Charts
>http://uk.my.yahoo.com
>
>-- 
>To unsubscribe, e-mail: beginners-unsubscribe@perl.org
>For additional commands, e-mail: beginners-help@perl.org
>
>


__________________________________________________________________
Your favorite stores, helpful shopping tools and great gift ideas. Experience the convenience of buying online with Shop@Netscape! http://shopnow.netscape.com/

Get your own FREE, personal Netscape Mail account today at http://webmail.netscape.com/




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About