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.
I wonder if anyone can see why it isn't working. The output is:#!/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 . '>'; }
It isn't reading 'line by line'. Thanks for any help you might offer!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;>
Update: It works ok without the extra specifiers if i just do for my $line (split/\n/, $s)
But wondering why.
In reply to matching lines in a long string by Cristoforo
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |