scripter87 has asked for the wisdom of the Perl Monks concerning the following question:
#!/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; }
So I am trying to extract data from a file that I use as an argument on the command line. When I print to the screen it shows the extracted information in "$email". I then open the file that I wanted to write to and write "$email" to it but it does not contain all the data that it should i.e. the information seen when I print screen has lot more than what my written file shows.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: extracting from 1 file and adding to another.
by Corion (Patriarch) on Oct 19, 2013 at 12:01 UTC | |
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 |