Last active
August 29, 2015 14:27
-
-
Save z448/433121ccbbca8f1c5fc3 to your computer and use it in GitHub Desktop.
Get names of installed packages and print out as json.
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
#!/usr/bin/env perl | |
# git clone https://gist.github.com/433121ccbbca8f1c5fc3.git | |
# for ios-jb + debian linux | |
use warnings; | |
use strict; | |
use JSON; | |
my @ar; | |
my %bundle; | |
my $status = '/usr/bin/dpkg-query -l | cut -d" " -f3'; | |
my @status = `$status`; | |
for (@status) { | |
chomp($_); | |
$bundle{"title"} = "$_"; | |
push @ar, {%bundle}; | |
} | |
my $p = \@ar; | |
my $jay = to_json($p); | |
my $jane = JSON->new->utf8(1)->pretty(1)->encode($p); | |
unless ($ARGV[0] eq '-p') { | |
print $jay; | |
} else {print $jane}; | |
=head1 NAME | |
lsdeb2json list all installed packages and print them in json | |
. | |
=head1 SYNOPSIS | |
lsdeb2json print out minified json list | |
lsdeb2json -p same as above but json is pretty printed | |
. | |
. | |
. | |
=cut | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment