婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > perl哈希的一個實例分析

perl哈希的一個實例分析

熱門標簽:外呼電信系統 上海企業外呼系統 okcc外呼系統怎么調速度 萬利達百貨商場地圖標注 電話機器人哪里有賣 河南虛擬外呼系統公司 智能機器人電銷神器 熱門電銷機器人 惠州龍門400電話要怎么申請

復制代碼 代碼如下:

#!/bin/perl
use strict; 
use warnings; 

my %movies; 
my $film; 
my %reverse_result; 
my $director; 
my @data; 

%movies = 

  'The Shining'       => 'Kubrick', 
  'Ten Commandments'  => 'DeMille', 
  'Goonies'           => 'Spielberg', 
); 

#輸出哈希的值,輸出的結果為Kubrick 
print $movies{'The Shining'}; 

#同時輸出鍵和值 
foreach $film(keys %movies) 

   print "$film was directed by $movies{$film}.\n"; 


#添加空格 
print "\n"; 

#哈希結構的切換 
%reverse_result=reverse %movies; 
foreach $director(keys %reverse_result) 

   print "$director directe the $reverse_result{$director}.\n";  
}

#添加空格 
print "\n";

#當哈希結構用于列表環境中時,perl會將hash重新變為由關鍵詞和鍵值組成的普通列表 
@data=%movies; 
 print "@data\n"; 

#添加空格 
print"\n"; 

#得到的數組是一個分為奇數為film,偶數為director的數組,或者相反 
#然后我們將數組賦值給hash 
%movies=@data; 
foreach $director(keys %reverse_result) 

  print "$director directe the $reverse_result{$director}.\n";  
}     
print "The result is not change\n";

以下為輸出結果:
    F:\&;perl\a.pl 
    KubrickGoonies was directed by Spielberg. 
    The Shining was directed by Kubrick. 
    Ten Commandments was directed by DeMille. 

    DeMille directe the Ten Commandments. 
    Spielberg directe the Goonies. 
    Kubrick directe the The Shining. 

    Goonies Spielberg The Shining Kubrick Ten Commandments DeMille 

    DeMille directe the Ten Commandments. 
    Spielberg directe the Goonies. 
    Kubrick directe the The Shining. 

    F:\&;

#----測試哈希key的方法:
if(exists $hash{keyval}) 


#----刪除關鍵字:
delete hash {keyval};

#---清空哈希:
%hash=();

您可能感興趣的文章:
  • php-perl哈希算法實現(times33哈希算法)
  • Perl 哈希的創建和引用介紹
  • Perl哈希表用法解析
  • Perl 哈希Hash用法之入門教程
  • perl哈希hash的常見用法介紹
  • Perl與JS的對比分析(數組、哈希)

標簽:淮安 綿陽 秦皇島 周口 周口 合肥 百色 綏化

巨人網絡通訊聲明:本文標題《perl哈希的一個實例分析》,本文關鍵詞  perl,哈希,的,一個,實例分析,;如發現本文內容存在版權問題,煩請提供相關信息告之我們,我們將及時溝通與處理。本站內容系統采集于網絡,涉及言論、版權與本站無關。
  • 相關文章
  • 下面列出與本文章《perl哈希的一個實例分析》相關的同類信息!
  • 本頁收集關于perl哈希的一個實例分析的相關信息資訊供網民參考!
  • 推薦文章
    主站蜘蛛池模板: 龙岩市| 兰溪市| 永顺县| 四平市| 沐川县| 望江县| 息烽县| 曲沃县| 界首市| 武穴市| 呼伦贝尔市| 石林| 汝州市| 长乐市| 绥德县| 洛宁县| 本溪| 连云港市| 黔东| 睢宁县| 海阳市| 漳平市| 大足县| 天等县| 沂源县| 罗平县| 舞钢市| 长治县| 元谋县| 平陆县| 武乡县| 高陵县| 云霄县| 通山县| 麟游县| 庄河市| 望城县| 郧西县| 衡阳市| 阿鲁科尔沁旗| 陵川县|