perl in place edit replace multiple values same time -


All I am trying to search and replacing on file. The code below does not work What am I doing wrong? Please help

$ file = "/ tmp / file"; My $ date = qx / date + '% Y% m% d-% H% M% S' /; @accounts = qw ($ account1 $ account2 $ account3 $ account4); @rrgv = ($ file); $ ^ I = ". $ Date"; While (my $ line = & lt; & gt;) {for my $ account (@accounts) {if ($ line = ~ / ^ $ account /) {.. < Search and Replace & gt; Print $ line; } And {print $ line; }}

qw () word excerpt, this variable Does not launch.

  @accounts = qw ($ account1 $ account2 $ account3 $ account4);  

is equal to

  @accounts = ('$ account1', '$ account2', '$ account3', '$ account4');  

Note a single quote!

Instead, use

  @accounts = ($ account1, $ account2, $ account3, $) account4);   

BTW, instead of calling to call, you can use it:

  Use time :: piece; My $ lt = local time; My $ date = add '-', $ lt- & gt; Ymd (q ()), $ lt- & gt; HMS (q ());  

Comments

Popular posts from this blog

apache - 504 Gateway Time-out The server didn't respond in time. How to fix it? -

c# - .net WebSocket: CloseOutputAsync vs CloseAsync -

c++ - How to properly scale qgroupbox title with stylesheet for high resolution display? -