Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > help about array and hash

Reply
Thread Tools

help about array and hash

 
 
sonet
Guest
Posts: n/a
 
      02-22-2005
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;


 
Reply With Quote
 
 
 
 
phaylon
Guest
Posts: n/a
 
      02-22-2005
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«

 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      02-22-2005
"sonet" <(E-Mail Removed)> wrote in message
news:cvftol$e2p$(E-Mail Removed)...
> 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

 
Reply With Quote
 
A. Sinan Unur
Guest
Posts: n/a
 
      02-22-2005
"sonet" <(E-Mail Removed)> 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
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
Benchmark segfault [Was: Array#inject to create a hash versus Hash[*array.collect{}.flatten] ] Michal Suchanek Ruby 6 06-13-2007 04:40 AM
Array#inject to create a hash versus Hash[*array.collect{}.flatten] -- Speed, segfault Anthony Martinez Ruby 4 06-11-2007 08:16 AM
Sort by hash vaule, an array of hash references fahdsultan@gmail.com Perl Misc 11 10-10-2005 09:35 PM



Advertisments