Mic*_*ger 0 embed shell perl command
有没有办法将数据嵌入到 perl 脚本中,然后以类似于 c-shell 的方式作为临时文件使用/读取它。
cat<< eof>tmp.txt
store a multiline text file
eof
run_some_function on [anotherexternalfile] with [tmp.txt]
rm tmp.txt
Run Code Online (Sandbox Code Playgroud)
我想在一个 perl 脚本中嵌入多组命令/数据文件来包装一组命令,以避免需要过多的外部命令文件。
更新
嵌入的文件/数据需要作为另一个可执行函数的输入文件读取,如下所示。
system("executable.exe [anotherexternalfile] [tmp.txt]");
Run Code Online (Sandbox Code Playgroud)
据我了解,perl有DATA句柄,您可以在其中保留要从脚本中使用的数据。这边走:
#!/usr/bin/env perl
while ( <DATA> ) {
## Work with this data as if you were reading it from an external file.
}
__DATA__
some data
more data
and more...
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
708 次 |
| 最近记录: |