Search pattern not terminated at (Spreadsheet::Read example)

Discussion in 'Perl Misc' started by Jorge, Jan 20, 2007.

  1. Jorge

    Jorge Guest

    Using ActiveState perl 5.8.8 on XP, I'm attempting to use an example
    from the Perl Hacks book by O'reilly.

    It uses Spreadsheet::Read and simply retrieves the row and cell data
    from a .xls file.

    However, it throws this error ...

    Search pattern not terminated at ...

    and then points to this line ...

    print join "\t" => map {$sheet->{cell}[$_][$row] // "-"} 1 ..
    $sheet->{maxcol};

    The only search pattern I see on this line is the 2 slashes (//) and as
    far as I know, they are valid delimiters for search patterns and are
    applied correctly. Can anyone shed some light on what this error could
    mean?

    I can post the complete program if needed.

    Thank You

    Jorge
     
    Jorge, Jan 20, 2007
    #1
    1. Advertising

  2. Jorge

    Paul Guest

    The syntax is wrong. I'm not sure what // is supposed to be doing, but
    whatever it is, it's wrong :)
     
    Paul, Jan 20, 2007
    #2
    1. Advertising

  3. Jorge

    Jorge Guest

    Paul wrote:
    > The syntax is wrong. I'm not sure what // is supposed to be doing, but
    > whatever it is, it's wrong :)


    You are correct. Since my posting, I have tracked down that the // is
    the Perl 6 construct for defined-or, not a set of pattern delimiters as
    I had presumed. Now, I have to re-write that portion of code so it
    plays in Perl 5.8.8 or look for a patch to Perl 5.8.8.

    Thank you

    Jorge
     
    Jorge, Jan 20, 2007
    #3
  4. Jorge

    -berlin.de Guest

    Jorge <> wrote in comp.lang.perl.misc:
    > Paul wrote:
    > > The syntax is wrong. I'm not sure what // is supposed to be doing, but
    > > whatever it is, it's wrong :)

    >
    > You are correct. Since my posting, I have tracked down that the // is
    > the Perl 6 construct for defined-or, not a set of pattern delimiters as
    > I had presumed. Now, I have to re-write that portion of code so it
    > plays in Perl 5.8.8 or look for a patch to Perl 5.8.8.


    Replace (untested)

    map {$sheet->{cell}[$_][$row] // "-"} 1 .. $sheet->{maxcol};

    with

    map defined ? $_ : '-', map $sheet->{cell}[$_][$row], 1 .. $sheet->{maxcol}

    Btw, in the original code, the first slash is parsed as a division
    operator. The second one seems to introduce an unterminated regex.

    Anno
     
    -berlin.de, Jan 21, 2007
    #4
  5. Jorge

    Paul Guest

    > You are correct. Since my posting, I have tracked down that the // is
    > the Perl 6 construct for defined-or, not a set of pattern delimiters as
    > I had presumed.


    No, defined-or is || so:

    $foo ||= 'something';
     
    Paul, Jan 21, 2007
    #5
  6. Jorge

    Dr.Ruud Guest

    Paul schreef:
    > [attribution repaired] Jorge:


    >> You are correct. Since my posting, I have tracked down that the // is
    >> the Perl 6 construct for defined-or, not a set of pattern delimiters
    >> as I had presumed.

    >
    > No, defined-or is || so:
    >
    > $foo ||= 'something';


    You are confusing logical-or and defined-or. And your attribution
    wasn't.

    --
    Affijn, Ruud

    "Gewoon is een tijger."
     
    Dr.Ruud, Jan 21, 2007
    #6
  7. Jorge

    Jorge Guest

    -berlin.de wrote:
    > Jorge <> wrote in comp.lang.perl.misc:
    > > Paul wrote:
    > > > The syntax is wrong. I'm not sure what // is supposed to be doing, but
    > > > whatever it is, it's wrong :)

    > >
    > > You are correct. Since my posting, I have tracked down that the // is
    > > the Perl 6 construct for defined-or, not a set of pattern delimiters as
    > > I had presumed. Now, I have to re-write that portion of code so it
    > > plays in Perl 5.8.8 or look for a patch to Perl 5.8.8.

    >
    > Replace (untested)
    >
    > map {$sheet->{cell}[$_][$row] // "-"} 1 .. $sheet->{maxcol};
    >
    > with
    >
    > map defined ? $_ : '-', map $sheet->{cell}[$_][$row], 1 .. $sheet->{maxcol}
    >
    > Btw, in the original code, the first slash is parsed as a division
    > operator. The second one seems to introduce an unterminated regex.
    >
    > Anno


    I agree the 2 slashes are being parsed incorectly.

    This is the correction which works.

    print join "\t" => map
    {
    my $val = $sheet->{cell}[$_][$row];
    defined $val ? $val : "-";
    } 1 .. $sheet->{maxcol};

    Thanks very much for all the responses.
     
    Jorge, Jan 21, 2007
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Roger Twomey
    Replies:
    1
    Views:
    12,692
    Roger Twomey
    Apr 27, 2004
  2. py
    Replies:
    0
    Views:
    689
  3. Anders Christensen

    char array not terminated with \0

    Anders Christensen, Jan 16, 2005, in forum: C Programming
    Replies:
    17
    Views:
    649
    Anders Christensen
    Jan 25, 2005
  4. semut
    Replies:
    7
    Views:
    331
    Thad Smith
    Dec 5, 2006
  5. Chris
    Replies:
    3
    Views:
    375
    Chris
    Feb 10, 2007
Loading...

Share This Page