Re: result of regexps into a string

2001-08-10 Thread Romek Krisztián

Hello Chasey and Akshay!

> You could use a regex:
>
>   $log_line =~ /([\d.]+)\s/;
>   my $ip_addr = $1;

> IP numbers have the format ddd.ddd.ddd.ddd ranging from 1 to 3 digits,
> so
> if(/$(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})/) would grab the IP and put it
> in $1
> the above will match IP numbers
>
> for this program, you can also use something simpler like
> if(/$(\S+)/)
> this will just grab all non space chars at the beginning of the line

The begining of the line doesn't start from ^?

I would rather use this:

if (/^[\d+.]+/)

or

if (/^[\d{1,3}.]{3}\d{1,3}/)

So why do you need \s to the end of the regexp? If the Apache log works
well. :-)

Check if this works.

Chris





-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




length of an array

2001-08-07 Thread Romek Krisztián

Hello!

@array[$a] = [1, 2, 3, 4, 5];

How can I determine the length of an array inside an array?

I tried the followings:

$length = $#array[$a]# --> syntax error
$length = scalar(@array[$a]) # --> ARRAY(blablabla)

Any ideas?

Krisztian


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: ideas to clean this up?

2001-08-07 Thread Romek Krisztián

Hello!

> And your exec code ought not to have to change.  If you're used to doing
> something that says
>
>  foo (@files)
>
> then just do instead
>
>  foo (@{$logFiles{$key})
>
> where $key is one of the hash keys - obviously now you can loop through
all
> of them.

Sorry, but did you forget a brace?

foo (@{$logFiles{$key}})

Krisztian


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




split problem

2001-08-05 Thread Romek Krisztián

Hello!

What's the problem with my split?

$line = "var=value";
($var, $value) = split(/\s*[=]\s*/, $line);

Krisztian

I experienced that $var and $value contained the first letter of the var and
the value. Sometimes  nothing. Where is the error?

Krisztian


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl reference

2001-08-01 Thread Romek Krisztián

Hello!

I would like to offer you this reference. I've downloaded that and looked very easy to 
use!

http://freshmeat.net/projects/perl-reference/

About: Perl-reference is a program to quickly display reference documentation for a 
Perl function, variable, regexp operator, or language keyword. This documentation is 
generated from the default Perl POD files, namely perlfunc, perlop, and perlvar. 
Unlike perldoc, perl-reference relies on documentation generated at compile-time, 
which results in a much higher response time.

Krisztian Romek
[EMAIL PROTECTED]