use warnings; use strict; use Getopt::Long; use Data::Dump::Streamer; my %options; Getopt::Long::GetOptions (\%options, "u=s", "p=s"); print "Option $_: value %options{$_}\n" for keys %options; my @commands; my $entry; for (@ARGV) { next unless /(\w+)=(.*)/; $entry = \%{$commands[scalar @commands]} if $1 eq 'cmdName'; $entry->{$1} = $2; } print "\n"; for my $command (@commands) { print join "\n", (map {"$_ = $command->{$_}"} sort keys %$command), "\n"; }