SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Nov 2007
    Posts
    130
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Perl script help

    Hi there,

    I am trying to fix a bug in a Perl script.

    Can someone explain what the below code does/would do?

    PHP Code:

    while (my $a readdir(DIR)){

        if(
    $a =~ m/(.+?)_(air)?port/ && $a !~ m/featured_(air)?port/ && $a !~ m/london_airport/&& $a !~ m/glasgow/ && $a !~ m/_opt/i){

            
    push(@dirs,$a);

        }


    Thanks

  2. #2
    SitePoint Member
    Join Date
    Jan 2014
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by ebsolutions View Post
    Hi there,

    I am trying to fix a bug in a Perl script.

    Can someone explain what the below code does/would do?

    PHP Code:

    while (my $a readdir(DIR)){

        if(
    $a =~ m/(.+?)_(air)?port/ && $a !~ m/featured_(air)?port/ && $a !~ m/london_airport/&& $a !~ m/glasgow/ && $a !~ m/_opt/i){

            
    push(@dirs,$a);

        }


    Thanks
    That code is reading all dirs and files in a certain directory
    If file or dir matches any of those criteria, it is added to @dirs array.

  3. #3
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You are not saying what error you are getting. The syntax is OK but is it that you have not done an opendir statement before.
    For example: opendir(DIR, $some_dir)

    Or is it that the matches are not picking up what you would expect to be picked up.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •