On 10/22/07, Siva Prasad <[EMAIL PROTECTED]> wrote something resembling:
> sub GET_Values > { > my $Rows; > my $cate; What are those variables used for? > my $self=shift; > print "$self->{InputFile}\n"; > (open my $FILE_H '<', $self->{InputFile}) || die"cannot open the input > file"; > while(<$FILE_H>) > { > next unless /(<div.*?<\/table><br><br>)/; > my @Rows=grep(/(<div.*?<\/table><br><br>)/,<$FILE_H>); > return(@Rows); > > close $FILE_H; > } I would have thought Perl would have warned you about having unreachable code after the return(). Are you telling us that it doesn't warn you about that? Nevertheless, the unreachable close() isn't a problem; since $FILE_H is a lexical variable, it's auto-closed when it goes out of scope. So I'd either put the close() before the return(), or omit it altogether. > my $obj=grepsite->new("sample.txt"); > > my @rows=$obj-> GET_Values; > > $obj-> Print_file(@rows); > Use of uninitialized value in concatenation (.) or string at grepsite.pm > line 37 Which one is line 37? We can't see that piece of the puzzle, but you can. You probably have a utility program that will show line numbers (the cat utility generally has a -n option), or one that will easily add or remove them (most programmer's text editors can do this, or you could even write a small Perl program to do it (Okay, the cat's out of the bag now: Somebody's going to make it a one-liner for this, I know it. Please, change the subject line to "[golf] add/remove line numbers" when you post it.)). > I understand this is because the file $self->{InputFile} is not visible to > the method GET_Values What makes you conclude that? From my reading of your code, having that problem should have given you the error message "cannot open the input file". But you're showing us totally different error messages. My best guess at the error is that you got fewer values back from GET_Values than you expected, and you called Print_file with too few parameters -- probably zero. And you probably got fewer values back from GET_Values because you're trying to parse something as complex as HTML using simple patterns. Do you also try to pound nails with your fists and turn screws with your thumbnails? Use real tools (i.e. modules from CPAN) to parse HTML, if that's what you're really doing, and you'll find the work goes more easily at the end of the day. Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/