简体   繁体   English

记住变量中字符串的一部分

[英]remember part of string in variable

The idea is that I have to read every line of file (CSV) and remember specific information in specific location as variable. 我的想法是我必须读取每行文件(CSV)并记住特定位置的特定信息作为变量。 example: 例:

a;b;c;d;e;f123;g;h;i;j

I know how to read every line but problem is how to save info where the f123 is and store it in the variable. 我知道如何阅读每一行,但问题是如何将信息保存在f123所在的f123并将其存储在变量中。 Any ideas? 有任何想法吗? Variable should change in every loop (when another line is checked, variable should change). 变量应该在每个循环中改变(当检查另一行时,变量应该改变)。

I suggest you to use CPAN module Text::CSV_XS 我建议你使用CPAN模块Text :: CSV_XS

It can utilize any user-specified characters as delimiters, separators, and escapes, it helps to deal with any csv files. 它可以利用任何用户指定的字符作为分隔符,分隔符和转义符,它有助于处理任何csv文件。

my @list = split ";", $line;
my $value = $list[5];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM