# read this from bottom to top (be sure to read 'perldoc -f map' first) print # print will print the list that is returned from map map { # map returns the last evaluated statement "$_" . # this is what $_ was ":\t" . # this is a colon followed by a tab # $h->{$_}[0] is the first element of that array # $h->{$_} points to an array ref $h->{$_}[0] . # $_ is each key from hash ref $h "\n" # this is a new line } keys %{ $h }; # get the keys from hash ref $h
> -----Original Message----- > From: Jerry Preston [mailto:g-preston1@;ti.com] > Sent: Monday, October 21, 2002 5:20 PM > To: Beginners Perl > Subject: lost - map { "$_:\t$h->{$_}[0]\n"} keys %$h > > > Hi! > > Can anyone explain to me how map works in this code? > > for my $h ( > > # grab the Subject and Date from every message in my > (fictional!) smut > folder; > # the first argument is a reference to an array listing > all messages in > the folder > # (which is what gets returned by the $imap->search("ALL") > method when > called in > # scalar context) and the remaining arguments are the > fields to parse out > > # The key is the message number, which in this case we > don't care about: > values %{$imap->parse_headers( > scalar($imap->search("ALL")) , "Subject", > "Date")} > ) { > # $h is the value of each element in the hash ref returned from > parse_headers, > # and $h is also a reference to a hash. > # We'll only print the first occurance of each field > because we don't > expect more > # than one Date: or Subject: line per message. > print map { "$_:\t$h->{$_}[0]\n"} keys %$h ; > } > > How can I access this and break it done to look at each line? > > Thanks, > > Jerry > > ---------------------------------------------------------------------------- -------------------- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]