in reply to $^I why this symbol does not work ?

I guess that $^I only works if you use the magic ARGV file handle, so you could try something along these lines:
sub replace { local $^I = ''; local @ARGV = ($para); while(<>) { s/UI_EM/$newpar/g; print; } }

(Untested)

Replies are listed 'Best First'.
Re^2: $^I why this symbol does not work ?
by kingwrcy (Initiate) on Oct 01, 2008 at 06:31 UTC
    my $new_par = "YI_OU"; open MYFILE,"c:/perl/test/1.txt" or die "cannot open file:$!"; local $^I = ''; local @ARGV = MYFILE; while(<>){ s/UI_EM/$new_par/g; print; }
    run it .an error occur:
    Bareword "MYFILE" not allowed while "strict subs" in use at C:\Perl\study\test.pl line 9.
    By the way could you tell me what is "magic ARGV file handle"?
    I am new perler.thanks.

      Put file names (not handles) in @ARGV:

      my $new_par = "YI_OU"; local $^I = ''; local @ARGV = 'c:/perl/test/1.txt'; while(<>) { s/UI_EM/$newpar/g; print; }
      local @ARGV = MYFILE;

      That's not the code I gave you.

      By the way could you tell me what is "magic ARGV file handle"?

      It's all in the docs.