Welcome to WebmasterWorld Guest from

Forum Moderators: coopster & jatar k & phranque

Message Too Old, No Replies

need a perl function

9:28 pm on Jul 3, 2005 (gmt 0)

Junior Member

10+ Year Member

joined:Jan 14, 2003
votes: 0

hi guys

i have a perl script x.pl with this line,.
when i run this script it registers domains.


instead of adding domain in this code.. i want it to pickup from txt file

the txt file will have a list of domains like

so when i run the script it shud pick each domain from the txt file and run in a loop.

can someone provide a perl function for this?


5:50 am on July 4, 2005 (gmt 0)

Preferred Member

10+ Year Member

joined:Aug 7, 2003
votes: 0

$textfile = /path/to/textfile.txt

open (INFILE,"$textfile");
@domains = <INFILE>;
close (INFILE);

foreach $DomainName(@domains) {
[code to register this $DomainName]

6:36 am on July 4, 2005 (gmt 0)

Full Member

10+ Year Member

joined:July 23, 2003
votes: 0

The previous code leaves a newline at the end of the domain name.

This code strips leading and trailing whitespace (including newlines), skips blank lines, and skips lines whose first non-whitespace character is a pound sign. This allows your input text file to have comments, which I find to be very useful.

It picks up a the file name from the command line, or uses a default if there is none.


use strict;
use warnings;

my $textfile = shift ¦¦ "your-default-filename";
open IN, "<", $textfile
or die "Unable to open $textfile $@";

while (<IN>) {
next if /^$/;
next if /^\#/;
my $DomainName = $_;
print "Processing: $DomainName\n";
# process domain name.

close IN;

The broken bars above (¦¦) should be the unbroken bars.


Join The Conversation

Moderators and Top Contributors

Hot Threads This Week

Featured Threads

Free SEO Tools

Hire Expert Members