Re: subpattern reference using vaiable subpattern index



On 01/29/2007 09:17 AM, Yakov wrote:
I have submatch index in a variable, $SUB=5. How do I write submatch reference $5 using $SUB ?
Is ${$SUB} ok ?


my $SUB = 5;
my @matches = m/.../;
print $matches[$SUB];

2. Is there array of subpatterns ($1..$<N>) so I can take it's size ?

Yakov


Yes, after you have assigned the output from the match operator to an array.

my @matches = m/.../;
print scalar(@matches);

Read the documentation: Start->Run->"perldoc perlrequick"


--
Windows Vista and your freedom in conflict:
http://www.badvista.org/

.



Relevant Pages

  • Re: problems cgi ex cook book perl
    ... i am beginner of perl ... Windows Vista and your freedom in conflict: ...
    (comp.lang.perl.misc)
  • Re: using no strict "refs"
    ... no strict "refs"; ... Windows Vista and your ... freedom in conflict: http://www.badvista.org/ ...
    (comp.lang.perl.misc)
  • Re: missing simple regex
    ... (yes, using strick) ... Windows Vista and your freedom in conflict: ...
    (comp.lang.perl.misc)
  • Re: system command wont run with -T option on
    ... one piece of external data used. ... Windows Vista and your freedom in conflict: ...
    (comp.lang.perl.misc)
  • sickness of hypocrisy
    ... freedom because Quran forbids enslaving of the people, ... other and are plagued with conflict after conflict, ... Is this the practice of Islam? ...
    (talk.religion.misc)