in reply to Code generation. Printing out regular expressions

In addition to roboticus's comments, I'm a little surprised that you get the literal $line in your output. The $line inside the double quotes of each print statement should have interpolated just as the $| did in the second line. Unless, of course, you did something like $line = '$line'; in your code somewhere.

Your comments detailing what the lines do are inaccurate, for instance, /^\s+|#/ will match one or more spaces anchored to the beginning of the string or a hash anywhere. Is that what you meant? I expect you know this but note that if you are trying to match literal dollar and pipe symbols, they are regular expression metacharacters and should be escaped. Also, if you are trying to match a forward slash it can be more readable to choose a different regex delimiter. Putting all this together:

print '$line =~ s{^\s+#}{}; #trim leading spaces and comment hash', "\ +n"; print '$line =~ s{\s+/$}{}; #trim trailing spaces and forward slash', +"\n";

I hope I have guessed your intention correctly and that this is helpful.

Cheers,

JohnGG