> Hi, I have the following string into a file:
>
> LOG_INFO : cpcdos23.col.bsf.alcatel.fr: read request for
/bootp/popo.txt:
> success.
>
> And I have this code:
>
> my ($f)=@_;
> $thistime=(stat($f))[9];
> return if ($thistime == $mtime);
>
> $mtime=$thistime;
> my $dummy;
> open (FILE, $f) || warn "Couldn't open file $f: $!";
> @lines=<FILE>;
> close (FILE);
> ($dummy, $IP_address, $read, $status)=split(":",$lines[$#lines-2]);
> $IP_address=~s/^\s*(.*)\s*$/$1/;
> ($client_name)=split(/\./,$IP_address);
> $read=~/.*bootp(.*)\s*/;
> $boot_file=$1;
> $install_file_path=~/\/(.+):/;
>
>
> It works fine but only ythe last line doesn't work in fact i want to
display
> /bootp/popo.txt.


> $install_file_path=~/\/(.+):/;

First, I'm pretty sure you expect this statement to set
$install_file_path to something, but the reverse is true;
the thing on the left of the =~ operator is assumed to be
the string being searched. If the thing to the left is not
defined, the statement does nothing. I'd assume you
want $read in place of $install_file_path.

Second, there's a ":" in your regex, but there can't be any
":"s in the string that's been split up, because ":" is the
character on which the original string was split, and the
character on which the string is split is thrown away
(unless you tell split to do otherwise).

Try:

    $read=~/.*(\/bootp.*)\s*/;
    $install_file_path=$1;


Reply via email to