这不是我的剧本。如果是的话,我会使用严格和警告。请原谅其粗俗。 我只需要解决它。 这个脚本转为:
44049U44049U1042014101511:30:579999123100:00:00RL5 Horizons Seasonal Rotation ETF HAC B77D2K4All
44049W44049W1002014101511:32:549999123100:00:00RL5 Horizons Enhanced Income US Equity HEA BJ3V9P0All
44049W44049W1002014101511:32:549999123100:00:00RL5 Horizons Enhanced Income US Equity HEA.U B4L4291All
44050P44050P1012014101510:59:159999123100:00:00RL5 Horizons Active Canadian Dividend EHAL B8GC630All
44050U44050U1002014101511:00:359999123100:00:00RL5 Horizons Auspice Managed Futures InHMF B7M39S6All
44051W44051W1132014101511:02:049999123100:00:00RL5 Horizons Active Diversified Income HAA B870J67All
44051X44051X1112014101511:04:169999123100:00:00RL5 Horizons Active Yield Matched DuratHAF BDXGDG2All
进入这个:
RL5, Horizons Seasonal Rotation ETF, HAC, All
RL5, Horizons Enhanced Income US Equity, HEA, All
RL5, Horizons Enhanced Income US Equity, HEA.U, All
RL5, Horizons Active Canadian Dividend E, HAL, All
RL5, Horizons Auspice Managed Futures In, HMF, All
RL5, Horizons Active Diversified Income, HAA, All
RL5, Horizons Active Yield Matched Durat, HAF, All
问题在于EHAL。下面的脚本将EHAL变成E,HAL。而且我认为这是必须要做的事情 使用解包声明。我真的没有理解这种说法 - 我认为它需要一个相应的包装' 声明,脚本中没有一个。
my ($restrict, $company, $symbol, $sectype) = unpack "x47A5A35A12x7A4", $_;
有趣的是,我没有在脚本中看到包语句 - 解压缩工作,只是在这种情况下不适用于 EHAL - 它被分成E,HAL,它搞砸了许多下游流程。
casper@70pap:/scripts/WebDownloads$ cat FOORestrictedList.pl
#!/usr/bin/perl
$today_date = `date +%d-%b-%Y`;
chop($today_date);
use LWP::Simple; # for internet proxy stuff^M
use LWP::UserAgent; # for internet proxy stuff^M
use LWP::Debug qw(+ -trace);
$url="http://casper.com/rlist/download/RESTRLISTCLASS.DAT";
$save = "restricted.csv";
%FOOsymbol = ();
$getContent= getstore($url,$save);
$i = 1;
my %restricted = map { $_ => undef } qw(RL3 RL5 RL5H RL6 REGM RAF RLMT RTCA RTCAH RTCB RTCBH RTCI RTCIH RLSI RLHK RLJP RPROP RLCB RLCS RLBZ RLBZH RLSUS);
$file=$save;
$outfile="restricted.html";
open( FILE, "< $file " ) or die "Can't open $file : $!";
while ( <FILE> ) {
chomp;
my ($restrict, $company, $symbol, $sectype) = unpack "x47A5A35A12x7A4", $_;
if ($FOOsymbol{$symbol} && ($sectype ne "Debt") && ($sectype ne "SpecificSecurity")
&& exists $restricted{$restrict})
{
print "Restricted FOO: $restrict $company $symbol\n";
print $restrict $company $symbol";
push(@restricted_sym_list,$symbol);
}
elsif ($FOOsymbol{$symbol}) {
print "FOO, but OK: $restrict $company $symbol $sectype\n";
}
elsif (exists $restricted{$restrict} && ($POSITION{$symbol})) {
print qq|$restrict$company$symbol (position only, not in FOO)|;
$t = 10;
}
}
〜
答案 0 :(得分:0)
我认为该软件是正确的。在我看来好像有一个35个字符的字段,其中包含实体的名称,后面跟着一个缩写,它们之间有没有空格。如果实体名称超过35个字符,则会将其截断为该长度。 (以printf
的格式考虑"%-35.35s"
。)
我认为您的实体是“Horizons Active Canadian Dividend ETF”,在加拿大市场上缩写为HAL。 “TF”丢失,因为35后的字符被截断,“EHAL”是红鲱鱼。
如果您在后续流程中遇到问题,可能会出于另一个原因,例如加拿大市场缩写与美国市场缩写相混淆。