这些perl变量意味着什么?
我对perl编码惯例有点陌生,有人能帮我解释一下:这些perl变量意味着什么?,perl,variables,coding-style,string-matching,slash,Perl,Variables,Coding Style,String Matching,Slash,我对perl编码惯例有点陌生,有人能帮我解释一下: 为什么perl变量前面有/和/new($file,“你在哪里看到这个语法的(或者更重要的是:你有没有把你看到的东西编辑掉)?/foo/表示使用正则表达式而不是变量的匹配运算符。换句话说,第一行是检查输入字符串$\u是否包含字符序列我已经编辑了代码。您认为第一行是检查inputstrng$\u是否包含字符“段”吗? use FileHandle; sub open_infile { my $file = shift; my $in =
- 为什么perl变量前面有
和/
/
my$in=FileHandle->new($file,“你在哪里看到这个语法的(或者更重要的是:你有没有把你看到的东西编辑掉)?
表示使用正则表达式而不是变量的匹配运算符。换句话说,第一行是检查输入字符串/foo/
是否包含字符序列$\u
我已经编辑了代码。您认为第一行是检查inputstrng$\u是否包含字符“段”吗?
use FileHandle; sub open_infile { my $file = shift; my $in = FileHandle->new($file,"<:encoding(UTF-8)") or die "ERROR: cannot open $file: $!\n" if ($Opt_utf8); $in = new FileHandle("$file") or die "ERROR: cannot open $file: $!\n" if (!$Opt_utf8); return $in; } $uamf = shift @ARGV; $uamin = open_infile($uamf); while (<$uamin>) { chomp; if(/<segment /){ /start=\'([0-9]+)\'/; /end=\'([0-9]+)\'/; /features=\'([^\']+)\'/; $features =~ s/annotation;//; push(@{$Start{$start}},$features); push(@{$End{$end}},$features); } }