in reply to newbie quoting question

what exactly does perl try to do with:

To find a full answer to that you need to look up capturing and clustering. But in short, as I understand it, if you give the regex engine your $var, it does this:

(1) looks for apple banana cherry;
(2) if it finds it, "captures" banana into a "dynamically scoped variable", which in this case will be $1 because it's the first capturing you've done.

The function of the brackets is to tell the regex engine which bit of the stuff you're searching for you want to capture. So it doesn't search for brackets. Which is why in your case it doesn't match.

You would have got a match with
$line = 'apple banana cherry kiwi lemon melon';
and you would have found that after you did
$line =~ s/$var//;
$1 miraculously returned "banana".

(Of course that wouldn't be very interesting, because you already knew it was a banana, which is why brackets usually have something other than literal characters in them).

§ George Sherston