Perl query

View: New views
6 Messages — Rating Filter:   Alert me  

Perl query

by anirudh nair :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello Guys

I would like to know the type of data structures that could be implemented
using Perl.
As of now, I've not seen any reference to pointers in Perl. So, is it
possible to implement
trees in Perl.

Cheers
Anirudh Nair


[Non-text portions of this message have been removed]


Re: Perl query

by Jagadeesh N. Malakannavar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Tes. very much possible. I would send sample implementation soon..

Thanks
Jagadeesh

On Thu, Jun 18, 2009 at 7:26 PM, anirudh nair <anirudh.anu01@...>wrote:

>
>
> Hello Guys
>
> I would like to know the type of data structures that could be implemented
> using Perl.
> As of now, I've not seen any reference to pointers in Perl. So, is it
> possible to implement
> trees in Perl.
>
> Cheers
> Anirudh Nair
>
> [Non-text portions of this message have been removed]
>
>  
>



--
Many Thanks
Jagadeesh N.Malakannavar
GSM: +91 9901001180


[Non-text portions of this message have been removed]


Re: Perl query (type of data structures ...)

by Saifi Khan-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 18 Jun 2009, anirudh nair wrote:

> Hello Guys
>
> I would like to know the type of data structures that could be implemented
> using Perl.
> As of now, I've not seen any reference to pointers in Perl. So, is it
> possible to implement
> trees in Perl.
>
> Cheers
> Anirudh Nair
>

Please see the names of the packages below related to
 . algorithm
 . list
 . iterator
 . tree
 . tie

p5-Algorithm-Accounting/                     p5-Inline-Files/
p5-Algorithm-Annotate/                       p5-Inline-Filters/
p5-Algorithm-Bucketizer/                     p5-Inline-Java/
p5-Algorithm-C3/                             p5-Inline-TT/
p5-Algorithm-ChooseSubsets/                  p5-Inline-Tcl/
p5-Algorithm-Cluster/                        p5-InlineX-C2XS/
p5-Algorithm-Dependency/                     p5-Ioctl/
p5-Algorithm-Dependency-Objects/             p5-Iterator/
p5-Algorithm-Diff/                           p5-Iterator-IO/
p5-Algorithm-Evolutionary/                   p5-Iterator-Misc/
p5-Algorithm-IncludeExclude/                 p5-Iterator-Util/
p5-Algorithm-Interval2Prefix/                p5-JIRA-Client/
p5-Algorithm-LCS/                            p5-JQuery/
p5-Algorithm-LUHN/                           p5-JSON-RPC/
p5-Algorithm-MDiff/                          p5-Java/
p5-Algorithm-MarkovChain/                    p5-Lexical-Alias/
p5-Algorithm-Merge/                          p5-Lexical-Persistence/
p5-Algorithm-MinMax/                         p5-Lingua-JA-Fold/
p5-Algorithm-NaiveBayes/                     p5-List-Cycle/
p5-Algorithm-Networksort/                    p5-List-Group/
p5-Algorithm-Numerical-Shuffle/              p5-List-Permutor/
p5-Algorithm-Permute/                        p5-List-PowerSet/
p5-Algorithm-SVM/                            p5-List-Rotation-Cycle/
p5-Alias/                                    p5-List-Uniq/

p5-Tie-Array-Pack/
p5-File-Remove/                              p5-Tie-Array-Sorted/
p5-File-ShareDir/                            p5-Tie-CPHash/
p5-File-ShareDir-PAR/                        p5-Tie-Cache/
p5-File-Slurp/                               p5-Tie-DB_File-SplitHash/
p5-File-Slurp-Tree/                          p5-Tie-DB_FileLock/
p5-File-Stream/                              p5-Tie-File/
p5-File-Sync/                                p5-Tie-File-AsHash/
p5-File-Tail/                                p5-Tie-FileLRUCache/
p5-File-Temp/                                p5-Tie-Hash-Indexed/
p5-File-Tempdir/                             p5-Tie-Hash-Regex/
p5-File-Type/                                p5-Tie-Hash-Sorted/
p5-File-Util/                                p5-Tie-Hash-TwoWay/
p5-File-chdir/                               p5-Tie-IxHash/
p5-File-chmod/                               p5-Tie-RefHash/
p5-File-pushd/                               p5-Tie-RefHash-Weak/
p5-FileHandle-Fmode/                         p5-Tie-Restore/
p5-FileHandle-Unget/                         p5-Tie-ShareLite/
p5-Filesys-Virtual/                          p5-Tie-Simple/
p5-Filesys-Virtual-Plain/                    p5-Tie-ToObject/
p5-Filter/                                   p5-Tie-iCal/

p5-TraceFuncs/                
p5-Tree-DAG_Node/              
p5-Tree-Simple/                
p5-Tree-Binary/                
p5-Tree-Node/                  
p5-Tree-Simple-View/          
p5-Tree-Binary-Dictionary/    
p5-Tree-Parser/                
p5-Tree-Simple-VisitorFactory/


i'll write another brief related to the building blocks in PERL.


thanks
Saifi.

Re: Perl query (Tree data structure)

by Saifi Khan-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 18 Jun 2009, anirudh nair wrote:

> is it possible to implement trees in Perl.
>
> Cheers
> Anirudh Nair
>

Perhaps, you may take a look at this one first
http://search.cpan.org/~rkinyon/Tree-1.01/lib/Tree.pm

Some of the tree implementations available are

Tree                A tree datastructure    
Tree::AVL           AVL tree for efficient storage and retrieval    
Tree::DAG_Node      base class for trees    
Tree::Fat           Embeddable F-Tree algorithm suite  
Tree::List2Tree     Convert list of nodes into tree structure  
Tree::Menu          Menus as trees  
Tree::Nary          Perl implementation of N-ary search trees  
Tree::Node          Memory-efficient tree node implementation  
Tree::Predicate     predicate trees, usually for SQL    
Tree::Suffix        Interface to the libstree library  
Tree::Ternary       Perl implementation of ternary search trees    
Tree::Ternary_XS    XS implementation of ternary search trees  
Tree::Trie          An implementation of the Trie data structure

For the complete list with links to code and modules, check out
http://search.cpan.org/modlist/Data_and_Data_Types/Tree

Blog post on the same at
http://www.twincling.org/node/622


thanks
Saifi.

Re: Perl reference, referent ...

by Saifi Khan-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, anirudh nair wrote:

> Hello Guys
>
> As of now, I've not seen any reference to pointers in Perl.
>
> Cheers
> Anirudh Nair
>

Hi Anirudh:

Nice to see you discuss core aspects of PERL.

You are already aware that PERL provides three fundamental data types:
 . scalars     $
 . arrays      @
 . hashes      %

Now each defined variable has a 'name' and the 'address' of the chunk of memory associated with it.

To create a reference, we need to have a value that stores the location of another value.

So, now we need TYPE information and SYNTAX support for the operation.

The SYNTAX is '\' and you can consider it similar to '&' operator in C.

Hence, if you have

  $name = "Anirudh Nair";

then reference is created by

  \$name;

We'd also need TYPE information, since in PERL we're allowed to create 'reference' to scalar, arrays, hashes, functions and even constants.

Thus,
  \$name;
  \@todo;
  \%capitals;
  \∑
  \3.14159;

are reference to scalar name, reference to array todo, reference to hash capitals, reference to function sum and reference to constant.

So, you can see that combining built-in types with references can produce rich and powerful data structures that can be used to represent anything.

To summarize, here are few points

 . The scalar value that contains the memory address is called a reference
   eg.
     $nameref = \$name;

 . The value at the memory address is called a 'referent'.

 . Referents in PERL are typed.

 . There is no way you can 'type cast' from one reference to another.

 . PERL uses reference counting internally to manage the memory associated with each reference.

 . you can use the ref( ) function and pass it a reference, which returns a string describing its reference.

 . if you call ref( ) on an object, it will return the class the object was blessed into, for example Twincling::Alan .

Blog post on the same at
http://www.twincling.org/node/627

PERL is rather nice and Hyderabad is the city of PERLs. ;-)


thanks
Saifi.

Re: Perl reference, referent ...

by anirudh nair :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

thanks Saifi

That was helpful.

Also found 'man perlreftut' a good read. A nicely structured tutorial.

Cheers
Anirudh Nair


[Non-text portions of this message have been removed]