in reply to Should I use $ and $# ?

Deprecated features are headed for removal. Don't expect them to survive into Perl 6. Also don't expect bugs that come up for them to be treated as a priority.

I remember hearing of at least one bug with $[ where the response was, "Oh well, people shouldn't be doing that any more anyways." I would have to search to verify that though.

YMMV, but I certainly believe that "deprecated" means "dangerous - avoid".

Replies are listed 'Best First'.
RE: Re: Should I use $[ and $# ?
by turnstep (Parson) on Aug 11, 2000 at 00:33 UTC

    See This node about the 'our' keyword for a discussion about the word "deprecated". Turns out that it really means "reserved" as in, it was used once, or may be used in the future.

    At any rate, $# is fairly widely used, and $[ is not widely used, but I'd hardly call it one of the more obscure special variables. It's one that you should almost never change but it is perfectly alright to use. Not that I ever do, but:

    for $x ($] .. $#myarray) ## is actually technically better than for $x (0..$#myarray)
    But still, the occasions to change it outside of an obfuscation are few and far between.

      My understanding matches japhy at RE: RE: History of 'our'. And here is why (from perldiag in 5.005_03):
      Use of reserved word """"%s"""" is deprecated (D) The indicated bareword is a reserved word. Future versions of perl may use it as a keyword, so you're better off either explicitly quoting the word in a manner appropriate for its context of use, or using a different name altogether. The warning can be suppressed for subroutine names by either adding a & prefix, or using a package qualifier, e.g. &our(), or Foo::our().
      In general if you get any message from Perl that you do not understand, you should try "perldoc perldiag" and search for that message.

      Compare with the related message:

      Use of %s is deprecated (D) The construct indicated is no longer recommended for use, generally because there's a better way to do it, and also because the old way has bad side effects.
      Which is, of course, what you get when the keyword is deprecated.

      So your believing that our was deprecated because someone got that message simply means that you (and they) did not understand the message, and didn't know how to RTFM. Now you do. :-)

        not to pick nits, but i've never seen either message. i was simply asking about something i had read in the Camel book and wondering how it applied to my code. i've been doing due diligence in RTFM, but it's hard to read something you've never seen.
        i've included here the definition of deprecate as defined by Merriam Webster online. i can see using definitions 2 or 3 when discussing features that will not be included in future releases, but it's quite a stretch for me to see this word used in context with something that will be _included_ in a future release. (2 comes close, but i still think a better message could be given.)

        Main Entry: dep·re·cate
        Pronunciation: 'de-pri-"kAt
        Function: transitive verb
        Inflected Form(s): -cat·ed; -cat·ing
        Etymology: Latin deprecatus, past participle of deprecari to avert by prayer, from de- + precari to pray
        Date: 1628
        1. a archaic : to pray against (as an evil) b : to seek to avert [deprecate the wrath ... of the Roman people -- Tobias Smollett]
        2. : to express disapproval of
        3. a : PLAY DOWN : make little of [speaks five languages ... but deprecates this facility -- Time] b : BELITTLE, DISPARAGE [the most reluctantly admired and least easily deprecated of ... novelists -- New Yorker]

        - dep·re·cat·ing·ly /-"kA-ti[ng]-lE/ adverb
        - dep·re·ca·tion /"de-pri-'kA-sh&n/ noun

        i apologize for the attitude of this post, but it's been one of those days, and the implication that i don't know how to find out things on my own really irks me.
      That's exactly how I've been using it, and it works much cleaner than other solutions I've tried.
      The new edition of the Camel book says for each, "Deprecated, do not use in anything new." It sounds more to me like calling the use of 'our' deprecated was a mistake. It should have been given a better message about being reserved for future use. Deprecated has always meant to me that something had been superceded by something better (safer, faster, etc) so you should transition before the feature is removed.
      Just my .02
      That construct is moot though. perlvar says:
      As of release 5 of Perl, assignment to $[ is treated as a compiler directive, and cannot influence the behavior of any other file. Its use is highly discouraged.
      So unless you fiddled with $[ yourself (which you shouldn't have in the first place), you can use 0 .. $#foo perfectly safely.

      Makeshifts last the longest.

RE: Re: Should I use $ and $# ?
by KM (Priest) on Aug 11, 2000 at 00:39 UTC
    And this is directly from perlvar:

    $[
    ...snip...
    As of Perl 5, assignment to "$[" is treated as a
    compiler directive, and cannot influence the
    behavior of any other file.  Its use is
    discouraged.
    

    Cheers,
    KM