in reply to How to replace in one regexp

CGI, URI
#!/usr/bin/perl -- use strict; use warnings; use URI; my $path = { URI->new( "/index.php?prefix=/user/" )->query_form }->{pr +efix}; print "$path\n"; use CGI; $path = CGI->new( "prefix=/user/")->param("prefix"); print "$path\n"; __END__ /user/ /user/

Replies are listed 'Best First'.
Re^2: How to replace in one regexp
by ikegami (Patriarch) on Sep 30, 2009 at 18:33 UTC
    Good call to use URI, but your code does something different than the OP's. The following would be equivalent:
    #!/bin/env perl use strict; use warnings; use URI qw( ); my $target = "/index.php?prefix=/user/"; my $path = URI->new_abs( '.', $target )->path(); print "$path\n";