Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Now I want to read this file and print it out so I can copy and paste to my e-mail program (outlook) and send them a announement. So I want to print the content of this textfile into a textarea to copy and paste.blah@blah.com blah@somedomain.com blah@johndoe.com
Now heres my problem, the above code prints this into the textarea:my $file = "emails.txt"; open(FILE, $file) or die "cannot open $file : $!\n"; @content = reverse (<FILE>); close FILE; print "<textarea cols=\"75\" rows=\"22\">"; foreach $address (@content) { chomp($address); print "$address, "; } print "</textarea>";
Notice the comma at end (blah@blah.com,), how can I detect the end of the line of this file so I can tell Perl not to print the last "," ? So basically I want the contents of textarea to look like thisblah@johndoe, blah@somedomain.com, blah@blah.comblah@johndoe, blah@somedomain.com, blah@blah.com,
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Detecting Last line of a file
by gam3 (Curate) on Jun 18, 2005 at 11:19 UTC | |
|
Re: Detecting Last line of a file
by davidrw (Prior) on Jun 18, 2005 at 13:26 UTC | |
by omega_monk (Scribe) on Jun 18, 2005 at 15:32 UTC | |
by GrandFather (Saint) on Jun 18, 2005 at 22:24 UTC | |
by davidrw (Prior) on Jun 18, 2005 at 22:51 UTC | |
by GrandFather (Saint) on Jun 19, 2005 at 04:44 UTC | |
|
Re: Detecting Last line of a file
by data64 (Chaplain) on Jun 18, 2005 at 14:46 UTC | |
by tphyahoo (Vicar) on Jun 18, 2005 at 15:38 UTC | |
|
Re: Detecting Last line of a file
by chas (Priest) on Jun 18, 2005 at 12:21 UTC | |
|
Re: Detecting Last line of a file
by g0n (Priest) on Jun 18, 2005 at 10:49 UTC |