小编Luk*_*uke的帖子

当你尝试使用Perl打印数组或哈希时,它是什么意思,你得到,数组(0xd3888)?

当您尝试打印数组或散列并且看到以下内容时,这意味着什么; 数组(0xd3888)或HASH(0xd3978)?

my @data = (  
['1_TEST','1_T','1_TESTER'],  
['2_TEST','2_T','2_TESTER'],  
['3_TEST','3_T','3_TESTER'],  
['4_TEST','4_T','4_TESTER'],  
['5_TEST','5_T','5_TESTER'],  
['6_TEST','6_T','^_TESTER']  
);  

foreach my $line (@data) {  
   chomp($line);  
   @random = split(/\|/,$line);  
   print "".$random[0]."".$random[1]."".$random[2]."","\n";  
}  
Run Code Online (Sandbox Code Playgroud)

结果

ARRAY(0xc1864)  
ARRAY(0xd384c)  
ARRAY(0xd3894)  
ARRAY(0xd38d0)  
ARRAY(0xd390c)  
ARRAY(0xd3948)  
Run Code Online (Sandbox Code Playgroud)

arrays perl hash

13
推荐指数
2
解决办法
9205
查看次数

如何使用Perl检查远程服务器上是否存在文件?

如何使用Perl检查远程服务器上是否存在文件?

我可以在使用Perl模块时执行此操作Net::FTP吗?

检查是否存在文件

if (-e $file_check) {  
    print "File Exists!\n";  
}   
else {  
    print "File Doesn't Exist!\n";  
}  
Run Code Online (Sandbox Code Playgroud)

ftp perl module

5
推荐指数
2
解决办法
1万
查看次数

为什么我的Perl CGI程序显示程序代码而不是输出?

代码 - TEST.CGI

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

use CGI::FastTemplate;

my $tpl = new CGI::FastTemplate("/some/directory");  
$tpl->no_strict();  
$tpl->define(main    => "test.htm");  
$tpl->assign(TEST_CONTENT=> "Test");  
$tpl->parse(CONTENT   => "main");  
$tpl->print('CONTENT');  
Run Code Online (Sandbox Code Playgroud)

模板文件

< html>  
< head>  
< title>TEST< /title>  
< /head>  

< body>  
$TEST_CONTENT  
< /body>  
< /html>
Run Code Online (Sandbox Code Playgroud)

说明

为什么我在浏览器中看不到所需的输出?当我导航到test.cgi文件时,我看到的只是实际的代码,而不是模板.我究竟做错了什么?

perl templates cgi module

3
推荐指数
1
解决办法
1009
查看次数

为什么这个Perl数组排序不起作用?

为什么数组不排序?

my @data = ('PJ RER Apts to Share|PROVIDENCE',  
'PJ RER Apts to Share|JOHNSTON',  
'PJ RER Apts to Share|JOHNSTON',  
'PJ RER Apts to Share|JOHNSTON',  
'PJ RER Condo|WEST WARWICK',  
'PJ RER Condo|WARWICK');  

foreach my $line (@data) {  
    $count = @data;  
    chomp($line);  
    @fields = split(/\|/,$line);  
    if ($fields[0] eq "PJ RER Apts to Share"){  
    @city = "\u\L$fields[1]";  
    @city_sort = sort (@city);  
    print "@city_sort","\n";  
    }  
}  
print "$count","\n";  
Run Code Online (Sandbox Code Playgroud)

OUTPUT

普罗维登斯
约翰斯顿
约翰斯顿
约翰斯顿
6

arrays sorting perl

1
推荐指数
1
解决办法
393
查看次数

如何使用Perl正则表达式来解析XML数据?

我有一段很长的XML要解析.我想删除除子类代码和城市之外的所有内容.所以我留下了类似下面的例子.

TEST SUBCLASS |迈阿密

<?xml version="1.0" standalone="no"?>  
<web-export>  
<run-date>06/01/2010  
<pub-code>TEST  
<ad-type>TEST  
<cat-code>Real Estate</cat-code>  
<class-code>TEST</class-code>  
<subclass-code>TEST SUBCLASS</subclass-code>  
<placement-description></placement-description>  
<position-description>Town House</position-description>  
<subclass3-code></subclass3-code>  
<subclass4-code></subclass4-code>  
<ad-number>0000284708-01</ad-number>  
<start-date>05/28/2010</start-date>  
<end-date>06/09/2010</end-date>  
<line-count>6</line-count>  
<run-count>13</run-count>  
<customer-type>Private Party</customer-type>  
<account-number>100099237</account-number>  
<account-name>DOE, JOHN</account-name>  
<addr-1>207 CLARENCE STREET</addr-1>  
<addr-2> </addr-2>  
<city>MIAMI</city>  
<state>FL</state>  
<postal-code>02910</postal-code>  
<country>USA</country>  
<phone-number>4014612880</phone-number>  
<fax-number></fax-number>  
<url-addr> </url-addr>  
<email-addr>noemail@ttest.com</email-addr>  
<pay-flag>N</pay-flag>  
<ad-description>DEANESTATES2BEDS2BATHSAPPLIANCED</ad-description>  
<order-source>Import</order-source>  
<order-status>Live</order-status>  
<payor-acct>100099237</payor-acct>  
<agency-flag>N</agency-flag>  
<rate-note></rate-note>  
<ad-content> MIAMI&#47;Dean Estates&#58; 2 
beds&#44; 2 baths&#46; Applianced&#46; Central air&#46; Carpets&#46; Laundry&#46; 2 decks&#46; Pool&#46; Parking&#46; Close to everything&#46;No smoking&#46; No utilities&#46; &#36;1275 mo&#46; 401&#45;578&#45;1501&#46;  </ad-content> …
Run Code Online (Sandbox Code Playgroud)

regex xml perl

0
推荐指数
4
解决办法
5897
查看次数

标签 统计

perl ×5

arrays ×2

module ×2

cgi ×1

ftp ×1

hash ×1

regex ×1

sorting ×1

templates ×1

xml ×1