All I am getting the error from my if statement:
^* matches null string many times in regex; marked by <-- HERE in m/^* <-- HERE Orig/ at .
I am trying to get everything except *Orig in this output :
<samlpe data snipped>
Here is my code:
foreach ($EDM_nonactive_tapelist) {
if ($EDM_nonactive_tapelist !~ "\^\*Orig") {
print $_;
}
}
- The ^ character shall not be escaped when marking the beginning of a string.
- You need to tell Perl that you want to use the m// operator, either like
m"^\*Orig"
or by using straight slashes:
/^\*Orig/
But why use a regex at all?
print unless substr($_, 0, 5) eq '*Orig';
*NOTE the variable $EDM_nonactive_tapelist has the Orig strings in it. Does foreach read line by line?
Not unless you tell Perl so:
foreach ( split /\n/, $EDM_nonactive_tapelist ) { print "$_\n" unless substr($_, 0, 5) eq '*Orig'; }
Do I even need the foreach statement?
No.
print map "$_\n", grep { substr($_, 0, 5) ne '*Orig' } $EDM_nonactive_tapelist =~ /(.+)/mg;
;-)
-- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>