jumk has asked for the wisdom of the Perl Monks concerning the following question:

Hello, I have this array @files , which contains subarries inside it , I am looking only for the subarries that starts with sss , somthing like sssty23 or sssxxrt ... etc,, snice I have some other files that starts with different letters other than sss , i have to grep for the sss ,, I am doing the following :
foreach (@files) { if ($_=~ m/^sss(\W+)) { push @wantedArray,$_ }; }
but don't seem to work

Replies are listed 'Best First'.
Re: subdir
by dragonchild (Archbishop) on Jan 27, 2003 at 22:13 UTC
    You have an array of arrays and you want to find the ones that are named by some naming mechanism. Riiiight.

    Arrays don't have named elements - hashes do. Arrays have numbered elements. That's the problem, brother.

    Without seeing the code that builds @files, I can't tell you how to fix it and my fix for the snippet you posted will make no sense without showing you code to build it. :-)

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      thanks I got it working
Re: subdir
by OM_Zen (Scribe) on Jan 27, 2003 at 22:22 UTC
    Hi ,

    The Sub array , are you naming references to the other array as subarrays or the elements of the array itself, could tell only if the code is written here,no clue on sub array or elements or references to suggest