#!/usr/bin/perl -w use strict; chdir "/usr/share/applications"; my (%collect, $out); while (our $Fn = <*.desktop>){ chomp $Fn; open Fn or die "$Fn: $!\n"; while (){ $collect{name} = "$1" if /^Name=(.*)$/; $collect{icon} = "$1" if /^Icon=(.*)$/; $collect{exec} = "$1" if /^Exec=(.*)$/; $collect{categories} = "$1" if /^Categories=(.*);?\s*$/; } $collect{categories} ||= "Misc"; $collect{icon} ||= "-"; for (qw/name exec categories/){ print "Bad value for '$Fn' ($_)\n" unless defined $collect{$_}; } my $val = qq#prog "$collect{name}" $collect{icon} $collect{exec}#; ### More code follows