Results 1 to 7 of 7
Thread: need some perl help
-
07-03-2005, 05:27 PM #1Newbie
- Join Date
- May 2005
- Posts
- 28
need some perl help
hi guys
i have a perl script x.pl with this line,.
when i run this script it registers domains.
$DomainName = 'UNITEDARABEMIRATES.COM';
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
dd.com
d3.com
df.com
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?
thanks
sohail
-
07-03-2005, 10:27 PM #2Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
hi,
Code:open(DOMAINS, "<domains.txt") || die "Could not open domains.txt. $!"; while (<DOMAINS>) { chomp; # Now your domain is in $_ } close(DOMAINS);
-
07-03-2005, 11:04 PM #3Newbie
- Join Date
- May 2005
- Posts
- 28
ive replaced
$DomainName = 'UNITEDARABEMIRATES.COM';
with
open(DOMAINS, "<domains.txt") || die "Could not open domains.txt. $!";
while (<DOMAINS> )
{
chomp;
# Now your domain is in $_
}
close(DOMAINS);
when i run the script it shows
Warning: DomainName variable not defined!
-
07-03-2005, 11:07 PM #4Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
Hi,
I gave the script so you can change it around to your needs, it simply showed how you can read the lines from the file. You need some knowledge of perl to make it work though.
-
07-03-2005, 11:10 PM #5Newbie
- Join Date
- May 2005
- Posts
- 28
i know .
just one question.
your script doesnt pass the variable $DomainName =
how do i do that?
hope you dont mind
-
07-03-2005, 11:15 PM #6Disabled
- Join Date
- Jan 2005
- Location
- USA
- Posts
- 1,379
Hi,
In every iteration of the loop, after the line that says chomp, the domain name will be in the variable $_
-
07-04-2005, 07:39 AM #7Web Hosting Master
- Join Date
- Feb 2002
- Location
- Vestal, NY
- Posts
- 1,381
You don't seem to know much (or any) perl, so I will try and simplify things for you. I made a modification to the code to push the domain names into an array called "@DomainName"
Code:my @DomainName; open(DOMAINS, "<domains.txt") || die "Could not open domains.txt. $!"; while (<DOMAINS> ) { chomp; # Now your domain is in $_ push @DomainName, $_; } close(DOMAINS);
$DomainName[0] is the first domain name
$DomainName[1] is the 2nd domain name
etcH4Y Technologies LLC .. Since 2001!!
"Smarter, Cheaper, Faster" - SMB, Reseller, VPS, Dedicated, Colo hosting done right.
ZERO PACKETLOSS, ZERO DOWNTIME Dedicated and Colo - USA: IA, CA, NC, OR, NV
**http://h4y.us** **http://iwfhosting.net**Voice: (866)435-5642. *** askus at host4yourself d0t com