Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Perl:将执行返回给调用方,然后再次唤醒_Perl - Fatal编程技术网

Perl:将执行返回给调用方,然后再次唤醒

Perl:将执行返回给调用方,然后再次唤醒,perl,Perl,假设我们有一个bash脚本: #!/bin/bash perl /home/user/myscript.pl echo "hello" myscript.pl: #!/usr/bin/perl print "First\n"; #here I want the script to sleep for 5 seconds #and return the execution back to the caller #so, "hello" will be printed #but after 5

假设我们有一个bash脚本:

#!/bin/bash

perl /home/user/myscript.pl
echo "hello"
myscript.pl:

#!/usr/bin/perl

print "First\n";
#here I want the script to sleep for 5 seconds
#and return the execution back to the caller
#so, "hello" will be printed
#but after 5 seconds the script will wake up from sleep and run the next line

print "Second\n";
我怎么能这样呢

#!/bin/bash
perl /home/user/myscript.pl &
sleep 5
echo "hello"

-或-

#!/usr/bin/perl
...
#!/bin/bash
perl /home/user/myscript.pl
echo "hello"
#!/usr/bin/perl
sleep(5);
$SIG{CHLD} = 'IGNORE';
exit(0) if fork();
...