$length = scalar @servernames;
You could also use
foreach $name(@servernames) {
print "$name\n";
}
John
-----Original Message-----
From: Tyler Longren [mailto:[EMAIL PROTECTED]]
Sent: 28 June 2001 15:39
To: Perl Beginners
Subject: Re: arrays
One more quick question. How can I count the values in an array
(@servernames)?
I want to print my servernames seperately:
$i=0;
while ($i <= $num_servers) {
print "$servernames[$i]\n";
}
Something like that (I don't know if that will even work in perl...but it
does in PHP).
Thanks!
Tyler
----- Original Message -----
From: "Brett W. McCoy" <[EMAIL PROTECTED]>
To: "Tyler Longren" <[EMAIL PROTECTED]>
Cc: "Perl Beginners" <[EMAIL PROTECTED]>
Sent: Thursday, June 28, 2001 9:18 AM
Subject: Re: arrays
> On Thu, 28 Jun 2001, Tyler Longren wrote:
>
> > I'm just starting perl. I want to search through httpd.conf and get the
> > ServerName from each virtual host.
>
> Sure:
>
> open(APACHE_CONF, "httpd.conf") or die "Could not open Apache config file:
> $!\n";
>
> my @servernames;
>
> while(<APACHE_CONF>) {
>
> if(/^ServerName\s(.*)$/i) {
> push @servernames, $1;
> }
> }
>
> close(APACHE_CONF);
>
> -- Brett
>
> http://www.chapelperilous.net/btfwk/
> ------------------------------------------------------------------------
> Tuesday After Lunch is the cosmic time of the week.
--------------------------Confidentiality--------------------------.
This E-mail is confidential. It should not be read, copied, disclosed or
used by any person other than the intended recipient. Unauthorised use,
disclosure or copying by whatever medium is strictly prohibited and may be
unlawful. If you have received this E-mail in error please contact the
sender immediately and delete the E-mail from your system.