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
Post a Comment