ararghat has asked for the wisdom of the Perl Monks concerning the following question:
I want to extract elements between " and ) & ) and ;; {or extract parameter and variables} from the given file
input.txt "BR")old_file="ods.csv" newfile="ods_nt_$curr_date.csv" newwack="rac_client_$curr_date.ack" IN_DIR="odc\5060" ;; "CL")old_file="ods_cash.csv" newfile="ods_nt_cash_acc_$curr_date.csv" newwack="rac_cash_acc_$curr_date.ack" IN_DIR="obc\5060" ;; "CUA")old_file="ods_ven.csv" newfile="ods_nt_ven_$curr_date.csv" newwack="rac_vendor_$curr_date.ack" IN_DIR="ofc\5060" ;; ##########################
OUTPUT should be : BR old_file="ods.csv" BR newfile="ods_nt_$curr_date.csv" BR newwack="rac_client_$curr_date.ack" BR IN_DIR="odc\5060" CL old_file="ods_cash.csv" CL newfile="ods_nt_cash_acc_$curr_date.csv" CL newwack="rac_cash_acc_$curr_date.ack" CL IN_DIR="obc\5060" CUA old_file="ods_ven.csv" CUA newfile="ods_nt_ven_$curr_date.csv" CUA newwack="rac_vendor_$curr_date.ack" CUA IN_DIR="ofc\5060"
please provide me solution. my code is given below which is not working properly.
open(data,"<input.txt"); while(<data>) { $line=<data>; if ($line=~/\"(.*)\)/) { $parameter=$1; } elsif (/\)/../\;\;/) { next if /\)/||/\;\;/; $var=$_; } print "$parameter. $var\n"; } close data;
|
|---|