system("lpstat -v -d -p -l -D >junk.txt"); open RI," }; # or however you load it. my( %device, %system ); for ( split /\n(?=\S)/, $data ) { if( /^device for (.*?):.*?\1$/ ) { $device{$1} = $1; } elsif ( /^system for (.*?): (\S+)/ ) { $system{$1} = $2; } #### my @output =`lpstat -o -v -d -p -l -D`;. my( %device, %system ); foreach my $line (@output) { chomp $line; for ( split /\n(?=\S)/, $line ) { if (/^system default/) { @test = split(/ /); chomp($test[3]); print "$test[3]|\n"; } if( /^device for (.*?):.*?\1$/ ) { $device{$1} = $1; } elsif ( /^system for (.*?): (\S+)/ ) { $system{$1} = $2; }