Re: map woes



seven.reeds wrote:
I can open the dir. I can readdir() to get the filenames, grep() to
get the "\d+\.zone" files but now I want to pull off the numbers, sort
them numericaly highest to lowest and store them for later use. I
have tried

my @list =
sort {$b <=> $a}
map {s/(\d+)\.news/$1/}
grep(/\d+\.news/, readdir(NEWSDIR));

The readdir and grep work as I expect. The result of the map is a
list of "1"s, prolly the count of successful s// matches. Where am I
messing this up?

There have been correct answers already, but I'll
add another version to the dozen (what I think what would
be somehow appropriate) ...

...
sub descending { $b<=>$a }
...

opendir my $dirh, '.' or die "cant't opendir!$!";

my @list = sort descending map /\d+(?=\.news)/g, readdir $dirh;

closedir $dirh;
...


Regards

M.
.



Relevant Pages

  • Re: map woes
    ... get the "\d+\.zone" files but now I want to pull off the numbers, ... them numericaly highest to lowest and store them for later use. ... sort ...
    (comp.lang.perl.misc)
  • [8FOLD] Template #3
    ... "You lead a very eventful life, don't you, Mr. Kidman?" ... lunatics collapsing in the middle of your store... ... threats have some sort of motivation behind them. ...
    (rec.arts.comics.creative)
  • Re: Bad feelings in Wickes
    ... to sort it out. ... insisted that I should approach the exit without the carrier bag, ... test if the machine would beep. ... A few years My brother and I went into a Wicks Store and bought a large ...
    (uk.legal)
  • C 128s ROM socket
    ... sort of a new topic, so I didn't reply to that. ... I've thought about that ROM socket in the C128 a lot and have on occasion ... So I'm hoping to use something on the IEC port to store more ... up trying to read/write to a serial flash ram chip via the user port.. ...
    (comp.sys.cbm)
  • Re: all this talk of clothing made in china...
    ... USA." and in her store, she's only going to sell items that are made ... and just the sort of person that should think about joining the ... I was brought up by parents (mother, mostly) who instilled me with all ...
    (uk.people.support.depression)