Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
テキスト ファイル内の選択された値を置き換える Perl コードを書くのに助けが必要です。以下は私のテキストファイルのサンプルです。
サーバー=ホスト1 network=true start=false end=YYYYMMDD key=34
サーバー=ホスト1
network=true start=false end=YYYYMMDD key=34
への変更
サーバー=ホスト network=false start=true end=YYYYMMDD key=10
サーバー=ホスト
network=false start=true end=YYYYMMDD key=10
start と network の値をランダムに false または true に生成したい.時々 true 時々 false
perl -i.bak -lpe' for my $word (qw(network start)) { s/$word=\K.*/rand > 0.5 ? "true" : "false"/e } ' *.txt