開発プラットフォームからの情報に沿って、次の読み取りを付加しましたは、ラインでの前回のリード
情報のPostgreSQLにコピー:行区切り文字は#記号
データベースのテーブル列です:id work composer artist conductor orchestra album_title
問題:現在のID行に次の情報行を追加してください
次の行の繰返し時に 'mmfmm01#'を保存するにはどうしたらいいですか?これが私の最初の投稿であるので、コードの例が多すぎるか少なすぎるかを教えてください。
私はこれからの予定です:
ルNOZZEディフィガロ、K. 492 /フィガロの結婚:ルNOZZEジ フィガロ、K. 492 /フィガロの結婚:チンクエ... DIECI ...ベンティ/ ファイブ...テン...これまで最終的に
トゥエンティ:
mfmm01#チンクエDIECIのベンティの#モーツァルト####遊び製シンプルメルロー、 フィレミニョン、モーツァルト
スクリプトを実行した後、私は次のようしている:
がどのように私は 'mfmm01#' を維持しなければならないの
mfmm01#次の行の時にそうそれを次の行に追加することができますか?
#!/usr/bin/perl # use clauses for File, cwd, etc# # usage statment # Variables - append _orig to input_file my $id = $ARGV[1]; my $input_file = $ARGV[0]; my $album_title = $ARGV[2]; my $output_file = output_file; my $input_file_orig = $input_file; $input_file_orig = $input_file_orig .= _orig; ############################################## # Ensure that the provided input file exists # ############################################## ########################################################## # Read all file lines into an array # ########################################################## ########################################################### # Modify each line to meet the following specs: # # id#work#composer#artist#conductor#orchestra#album_title # ########################################################### for my $line (@lines) { $line =~ s/[\n\r\t]+//g; ###################################################### # Ignore lines with num:num, lines that begin with $ # # and emptry string lines # # #################################################### if ($line =~ /[0-9]:/m) { next; } elsif ($line =~ /^\$/m) { next; } else { if ($line =~ /^\s*$/m) { next; } } ######################################################## # If line is a number followed by a space, prepend id # # and replace space with the # character # ######################################################## if ($line =~ /^\d\d\s/m) { $id_num = $line; $id_num =~ s/(\d\d)\s/$id$1#/g; } else { if ($line =~ /^\d\s/m) { $id_num = $line; $id_num =~ s/(\d)\s/$id$1#/g; # print ("\$line after removing space: \"$line\"\n"); } } #################################################### # If line begins with an alphabetic character then # # prepend id_num and append album_title # #################################################### if ($line =~ /Sold/m) { next; } if ($line =~ /^[A-Z]/m) { ################################################i## # At this point $line exists but $id_num is empty # # I thought $id_num would live through the next # # line read # ################################################### $prepend_line =~ s/($line)/$id_num$1/g; print("$prepend_line"); $append_line =~ s/($prepend_line)/$1#Mozart###$album_title/g; open my $ofh, '>>', $output_file or die $!; print $ofh "$append_line\n"; close $ofh or die $!; print("\$append_line: $append_line\n"); } } 1;
あなたの投稿を編集して、入力と希望する出力のより明確な例を得ることができますか? – beasy