
rork
User
Nov 21, 2005, 11:29 AM
Views: 1718
|
|
Re: [Goldc0der] Write text Between Two Tags
|
|
|
You could load the whole file at once and strip everything up until [start] and everything from [end]
{ undef $/; open(LISTA, '<', $fichero) or die "Can't open $fichero: $!"; my $retorno = <LISTA>; close(LISTA); } $retorno =~ s/^.*\[start\]//i; $retorno =~ s/\[end\].$//i; print $retorno; Some notes: the open is between { } so the undef of $/ won't affect the rest of your script. The first regexp will remove everything untill and including the last [start] The second regexp will remove everything from and including the first [end] after the last [start] edit: fixed the code -- Don't reinvent the wheel, use it, abuse it or hack it.
(This post was edited by rork on Nov 23, 2005, 7:42 AM)
|