As ikegami has mentioned, you have to remember what "map" returns - as the docs say, it's an evaluation of each operation within the block as a list (in my experience, the "s///" inside a "map" is one of the most common mistakes that new users of "map" make.)

Incidentally, since you're already using a regex inside your block, you don't really need that "split":

#!/usr/bin/perl -w use strict; my @teststr = ( "32977186 4 -rw-r--r-- 1 owner mygrp 65 Aug 4 13:16 /long/pa +th/to/my/file/file1.txt", "32977186 4 -rw-r--r-- 1 owner mygrp 65 Aug 4 13:16 /long/pa +th/to/my/file/file2.txt", "32977186 4 -rw-r--r-- 1 owner mygrp 65 Aug 4 13:16 /long/pa +th/to/my/file/file3.txt", "32977186 4 -rw-r--r-- 1 owner mygrp 65 Aug 4 13:16 /long/pa +th/to/my/file/file4.txt", ); my %testhash = map { m{(([^/]+)\.[^/]+)$}; $2, $1 } @teststr; print "$_ => $testhash{$_}\n" for sort keys %testhash;

Output:

file1 => file1.txt file2 => file2.txt file3 => file3.txt file4 => file4.txt

--
"Language shapes the way we think, and determines what we can think about."
-- B. L. Whorf

In reply to Re: hash assignment using map with multiple statements by oko1
in thread hash assignment using map with multiple statements by diomedea

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.