CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: Re: [Goldc0der] Write text Between Two Tags: Edit Log


Nov 21, 2005, 11:29 AM

Views: 3516
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>;

$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)

Edit Log:
Post edited by rork (User) on Nov 23, 2005, 7:42 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives