Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use warnings; use Data::Dump 'pp'; use Text::CSV; main(); sub main { my $data = shift || return; my $file = "file.txt"; eval { open my $fh, ">", $file or die "Unable to create or open file: $!"; $csv->print($fh, $_) for @{ $data }; close $fh; }; if ($@) { print "ERROR!"; }else { # A message code will be here, using 1114 as sample; my $message = check('1114'); print $message; # I want to print " Exit " <<<<<<<<<<< }; } sub check { my $ck = shift; my %message= ( 'y345' => " Close ", '1223dx' => " Open ", '88888' => " Gone ", 'acb2' => " Available ", '1114' => " Exit ", ); }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Return a hash value based on its key
by kennethk (Abbot) on Feb 16, 2016 at 19:38 UTC | |
by Anonymous Monk on Feb 16, 2016 at 19:52 UTC | |
|
Re: Return a hash value based on its key
by AnomalousMonk (Archbishop) on Feb 16, 2016 at 21:43 UTC |