#!/usr/bin/env perl

use strict;
use warnings;

my @array = qw (
http://abc.com/files/randomthings/A/1.html
http://abc.com/files/randomthings/A/2.html
);

for ( @array ) {

#   This works
#   s!/A/\d+.html$!!; $url = $_;

#   Doesn't work ~ gives "1"
    ( my $url ) = ( $_ ) =~ s!/A/\d+.html$!!;
    print "$url" . "\n";

}

__END__

I want to remove the '/A/1.html' and assign the remaining value i.e. link to
"$url"
But all I get is "1" as value of "$url" which I think is return value that
substitution worked.

How can I remove '/A/1.html' and assign remaining "$_" to "$url"?

Reply via email to