Hi List
I need to find the index positions of many elements. For a single
occurrence there are many ways to find it. But in my case the element which
I am searching for has multiple occurrence.
The following is the array from where I have to find the indexes of a
specific element say bspwrt.
On 17 June 2015 at 04:46, Vincent Lequertier s...@riseup.net wrote:
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '', 'text';
my @words = split ' ', $fh;
my @matchs;
while (my ($index, $elem) = each @words) {
if ($elem eq 'bspwrt') {
push @matchs, $index++;
Hi Anirban,
Assuming you have a file named text.txt containing your data, this code
should do the trick :
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '', 'text';
my @words = split ' ', $fh;
my @matchs;
while (my ($index, $elem) = each @words) {
if ($elem eq 'bspwrt') {
On Wed, Jun 17, 2015 at 07:01:06AM +1200, Kent Fredric wrote:
On 17 June 2015 at 04:46, Vincent Lequertier s...@riseup.net wrote:
#!/usr/bin/perl
use strict;
use warnings;
open my $fh, '', 'text';
my @words = split ' ', $fh;
my @matchs;
while (my ($index, $elem) = each @words) {