Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: substitution using hash issue

by choroba (Abbot)
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
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 chanting in the Monastery: (3)
As of 2014-09-20 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (157 votes), past polls