[Melbourne-pm] Regexps - how does the lexical scope of capture buffers work? (Was: Regexp: What's the right way to do this?)

Nathan Bailey nathan.bailey at monash.edu
Wed Oct 17 05:24:03 PDT 2012


Oops, accidentally only replied to Shlomi.

With the input file:
   8:10 -
   9:15

a.pl products:
8:10 - 9:15

but b.pl produces:
Why is start_time undefined now? at b.pl line 8, <> line 2.
- 9:15

I presume it fails because the regexp fails, returning undef which is then assigned to $start_time, rather than failing and skipping the assignment.

I'm just wondering if there's a better way to grab text out of multiple lines that are related to each other. A simple solution would be to go for multi-line strings but I'm actually curious to know (a) if that's the way the evaluation of the regexp and assignment works and (b) if there are better ways of doing multi-line parsing, without simply treating it as one big complex line.
N
PS: Files attached in a tarball.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: files.tgz
Type: application/octet-stream
Size: 366 bytes
Desc: not available
URL: <http://mail.pm.org/pipermail/melbourne-pm/attachments/20121017/e165c333/attachment.obj>


More information about the Melbourne-pm mailing list