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

RE: [PBML] why use Strict?

Expand Messages
  • Adrian Stovall
    The main reasons to use strict are : 1: Make the best use of memory (variables go out of scope when not used) 2: More easily identify things that you ve left
    Message 1 of 9 , Dec 31, 2001
      The main reasons to use strict are :

      1: Make the best use of memory (variables go out of scope when not used)
      2: More easily identify things that you've left "undone" (undefined
      variables, etc)

      use warnings and use strict help to ensure that the code you write is
      somewhat standardized and that you'll be able to spot your own programming
      snafu's more easily.

      Your scripts may easily work fine without it (all of my early ones do), but
      that doesn't help when you're troubleshooting a big hunk of code that
      *doesn't* work fine.

      Using strict and getting in the habit of paing attention to variable
      declarations and scope can make it *much* easier to find problems that would
      be almost invisible if you don't use strict.

      If you're not working on anything huge, or if you enjoy looking through 1000
      lines of code to find out why you're getting "undefined variable" errors,
      don't sweat it. Otherwise, get in the practice of using strict (and
      warnings), they're serious time-savers in the long run.


      >-----Original Message-----
      >From: raezorblaedz [mailto:raezorblaedz@...]
      >Sent: Monday, December 31, 2001 3:34 PM
      >To: perl-beginner@yahoogroups.com
      >Subject: [PBML] why use Strict?
      >
      >
      >All,
      >
      > I keep hearing use::strict. Why? All of my scripts work perfectly
      >without it. What bene's are there to using this? (h-link to a
      >reference page?)
      >
      >...and as much as I hate to say this, but please inform me of the
      >downfalls of using strict.
      >
      >thanks,
      >John
      >
      >
      >------------------------ Yahoo! Groups Sponsor
      >---------------------~-->
      >Tiny Wireless Camera under $80!
      >Order Now! FREE VCR Commander!
      >Click Here - Only 1 Day Left!
      >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
      >---------------------------------------------------------------
      >------~->
      >
      >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/
      >
      >
    • raezorblaedz
      Adrian, I do appreciate your input/knowledge. I ll use strict on my current project and check to see what the difference is. I do not get undefined variables,
      Message 2 of 9 , Dec 31, 2001
        Adrian,

        I do appreciate your input/knowledge. I'll use strict on my
        current project and check to see what the difference is. I do not get
        undefined variables, I get invalid headers all of the time. Will
        strict help?

        The syntax is:
        #!/Perl location..blah blah blah
        use::strict

        right?
        ________________________________


        --- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
        > The main reasons to use strict are :
        >
        > 1: Make the best use of memory (variables go out of scope when not
        used)
        > 2: More easily identify things that you've left "undone" (undefined
        > variables, etc)
        >
        > use warnings and use strict help to ensure that the code you write
        is
        > somewhat standardized and that you'll be able to spot your own
        programming
        > snafu's more easily.
        >
        > Your scripts may easily work fine without it (all of my early ones
        do), but
        > that doesn't help when you're troubleshooting a big hunk of code
        that
        > *doesn't* work fine.
        >
        > Using strict and getting in the habit of paing attention to variable
        > declarations and scope can make it *much* easier to find problems
        that would
        > be almost invisible if you don't use strict.
        >
        > If you're not working on anything huge, or if you enjoy looking
        through 1000
        > lines of code to find out why you're getting "undefined variable"
        errors,
        > don't sweat it. Otherwise, get in the practice of using strict (and
        > warnings), they're serious time-savers in the long run.
        >
        >
        > >-----Original Message-----
        > >From: raezorblaedz [mailto:raezorblaedz@y...]
        > >Sent: Monday, December 31, 2001 3:34 PM
        > >To: perl-beginner@y...
        > >Subject: [PBML] why use Strict?
        > >
        > >
        > >All,
        > >
        > > I keep hearing use::strict. Why? All of my scripts work perfectly
        > >without it. What bene's are there to using this? (h-link to a
        > >reference page?)
        > >
        > >...and as much as I hate to say this, but please inform me of the
        > >downfalls of using strict.
        > >
        > >thanks,
        > >John
        > >
        > >
        > >------------------------ Yahoo! Groups Sponsor
        > >---------------------~-->
        > >Tiny Wireless Camera under $80!
        > >Order Now! FREE VCR Commander!
        > >Click Here - Only 1 Day Left!
        > >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
        > >---------------------------------------------------------------
        > >------~->
        > >
        > >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/
        > >
        > >
      • Adrian Stovall
        almost... #!perl -w (etc...) use strict;
        Message 3 of 9 , Dec 31, 2001
          almost...

          #!perl -w (etc...)
          use strict;


          >-----Original Message-----
          >From: raezorblaedz [mailto:raezorblaedz@...]
          >Sent: Monday, December 31, 2001 4:31 PM
          >To: perl-beginner@yahoogroups.com
          >Subject: Re: [PBML] why use Strict?
          >
          >
          >Adrian,
          >
          > I do appreciate your input/knowledge. I'll use strict on my
          >current project and check to see what the difference is. I do not get
          >undefined variables, I get invalid headers all of the time. Will
          >strict help?
          >
          >The syntax is:
          >#!/Perl location..blah blah blah
          >use::strict
          >
          >right?
          >________________________________
          >
          >
          >--- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
          >> The main reasons to use strict are :
          >>
          >> 1: Make the best use of memory (variables go out of scope when not
          >used)
          >> 2: More easily identify things that you've left "undone" (undefined
          >> variables, etc)
          >>
          >> use warnings and use strict help to ensure that the code you write
          >is
          >> somewhat standardized and that you'll be able to spot your own
          >programming
          >> snafu's more easily.
          >>
          >> Your scripts may easily work fine without it (all of my early ones
          >do), but
          >> that doesn't help when you're troubleshooting a big hunk of code
          >that
          >> *doesn't* work fine.
          >>
          >> Using strict and getting in the habit of paing attention to variable
          >> declarations and scope can make it *much* easier to find problems
          >that would
          >> be almost invisible if you don't use strict.
          >>
          >> If you're not working on anything huge, or if you enjoy looking
          >through 1000
          >> lines of code to find out why you're getting "undefined variable"
          >errors,
          >> don't sweat it. Otherwise, get in the practice of using strict (and
          >> warnings), they're serious time-savers in the long run.
          >>
          >>
          >> >-----Original Message-----
          >> >From: raezorblaedz [mailto:raezorblaedz@y...]
          >> >Sent: Monday, December 31, 2001 3:34 PM
          >> >To: perl-beginner@y...
          >> >Subject: [PBML] why use Strict?
          >> >
          >> >
          >> >All,
          >> >
          >> > I keep hearing use::strict. Why? All of my scripts work perfectly
          >> >without it. What bene's are there to using this? (h-link to a
          >> >reference page?)
          >> >
          >> >...and as much as I hate to say this, but please inform me of the
          >> >downfalls of using strict.
          >> >
          >> >thanks,
          >> >John
          >> >
          >> >
          >> >------------------------ Yahoo! Groups Sponsor
          >> >---------------------~-->
          >> >Tiny Wireless Camera under $80!
          >> >Order Now! FREE VCR Commander!
          >> >Click Here - Only 1 Day Left!
          >> >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
          >> >---------------------------------------------------------------
          >> >------~->
          >> >
          >> >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/
          >> >
          >> >
          >
          >
          >------------------------ Yahoo! Groups Sponsor
          >---------------------~-->
          >Tiny Wireless Camera under $80!
          >Order Now! FREE VCR Commander!
          >Click Here - Only 1 Day Left!
          >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
          >---------------------------------------------------------------
          >------~->
          >
          >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/
          >
          >
        • raezorblaedz
          Adrian, I have turned on strict, now I am getting compilation errors. I assume that is exactly what I should see. Now, what do I do to resolve the requires
          Message 4 of 9 , Jan 2, 2002
            Adrian,

            I have turned on strict, now I am getting compilation errors. I
            assume that is exactly what I should see.
            Now, what do I do to resolve the "requires explicit package name
            at new.pl" message?
            What is this missing package Perl speaks of?

            Global symbol "$MyOutFile" requires explicit package name at new.pl
            line 12.
            Global symbol "$sth" requires explicit package name at new.pl line 41.
            Global symbol "$ref" requires explicit package name at new.pl line 44.
            Global symbol "$buf" requires explicit package name at new.pl line
            131.
            Variable "@fval" is not imported at new.pl line 140.
            Global symbol "$i" requires explicit package name at new.pl line 141.
            Global symbol "$name" requires explicit package name at new.pl line
            142.
            Global symbol "$val" requires explicit package name at new.pl line
            142.
            new.pl had compilation errors.

            -maybe I'm just still hung over.
            John
            _________________________________________
            --- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
            > almost...
            >
            > #!perl -w (etc...)
            > use strict;
            >
            >
            > >-----Original Message-----
            > >From: raezorblaedz [mailto:raezorblaedz@y...]
            > >Sent: Monday, December 31, 2001 4:31 PM
            > >To: perl-beginner@y...
            > >Subject: Re: [PBML] why use Strict?
            > >
            > >
            > >Adrian,
            > >
            > > I do appreciate your input/knowledge. I'll use strict on my
            > >current project and check to see what the difference is. I do not
            get
            > >undefined variables, I get invalid headers all of the time. Will
            > >strict help?
            > >
            > >The syntax is:
            > >#!/Perl location..blah blah blah
            > >use::strict
            > >
            > >right?
            > >________________________________
            > >
            > >
            > >--- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
            > >> The main reasons to use strict are :
            > >>
            > >> 1: Make the best use of memory (variables go out of scope when
            not
            > >used)
            > >> 2: More easily identify things that you've left "undone"
            (undefined
            > >> variables, etc)
            > >>
            > >> use warnings and use strict help to ensure that the code you
            write
            > >is
            > >> somewhat standardized and that you'll be able to spot your own
            > >programming
            > >> snafu's more easily.
            > >>
            > >> Your scripts may easily work fine without it (all of my early
            ones
            > >do), but
            > >> that doesn't help when you're troubleshooting a big hunk of code
            > >that
            > >> *doesn't* work fine.
            > >>
            > >> Using strict and getting in the habit of paing attention to
            variable
            > >> declarations and scope can make it *much* easier to find
            problems
            > >that would
            > >> be almost invisible if you don't use strict.
            > >>
            > >> If you're not working on anything huge, or if you enjoy looking
            > >through 1000
            > >> lines of code to find out why you're getting "undefined
            variable"
            > >errors,
            > >> don't sweat it. Otherwise, get in the practice of using strict
            (and
            > >> warnings), they're serious time-savers in the long run.
            > >>
            > >>
            > >> >-----Original Message-----
            > >> >From: raezorblaedz [mailto:raezorblaedz@y...]
            > >> >Sent: Monday, December 31, 2001 3:34 PM
            > >> >To: perl-beginner@y...
            > >> >Subject: [PBML] why use Strict?
            > >> >
            > >> >
            > >> >All,
            > >> >
            > >> > I keep hearing use::strict. Why? All of my scripts work
            perfectly
            > >> >without it. What bene's are there to using this? (h-link to a
            > >> >reference page?)
            > >> >
            > >> >...and as much as I hate to say this, but please inform me of
            the
            > >> >downfalls of using strict.
            > >> >
            > >> >thanks,
            > >> >John
            > >> >
            > >> >
            > >> >------------------------ Yahoo! Groups Sponsor
            > >> >---------------------~-->
            > >> >Tiny Wireless Camera under $80!
            > >> >Order Now! FREE VCR Commander!
            > >> >Click Here - Only 1 Day Left!
            > >> >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
            > >> >---------------------------------------------------------------
            > >> >------~->
            > >> >
            > >> >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/
            > >> >
            > >> >
            > >
            > >
            > >------------------------ Yahoo! Groups Sponsor
            > >---------------------~-->
            > >Tiny Wireless Camera under $80!
            > >Order Now! FREE VCR Commander!
            > >Click Here - Only 1 Day Left!
            > >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
            > >---------------------------------------------------------------
            > >------~->
            > >
            > >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/
            > >
            > >
          • Greg Webster
            This just mean you need to declare the variable names [using my ($variable1, $variable2); would be easiest here for you.]. It s a way for use strict to make
            Message 5 of 9 , Jan 2, 2002
              This just mean you need to declare the variable names [using "my
              ($variable1, $variable2);" would be easiest here for you.]. It's a way for
              use strict to make sure that you are keeping track of things nicely and
              saving a bit of memory.

              Greg


              On Wed, 02 Jan 2002 14:12:51 -0000
              "raezorblaedz" <raezorblaedz@...> wrote:
              > Adrian,
              >
              > I have turned on strict, now I am getting compilation errors. I
              > assume that is exactly what I should see.
              > Now, what do I do to resolve the "requires explicit package name
              > at new.pl" message?
              > What is this missing package Perl speaks of?
              >
              > Global symbol "$MyOutFile" requires explicit package name at new.pl
              > line 12.
              > Global symbol "$sth" requires explicit package name at new.pl line 41.
              > Global symbol "$ref" requires explicit package name at new.pl line 44.
              > Global symbol "$buf" requires explicit package name at new.pl line
              > 131.
              > Variable "@fval" is not imported at new.pl line 140.
              > Global symbol "$i" requires explicit package name at new.pl line 141.
              > Global symbol "$name" requires explicit package name at new.pl line
              > 142.
              > Global symbol "$val" requires explicit package name at new.pl line
              > 142.
              > new.pl had compilation errors.
              >
              > -maybe I'm just still hung over.
              > John
              > _________________________________________
              > --- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
              > > almost...
              > >
              > > #!perl -w (etc...)
              > > use strict;
              > >
              > >
              > > >-----Original Message-----
              > > >From: raezorblaedz [mailto:raezorblaedz@y...]
              > > >Sent: Monday, December 31, 2001 4:31 PM
              > > >To: perl-beginner@y...
              > > >Subject: Re: [PBML] why use Strict?
              > > >
              > > >
              > > >Adrian,
              > > >
              > > > I do appreciate your input/knowledge. I'll use strict on my
              > > >current project and check to see what the difference is. I do not
              > get
              > > >undefined variables, I get invalid headers all of the time. Will
              > > >strict help?
              > > >
              > > >The syntax is:
              > > >#!/Perl location..blah blah blah
              > > >use::strict
              > > >
              > > >right?
              > > >________________________________
              > > >
              > > >
              > > >--- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
              > > >> The main reasons to use strict are :
              > > >>
              > > >> 1: Make the best use of memory (variables go out of scope when
              > not
              > > >used)
              > > >> 2: More easily identify things that you've left "undone"
              > (undefined
              > > >> variables, etc)
              > > >>
              > > >> use warnings and use strict help to ensure that the code you
              > write
              > > >is
              > > >> somewhat standardized and that you'll be able to spot your own
              > > >programming
              > > >> snafu's more easily.
              > > >>
              > > >> Your scripts may easily work fine without it (all of my early
              > ones
              > > >do), but
              > > >> that doesn't help when you're troubleshooting a big hunk of code
              > > >that
              > > >> *doesn't* work fine.
              > > >>
              > > >> Using strict and getting in the habit of paing attention to
              > variable
              > > >> declarations and scope can make it *much* easier to find
              > problems
              > > >that would
              > > >> be almost invisible if you don't use strict.
              > > >>
              > > >> If you're not working on anything huge, or if you enjoy looking
              > > >through 1000
              > > >> lines of code to find out why you're getting "undefined
              > variable"
              > > >errors,
              > > >> don't sweat it. Otherwise, get in the practice of using strict
              > (and
              > > >> warnings), they're serious time-savers in the long run.
              > > >>
              > > >>
              > > >> >-----Original Message-----
              > > >> >From: raezorblaedz [mailto:raezorblaedz@y...]
              > > >> >Sent: Monday, December 31, 2001 3:34 PM
              > > >> >To: perl-beginner@y...
              > > >> >Subject: [PBML] why use Strict?
              > > >> >
              > > >> >
              > > >> >All,
              > > >> >
              > > >> > I keep hearing use::strict. Why? All of my scripts work
              > perfectly
              > > >> >without it. What bene's are there to using this? (h-link to a
              > > >> >reference page?)
              > > >> >
              > > >> >...and as much as I hate to say this, but please inform me of
              > the
              > > >> >downfalls of using strict.
              > > >> >
              > > >> >thanks,
              > > >> >John
              > > >> >
              > > >> >
              > > >> >------------------------ Yahoo! Groups Sponsor
              > > >> >---------------------~-->
              > > >> >Tiny Wireless Camera under $80!
              > > >> >Order Now! FREE VCR Commander!
              > > >> >Click Here - Only 1 Day Left!
              > > >> >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
              > > >> >---------------------------------------------------------------
              > > >> >------~->
              > > >> >
              > > >> >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/
              > > >> >
              > > >> >
              > > >
              > > >
              > > >------------------------ Yahoo! Groups Sponsor
              > > >---------------------~-->
              > > >Tiny Wireless Camera under $80!
              > > >Order Now! FREE VCR Commander!
              > > >Click Here - Only 1 Day Left!
              > > >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
              > > >---------------------------------------------------------------
              > > >------~->
              > > >
              > > >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/
              > > >
              > > >
              >
              >
              >
              > 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/
              >
              >
            • raezorblaedz
              Sorry to sound so ignorant, but what I believe you just said was the following: I declared: $MyOutFile = /tmp/harvey@wallbanger.com.search.html ; but using
              Message 6 of 9 , Jan 2, 2002
                Sorry to sound so ignorant, but what I believe you just said was the
                following:

                I declared:

                $MyOutFile = "/tmp/harvey@...";

                but using strict, I should delclare the following:

                my ($MyOutFile = "/tmp/harvey@...");

                right?


                --- In perl-beginner@y..., Greg Webster <greg@g...> wrote:
                >
                > This just mean you need to declare the variable names [using "my
                > ($variable1, $variable2);" would be easiest here for you.]. It's a
                way for
                > use strict to make sure that you are keeping track of things nicely
                and
                > saving a bit of memory.
                >
                > Greg
                >
                >
                > On Wed, 02 Jan 2002 14:12:51 -0000
                > "raezorblaedz" <raezorblaedz@y...> wrote:
                > > Adrian,
                > >
                > > I have turned on strict, now I am getting compilation errors.
                I
                > > assume that is exactly what I should see.
                > > Now, what do I do to resolve the "requires explicit package
                name
                > > at new.pl" message?
                > > What is this missing package Perl speaks of?
                > >
                > > Global symbol "$MyOutFile" requires explicit package name at
                new.pl
                > > line 12.
                > > Global symbol "$sth" requires explicit package name at new.pl
                line 41.
                > > Global symbol "$ref" requires explicit package name at new.pl
                line 44.
                > > Global symbol "$buf" requires explicit package name at new.pl
                line
                > > 131.
                > > Variable "@fval" is not imported at new.pl line 140.
                > > Global symbol "$i" requires explicit package name at new.pl line
                141.
                > > Global symbol "$name" requires explicit package name at new.pl
                line
                > > 142.
                > > Global symbol "$val" requires explicit package name at new.pl
                line
                > > 142.
                > > new.pl had compilation errors.
                > >
                > > -maybe I'm just still hung over.
                > > John
                > > _________________________________________
                > > --- In perl-beginner@y..., Adrian Stovall <AdrianS@p...> wrote:
                > > > almost...
                > > >
                > > > #!perl -w (etc...)
                > > > use strict;
                > > >
                > > >
                > > > >-----Original Message-----
                > > > >From: raezorblaedz [mailto:raezorblaedz@y...]
                > > > >Sent: Monday, December 31, 2001 4:31 PM
                > > > >To: perl-beginner@y...
                > > > >Subject: Re: [PBML] why use Strict?
                > > > >
                > > > >
                > > > >Adrian,
                > > > >
                > > > > I do appreciate your input/knowledge. I'll use strict on my
                > > > >current project and check to see what the difference is. I do
                not
                > > get
                > > > >undefined variables, I get invalid headers all of the time.
                Will
                > > > >strict help?
                > > > >
                > > > >The syntax is:
                > > > >#!/Perl location..blah blah blah
                > > > >use::strict
                > > > >
                > > > >right?
                > > > >________________________________
                > > > >
                > > > >
                > > > >--- In perl-beginner@y..., Adrian Stovall <AdrianS@p...>
                wrote:
                > > > >> The main reasons to use strict are :
                > > > >>
                > > > >> 1: Make the best use of memory (variables go out of scope
                when
                > > not
                > > > >used)
                > > > >> 2: More easily identify things that you've left "undone"
                > > (undefined
                > > > >> variables, etc)
                > > > >>
                > > > >> use warnings and use strict help to ensure that the code you
                > > write
                > > > >is
                > > > >> somewhat standardized and that you'll be able to spot your
                own
                > > > >programming
                > > > >> snafu's more easily.
                > > > >>
                > > > >> Your scripts may easily work fine without it (all of my
                early
                > > ones
                > > > >do), but
                > > > >> that doesn't help when you're troubleshooting a big hunk of
                code
                > > > >that
                > > > >> *doesn't* work fine.
                > > > >>
                > > > >> Using strict and getting in the habit of paing attention to
                > > variable
                > > > >> declarations and scope can make it *much* easier to find
                > > problems
                > > > >that would
                > > > >> be almost invisible if you don't use strict.
                > > > >>
                > > > >> If you're not working on anything huge, or if you enjoy
                looking
                > > > >through 1000
                > > > >> lines of code to find out why you're getting "undefined
                > > variable"
                > > > >errors,
                > > > >> don't sweat it. Otherwise, get in the practice of using
                strict
                > > (and
                > > > >> warnings), they're serious time-savers in the long run.
                > > > >>
                > > > >>
                > > > >> >-----Original Message-----
                > > > >> >From: raezorblaedz [mailto:raezorblaedz@y...]
                > > > >> >Sent: Monday, December 31, 2001 3:34 PM
                > > > >> >To: perl-beginner@y...
                > > > >> >Subject: [PBML] why use Strict?
                > > > >> >
                > > > >> >
                > > > >> >All,
                > > > >> >
                > > > >> > I keep hearing use::strict. Why? All of my scripts work
                > > perfectly
                > > > >> >without it. What bene's are there to using this? (h-link to
                a
                > > > >> >reference page?)
                > > > >> >
                > > > >> >...and as much as I hate to say this, but please inform me
                of
                > > the
                > > > >> >downfalls of using strict.
                > > > >> >
                > > > >> >thanks,
                > > > >> >John
                > > > >> >
                > > > >> >
                > > > >> >------------------------ Yahoo! Groups Sponsor
                > > > >> >---------------------~-->
                > > > >> >Tiny Wireless Camera under $80!
                > > > >> >Order Now! FREE VCR Commander!
                > > > >> >Click Here - Only 1 Day Left!
                > > > >> >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
                > > > >> >------------------------------------------------------------
                ---
                > > > >> >------~->
                > > > >> >
                > > > >> >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/
                > > > >> >
                > > > >> >
                > > > >
                > > > >
                > > > >------------------------ Yahoo! Groups Sponsor
                > > > >---------------------~-->
                > > > >Tiny Wireless Camera under $80!
                > > > >Order Now! FREE VCR Commander!
                > > > >Click Here - Only 1 Day Left!
                > > > >http://us.click.yahoo.com/WoOlbB/7.PDAA/ySSFAA/ndFolB/TM
                > > > >---------------------------------------------------------------
                > > > >------~->
                > > > >
                > > > >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/
                > > > >
                > > > >
                > >
                > >
                > >
                > > 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/
                > >
                > >
              • Greg Webster
                ... No worries, we all have to learn in this world. Plus, this wouldn t be called the Perl-Beginners Mailing List if we weren t able to answer questions. :)
                Message 7 of 9 , Jan 2, 2002
                  On Wed, 2 Jan 2002, raezorblaedz wrote:
                  > Sorry to sound so ignorant, but what I believe you just said was the
                  > following:

                  No worries, we all have to learn in this world. Plus, this wouldn't be
                  called the Perl-Beginners Mailing List if we weren't able to answer
                  questions. :)

                  > I declared:
                  >
                  > $MyOutFile = "/tmp/harvey@...";
                  >
                  > but using strict, I should delclare the following:
                  >
                  > my ($MyOutFile = "/tmp/harvey@...");
                  >
                  > right?

                  In the case of a single variable declaration like this you don't need the
                  brackets.

                  ie.
                  my $variable = "some data";

                  Remember, you only need to use 'my' once for each variable.

                  What you can do to get by a lot of this, especially in converting a
                  already-written script to use strict, is have a variable declaration
                  section at the top of your script. For example:

                  my ($variable1, $var2, @foo, @bar, $var3);

                  ....
                  further down in the script...
                  ....

                  $var2 = "some text";

                  I can use all the things I declared in the 'my' at the top of the script
                  throughout the script without re-declaring them. This is the simplest
                  example of using 'my'.

                  Where the real power comes in though is in what is called "scope". Meaning
                  that you can delcare a variable only for a specific use. Take this
                  example:

                  use strict;

                  my ($var1, $var2);

                  $var1 = "text for variable 1";

                  sub this_subroutine {
                  my $var3 = "text for variable 3";
                  $var2 = "text for variable 2";
                  print "$var1\n";
                  print "$var2\n";
                  print "$var3\n";
                  }

                  &this_subroutine;

                  $var1 and $var2 are declared 'globally' (meaning they are
                  accessible anywhere in the script). $var3 is declared locally in a
                  subroutine, and so is only accessible inside that subroutine. Once the
                  subroutine is over, $var3 disappears from memory. If I tried to put '$var3
                  = "some new text for variable 3";' outside the subroutine without
                  declaring it globally I'd get errors. This prevents from from making
                  mistakes about how I am using the variables in my script.

                  Understand?

                  GregW
                • raezorblaedz
                  Wow. That makes perfect sense. Why don t you revise some of the crappy (I m a hardcore coder) documentation, and write books for O Reilly. Even their Beginning
                  Message 8 of 9 , Jan 2, 2002
                    Wow. That makes perfect sense. Why don't you revise some of the
                    crappy (I'm a hardcore coder) documentation, and write books for
                    O'Reilly. Even their Beginning Perl book doesn't state things that
                    clearly.
                    thank you,
                    John

                    --- In perl-beginner@y..., Greg Webster <greg@g...> wrote:
                    > On Wed, 2 Jan 2002, raezorblaedz wrote:
                    > > Sorry to sound so ignorant, but what I believe you just said was
                    the
                    > > following:
                    >
                    > No worries, we all have to learn in this world. Plus, this wouldn't
                    be
                    > called the Perl-Beginners Mailing List if we weren't able to answer
                    > questions. :)
                    >
                    > > I declared:
                    > >
                    > > $MyOutFile = "/tmp/harvey@w...";
                    > >
                    > > but using strict, I should delclare the following:
                    > >
                    > > my ($MyOutFile = "/tmp/harvey@w...");
                    > >
                    > > right?
                    >
                    > In the case of a single variable declaration like this you don't
                    need the
                    > brackets.
                    >
                    > ie.
                    > my $variable = "some data";
                    >
                    > Remember, you only need to use 'my' once for each variable.
                    >
                    > What you can do to get by a lot of this, especially in converting a
                    > already-written script to use strict, is have a variable
                    declaration
                    > section at the top of your script. For example:
                    >
                    > my ($variable1, $var2, @foo, @bar, $var3);
                    >
                    > ....
                    > further down in the script...
                    > ....
                    >
                    > $var2 = "some text";
                    >
                    > I can use all the things I declared in the 'my' at the top of the
                    script
                    > throughout the script without re-declaring them. This is the
                    simplest
                    > example of using 'my'.
                    >
                    > Where the real power comes in though is in what is called "scope".
                    Meaning
                    > that you can delcare a variable only for a specific use. Take this
                    > example:
                    >
                    > use strict;
                    >
                    > my ($var1, $var2);
                    >
                    > $var1 = "text for variable 1";
                    >
                    > sub this_subroutine {
                    > my $var3 = "text for variable 3";
                    > $var2 = "text for variable 2";
                    > print "$var1\n";
                    > print "$var2\n";
                    > print "$var3\n";
                    > }
                    >
                    > &this_subroutine;
                    >
                    > $var1 and $var2 are declared 'globally' (meaning they are
                    > accessible anywhere in the script). $var3 is declared locally in a
                    > subroutine, and so is only accessible inside that subroutine. Once
                    the
                    > subroutine is over, $var3 disappears from memory. If I tried to
                    put '$var3
                    > = "some new text for variable 3";' outside the subroutine without
                    > declaring it globally I'd get errors. This prevents from from
                    making
                    > mistakes about how I am using the variables in my script.
                    >
                    > Understand?
                    >
                    > GregW
                  • Greg Webster
                    ... I ve actually thought about this quite a bit. I m currently working on a sci-fi novel (yeah, seriously), but maybe I should take a break and write some
                    Message 9 of 9 , Jan 2, 2002
                      On Wed, 2 Jan 2002, raezorblaedz wrote:

                      > Wow. That makes perfect sense. Why don't you revise some of the
                      > crappy (I'm a hardcore coder) documentation, and write books for
                      > O'Reilly. Even their Beginning Perl book doesn't state things that
                      > clearly.
                      > thank you,
                      > John

                      I've actually thought about this quite a bit. I'm currently working on a
                      sci-fi novel (yeah, seriously), but maybe I should take a break and write
                      some easy-to-read perl docs. Probably pay better anyway :)

                      GregW
                    Your message has been successfully submitted and would be delivered to recipients shortly.