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

Re: Pattern Seperator

Expand Messages
  • daymobrew
    ... ... in the dark. Can someone give me a push in the right direction? ... nowhere. :-P ... The code above won t work. The open() call is invalid. Look at
    Message 1 of 2 , Jun 29, 2002
    • 0 Attachment
      --- In perl-beginner@y..., "Jeremiah Megie" <jmegie81@e...> wrote:
      > Ok, next question..
      >
      > In my text file, I have (on each line) these fields:
      >
      > "question#", "asker", "question", "answer", "staffer", "prev", "next
      "
      >
      > I need to seperate these fields and output them into a pretty
      format like:
      >
      > Number: QUESTION# HERE
      > Asker: ASKER NAME HERE
      >
      > Question: QUESTION HERE
      >
      > -
      >
      > Answer: ANSWER HERE
      > Staff: STAFF HERE
      > PREV | NEXT
      > EOF
      >
      > I've never done pattern seperation before, so I'm kinda doing this
      in the dark. Can someone give me a push in the right direction?
      >
      > This is what I have:
      >
      > #!/usr/bin/perl -w
      >
      > use strict;
      >
      > my $outfile = "outfile";
      > my @chunks;
      >
      > open(OUTFILE, ");
      > }
      > print "I read ", scalar(@chunks), " chunks.\n";
      >
      > close(OUTFILE);
      >
      > __END__
      >
      > At first I was just trying to print the output. But, it got me
      nowhere. :-P
      >
      > Thanks for any suggestions,
      > Jeremiah
      >

      The code above won't work. The open() call is invalid.
      Look at using:
      @chunks = <OUTFILE>; # Confusing handle for reading!!
      and then using:
      foreach my $line ( @chunks ) {
      my $pieces = split( /,/, $line );
      print "something ....";
      }
    Your message has been successfully submitted and would be delivered to recipients shortly.