This repository has been archived by the owner on Dec 5, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from sanger-pathogens/sorting_conf_files
Sorted conf files by key
- Loading branch information
Showing
5 changed files
with
117 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#!/usr/bin/env perl | ||
|
||
# ABSTRACT: Sorts conf files by key | ||
# PODNAME: sort_conf | ||
|
||
=head1 SYNOPSIS | ||
Sorts conf files by key. Reads conf from STDIN, or conf file name can be | ||
provided on the command line. Writes sorted conf to STDOUT. | ||
sort_conf unsorted.conf | ||
cat unsorted.conf | sort_conf > sorted.conf | ||
=cut | ||
|
||
|
||
use strict; | ||
use warnings; | ||
use Data::Dumper; | ||
BEGIN { unshift( @INC, '../lib' ) } | ||
BEGIN { unshift( @INC, './lib' ) } | ||
BEGIN { unshift( @INC, '/software/pathogen/internal/prod/lib/' ) } | ||
|
||
use Bio::VertRes::Config::Utils qw(sort_hash_keys); | ||
|
||
$Data::Dumper::Sortkeys = sub { [ sort {sort_hash_keys($a,$b)} keys %{$_[0]} ] }; | ||
|
||
print Dumper eval join('', <>); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
package Bio::VertRes::Config::Utils; | ||
|
||
# ABSTRACT: Minor functions available throughout Bio::VertRes::Config | ||
|
||
=head1 SYNOPSIS | ||
Just somewhere to keep minor functions (which don't warrant instantiating an object) | ||
that we want to be available throughout Bio::VertRes::Config | ||
=cut | ||
|
||
require Exporter; | ||
@ISA = qw(Exporter); | ||
@EXPORT_OK = qw(sort_hash_keys); | ||
|
||
=head2 sort_hash_keys | ||
Use this with C<sort> for a standardized sorting of hash keys. | ||
=cut | ||
|
||
sub sort_hash_keys { | ||
my($a,$b) = @_; | ||
return($a cmp $b); | ||
} | ||
|
||
1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters