in reply to Manipulating Date Numbers

just because no one has done it in one line yet :P
my @old = ('74/05/25', '54/03/04', '69/08/23', '55/08/24'); my @new = map { join('/', ( split('/') )[1,2,0]) } @old; Produces: old: 74/05/25 new: 05/25/74 old: 54/03/04 new: 03/04/54 old: 69/08/23 new: 08/23/69 old: 55/08/24 new: 08/24/55
I dont know if someone could golf this, but *shrug*

/* And the Creator, against his better judgement, wrote man.c */

Replies are listed 'Best First'.
Re: Re: Manipulating Date Numbers
by caedes (Pilgrim) on Feb 27, 2003 at 20:59 UTC
    How about
    s!(..)/(.*)!$2/$1! for @old;
    to edit in place or
    my @new = map {s!(..)/(.*)!$2/$1!;$_} @old;
    for a new array.

    -caedes

Re: Re: Manipulating Date Numbers
by tachyon (Chancellor) on Feb 27, 2003 at 20:54 UTC
    my @new = map { s!(..).(..).(..)!$2/$3/$1!; $_ } @old;

    cheers

    tachyon

    s&&rsenoyhcatreve&&&s&n.+t&"$'$`$\"$\&"&ee&&y&srve&&d&&print

      my@new=map s|(^..)/(.*)|$2/$1|,@old;

      or as a filter

      C:\test>copy con junk 74/05/25 54/03/04 69/08/23 55/08/24 ^Z 1 file(s) copied. C:\test>perl -pes=(..)/(.*)=$2/$1= <junk 05/25/74 03/04/54 08/23/69 08/24/55

      ..and remember there are a lot of things monks are supposed to be but lazy is not one of them

      Examine what is said, not who speaks.
      1) When a distinguished but elderly scientist states that something is possible, he is almost certainly right. When he states that something is impossible, he is very probably wrong.
      2) The only way of discovering the limits of the possible is to venture a little way past them into the impossible
      3) Any sufficiently advanced technology is indistinguishable from magic.
      Arthur C. Clarke.