|
Re: Question on approach: msg#00352perl-beginners
Shawn H. Corey wrote: Chas. Owens wrote: I usually like simplicity: split /\@/, $_, 2 my ( $mo, $day, $yr, $time ) = split m{ \- }msx, $am_date; split /-/, $am_date $data{$yr}{$mo}{$day}{$time} = $_; When I run your code I get: Name "main::Dumper" used only once: possible typo at Question_on_approach.pl line 13. print() on unopened filehandle Dumper at Question_on_approach.pl line 13, <DATA> line 4. Or you could use an ST instead: #!/usr/bin/perl use strict; use warnings; map $_->[ 0 ], sort { $a->[ 1 ] cmp $b->[ 1 ] } map [ $_, join '', ( /^([^\@]+)\@(\d+)-(\d+)-(\d+)-(.+)/ )[ 3, 1, 2, 4, 0 ] ], <DATA>; Or a GRT: #!/usr/bin/perl use strict; use warnings; map /\0([^\0]+)/, sort map join( '', ( /^([^\@]+)\@(\d+)-(\d+)-(\d+)-(.+)/ )[ 3, 1, 2, 4, 0 ] ) . "\0$_", <DATA>; John -- Those people who think they know everything are a great annoyance to those of us who do. -- Isaac Asimov -- To unsubscribe, e-mail: beginners-unsubscribe@xxxxxxxx For additional commands, e-mail: beginners-help@xxxxxxxx http://learn.perl.org/
|
|
||||||||||||||||||||||||||
| News | Mail Home | sitemap | FAQ | advertise |