m_alper_yildiz has asked for the wisdom of the Perl Monks concerning the following question:
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Please help me with hash
by frozenwithjoy (Priest) on Jun 06, 2013 at 18:43 UTC |