为什么这两个变量`$ {“ _ <$ filename”}`和`$ {“ :: _ <$ filename”}`不相等?

时间:2019-05-23 07:35:18

标签: perl

这个问题与this一个问题有关。

您说这两个是相同的:

${ "::_<$filename" }                       # Not allowed under strict.
${ "_<$filename" }     # In main package   # Not allowed under strict.

但是接下来怎么可能?

if( ${ "_<$filename" } ne ${ "::_<$filename" } ) {
    print "MISMATCH\n";
    print ">>${ '_<$filename' }<<\n>>${ '::_<$filename' }<<\n";
}

输出:

MISMATCH
>><<
>><<

$filename/home/kes/work/projects/tucha/monkeyman/app/maitre_d/../..//local/lib/perl5/Specio/Constraint/Role/Interface.pm

时会发生这种情况

UPD
"的引号是@HåkonHægland的建议

    print "MISMATCH\n";
    print ">>${ \"_<$filename\" }<<\n>>${ \"::_<$filename\" }<<\n";
    Devel::Peek::Dump( ${         "_<$filename"  } );
    Devel::Peek::Dump( ${       "::_<$filename"  } );
    Devel::Peek::Dump( ${     $::{"_<$filename"} } );
    Devel::Peek::Dump( ${ ${'::'}{"_<$filename"} } );

输出为:

MISMATCH
>><<
>>/home/kes/work/projects/tucha/monkeyman/app/maitre_d/../..//local/lib/perl5/Specio/Constraint/Role/Interface.pm<<
SV = PV(0xfb84520) at 0xff527a0
  REFCNT = 1
  FLAGS = ()
  PV = 0
SV = PV(0x2e43d80) at 0x2f40400
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x2edc4a0 "/home/kes/work/projects/tucha/monkeyman/app/maitre_d/../..//local/lib/perl5/Specio/Constraint/Role/Interface.pm"\0
  CUR = 111
  LEN = 113
  COW_REFCNT = 0
SV = PV(0x2e43d80) at 0x2f40400
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x2edc4a0 "/home/kes/work/projects/tucha/monkeyman/app/maitre_d/../..//local/lib/perl5/Specio/Constraint/Role/Interface.pm"\0
  CUR = 111
  LEN = 113
  COW_REFCNT = 0
SV = PV(0x2e43d80) at 0x2f40400
  REFCNT = 1
  FLAGS = (POK,IsCOW,pPOK)
  PV = 0x2edc4a0 "/home/kes/work/projects/tucha/monkeyman/app/maitre_d/../..//local/lib/perl5/Specio/Constraint/Role/Interface.pm"\0
  CUR = 111
  LEN = 113
  COW_REFCNT = 0

从输出中我们可以看到主题变量是不同的:

SV = PV(0xfb84520) at 0xff527a0
SV = PV(0x2e43d80) at 0x2f40400

1 个答案:

答案 0 :(得分:0)

感谢library(circular) ## simulate circular data bcirc1 <- rvonmises(100, circular(90, units = 'degrees'), 10, control.circular=list(units="degrees")) bcirc2 <- rvonmises(100, circular(0, units = 'degrees'), 10, control.circular=list(units="degrees")) bcirc <- data.frame(condition = c( rep(1,length(bcirc1)), rep(2,length(bcirc2)) ), angles = c(bcirc1, bcirc2) ) ## start with blank plot, then add group-specific points dev.new(); par(mai = c(1, 1, 0.1,0.1)) plot(circular(subset(bcirc, condition == 1)$angles, units = 'degrees'), stack=T, bins=60, shrink= 1, col=1,sep = 0.005, tcl.text = -0.073,#text outside axes=T, xlab ="Basal sCORT", ylab = "Basal sAA") par(new = T) plot(circular(subset(bcirc, condition == 2)$angles, units = 'degrees'), stack=T, bins=60, shrink= 1.05, col=2, sep = -0.005, axes=F)#inner circle, no axes, stacks inwards 。我错过了@HåkonHægland意味着::的包裹。

我被以下情况弄糊涂了:

  

以下等同:

main

现在我明白这意味着

${ "::_<$filename" }                       # Not allowed under strict.
${ "_<$filename" }     # In main package   # Not allowed under strict.