Loading ...
Sorry, an error occurred while loading the content.

RE: [PBML] Force initialise unitialised values ??

Expand Messages
  • Rai,Dharmender
    one safe way is to always initialize the scalars variables with 0 (numerical context) or empty string (string context) if none other value is their for them
    Message 1 of 3 , Jun 8, 2003
    • 0 Attachment
      one safe way is to always initialize the scalars variables with 0 (numerical
      context) or empty string (string context) if none other value is their for
      them for initialization.

      > ----------
      > From: Susan James[SMTP:susanjames@...]
      > Reply To: perl-beginner@yahoogroups.com
      > Sent: Friday, June 06, 2003 7:44 PM
      > To: perl-beginner@yahoogroups.com
      > Subject: [PBML] Force initialise unitialised values ??
      >
      > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in string
      > eq at C:\www\s\cgi-bin\spam\test.cgi line 84.
      > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in string
      > eq at C:\www\s\cgi-bin\spam\test.cgi line 87.
      > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
      > concatenation (.) or string at C:\www\s\cgi-bin\spam\test.cgi line 89.
      > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in pattern
      >
      > match (m//) at C:\www\s\cgi-bin\spam\test.cgi line 98.
      > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
      > concatenation (.) or string at C:\www\s\cgi-bin\spam\test.cgi line 103.
      > [Sat Jun 7 01:40:01 2003] test.cgi: flock() unimplemented on this
      > platform
      > at C:\www\s\cgi-bin\spam\test.cgi line 118.
      > Content-type: text/html
      >
      > Hi there - is there a perl de-bug command that you can put on the top of
      > the script - eg :-
      > #!/usr/bin/perl -w
      >
      >
      > I've put "my $value" (etc) for all the 'unitialised values' - near the top
      >
      > of the script but it still says theyre unitialised...
      >
      > is there a bomb-proof, child-proof, spam-proof, anything-proof way of
      > initialising values & making scripts "go" ??
      >
      > Ive got an off-line server - The script works perfectly fine (except the
      > above warnings) - but I can easily turn off the warnings etc..
      > - However on the main website - It refuses to go - with or without
      > warnings
      > / strict etc.. :-(
      >
      > HEALP
      >
      > S
      >
      >
      >
      > [Non-text portions of this message have been removed]
      >
      >
      >
      > Unsubscribing info is here:
      > http://help.yahoo.com/help/us/groups/groups-32.html
      >
      > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
      >
      >
      >
      ____________________________________________
      Confidential: This electronic message and all contents contain information
      from Syntel, Inc. which may be privileged, confidential or otherwise
      protected from disclosure. The information is intended to be for the
      addressee only. If you are not the addressee, any disclosure, copy,
      distribution or use of the contents of this message is prohibited. If you
      have received this electronic message in error, please notify the sender
      immediately and destroy the original message and all copies.
    • greg.hering@bench.com
      Dear Susan, Did you ever get what you needed on this? I think perl will silently initialize variables when you declare them. The complaint you get is from
      Message 2 of 3 , Jun 27, 2003
      • 0 Attachment
        Dear Susan,

        Did you ever get what you needed on this?

        I think perl will silently initialize variables when you declare them.
        The complaint you get is from trying to USE something that is not defined.

        Check this out.

        #! /usr/local/bin/perl -w

        use strict;

        my $size;
        printf "size = %s\t", defined $size ? $size : "?";


        If there is no value in $size you get 'size = ?' and no compilation errors.
        The '? :' is called a ternary operator and has the same function as an
        'if then else' construct.

        You can also use it IN an if statement

        if (!defined($dirname . "/" . $file)) {
        printf "file for which mode not defined = %s\n", $file;
        }
        elsif ( $mode & 0x4000 ) {
        &find( $dirname . "/" . $file );
        }

        Your error says 'undefined in string eq'. You probably have some code like

        my $string_thing;
        if ( "bob" = $string_thing )

        Where what you REALLY need to say

        if ( defined( $string_thing ) ) {
        stuff on string_thing...
        } else {
        print "no string_thing defined to work on";
        }

        Hope this helps

        Gregory L. Hering
        (256) 722-6420
        4807 Bradford Dr
        Benchmark Electronics, Inc.
        Huntsville, Al 35805

        > From:       Susan James[SMTP:susanjames@...]
        > Reply To:       perl-beginner@yahoogroups.com
        > Sent:       Friday, June 06, 2003 7:44 PM
        > To:       perl-beginner@yahoogroups.com
        > Subject:       [PBML] Force initialise unitialised values ??
        >
        > [Sat Jun  7 01:40:01 2003] test.cgi: Use of uninitialized value in string
        > eq at C:\www\s\cgi-bin\spam\test.cgi line 84.
        > [Sat Jun  7 01:40:01 2003] test.cgi: Use of uninitialized value in string
        > eq at C:\www\s\cgi-bin\spam\test.cgi line 87.
        > [Sat Jun  7 01:40:01 2003] test.cgi: Use of uninitialized value in
        > concatenation (.) or string at C:\www\s\cgi-bin\spam\test.cgi line 89.
        > [Sat Jun  7 01:40:01 2003] test.cgi: Use of uninitialized value in pattern
        >
        > match (m//) at C:\www\s\cgi-bin\spam\test.cgi line 98.
        > [Sat Jun  7 01:40:01 2003] test.cgi: Use of uninitialized value in
        > concatenation (.) or string at C:\www\s\cgi-bin\spam\test.cgi line 103.
        > [Sat Jun  7 01:40:01 2003] test.cgi: flock() unimplemented on this
        > platform
        > at C:\www\s\cgi-bin\spam\test.cgi line 118.
        > Content-type: text/html
        >
        > Hi there - is there a perl de-bug command that you can put on the top of
        > the script - eg :-
        > #!/usr/bin/perl -w
        >
        >
        > I've put "my $value" (etc) for all the 'unitialised values' - near the top
        >
        > of the script but it still says theyre unitialised...
        >
        > is there a bomb-proof, child-proof, spam-proof, anything-proof way of
        > initialising values & making scripts "go" ??
        >
        > Ive got an off-line server - The script works perfectly fine (except the
        > above warnings) - but I can easily turn off the warnings etc..
        > - However on the main website - It refuses to go - with or without
        > warnings
        > / strict etc..  :-(
        >
        > HEALP
        >
        > S
      • Rai,Dharmender
        the warning is generated as you are using -w. ... ____________________________________________ Confidential: This electronic message and all contents contain
        Message 3 of 3 , Jun 29, 2003
        • 0 Attachment
          the warning is generated as you are using -w.

          > ----------
          > From: greg.hering@...[SMTP:greg.hering@...]
          > Reply To: perl-beginner@yahoogroups.com
          > Sent: Saturday, June 28, 2003 12:03 AM
          > To: perl-beginner@yahoogroups.com
          > Subject: RE: [PBML] Force initialise unitialised values ??
          >
          > Dear Susan,
          >
          > Did you ever get what you needed on this?
          >
          > I think perl will silently initialize variables when you declare them.
          > The complaint you get is from trying to USE something that is not defined.
          >
          > Check this out.
          >
          > #! /usr/local/bin/perl -w
          >
          > use strict;
          >
          > my $size;
          > printf "size = %s\t", defined $size ? $size : "?";
          >
          >
          > If there is no value in $size you get 'size = ?' and no compilation
          > errors.
          > The '? :' is called a ternary operator and has the same function as an
          > 'if then else' construct.
          >
          > You can also use it IN an if statement
          >
          > if (!defined($dirname . "/" . $file)) {
          > printf "file for which mode not defined = %s\n", $file;
          > }
          > elsif ( $mode & 0x4000 ) {
          > &find( $dirname . "/" . $file );
          > }
          >
          > Your error says 'undefined in string eq'. You probably have some code
          > like
          >
          > my $string_thing;
          > if ( "bob" = $string_thing )
          >
          > Where what you REALLY need to say
          >
          > if ( defined( $string_thing ) ) {
          > stuff on string_thing...
          > } else {
          > print "no string_thing defined to work on";
          > }
          >
          > Hope this helps
          >
          > Gregory L. Hering
          > (256) 722-6420
          > 4807 Bradford Dr
          > Benchmark Electronics, Inc.
          > Huntsville, Al 35805
          >
          > > From: Susan James[SMTP:susanjames@...]
          > > Reply To: perl-beginner@yahoogroups.com
          > > Sent: Friday, June 06, 2003 7:44 PM
          > > To: perl-beginner@yahoogroups.com
          > > Subject: [PBML] Force initialise unitialised values ??
          > >
          > > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
          > string
          > > eq at C:\www\s\cgi-bin\spam\test.cgi line 84.
          > > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
          > string
          > > eq at C:\www\s\cgi-bin\spam\test.cgi line 87.
          > > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
          > > concatenation (.) or string at C:\www\s\cgi-bin\spam\test.cgi line 89.
          > > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
          > pattern
          > >
          > > match (m//) at C:\www\s\cgi-bin\spam\test.cgi line 98.
          > > [Sat Jun 7 01:40:01 2003] test.cgi: Use of uninitialized value in
          > > concatenation (.) or string at C:\www\s\cgi-bin\spam\test.cgi line 103.
          > > [Sat Jun 7 01:40:01 2003] test.cgi: flock() unimplemented on this
          > > platform
          > > at C:\www\s\cgi-bin\spam\test.cgi line 118.
          > > Content-type: text/html
          > >
          > > Hi there - is there a perl de-bug command that you can put on the top of
          >
          > > the script - eg :-
          > > #!/usr/bin/perl -w
          > >
          > >
          > > I've put "my $value" (etc) for all the 'unitialised values' - near the
          > top
          > >
          > > of the script but it still says theyre unitialised...
          > >
          > > is there a bomb-proof, child-proof, spam-proof, anything-proof way of
          > > initialising values & making scripts "go" ??
          > >
          > > Ive got an off-line server - The script works perfectly fine (except the
          >
          > > above warnings) - but I can easily turn off the warnings etc..
          > > - However on the main website - It refuses to go - with or without
          > > warnings
          > > / strict etc.. :-(
          > >
          > > HEALP
          > >
          > > S
          >
          >
          >
          > Unsubscribing info is here:
          > http://help.yahoo.com/help/us/groups/groups-32.html
          >
          > Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
          >
          >
          >
          ____________________________________________
          Confidential: This electronic message and all contents contain information
          from Syntel, Inc. which may be privileged, confidential or otherwise
          protected from disclosure. The information is intended to be for the
          addressee only. If you are not the addressee, any disclosure, copy,
          distribution or use of the contents of this message is prohibited. If you
          have received this electronic message in error, please notify the sender
          immediately and destroy the original message and all copies.
        Your message has been successfully submitted and would be delivered to recipients shortly.