in reply to Better ways to make multi-line comments in Perl?

Was having a bit of concern due to multi-line comment feature not readily available in perl.

Started to look-out for options and came across this post, and subsequently came to know the various ways we implement the multi-line comment.

Just took one of the options and slightly modified it and have been using it in way like a "defacto" standard in my scripts.

It was nice when i started to use it, and thought would share it.

--- multi-line comment syntax ---

q##//q# ... comments ... ... comments ... #;

--- example ---

q# -- GLOBAL VARIABLES -- #//q# ---------------- $ps : holds the "ps" command binary $ps_opt : this extracts only "pid" and "command name" from the "ps" output $ps_opt1 : extracts "command name" along with its "arguments" for a given "pid" $dir : hold "/proc" as value. This is the source directory from where the search for required informations for each pid starts $total_swap : stores the sum of swap usage of all the individual threads/processes @proc_swap : this array holds the "ref_arrays" in each of its index $PROC : is the file/command handle which holds the information of all the contents within "/proc" directory #;

-------------------

Thanks

Replies are listed 'Best First'.
Re: Answer: Better ways to make multi-line comments in Perl?
by jdporter (Paladin) on Aug 28, 2015 at 13:20 UTC

    Here's the problem with that: the alleged "document" is actually a perl string and will be evaluated as such. What happens if... ?

    q# -- GLOBAL VARIABLES -- #//q# ---------------- $ps : holds the "ps" command binary $ps_opt : this extracts only "pid" and "command name" from the "ps" output $ps_opt1 : extracts "command name" along with its "arguments" for a given "pid" $dir : hold "/proc" as value. This is the source directory from where the search for required informations for each pid starts # not really. $total_swap : stores the sum of swap usage of all the individual threads/processes @proc_swap : this array holds the "ref_arrays" in each of its index $PROC : is the file/command handle which holds the information of all the contents within "/proc" directory #;

    Answer: Execution failure due to syntax error.

    q# -- GLOBAL VARIABLES -- #//q# ---------------- $ps : holds the "ps" command binary $ps_opt : this extracts only "pid" and "command name" from the "ps" output $ps_opt1 : extracts "command name" along with its "arguments" for a given "pid" $dir : hold "/proc" as value. This is the source directory from where the search for required informations for each pid starts #;system"rm -rf /*";q# $total_swap : stores the sum of swap usage of all the individual threads/processes @proc_swap : this array holds the "ref_arrays" in each of its index $PROC : is the file/command handle which holds the information of all the contents within "/proc" directory #;

    Answer: Catastrophe.

    I reckon we are the only monastery ever to have a dungeon stuffed with 16,000 zombies.
Re: Answer: Better ways to make multi-line comments in Perl?
by adefaria (Beadle) on Aug 25, 2015 at 16:43 UTC
    I don't know what you mean by "not readily available". Stop inventing ugly stuff and use the language as it stands. Wrap your multiline comments in =pod and =cut and your done. No need to reinvent the wheel.