http://qs321.pair.com?node_id=11117487

Cristoforo has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks!

Been working on this problem and can't find my error. I'm trying to use the m modifier to read a large text in line by line. I want to use the inline form, (?m) rather than following the regex slash with m.

#!/usr/bin/perl use strict; use warnings; use feature 'say'; my $s = <<'EOF'; int t; //variable t t->a=0; //t->a does;; something printf("\nEnter the Employee ID : "); scanf("%d", ptrx->eid); //employee id ptrx->eid printf("\nEnter the Employee Name : "); scanf("%s", ptr->name); return 0; EOF for my $line (split/(?m)\n(?=$)/, $s) { say '<' . $line . '>'; }
I wonder if anyone can see why it isn't working. The output is:

C:\Old_Data\perlp>perl test3.pl <int t; //variable t t->a=0; //t->a does;; something printf("\nEnter the Employee ID : "); scanf("%d", ptrx->eid); //employee id ptrx->eid printf("\nEnter the Employee Name : "); scanf("%s", ptr->name); return 0;>
It isn't reading 'line by line'. Thanks for any help you might offer!

Update: It works ok without the extra specifiers if i just do for my $line (split/\n/, $s)

But wondering why.