in reply to Re: How to split line of text into array containing macros and non-macro text
in thread How to split line of text into array containing macros and non-macro text

Thank. This seems to work, but I have to hit the ENTER key when I run my test program, to see the output from the print statement. I'd like to make this a subroutine. Test program:
#!/usr/bin/perl -nl use strict; my($i,$t); $t="<macro1>[tag1]This is plain text.<macro2>More text.[tag2]And more +text."; my @fields=split /((?:<[^>]+>|\[[^]]+])+)/, $t; shift @fields if $fields[0] eq ''; print for @fields; exit;
Why do I have to hit ENTER to execute the print statement?
  • Comment on Re^2: How to split line of text into array containing macros and non-macro text
  • Download Code

Replies are listed 'Best First'.
Re^3: How to split line of text into array containing macros and non-macro text
by choroba (Cardinal) on Mar 26, 2014 at 10:45 UTC
    I have to hit the ENTER key when I run my test program
    Because you called Perl with -n which makes it read from input. See perlrun - how to execute the Perl interpreter for details.
    لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ