I just started to learn PERL and i'm getting crazy

I stuck on hashes. I wrote two different codes which are just to learn some staff and hash doesnt work on first one but works on second code

This is first

#!/usr/bin/perl use strict; #no strict "vars"; use warnings; print "Hello Alper\n"; print "43\n"; #SCALARS my $alper = 35; #DEGISKENLER BOYLE TANIMLANIYOR my $sarper = "What THE fuck"; #NE TUR OLDUKLARI ONEMLI DEGI +L PERL ANLIYOR print "$sarper "; #TANIMLANAN DEGISKEN BOYLE YAZDIRILIY +OR print "$alper \n"; #BOYLE DE YAZDIRILIYOR BIR SONRAKI +SATIRA ATLATILARAK print $sarper," = ",$alper*$alper ,"\n" ; #BU SEKILDE BIR KAC SEYI +BIRDEN YAZDIRABILIRSIN #ARRAYS my @array = ("3","2","1","4","alper"); #DIZI BU SEKILDE TANIMLA +NIYOR print @array, "\n"; #DIZI BU SEKILDE YAZDIRILIYOR print $array[1],"\n"; #DIZININ HER HANGI BIR ELEMANI BU + SEKILDE YAZDIRILIYOR print $array[$#array],"\n"; # $#diziadi DIZININ SON ELEMANI +N INDEX NUMARASINI VERIYOR VE print $#array,"\n"; #DIZININ ELEMANLARINA 0'DAN BASLAYA +RAK INDEX ATAN print $#array+1,"\n"; #DIZININ ELEMAN SAYISINI VERIR print @array[1,2],"\n"; #DIZININ BIR KAC ELEMANINI BIRD +EN YAZDIRMAK ICIN KULLANILIR print @array[1..3] #DIZININ 1. ELEMANINDAN 3. ELEMANINA + KADARINI YAZAR # http://perldoc.perl.org/perlintro.html#Runni +ng-Perl-programs #kisminda my @sorted kismini calistiramadin bu +nun cevabini bul #HASHES my %bahar = ( ilk => "1", son => "2", );

This is second

#!/usr/bin/perl use strict; use warnings; my $ali = 5; print "$ali\n\n"; my @array = (1, 2, 3, 4, 5); print $array[$#array]+1,"\n\n"; my %fruit_color = ( apple => "5", banana => "2", ); #print $fruit_color{"banana"},"\n"; #print $fruit_color{"banana"}*5,"\n"; if ($#array<5){ print $fruit_color{"banana"},"\n"; };

I just cant find what is wrong in first code. Please someone tell me what's the problem in first code?

Thanks in advance


In reply to Please help me with hash by m_alper_yildiz

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.