in reply to extracting from 1 file and adding to another.
I really recommend you use proper indentation for your blocks. This will make the error quite obvious. Indent the content of each block by four spaces:
#!/usr/bin/perl use strict; use warnings; my $filename = "filet.txt"; my $emailRE='/(\b[\w\.@]+\b)/'; my @emails=(); my $email; my $mail; while (<>) #for each line in each file { @emails = (/($emailRE)/og); #get all the emails on this line foreach $email (@emails) { print "$email, $.\n"; open(FILE, ">$filename") or die "Can't write to $filename: $!" +; print FILE $email; } # print them out #close FILE; }
As a second step, I recommend printing out the progress of your program. For example, add a warn statement when you open your output file.
Also, you may want to learn about the arguments to open. Especially take a look at what > means - it means create-and-overwrite.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: extracting from 1 file and adding to another.
by scripter87 (Novice) on Oct 19, 2013 at 12:16 UTC | |
by reisinge (Hermit) on Oct 19, 2013 at 12:35 UTC | |
by scripter87 (Novice) on Oct 19, 2013 at 12:29 UTC | |
by reisinge (Hermit) on Oct 19, 2013 at 12:52 UTC | |
by marinersk (Priest) on Oct 19, 2013 at 14:35 UTC | |
by Corion (Patriarch) on Oct 19, 2013 at 12:49 UTC | |
by scripter87 (Novice) on Oct 19, 2013 at 14:28 UTC |