sed to add a string to beginning of lines,starting from line say line 20 to line 30 only
<p>I have  a file with 42 lines of code.
I need to add a '#' string to beginning of each line from line 27 to line 40 only,so as to declare it as comments.</p>

<p>Is there a way to achieve this using sed?Please provide the way to achive this.</p>

<p>Thanks in advance!</p>

<pre><code>#!/usr/bin/perl
use Expect;
use Switch;
use POSIX;
use XML::Simple;
use ATS::DB::connect;
use ATS::DB::build;
use ATS::Misc::helperFuncs;
use ATS::L2L3::Object;
use ATS::L2L3::Router;
use ATS::L2L3::NS;
use ATS::DB::testinstance;
use ATS::DB::L1;
use ATS::DB::resource;
use Term::ANSIColor ;
use Term::ANSIColor qw(:constants);
use Term::ExtendedColor qw(:all);
use Data::Dumper;
BEGIN{ push @INC,"//home/atsuser/Scripts/LSN/";
push @INC,"/export/home/userAutomation/LSN/Scripts/";}
use LSN;
use File::Basename;
BEGIN{ push @INC,"//home/atsuser/Scripts/Failover/";}
use FileSync;

##############
Script Flow:
1.Determine the devices which are reachable.
2.Load the build passed to script on all UP devices
3.Check Devices are UP after buildUpdate.
4.Load config on devices which are UP.
5.Exit IF any config failed Or devices are n't UP after buildUpdate.
6.Proceed to Ping test
Clt -&gt; SNIP on R1
R1 -&gt; SNIP on HA
Prim -&gt; SNIP on R2
R2 -&gt; SNIP on Server
7. EXIT IF ping test failed
8. Proceed to CURL test.
Clt -&gt; service on Server   
#START:parser inserted variables                   
</code></pre>