Skip to content

Instantly share code, notes, and snippets.

@Woody2143
Last active December 19, 2015 01:39
Show Gist options
  • Save Woody2143/5877757 to your computer and use it in GitHub Desktop.
Save Woody2143/5877757 to your computer and use it in GitHub Desktop.
My first time using a Schwartzian-transform
$ ./Schwartzian.pl
$VAR1 = [
'/data/switch/cdr/SWITCH_20130627_151800',
'/data/switch/cdr/SWITCH_20130627_151500',
'/data/switch/cdr/SWITCH_20130627_151900',
'/data/switch/cdr/SWITCH_20130627_151700',
'/data/switch/cdr/SWITCH_20130627_151600',
'/data/switch/otherCDR/SWITCH_20130627_151900',
'/data/switch/otherCDR/SWITCH_20130627_151600',
'/data/switch/otherCDR/SWITCH_20130627_151800',
'/data/switch/otherCDR/SWITCH_20130627_151500',
'/data/switch/otherCDR/SWITCH_20130627_151700'
];
$VAR1 = [
'/data/switch/cdr/SWITCH_20130627_151500',
'/data/switch/otherCDR/SWITCH_20130627_151500',
'/data/switch/cdr/SWITCH_20130627_151600',
'/data/switch/otherCDR/SWITCH_20130627_151600',
'/data/switch/cdr/SWITCH_20130627_151700',
'/data/switch/otherCDR/SWITCH_20130627_151700',
'/data/switch/cdr/SWITCH_20130627_151800',
'/data/switch/otherCDR/SWITCH_20130627_151800',
'/data/switch/cdr/SWITCH_20130627_151900',
'/data/switch/otherCDR/SWITCH_20130627_151900'
];
#!/opt/perlbrew/perls/cdrtools/bin/perl
use Modern::Perl;
use Data::Dumper;
my @files = qw(
/data/switch/cdr/SWITCH_20130627_151800
/data/switch/cdr/SWITCH_20130627_151500
/data/switch/cdr/SWITCH_20130627_151900
/data/switch/cdr/SWITCH_20130627_151700
/data/switch/cdr/SWITCH_20130627_151600
/data/switch/otherCDR/SWITCH_20130627_151900
/data/switch/otherCDR/SWITCH_20130627_151600
/data/switch/otherCDR/SWITCH_20130627_151800
/data/switch/otherCDR/SWITCH_20130627_151500
/data/switch/otherCDR/SWITCH_20130627_151700
);
print Dumper \@files;
my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [$_, $_=~ /SWITCH_(?:\d{8})_(\d{6})/] }
@files;
print Dumper \@sorted;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment