in reply to check in an array for variable

ok,

also having trouble understanding what you were aiming for....

but here is what i figured you were looking for...

#!/usr/bin/perl while(<DATA>){ chomp($_); my @array = split("&amp;|&rdquo;|&ldquo;|&apos;",$_); foreach (@array){ ($_ eq ' ') ? (print "--Value missing--") : (print $_) } } __DATA__ &rdquo; How big are &amp; the Brothers? &rdquo; &ldquo; One day hiere last wee +k, not knowing the cause, some floors of Rockefeller Center were evacuated when the floor shaking and screams of the lads&apos; fans during a TV
cheers

Update:

while(<DATA>){ chomp($_); my @array1 = split(/(&amp;|&rdquo;|&ldquo;|&apos;)/,$_); foreach (@array1){ ($_ eq ' ') ? (print "--Value missing--\n") : (print $_ . "\n") } } result &rdquo; How big are &amp; the Brothers? &rdquo; --Value missing-- &ldquo; One day hiere last week, not knowing the cause, some floors of Rockefeller Center were evacuated when the floor shaking and screams of the lads &apos; fans during a TV
is this ok :)

if the spitted sentence (One day hiere...) is annoying you it is up to you to fix it :)

Replies are listed 'Best First'.
Re^2: check in an array for variable
by Anonymous Monk on Aug 13, 2009 at 09:11 UTC
    Hi, The output should print even the elements of the array in between the text. ex: output should print like this:
    &rdquo; How big are &amp; the Brothers? &rdquo; Value missing &ldquo; One day hiere last week, not knowing the cause, some floors of Rockefe +ller Center were evacuated when the floor shaking and screams of the +lads &apos; fans during a TV
      I'd suggest splitting on /(\s*&\w+;\s*)/, then iterate over the return list and insert a "Value missing" where appropriate. That'll be much easier and more maintainable than trying to write it one regex.