in reply to text reformatting woes

heres the really strange thing...i run it with a -d flag, and after the split (you were right, changed it to /\n\n/), @sections is assigned "4881", i dont know why. its not returning scalar because there are only about 800 lines in the text file im inputting. and it IS loading the file contents into @infile, i verified that.

Replies are listed 'Best First'.
Re: Re: text reformatting woes
by ysth (Canon) on Apr 19, 2004 at 08:02 UTC
    How are you printing @sections and getting 4881? What does this show:
    use Data::Dumper; print Dumper \@sections;
      i run the script with the -d flag, and after the split() line, i type "print @sections" in the debugger. then it prints out "4811"
        And what does the beginning of @infile look like? Update: you can't use @infile the way you are; you would need to say:@sections = split /\n\n/, join("", @infile);since split is expecting a scalar to split. Or slurp the whole file into a $infile and use that in the split. Or just assign to sections in the first place:
        open(IN,"./$file"); { local $/ = "\n\n"; chomp(@sections = <IN>); } close(IN);
        (See perlvar for what $/ does.)