57 users online (0 members and 57 guests)  


  Results 1 to 4 of 4
  1. #1
    Priya Agarwal's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2006
    Posts
    3

    cant call method "Value"

    while executing a perl file, i got an error saying--cant call method "Value" on an undefined value.
    what does this mean?
    pla reply

  2. #2
    DeadMeatGF's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    381

    Re: cant call method "Value"

    This is an error that people will need to see the code for.
    Please post the code that is causing the error, and don't forget to use the proper tags ...

  3. #3
    Priya Agarwal's Avatar
    New User

    Status
    Offline
    Join Date
    Jun 2006
    Posts
    3

    Re: cant call method "Value"

    Am jus pasting a part of the code here with the error line..
    Pls tell me wats wrong with this code


    my $status;
    my($iC, $oWkS);

    for(my $iC = 0;$iC <= $oWkS->{MaxCol} ; $iC++)
    {

    $oWkC9 = $oWkS->{Cells}[1][$iC];
    $status = $oWkC9->Value; (ERROR IN THIS LINE)
    print "$status\n";
    $_=$status;
    #print "$_\n";


    if(/F-record/){my $frecord = $iC;} #0
    if(/Brief Description/){my $briefdescription = $iC;} #4
    if(/prio/){my $priority = $iC;} #15
    if(/failure detected by/){my $failuredetected = $iC;} #22
    if(/Date Assign/){my $dateassign = $iC;} #35
    if(/Date Corrected/){my $datecorrected = $iC;} #38
    if(/Date Unverify/){my $dateunverify = $iC;} #41
    if(/Date Reopened/){my $datereopened = $iC;} #42
    if(/Status Action date/){my $statusactiondate = $iC;} #45
    }

  4. #4
    Michaels PerlSrv's Avatar
    New User

    Status
    Offline
    Join Date
    Jul 2006
    Location
    Europe
    Posts
    2

    Re: cant call method "Value"

    From: Michael (http://Perl-services.mprv.biz)

    Hi Priya,

    I wonder, what you are trying to do here. Is this your complete code or just a fraction?

    To your question.

    $oWkC9->Value is a function call in Perls approach to Object Oriented Programming (OOP). More explicitely you'd write $oWkC9->Value(). Perl assumes:

    * you have defined the object somewhere
    * you create a new instance calling the new() function.

    So something like this should appear in your code:

    Code:
    $oWkC9 = YOUROBJECT->new(); # creating a new instance
    which I do not see in your code. Within YOUROBJECT.pm you'd define a subroutine Value():

    Code:
    package YOUROBJECT;
    sub Value {
      # some operations
    }
    
    ..
    1;
    Value() has to be defined either in the package where you derive $oWkS or $oWkC9 from.

    A way to save variables permanently inside a Perl object is assigning it to an anonymous hash (during calling new()). When you intend Value to be just a value, you probably meant:

    Code:
    $oWkC9->{Value};
    Kind regards,
    Michael



Tags for this Thread