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

Re: [PBML] please help

Expand Messages
  • 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 1 of 13 , Dec 23, 2010
    • 0 Attachment
      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 2 of 13 , Dec 23, 2010
      • 0 Attachment
        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.