Need help with Use of uninitialized value in concatenation (.) or string

Hello,

In the following script my goal is pull the date value each time an error value (hardcoded) is found in the specified log file. The script retrieves the error value without a problem but I cannot seem get the date value. Can anyone tell me what I need to do?

The error message when I run the script is:

Use of uninitialized value in concatenation (.) or string at script.pl line 32

where line 32 is where I am calling this:

"print $date";

Here is the script:

use warnings;
use strict;

#Specify the path to the log file you want to read, for ex. application log#

open (FILEHANDLE, 'd:/scripts/server2.log') or print "Can't Open File!!!";

while(( my $line = <FILEHANDLE>)) {

#Searching for keywords from application log#

if (($line =~ m/CQCommitException/i ) || ($line =~ m/Communication link failure/i)) {

my [at] fields = split '\|', $_;
my $date = $fields[1];

print $date;

#prints $line to file
open (my $outfile, ">>", "d:/scripts/loginfo.txt") or die "Can't open loginfo.txt: $!";

print $outfile "$date, $_\n";

#close $outfile or die "$outfile:$!";

}
}

my $outfile = 'd:/scripts/loginfo.txt';

#To send or not to send - file size check

#Delete file when done
#unlink 'd:\scripts\loginfo.txt';

-END-




--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
CM Analyst [ Do, 27 Januar 2011 21:57 ] [ ID #2053968 ]

RE: Need help with Use of uninitialized value in concatenation (.) or string

Can you send an example of the data in the log file?

tm

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Mark Meyer [ Do, 27 Januar 2011 23:40 ] [ ID #2053969 ]

Re: Need help with Use of uninitialized value in concatenation (.) or string

--001636c5a5d0cf7cca049adbb621
Content-Type: text/plain; charset=UTF-8

When you are already storing the line under $line
>>>while(( my $line = <FILEHANDLE>)) {

Then why are you using $_
>>>my [at] fields = split '\|', $_;

Cheers,
Parag



On Thu, Jan 27, 2011 at 12:57 PM, CM Analyst <cmanalyst [at] yahoo.com> wrote:

> Hello,
>
> In the following script my goal is pull the date value each time an error
> value (hardcoded) is found in the specified log file. The script retrieves
> the error value without a problem but I cannot seem get the date value. Can
> anyone tell me what I need to do?
>
> The error message when I run the script is:
>
> Use of uninitialized value in concatenation (.) or string at script.plline 32
>
> where line 32 is where I am calling this:
>
> "print $date";
>
> Here is the script:
>
> use warnings;
> use strict;
>
> #Specify the path to the log file you want to read, for ex. application
> log#
>
> open (FILEHANDLE, 'd:/scripts/server2.log') or print "Can't Open File!!!";
>
> while(( my $line = <FILEHANDLE>)) {
>
> #Searching for keywords from application log#
>
> if (($line =~ m/CQCommitException/i ) || ($line =~ m/Communication link
> failure/i)) {
>
> my [at] fields = split '\|', $_;
> my $date = $fields[1];
>
> print $date;
>
> #prints $line to file
> open (my $outfile, ">>", "d:/scripts/loginfo.txt") or die "Can't open
> loginfo.txt: $!";
>
> print $outfile "$date, $_\n";
>
> #close $outfile or die "$outfile:$!";
>
> }
> }
>
> my $outfile = 'd:/scripts/loginfo.txt';
>
> #To send or not to send - file size check
>
> #Delete file when done
> #unlink 'd:\scripts\loginfo.txt';
>
> -END-
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>
>
>

--001636c5a5d0cf7cca049adbb621--
Parag Kalra [ Do, 27 Januar 2011 23:45 ] [ ID #2053970 ]

Re: Need help with Use of uninitialized value in concatenation (.) or string

This is a sample of the data I am reading in:
=A0
[#|2011-01-19T07:05:10.734-0800|WARNING|sun-appserver2.1|jav ax.enterprise.s=
ystem.stream.err|_ThreadID=3D15;_ThreadName=3DhttpSSLWorkerT hread-8080-1;_R=
equestID=3Dc5cefdc4-4651-4c77-b9e6-84f9e0f6609e;|]
com.raec.cq.CQCommitException: You wanted to commit a modifyCR based record=
, but the record was not found in the ClearQuest Database.
[#|2011-01-19T07:05:10.734-0800|WARNING|sun-appserver2.1|jav ax.enterprise.s=
ystem.stream.err|_ThreadID=3D15;_ThreadName=3DhttpSSLWorkerT hread-8080-1;_R=
equestID=3Dc5cefdc4-4651-4c77-b9e6-84f9e0f6609e;|]
com.raec.cq.CQCommitException: You wanted to commit a modifyCR based record=
, but the record was not found in the ClearQuest Database.
[#|2011-01-19T07:05:10.734-0800|WARNING|sun-appserver2.1|jav ax.enterprise.s=
ystem.stream.err|_ThreadID=3D15;_ThreadName=3DhttpSSLWorkerT hread-8080-1;_R=
equestID=3Dc5cefdc4-4651-4c77-b9e6-84f9e0f6609e;|]
com.raec.cq.CQCommitException: You wanted to commit a modifyCR based record=
, but the record was
not found in the ClearQuest Database.


--- On Thu, 1/27/11, Parag Kalra <paragkalra [at] gmail.com> wrote:


From: Parag Kalra <paragkalra [at] gmail.com>
Subject: Re: Need help with Use of uninitialized value in concatenation (.)=
or string
To: "CM Analyst" <cmanalyst [at] yahoo.com>
Date: Thursday, January 27, 2011, 6:03 PM


Ok. Post sample from the log file to entire list. :)


Cheers,
Parag




On Thu, Jan 27, 2011 at 4:02 PM, CM Analyst <cmanalyst [at] yahoo.com> wrote:

Yes, changiing to $line does not make a difference.


On Thu Jan 27th, 2011 5:31 PM CST Parag Kalra wrote:

>No problem. :)
>
>But are you still facing the issue?
>
>Cheers,
>Parag
>
>
>
>On Thu, Jan 27, 2011 at 3:27 PM, CM Analyst <cmanalyst [at] yahoo.com> wrote:
>
>> Lack of experience :-(
>>
>> --- On *Thu, 1/27/11, Parag Kalra <paragkalra [at] gmail.com>* wrote:
>>
>>
>> From: Parag Kalra <paragkalra [at] gmail.com>
>> Subject: Re: Need help with Use of uninitialized value in concatenation =
(.)
>> or string
>> To: "CM Analyst" <cmanalyst [at] yahoo.com>
>> Cc: beginners [at] perl.org
>> Date: Thursday, January 27, 2011, 4:45 PM
>>
>>
>> =A0When you are already storing the line under $line
>> >>>while(( my $line =3D <FILEHANDLE>)) {
>>
>> Then why are you using $_
>> >>>my [at] fields =3D split '\|', $_;
>>
>> Cheers,
>>
Parag
>>
>>
>>
>> On Thu, Jan 27, 2011 at 12:57 PM, CM Analyst <cmanalyst [at] yahoo.com<http:/=
/us.mc380.mail.yahoo.com/mc/compose?to=3Dcmanalyst [at] yahoo.com >

>> > wrote:
>>
>> Hello,
>>
>> In the following script my goal is pull the date value each time an erro=
r
>> value (hardcoded) is found in the specified log file. The script retriev=
es
>> the error value without a problem but I cannot seem get the date value. =
Can
>> anyone tell me what I need to do?
>>
>> The error message when I run the script is:
>>
>> Use of uninitialized value in concatenation (.) or string at script.plli=
ne 32



>>
>> where line 32 is where I am calling this:
>>
>> "print $date";
>>
>> Here is the script:
>>
>> use warnings;
>> use strict;
>>
>> #Specify the path to the log file you want to read, for ex. application
>> log#
>>
>> open (FILEHANDLE, 'd:/scripts/server2.log') or print "Can't Open File!!!=
";
>>
>> while(( my $line =3D <FILEHANDLE>)) {
>>
>> #Searching for keywords from application log#
>>
>> if (($line =3D~ m/CQCommitException/i ) || ($line =3D~ m/Communication l=
ink
>> failure/i)) {
>>
>> my [at] fields =3D split '\|', $_;
>> my $date =A0 =A0 =A0 =3D $fields[1];
>>
>> print $date;
>>
>> #prints $line to file
>> open (my $outfile, ">>", "d:/scripts/loginfo.txt") or
die "Can't open
>> loginfo.txt: $!";
>>
>> print $outfile "$date, $_\n";
>>
>> #close $outfile or die "$outfile:$!";
>>
>> =A0 =A0}
>> }
>>
>> my $outfile =3D 'd:/scripts/loginfo.txt';
>>
>> #To send or not to send - file size check
>>
>> #Delete file when done
>> #unlink 'd:\scripts\loginfo.txt';
>>
>> -END-
>>
>>
>>
>>
>> --
>> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org<http://us.mc380.m=
ail.yahoo.com/mc/compose?to=3Dbeginners-unsubscribe [at] perl.org >
>> For additional commands, e-mail: beginners-help [at] perl.org<http://us.mc380=
..mail.yahoo.com/mc/compose?to=3Dbeginners-help [at] perl.org>
>> http://learn.perl.org/
>>
>>
>>
>>
>>





=0A=0A=0A

--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
CM Analyst [ Fr, 28 Januar 2011 01:24 ] [ ID #2054027 ]

RE: Need help with Use of uninitialized value in concatenation (.) or string

Ok

I took your code and your "log" file and did some testing on my linux =
box.

this small snippet of code seems to parse the lines (you actually want =
to grab) in a predictable manner.

tm


while(( my $line =3D <FILEHANDLE>)) {
# print "my line is: >$line<", "\n";

if ($line =3D~ /^\[/) {
print "this is a line i need to keep: \n\n";
print "$line\n\n";
my [at] fields =3D split '\|', $line;
my $date =3D $fields[1];
print "my date is: $date", "\n";
}
}


> -----Original Message-----
> From: CM Analyst [mailto:cmanalyst [at] yahoo.com]
> Sent: Thursday, January 27, 2011 6:25 PM
> To: Parag Kalra
> Cc: beginners [at] perl.org
> Subject: Re: Need help with Use of uninitialized value in =
concatenation
> (.) or string
>
> This is a sample of the data I am reading in:
>
> [#|2011-01-19T07:05:10.734-0800|WARNING|sun-
> =
appserver2.1|javax.enterprise.system.stream.err|_ThreadID=3D 15;_ThreadNam=
e=3Dh
> ttpSSLWorkerThread-8080-1;_RequestID=3Dc5cefdc4-4651-4c77-b9 e6-
> 84f9e0f6609e;|]
> com.raec.cq.CQCommitException: You wanted to commit a modifyCR based
> record, but the record was not found in the ClearQuest Database.
> [#|2011-01-19T07:05:10.734-0800|WARNING|sun-
> =
appserver2.1|javax.enterprise.system.stream.err|_ThreadID=3D 15;_ThreadNam=
e=3Dh
> ttpSSLWorkerThread-8080-1;_RequestID=3Dc5cefdc4-4651-4c77-b9 e6-
> 84f9e0f6609e;|]
> com.raec.cq.CQCommitException: You wanted to commit a modifyCR based
> record, but the record was not found in the ClearQuest Database.
> [#|2011-01-19T07:05:10.734-0800|WARNING|sun-
> =
appserver2.1|javax.enterprise.system.stream.err|_ThreadID=3D 15;_ThreadNam=
e=3Dh
> ttpSSLWorkerThread-8080-1;_RequestID=3Dc5cefdc4-4651-4c77-b9 e6-
> 84f9e0f6609e;|]
> com.raec.cq.CQCommitException: You wanted to commit a modifyCR based
> record, but the record was
> not found in the ClearQuest Database.
>
>
> --- On Thu, 1/27/11, Parag Kalra <paragkalra [at] gmail.com> wrote:
>
>
> From: Parag Kalra <paragkalra [at] gmail.com>
> Subject: Re: Need help with Use of uninitialized value in =
concatenation
> (.) or string
> To: "CM Analyst" <cmanalyst [at] yahoo.com>
> Date: Thursday, January 27, 2011, 6:03 PM
>
>
> Ok. Post sample from the log file to entire list. :)
>
>
> Cheers,
> Parag
>
>
>
>
> On Thu, Jan 27, 2011 at 4:02 PM, CM Analyst <cmanalyst [at] yahoo.com> =
wrote:
>
> Yes, changiing to $line does not make a difference.
>
>
> On Thu Jan 27th, 2011 5:31 PM CST Parag Kalra wrote:
>
> >No problem. :)
> >
> >But are you still facing the issue?
> >
> >Cheers,
> >Parag
> >
> >
> >
> >On Thu, Jan 27, 2011 at 3:27 PM, CM Analyst <cmanalyst [at] yahoo.com> =
wrote:
> >
> >> Lack of experience :-(
> >>
> >> --- On *Thu, 1/27/11, Parag Kalra <paragkalra [at] gmail.com>* wrote:
> >>
> >>
> >> From: Parag Kalra <paragkalra [at] gmail.com>
> >> Subject: Re: Need help with Use of uninitialized value in =
concatenation
> (.)
> >> or string
> >> To: "CM Analyst" <cmanalyst [at] yahoo.com>
> >> Cc: beginners [at] perl.org
> >> Date: Thursday, January 27, 2011, 4:45 PM
> >>
> >>
> >> =A0When you are already storing the line under $line
> >> >>>while(( my $line =3D <FILEHANDLE>)) {
> >>
> >> Then why are you using $_
> >> >>>my [at] fields =3D split '\|', $_;
> >>
> >> Cheers,
> >>
> Parag
> >>
> >>
> >>
> >> On Thu, Jan 27, 2011 at 12:57 PM, CM Analyst
> =
<cmanalyst [at] yahoo.com<http://us.mc380.mail.yahoo.com/mc/compose?to=3Dcmana=
lys
> t [at] yahoo.com>
>
> >> > wrote:
> >>
> >> Hello,
> >>
> >> In the following script my goal is pull the date value each time an
> error
> >> value (hardcoded) is found in the specified log file. The script
> retrieves
> >> the error value without a problem but I cannot seem get the date =
value.
> Can
> >> anyone tell me what I need to do?
> >>
> >> The error message when I run the script is:
> >>
> >> Use of uninitialized value in concatenation (.) or string at
> script.plline 32
>
>
>
> >>
> >> where line 32 is where I am calling this:
> >>
> >> "print $date";
> >>
> >> Here is the script:
> >>
> >> use warnings;
> >> use strict;
> >>
> >> #Specify the path to the log file you want to read, for ex. =
application
> >> log#
> >>
> >> open (FILEHANDLE, 'd:/scripts/server2.log') or print "Can't Open
> File!!!";
> >>
> >> while(( my $line =3D <FILEHANDLE>)) {
> >>
> >> #Searching for keywords from application log#
> >>
> >> if (($line =3D~ m/CQCommitException/i ) || ($line =3D~ =
m/Communication link
> >> failure/i)) {
> >>
> >> my [at] fields =3D split '\|', $_;
> >> my $date =A0 =A0 =A0 =3D $fields[1];
> >>
> >> print $date;
> >>
> >> #prints $line to file
> >> open (my $outfile, ">>", "d:/scripts/loginfo.txt") or
> die "Can't open
> >> loginfo.txt: $!";
> >>
> >> print $outfile "$date, $_\n";
> >>
> >> #close $outfile or die "$outfile:$!";
> >>
> >> =A0 =A0}
> >> }
> >>
> >> my $outfile =3D 'd:/scripts/loginfo.txt';
> >>
> >> #To send or not to send - file size check
> >>
> >> #Delete file when done
> >> #unlink 'd:\scripts\loginfo.txt';
> >>
> >> -END-
> >>
> >>
> >>
> >>
> >> --
> >> To unsubscribe, e-mail: beginners-
> =
unsubscribe [at] perl.org<http://us.mc380.mail.yahoo.com/mc/compose?to=3Dbegin=
ner
> s-unsubscribe [at] perl.org>
> >> For additional commands, e-mail: beginners-
> =
help [at] perl.org<http://us.mc380.mail.yahoo.com/mc/compose?to=3Dbeginners-
> help [at] perl.org>
> >> http://learn.perl.org/
> >>
> >>
> >>
> >>
> >>
>
>
>
>
>
>
>
>
>
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
> For additional commands, e-mail: beginners-help [at] perl.org
> http://learn.perl.org/
>


--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/
Mark Meyer [ Fr, 28 Januar 2011 02:00 ] [ ID #2054028 ]
Perl » gmane.comp.lang.perl.beginners » Need help with Use of uninitialized value in concatenation (.) or string

Vorheriges Thema: Regex
Nächstes Thema: Out of memory, HTML::TableExtract