You've been pointed to nodes that detail that homework questions are not liked here. I found it a neat challenge to write a program that does what you want but is a bit opaque in what it does:
#!/opt/perl/bin/perl -w no strict; no warnings; # Handle data by prefixing # the string with "#". The string # is passed in implicitly via $_ sub handle_data { do{eval}->() }; $/ = ""; while (<DATA>) { handle_data; }; __DATA__ # This program was written by Corion for # Anonymous Monk - http://www.perlmonks.org ( # see http://perlmonks.org/?node_id=567615 sub { $/ = "\n" }, sub { *DATA = *ARGV; $(}) {$_->()}; sub { *::handle_data = sub { substr $_, $(,$), "#"; print } };
In reply to Re: Adding '#' in the beginning of each line
by Corion
in thread Adding '#' in the beginning of each line
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |