当您尝试打印数组或散列并且看到以下内容时,这意味着什么; 数组(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) 如何使用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) #!/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文件时,我看到的只是实际的代码,而不是模板.我究竟做错了什么?
为什么数组不排序?
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)
普罗维登斯
约翰斯顿
约翰斯顿
约翰斯顿
6
我有一段很长的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/Dean Estates: 2
beds, 2 baths. Applianced. Central air. Carpets. Laundry. 2 decks. Pool. Parking. Close to everything.No smoking. No utilities. $1275 mo. 401-578-1501. </ad-content> …Run Code Online (Sandbox Code Playgroud)