use warnings;
use strict;
my @bundle1 = qw/ch3 ch4 ch6/;
my %bundle1 = (
ch3 => 0,
ch4 => 0,
ch6 => 0,
);
my $i = 0;
my @charges = qw/ch1 ch2 ch3 ch4 ch5 ch6 ch7 ch8 ch1 ch2 ch3 ch4 ch5 c
+h1 ch2 ch6 ch7 ch4 ch3 ch9 ch2 ch4/;
foreach my $bundle (@bundle1) {
foreach my $charge (@charges) {
if ($bundle eq $charge) {
$i++;
$bundle1{$bundle} = $i;
print $bundle1{$bundle};
}
}
}
Now my main goal I am trying to accomplish is if @bundle1 is found in @charges, then remove the corresponding @bundle1 in @charges and replaced with 'chx'.
So input is-->
ch1 ch2 ch3 ch4 ch5 ch6 ch7 ch8 ch1 ch2 ch3 ch4 ch5 ch1 ch2 ch6 ch7 ch4 ch3 ch9 ch2 ch4
So output is-->
ch1 ch2 ch5 chx ch7 ch8 ch1 ch2 ch5 ch1 ch2 chx ch7 ch4 ch3 ch9 ch2 ch4
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.