Sorry for confusing, should have removed the reference part as its not really important to my question. I removed it, use strict and warnings and now here is it:
my @result;
foreach my $x (@cleared) {
if ($x =~ /JOB::(.*)/){
print $x, "\n";
}
else {
unless ($x =~ m/^Something/){
print "~~Something~~", $x, "\n";
}
else {
unless ($x =~ m/^Something Else/){
print "~~Something Else~~", $x, "\n";
}
}
}
}
Lets see the @cleared (Dump):
$VAR1 = 'JOB::HEREISASTRING';
$VAR2 = 'Something';
$VAR3 = 'StringA';
$VAR4 = 'StringB';
$VAR5 = 'StringC';
$VAR6 = 'StringD';
$VAR7 = 'Something Else';
$VAR8 = 'StringE';
$VAR9 = 'StringF';
$VAR10 = 'StringG';
$VAR11 = 'StringH ';
$VAR12 = 'JOB::HEREISANOTHERSTRING';
$VAR13 = 'Something';
$VAR14 = 'StringI';
$VAR15 = 'StringJ';
$VAR16 = 'StringK';
$VAR17 = 'StringL';
$VAR18 = 'Something Else';
$VAR19 = 'StringM';
$VAR20 = 'StringN';
$VAR21 = 'StringO';
$VAR22 = 'StringP ';
Output:
JOB::HEREISASTRING
~~Something Else~~Something
~~Something~~StringA
~~Something~~StringB
~~Something~~StringC
~~Something~~StringD
~~Something~~Something Else
~~Something~~StringE
~~Something~~StringF
~~Something~~StringG
~~Something~~StringH
JOB::HEREISANOTHERSTRING
~~Something Else~~Something
~~Something~~StringI
~~Something~~StringJ
~~Something~~StringK
~~Something~~StringL
~~Something~~Something Else
~~Something~~StringM
~~Something~~StringN
~~Something~~StringO
~~Something~~StringP
I wish output:
JOB::HEREISASTRING
~~Something Else~~Something Else (could be removed)
~~Something~~StringA
~~Something~~StringB
~~Something~~StringC
~~Something~~StringD
~~Something Else~~Something Else (could be removed)
~~Something Else~~StringE
~~Something Else~~StringF
~~Something Else~~StringG
~~Something Else~~StringH
JOB::HEREISANOTHERSTRING
~~Something Else~~Something Else (could be removed)
~~Something~~StringI
~~Something~~StringJ
~~Something~~StringK
~~Something~~StringL
~~Something Else~~Something Else (could be removed)
~~Something Else~~StringM
~~Something Else~~StringN
~~Something Else~~StringO
~~Something Else~~StringP
In fact i want to tag my values from a start until a match occurs and tag it different and so on....
What comes to my mind is that with foreach loop variable $x changes and in the loop is again "Something"!? |