perl - How can I pass in text rather than a file as a variable -


i want pass text in variable rather file. not sure how explain example.

i have perl script usage follows printme.pl [file] want run without passing in file , passing text.

echo print_me | perl printme.pl 

rather doing

perl printme.pl textfile.txt 

i trying run perl script takes text file variable , outputs using echo.

bash (amongst other shells) has feature called process substitution. in feature, can add shell code outputs stdout , have shell treat file.

in case, write:

perl printme.pl <(echo "hello world") 

perl receive in $argv[0] filename looks /dev/fd/63 can read line "hello world\n"


Comments

Popular posts from this blog

resizing Telegram inline keyboard -

command line - How can a Python program background itself? -

php - "cURL error 28: Resolving timed out" on Wordpress on Azure App Service on Linux -