You need to apply a regular expression mask from the console. Those. "Type a mask" is written in the console, the mask is printed and symbols are already being replaced.

Here is what is available:

#! /usr/bin/perl print < STDOUT >."Введите маску"; $pattern = < STDIN >; $stroka = " as df as df a sd ff as df asdfasdf asdf"; $stroka=~s/$pattern//g; print $stroka; 

But it is impossible to apply a mask. What is the problem here?

  • one
    And who is the $line and where does it come from? Maybe $stroka ? And by the way, not $pattern = < STDIN >; , and $ pattern = <STDIN>; and print <STDOUT> I don’t remember how to be fine. And further. $pattern will contain the end of the string, so after $ pattern = <STDIN>; chop $ pattern does not hurt; (although chomp $pattern; is better chomp $pattern; safer) - alexlz
  • I apologize, a defect. Corrected as it should. - RomkaKraynov
  • Neither chop nor chomp helps. - RomkaKraynov
  • one
    @RomkaKraynov #! / Usr / bin / perl print STDOUT "Enter the mask>"; $ pattern = <STDIN>; chomp $ pattern; $ stroka = "as df as df a sd ff as df asdfasdf asdf"; $ stroka = ~ s / $ pattern // g; print $ stroka; alex @ ubuntu: ~ / tmp $ ./a.perl Enter the mask> sd as df as df aff as df afaf af - alexlz
  • 3
    Without use strict - shooting without the right to rehabilitate :) - user6550

0