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

Re: [PBML] please help

Expand Messages
  • Rob Richardson
    I can t answer your question, but I do have a suggestion: Please use a descriptive subject. Many members see Please Help and assume it s another appeal
    Message 1 of 13 , Dec 22, 2010
      I can't answer your question, but I do have a suggestion: Please use
      a descriptive subject. Many members see "Please Help" and assume it's
      another appeal from a Nigerian wanna-be millionaire or somebody who
      got mugged in England.

      RobR, group moderator
    • Karl Kaufman
      How do you know it wasn t able to find the FOOD EXPENSES header without testing for it? (i.e. you re not doing anything in the script to verify whether the
      Message 2 of 13 , Dec 22, 2010
        How do you know it wasn't able to find the 'FOOD EXPENSES' header without testing for it? (i.e. you're not doing anything in the script to verify whether the header was recognized) I added a print statement within the empty braces ({}) and it seemed to work fine.


        ----- Original Message -----
        From: dhageuk
        To: perl-beginner@yahoogroups.com
        Sent: Wednesday, December 22, 2010 4:13 AM
        Subject: [PBML] please help



        i have the following code:

        open filehandle, "$somefile";
        while (<filehandle>) {
        my $line = $_;
        if ($line =~ /^<(.*)>-+$/) {
        $cgroup = $1;
        next;
        }
        if ($cgroup eq 'FOOD EXPENSES') {}

        which attempts to open a file which contains:

        <FOOD EXPENSES>-----------
        some data...
        <UTILITY EXPENSES>--------
        some data...

        However, it was not able to find the FOOD EXPENSES. can someone tell me what is wrong with my code





        [Non-text portions of this message have been removed]
      • dhageuk
        i forgot to tell that on windows it is working. but on ubuntu 10 it is not. i tried debugging and was not able to find it.
        Message 3 of 13 , Dec 22, 2010
          i forgot to tell that on windows it is working. but on ubuntu 10 it is not. i tried debugging and was not able to find it.

          --- In perl-beginner@yahoogroups.com, "Karl Kaufman" <krkweb@...> wrote:
          >
          > How do you know it wasn't able to find the 'FOOD EXPENSES' header without testing for it? (i.e. you're not doing anything in the script to verify whether the header was recognized) I added a print statement within the empty braces ({}) and it seemed to work fine.
          >
          >
          > ----- Original Message -----
          > From: dhageuk
          > To: perl-beginner@yahoogroups.com
          > Sent: Wednesday, December 22, 2010 4:13 AM
          > Subject: [PBML] please help
          >
          >
          >
          > i have the following code:
          >
          > open filehandle, "$somefile";
          > while (<filehandle>) {
          > my $line = $_;
          > if ($line =~ /^<(.*)>-+$/) {
          > $cgroup = $1;
          > next;
          > }
          > if ($cgroup eq 'FOOD EXPENSES') {}
          >
          > which attempts to open a file which contains:
          >
          > <FOOD EXPENSES>-----------
          > some data...
          > <UTILITY EXPENSES>--------
          > some data...
          >
          > However, it was not able to find the FOOD EXPENSES. can someone tell me what is wrong with my code
          >
          >
          >
          >
          >
          > [Non-text portions of this message have been removed]
          >
        • Karl Kaufman
          as a quick test, you might try loosening-up your regular expression, removing the end-of-record anchoring. (remove the $ ) ... I expect anchoring to the
          Message 4 of 13 , Dec 23, 2010
            as a quick test, you might try loosening-up your regular expression, removing the end-of-record anchoring. (remove the '$')

            > if ($line =~ /^<(.*)>-+/) {

            I expect anchoring to the beginning of the line and looking for the trailing dashes should be sufficient to ident the header records, ya? (I'm wondering if failing to "chop" the end-of-line whitespace causes differing behaviors between Windows and Ubuntu10.)

            Another test of the above would be to add a whitespace consideration to the regular expression, allowing you to keep the end-of-record anchoring...

            > if ($line =~ /^<(.*)>-+\s*$/) {




            ----- Original Message -----
            From: dhageuk
            To: perl-beginner@yahoogroups.com
            Sent: Wednesday, December 22, 2010 5:41 PM
            Subject: Re: [PBML] please help



            i forgot to tell that on windows it is working. but on ubuntu 10 it is not. i tried debugging and was not able to find it.

            --- In perl-beginner@yahoogroups.com, "Karl Kaufman" <krkweb@...> wrote:
            >
            > How do you know it wasn't able to find the 'FOOD EXPENSES' header without testing for it? (i.e. you're not doing anything in the script to verify whether the header was recognized) I added a print statement within the empty braces ({}) and it seemed to work fine.
            >
            >
            > ----- Original Message -----
            > From: dhageuk
            > To: perl-beginner@yahoogroups.com
            > Sent: Wednesday, December 22, 2010 4:13 AM
            > Subject: [PBML] please help
            >
            >
            >
            > i have the following code:
            >
            > open filehandle, "$somefile";
            > while (<filehandle>) {
            > my $line = $_;
            > if ($line =~ /^<(.*)>-+$/) {
            > $cgroup = $1;
            > next;
            > }
            > if ($cgroup eq 'FOOD EXPENSES') {}
            >
            > which attempts to open a file which contains:
            >
            > <FOOD EXPENSES>-----------
            > some data...
            > <UTILITY EXPENSES>--------
            > some data...
            >
            > However, it was not able to find the FOOD EXPENSES. can someone tell me what is wrong with my code
            >
            >
            >
            >
            >
            > [Non-text portions of this message have been removed]
            >





            [Non-text portions of this message have been removed]
          • Karl Kaufman
            as a quick test, you might try loosening-up your regular expression, removing the end-of-record anchoring. (remove the $ ) ... I expect anchoring to the
            Message 5 of 13 , Dec 23, 2010
              as a quick test, you might try loosening-up your regular expression,
              removing the end-of-record anchoring. (remove the '$')

              > if ($line =~ /^<(.*)>-+/) {

              I expect anchoring to the beginning of the line and looking for the trailing
              dashes should be sufficient to ident the header records, ya? (I'm wondering
              if failing to "chop" the end-of-line whitespace causes differing behaviors
              between Windows and Ubuntu10.)

              Another test of the above would be to add a whitespace consideration to the
              regular expression, allowing you to keep the end-of-record anchoring...

              > if ($line =~ /^<(.*)>-+\s*$/) {




              ----- Original Message -----
              From: dhageuk
              To: perl-beginner@yahoogroups.com
              Sent: Wednesday, December 22, 2010 5:41 PM
              Subject: Re: [PBML] please help



              i forgot to tell that on windows it is working. but on ubuntu 10 it is not.
              i tried debugging and was not able to find it.

              --- In perl-beginner@yahoogroups.com, "Karl Kaufman" <krkweb@...> wrote:
              >
              > How do you know it wasn't able to find the 'FOOD EXPENSES' header without
              > testing for it? (i.e. you're not doing anything in the script to verify
              > whether the header was recognized) I added a print statement within the
              > empty braces ({}) and it seemed to work fine.
              >
              >
              > ----- Original Message -----
              > From: dhageuk
              > To: perl-beginner@yahoogroups.com
              > Sent: Wednesday, December 22, 2010 4:13 AM
              > Subject: [PBML] please help
              >
              >
              >
              > i have the following code:
              >
              > open filehandle, "$somefile";
              > while (<filehandle>) {
              > my $line = $_;
              > if ($line =~ /^<(.*)>-+$/) {
              > $cgroup = $1;
              > next;
              > }
              > if ($cgroup eq 'FOOD EXPENSES') {}
              >
              > which attempts to open a file which contains:
              >
              > <FOOD EXPENSES>-----------
              > some data...
              > <UTILITY EXPENSES>--------
              > some data...
              >
              > However, it was not able to find the FOOD EXPENSES. can someone tell me
              > what is wrong with my code
              >
              >
              >
              >
              >
              > [Non-text portions of this message have been removed]
              >
            Your message has been successfully submitted and would be delivered to recipients shortly.