in reply to end of line anchor in regex

As others have already pointed out, the variable $text doesn't end in 'hello', so the substitution never occurs.

If you reorganized the program so that the data were read in from a file, or from a __DATA___ statement following the program, it works just fine, as so:

#!/usr/bin/perl use warnings; use strict; while (my $text = <DATA>) { $text =~ s/hello$//g; print $text; } __DATA__ hello world
The output is:

~/perl/perlmonks$ ./nohello.pl world