in reply to Re^2: Using an hash ref to match files with directories
in thread Using an hash ref to match files with directories

Unfortunately, your telepathic transmissions have a very poor signal-to-noise ratio, and even with reception tuned to the highest sensitivity, I am regrettably unable to decode them.

Please describe your problem better, and also let us know the results of following the suggestions you have received.

     Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)

  • Comment on Re^3: Using an hash ref to match files with directories

Replies are listed 'Best First'.
Re^4: Using an hash ref to match files with directories
by lomSpace (Scribe) on Aug 11, 2009 at 21:09 UTC
    NetWallah,
    I need to copy files from one dir to another. The directories are on two
    separate machines across a file share. The files names start with initials
    followed by an underscore, then some other characters. I need to put
    these files into their respective customer dir.

    The customer dir name is the first and last name of the
    customer. Example: Michael Jackson. So, in order to copy
    a file/s that belong to Michael Jackson I need to match
    his initials with his name. That is where the %sequser
    hash comes in. It creates a mapping between the initials and name.

    My idea is to match the initials of the customer, the values in the hash,
    with the initials at the beginning of the file. Then I will know which user
    dir to copy the file.

    I hope that I have significantly decreased the signal-to-noise ratio.

    LomSpace
      Thanks - that is a significantly improved S/N ratio.

      First : Why are you doing this no-op ?

      my $seq = $seq; # capture the intials ($seq) from $targetfile

      So it appears that you want to use the Initials-to-hash conversion in the sub "seq_customer_dirs".

      Simply replace " if ($dir=~m%$seq%){" with

      if ($dir =~m|$sequser{$seq}| ){

           Potentia vobiscum ! (Si hoc legere scis nimium eruditionis habes)

        first response:
        This captures the initials from the targetfile. Those initials
        are what I need to check for a match with the keys in
        in the hash. Once I find a match, then I can use the value to
        work on the correct dir.

        Second response:
        The idea behind the sub seq_customer_dirs is to find the customer/user dir.
        Example: When the program runs across a file with the initials "MJ",
        which is captured by $seq, it checks for eq with a hash $key.
        If there is eq, hash $key = "MJ", then the value is returned as the dir.
        In this case the $value is "Michael Jordan" and that would be returned
        to the main program as the
        directory to work on.

        LomSpace
      And do you have a plan of action ready for the day when Marvin Jones and Mary Johnson join the late Mr. Jackson on your customer list?
        "Mjon"=>"Marvin Jones", "MJoh"=>"Mary Johnson" will be added to the hash.