Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Re: Really Perl?

by hippo (Canon)
on Aug 15, 2017 at 15:04 UTC ( #1197435=note: print w/replies, xml ) Need Help??

in reply to REALLY PERL ??

next unless s->{ID} =~ /\d\d+/;

The "s" there is a substitution and your expression as written is unterminated (there are no matching "-"s to indicate the end). If you think perl should tell you that you are missing a $ rather than a - then you are free to suggest a method for determining that, of course.

Me? I'd avoid using variables with the same names as built-in functions where possible. Saves loads of bother.

Addendum: while attempting to reproduce your error, the syntax highlighting in my editor (vim) made it very obvious indeed where the problem lay. It's not for everyone and not necessarily all the time, but syntax highlighting can be a real bonus on occasions such as this.

Replies are listed 'Best First'.
Re^2: Really Perl?
by davies (Parson) on Aug 15, 2017 at 15:27 UTC

    While not disagreeing, I'm as sure as I can be without checking that there are CPAN modules that use "$s" in the synopsis (and later examples) as the example object. It only takes the smallest of mis-clicks when cutting & pasting to get into the position of the OP, for whom I have a great deal of sympathy. I'll see tomorrow if I can find such a culprit & if it's appropriate to try to do anything about it. When I use CPAN modules, I try to stay as close as I can to the synopsis & example code, as it makes appeals for help easier to write.


    John Davies

    Update: finding examples of this is trivial. is one of many, chosen for no particular reason. I've made a personal resolution to avoid single character names in future, but I have no great ideas as to how to solve this issue generically.

Re^2: Really Perl?
by huck (Vicar) on Aug 15, 2017 at 17:28 UTC

      Hey huck,

      I don't believe this is a sub named "s" issue. It looks like OP simply forgot the sigil on a hash reference.

        Its the same issue, my $p1=s($n-1,$k-1); looks like an unterminated search

Re^2: Really Perl?
by Anonymous Monk on Aug 15, 2017 at 17:04 UTC

    Sometimes perl will come up with a warning like this

    (Might be a runaway multi-line -- string starting on line 42)

    when you have a bad q-- somewhere. That's helpful, but it doesn't seem to happen with s---.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1197435]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-07-20 07:09 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (426 votes). Check out past polls.