in reply to splitting an array element

Hi,
a map solution...
#!/usr/local/bin/perl -w use strict; my $olddate = "20020911"; my $newdate; map { /([\d]{4})([\d]{2})([\d]{2})/; $newdate= "$1-$2-$3"; } $olddate; print $newdate."\n";

Replies are listed 'Best First'.
Re: Re: splitting an array element
by fruiture (Curate) on Nov 25, 2002 at 15:29 UTC

    map in void context is bad. In your case, it's really useless...

    $olddate =~ /(\d{4})(\d{2})(\d{2})/ and $newdate = "$1-$2-$3";
    --
    http://fruiture.de