Perl中与PHP的get_file_contents()函数相当的函数是什么?

7
下面的PHP代码正好实现了我想要的功能。问题是,我需要使用Perl重新创建它,我一直在尝试使用Perl中的open()sysopen()函数,但无法实现。有人能提供帮助或知道任何可能有用的链接吗?谢谢。
$URL = "http://example.com/api.php?arguments=values";
echo file_get_contents($URL);

请查看以下链接: https://dev59.com/QHNA5IYBdhLWcg3wdtld - Clément Moulin - SimpleRezo
1个回答

13

你可以使用 LWP

use LWP::Simple;
$contents = get $URL or die;
print $contents;

显然,您不需要存储内容。 use LWP::Simple; print get "http://google.com" or die;die 是一个安全退出。 - vol7ron
当然,您也可以直接使用getprint()use LWP::Simple; getprint("http://www.google.com") or die; - vol7ron

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接