in reply to Use of uninitialized value $site in concatenation (.) when excute the perl script

You probably have blank lines in your input.

In the split doco, under "As another special case, ...", you'll see how your pattern (' ') is handled specially.

Whenever $line equals "\n", split(' ',$line) will return (): all of those 10 variables ($site, ..., $length) will be undef (i.e. "uninitialized value").

If you want to ignore them, you can do something like this:

foreach my $line (<LOGFILE>) { next if $line =~ /\A\Z/; ($site, ... ... }

[Aside: $a and $b are not good choices for variable names as they have special meaning to Perl - see perlvar]

-- Ken

Replies are listed 'Best First'.
Re^2: Use of uninitialized value $site in concatenation (.) when excute the perl script
by Anonymous Monk on Sep 02, 2012 at 14:43 UTC

    And, foreach my $line (<LOGFILE>) reads the whole LOGFILE straight into memory before starting to enumerate through the lines. (Unless Perl has special-case handling for that case. Which I don't recall Perl having.) The OP should use the iterator form: while (my $line = <LOGFILE>) {