$ /usr/bin/zypper info ... > info.out #### #!/usr/bin/env perl use strict; use warnings; use autodie; my $file = 'info.out'; my %repo_for; { open my $fh, '<', $file; local $/ = "\nInformation for package "; while (<$fh>) { next unless /\A([^:]+).*?Repository\s+:\s(\S+)/ms; $repo_for{$1} = $2; } } # For demo use Data::Dump; dd \%repo_for; #### { "fontconfig-devel" => "prod-sdk12-sp5-pool-x86_64-hpc", "libedit0" => "prod-sp5-pool-x86_64-hpc", "Mesa-libEGL1" => "prod-sp5-pool-x86_64-hpc", "python-rpm-macros" => "prod-sdk12-sp5-pool-x86_64-hpc", }