Loading ...
Sorry, an error occurred while loading the content.
 

Expand Messages
  • Piroska Devay
    Hi MIke, Try to use elsif if ($_ =~ /SUMMARY ) {bla; } elsif ($counter==0) {bla; } elsif ($_ =~ /d+) { bla; last; } with last it should jump out of the loop
    Message 1 of 2 , Mar 5, 2008
      Hi MIke,

      Try to use elsif

      if ($_ =~ /SUMMARY ) {bla; }
      elsif ($counter==0) {bla; }
      elsif ($_ =~ /d+) { bla; last; }

      with last it should jump out of the loop


      On Mar 6, 2008, at 6:07 PM, mike97739 wrote:

      > I am trying to write a perl program to print out just the summaries of
      > poker hand histories. These are text files.The problem I seem to have
      > is that it prints the first summary but won't stop at the end of the
      > summary but goes on to print out the entire rest of the file.
      > The patterns are (m/SUMMARY/)to begin and to end (m/ \d+ /).
      > Here's my code:
      >
      > use strict;
      > use warnings;
      > use diagnostics;
      > my $file="hand.txt";
      > my @array_var;
      > my $counter=0;
      > open (FILE,$file) or die "can't open";
      > while (<FILE> ) {
      > if(m/SUMMARY/) {
      >
      > $counter++;
      > print " $counter ";}
      > if($counter==1){
      > @array_var=$_;
      > print "@array_var";}
      > if(m/ \d /) {
      > $counter--; }
      >
      > }
      > close FILE;
      > ##############I want to put summaries into an array , one for each
      > hand
      > ############## I can't seem to get it to stop putting stuff into the
      > array all i want is the summary
      >
      >
      >



      [Non-text portions of this message have been removed]
    • mike97739
      I am trying to write a perl program to print out just the summaries of poker hand histories. These are text files.The problem I seem to have is that it prints
      Message 2 of 2 , Mar 6, 2008
        I am trying to write a perl program to print out just the summaries of
        poker hand histories. These are text files.The problem I seem to have
        is that it prints the first summary but won't stop at the end of the
        summary but goes on to print out the entire rest of the file.
        The patterns are (m/SUMMARY/)to begin and to end (m/ \d+ /).
        Here's my code:

        use strict;
        use warnings;
        use diagnostics;
        my $file="hand.txt";
        my @array_var;
        my $counter=0;
        open (FILE,$file) or die "can't open";
        while (<FILE> ) {
        if(m/SUMMARY/) {

        $counter++;
        print " $counter ";}
        if($counter==1){
        @array_var=$_;
        print "@array_var";}
        if(m/ \d /) {
        $counter--; }

        }
        close FILE;
        ##############I want to put summaries into an array , one for each hand
        ############## I can't seem to get it to stop putting stuff into the
        array all i want is the summary
      Your message has been successfully submitted and would be delivered to recipients shortly.