help about array and hash

Discussion in 'Perl Misc' started by sonet, Feb 22, 2005.

  1. sonet

    sonet Guest

    undef %saw;

    @saw{@in} = (); #why? @saw not $saw, @saw is array or
    hash?<===============
    @out = sort keys %saw; # remove sort if undesired


    undef @ary;
    @ary[@in] = @in; #why? @saw not $saw<===============
    @out = grep {defined} @ary;
     
    sonet, Feb 22, 2005
    #1
    1. Advertising

  2. sonet

    phaylon Guest

    sonet wrote:
    > #why? @saw not $saw, @saw is array or hash?<===============


    That's absolutely gibberish for me, but my third eye says you should get a
    look at hash-slices in perldoc perldata. Also you should read the posting
    guidelines, which were last posted awful 10 hours ago.

    --
    http://www.dunkelheit.at/

    »Better to reign in hell than to serve in heaven«
    -- John Milton, »Paradise Lost«
     
    phaylon, Feb 22, 2005
    #2
    1. Advertising

  3. sonet

    Paul Lalli Guest

    "sonet" <> wrote in message
    news:cvftol$e2p$...
    > undef %saw;
    >
    > @saw{@in} = (); #why? @saw not $saw, @saw is array or
    > hash?<===============
    > @out = sort keys %saw; # remove sort if undesired
    >
    >
    > undef @ary;
    > @ary[@in] = @in; #why? @saw not $saw<===============
    > @out = grep {defined} @ary;



    @saw{@in} is a hash slice
    @ary[@in] is an array slice

    You can read more about slices in:
    perldoc perldata

    Search for the section labeled "Slices"

    Hope this helps,
    Paul Lalli
     
    Paul Lalli, Feb 22, 2005
    #3
  4. "sonet" <> wrote in news:cvftol$e2p$1
    @netnews.hinet.net:

    > undef %saw;


    WTF?

    > @saw{@in} = (); #why? @saw not $saw, @saw is array or
    > hash?<===============
    > @out = sort keys %saw; # remove sort if undesired


    Do you need lumber?

    >
    > undef @ary;
    > @ary[@in] = @in; #why? @saw not $saw<===============


    I don't mean to be disrespectful here but are you suffering from some
    mental problem that cuases you to repeat "@saw not $saw" ad infinitum? I
    tried saying that repeatedly and did not do anything for me. What does it
    do for you?


    Please read the posting guidelines posted here frequently for advice on
    how to help others help you. First, make sure to always put

    use strict;
    use warnings;

    in your scripts. With that:

    use strict;
    use warnings;

    undef %saw;

    @saw{@in} = ();
    @out = sort keys %saw;

    undef @ary;
    @ary[@in] = @in;
    @out = grep {defined} @ary;

    __END__

    generates the following messages:

    C:\Documents and Settings\asu1\My Documents> t.pl
    Global symbol "%saw" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 4.
    Global symbol "%saw" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 6.
    Global symbol "@in" requires explicit package name at C:\Documents and
    Settings\
    asu1\My Documents\t.pl line 6.
    Global symbol "@out" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 7.
    Global symbol "%saw" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 7.
    Global symbol "@ary" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 10.
    Global symbol "@ary" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 11.
    Global symbol "@in" requires explicit package name at C:\Documents and
    Settings\
    asu1\My Documents\t.pl line 11.
    Global symbol "@in" requires explicit package name at C:\Documents and
    Settings\
    asu1\My Documents\t.pl line 11.
    Global symbol "@out" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 12.
    Global symbol "@ary" requires explicit package name at C:\Documents and
    Settings
    \asu1\My Documents\t.pl line 12.
    Execution of C:\Documents and Settings\asu1\My Documents\t.pl aborted due
    to com
    pilation errors.

    What are you trying to do?

    Sinan
     
    A. Sinan Unur, Feb 22, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. rp
    Replies:
    1
    Views:
    555
    red floyd
    Nov 10, 2011
  2. Anthony Martinez
    Replies:
    4
    Views:
    283
    Robert Klemme
    Jun 11, 2007
  3. Michal Suchanek
    Replies:
    6
    Views:
    241
    Nobuyoshi Nakada
    Jun 13, 2007
  4. Srijayanth Sridhar
    Replies:
    19
    Views:
    640
    David A. Black
    Jul 2, 2008
  5. Replies:
    11
    Views:
    195
    Eric Schwartz
    Oct 10, 2005
Loading...

Share This Page