Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: substitution using hash issue

by choroba (Canon)
on Nov 12, 2012 at 15:17 UTC ( #1003458=note: print w/ replies, xml ) Need Help??


in reply to [SOLVED]substitution using hash issue

No substitution is required, a hash is all you need:

#!/usr/bin/perl use warnings; use strict; print "Enter date: "; chomp(my $date = <STDIN>); my ($day, $month, $year) = split '/', $date; print "$day $month $year\n"; my $m; my %dates = map { $_, sprintf '%02d', ++$m } qw/Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec/; my $month_n = $dates{$month}; print "$day $month_n $year\n";
لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ


Comment on Re: substitution using hash issue
Download Code
Replies are listed 'Best First'.
Re^2: substitution using hash issue
by jaffinito34 (Acolyte) on Nov 12, 2012 at 15:21 UTC

    The program seemed to run but got some errors after entering the date, not sure what they mean though.

    Enter date: 23 Oct 2222 Use of uninitialized value $month in concatenation (.) or string at ./ +dateWork line 9, <STDIN> line 1. Use of uninitialized value $year in concatenation (.) or string at ./d +ateWork line 9, <STDIN> line 1. 23 Oct 2222 Use of uninitialized value $month in hash element at ./dateWork line 1 +5, <STDIN> line 1. Use of uninitialized value $month_n in concatenation (.) or string at +./dateWork line 16, <STDIN> line 1. Use of uninitialized value $year in concatenation (.) or string at ./d +ateWork line 16, <STDIN> line 1. 23 Oct 2222
      You should enter the date in the specified format.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

        HAHA WHOOPS

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1003458]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-07-07 23:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (93 votes), past polls