Thank you guys for your help. I will have a look on Text:CSV as soon as possible.
The RegEx aren't the Problem. I know how to match the Strings. The Problem is that i don't know how to overwrite the line with my new line, I'll give you an example:
my first thoughts were something like this:
open FILEHANDLE, "/root/Desktop/file1.txt";
open FILEHANDLE2,">>", "/root/Desktop/file2.txt";
while (my $line = <FILEHANDLE>) {
$line =~ /RegEx/i;
my $telefonnummer = $1;
my $name = $2;
foreach (my $line2 = <FILEHANDLE2>) {
$line2 =~ /RegExp/i;
my $name2 = "$1,$2";
if ($name =~ /$name2/i) {
$line2 = "$line2;+49$telefonnummer"; }
}
}
I hope that it doesn't look to strange :)
The Problem in this code is that i can't simply print the
$line2 = "$line2;+49$telefonnummer";
line in the file.
If that Code wont work at all please tell me, if it would work with some modifications please tell me too. :D
Thanks.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.