Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't match regex in 'while' loop #276

Closed
p6rt opened this issue Aug 24, 2008 · 5 comments
Closed

Can't match regex in 'while' loop #276

p6rt opened this issue Aug 24, 2008 · 5 comments
Labels

Comments

@p6rt
Copy link

p6rt commented Aug 24, 2008

Migrated from rt.perl.org#58306 (status was 'resolved')

Searchable as RT58306$

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

From @moritz

r30499

This works​:
use v6;
my $str = 'foo <TMPL_VAR NAME=STUFF> <dsadf ';

if ( $str.chars > 0 ) {
  if $str ~~ /('<TMPL_' .*? '>')/ {
  say "yes"
  } else {
  say "no"
  }
}

(output​: yes)
However, when I change the outer 'if' to 'while', it breaks​:

use v6;
my $str = 'foo <TMPL_VAR NAME=STUFF> <dsadf ';

while ( $str.chars > 0 ) {
  if $str ~~ /('<TMPL_' .*? '>')/ {
  say "yes"
  } else {
  say "no"
  }
}

Lexical '$/' not found
current instr.​: 'parrot;Code;ACCEPTS' pc 5567 (src/gen_builtins.pir​:3702)
called from Sub '_block22' pc 110 (EVAL_13​:43)

So it seems that block after a while doesn't propagate $/ properly to
its inner block, thus the match dies while assigning (or binding) to $/.

You don't the inner 'if' to reproduce this problem​:

while ( $str.chars > 0 ) {
  $str ~~ /('<TMPL_' .*? '>')/
}
Lexical '$/' not found
current instr.​: 'parrot;Code;ACCEPTS' pc 5567 (src/gen_builtins.pir​:3702)

Cheers,
Moritz

--
Moritz Lenz
http://moritz.faui2k3.org/ | http://perl-6.de/

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

From @moritz

Fixed in r30503, but I'd like some tests for it before I close this ticket.

@p6rt
Copy link
Author

p6rt commented Aug 24, 2008

The RT System itself - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Sep 16, 2008

From @moritz

Tests are now in t/spec/S05-match/blocks.t, resolving the ticket...

@p6rt
Copy link
Author

p6rt commented Sep 16, 2008

@moritz - Status changed from 'open' to 'resolved'

@p6rt p6rt closed this as completed Sep 16, 2008
@p6rt p6rt added the Bug label Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant