• 締切済み

perlで超素朴な質問

超初心者です。 辞書から不必要な文字を消そうをしていますが、はじめのファイルを読み出すから 行き詰っています。 下が使いたい辞書データです。 ------------ word,trans,exp,level,memory,modify,pron,filelink "さまざまな理由から [さまざまなりゆうから]","(exp) for various reasons","",0,0,0,"" "さめざめ","(adv) sorrowfully/anguishedly","",0,0,0,"" "さもしい","(adj) selfish/self-seeking/self-interested/mean","",0,0,0,"" "さようならホームラン","(n) game-ending home run (baseball)","",0,0,0,"" "さよならホームラン","(n) game-ending home run (baseball)","",0,0,0,"" "さらけ出す [さらけだす]","(v5s) to expose/to disclose/to lay bare/to confess","",0,0,0,"" "さらさら","(adj-na,adv,n,vs) (1) rustling/murmuring/(2) fluently/(3) silky (hair)/(P)","",0,0,0,"" "さらば","(conj,int) farewell","",0,0,0,"" "さん","(suf) Mr or Mrs/(P)","",0,0,0,"" "さーたーあんだぎー","(n) type of Okinawan doughnut (donut)","",0,0,0,"" "さ来週 [さらいしゅう]","(n-adv,n-t) week after next","",0,0,0,"" "さ迷う [さまよう]","(v5u) to loiter/to putter/to prowl/to wander about/to roam about/to knock around","",0,0,0,"" "ざあざあ","(adv) sound of rushing water/sound of pouring rain/white noise sound/(P)","",0,0,0,"" "ざあっ","(n) (onom) sound of water","",0,0,0,"" "ざくざく","(adj-na,adv) lots of coins or jewels/cutting up roughly/mixing gravel/walking on frost","",0,0,0,"" "ざけんなよ","(exp) (X) (vulg) fuck you!/""don't fuck around""/""don't be a screw off""","",0,0,0,"" "ざっくざっく","(adv) crunch crunch/thud thud/tramp tramp","",0,0,0,"" "ざっくばらん","(adj-na,n) frankness","",0,0,0,"" "ざっと","(adv) roughly/in round numbers/(P)","",0,0,0,"" "ざぶんと","(adv) with a splash","",0,0,0,"" ------------------ そして組んだのがこれです。 use encoding "cp932"; $/ = "\r\n"; open(DIC, "+> DicData.csv") or die("Error:$!"); while(<DIC>){ $data = $_; } if($a =~ /&quot/){ $a =~ s/&quot//g; } close(DIC); ----------- お恥ずかしい限りです。 なにとぞよろしくお願いします。

みんなの回答

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.4

いまさらだけど なんで質問者である neo_j とはまったく縁もゆかりもない neowave2001 さんが閉め切ろうとするの>#3.

回答No.3

ご親切な返事をありがとうございます。 本当に助かりましました。 *なお、締め切りたいのですが私からは操作できません。

  • kuroizell
  • ベストアンサー率55% (95/170)
回答No.2

> open(DIC, "+> DicData.csv") or die("Error:$!"); "+>"を使うと、ファイルの内容をクリアしてから読み書き両用に使います。 これ以上説明はしんどいのでコードで・・・ たぶんやりたいのはこういうことでしょう。 #!/usr/bin/env perl use strict; use warnings; undef $/; open my $fh, '<', "DicData.csv" or die $!; my $data = <$fh>; close $fh; $data =~ s/"//g; open my $fh, '>', "DicData.csv" or die $!; print $fh $data; close $fh;

  • Tacosan
  • ベストアンサー率23% (3656/15482)
回答No.1

何をどう困っているのか, 明らかにしようとは思いませんか?

関連するQ&A