summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/cargo.pl32
1 files changed, 32 insertions, 0 deletions
diff --git a/scripts/cargo.pl b/scripts/cargo.pl
new file mode 100755
index 000000000..54d716e47
--- /dev/null
+++ b/scripts/cargo.pl
@@ -0,0 +1,32 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+use feature qw(:5.22);
+
+open my $cargo, '<', $ARGV[0] or die "can't open $ARGV[0]: $!\n";
+my $data = '';
+# This block reads in the entire file.
+{
+ local $/;
+ $data = <$cargo>;
+}
+
+my $name = '';
+my %cargo = ();
+my @lines = split /\r?\n/, $data;
+
+# Parse the file; we just want the name and version.
+foreach my $line (@lines) {
+ if ($line =~ /^name = "(.*?)"$/) {
+ $name = $1;
+ } elsif ($line =~ /^version = "(.*?)"$/) {
+ $cargo{$name} = $1;
+ }
+}
+
+open my $file, '>', 'crates.txt' or die "can't open output file: $!\n";
+# Print the data we pulled out above to a file.
+foreach my $pkg (keys %cargo) {
+ say $file $pkg . ' ' . $cargo{$pkg};
+}