Hello, i am new in Perl and i have a doubt that i think is very easy to result.
I have this portion code:
my $string = "cccabccc"; my @array =$string =~ /ab|a/g;
I execute this and array contains 1 element with value "ab".
I would like to know if there is some way for array contains all the matches "ab" and "a".(container and contents).
There is only one instance of /ab|a/ in 'cccabccc': the 'ab'. If you search (for example) 'cccabcacabc', you will get 'ab', 'a', and 'ab'.
If you mean that you wish the 'a' in 'cccabccc' to count twice, once as /ab/, and once as /a/, you will need to code:
my $string = 'cccabccc'; my @array = $string =~ /ab/g; push @array, $string =~ /a/g;
--- John W. Kennedy "Information is light. Information, in itself, about anything, is light." -- Tom Stoppard. "Night and Day"
_______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
