<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic using structure on perl scripts in Operating System - Linux</title>
    <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821831#M100306</link>
    <description>Hi everyone,&lt;BR /&gt;I'm trying to write a perl script using structure. (using Class::Struct)&lt;BR /&gt;the structure is defined as follows:&lt;BR /&gt;struct DiskAllocation =&amp;gt;&lt;BR /&gt;        [&lt;BR /&gt;                Disk =&amp;gt; '$',&lt;BR /&gt;                Fa =&amp;gt; '@',&lt;BR /&gt;        ];&lt;BR /&gt;&lt;BR /&gt;I'm using the following method to update the array (see also the function below)- &lt;BR /&gt;first I create another array,temporary, and then when I finish to fill it out with values, I copy the temporary array into the structure array.&lt;BR /&gt;I have two problems (so far...) &lt;BR /&gt;1. I cannot 'copy' the temporary array into the structure array, it ask me to use pointers instead. since it's a temporary array (and I want to use it afterwards), it's a problem&lt;BR /&gt;2. when attempting to reach data in the structure (from the 'Disk' field, which is an integer) I received the following warning (I still recieve the requested data)&lt;BR /&gt;&lt;BR /&gt;Can't call method "Disk" on unblessed reference at DrpMan.pl line 219. &lt;BR /&gt;&lt;BR /&gt;3. when attempting to read data from the Fa field (which is an array) I keep receving syntax errors, no matter how I try to read it.&lt;BR /&gt;this is the function I use to read/write the structure - &lt;BR /&gt;&lt;BR /&gt;attched the section from the script, with the struct defintion and function&lt;BR /&gt;</description>
    <pubDate>Wed, 12 Jul 2006 02:14:02 GMT</pubDate>
    <dc:creator>itai weisman</dc:creator>
    <dc:date>2006-07-12T02:14:02Z</dc:date>
    <item>
      <title>using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821831#M100306</link>
      <description>Hi everyone,&lt;BR /&gt;I'm trying to write a perl script using structure. (using Class::Struct)&lt;BR /&gt;the structure is defined as follows:&lt;BR /&gt;struct DiskAllocation =&amp;gt;&lt;BR /&gt;        [&lt;BR /&gt;                Disk =&amp;gt; '$',&lt;BR /&gt;                Fa =&amp;gt; '@',&lt;BR /&gt;        ];&lt;BR /&gt;&lt;BR /&gt;I'm using the following method to update the array (see also the function below)- &lt;BR /&gt;first I create another array,temporary, and then when I finish to fill it out with values, I copy the temporary array into the structure array.&lt;BR /&gt;I have two problems (so far...) &lt;BR /&gt;1. I cannot 'copy' the temporary array into the structure array, it ask me to use pointers instead. since it's a temporary array (and I want to use it afterwards), it's a problem&lt;BR /&gt;2. when attempting to reach data in the structure (from the 'Disk' field, which is an integer) I received the following warning (I still recieve the requested data)&lt;BR /&gt;&lt;BR /&gt;Can't call method "Disk" on unblessed reference at DrpMan.pl line 219. &lt;BR /&gt;&lt;BR /&gt;3. when attempting to read data from the Fa field (which is an array) I keep receving syntax errors, no matter how I try to read it.&lt;BR /&gt;this is the function I use to read/write the structure - &lt;BR /&gt;&lt;BR /&gt;attched the section from the script, with the struct defintion and function&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2006 02:14:02 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821831#M100306</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T02:14:02Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821832#M100307</link>
      <description>I managed to solve some of the problem,&lt;BR /&gt;but the biggest problem remains - &lt;BR /&gt;I can't assign an Array to structure array -&lt;BR /&gt;(by $Struct-&amp;gt;new (array =&amp;gt; @another_array&lt;BR /&gt;only by&lt;BR /&gt;$Struct-&amp;gt;array=\@another_array)&lt;BR /&gt;which is not good!! since I need to clean '@another_array' from values, using refrences is not good for me...&lt;BR /&gt;Help me ppl!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2006 09:36:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821832#M100307</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T09:36:49Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821833#M100308</link>
      <description>I managed to solve some of the problems,&lt;BR /&gt;but the biggest problem remains - &lt;BR /&gt;I can't assign an Array to structure array -&lt;BR /&gt;(by $Struct-&amp;gt;new (array =&amp;gt; @another_array&lt;BR /&gt;only by&lt;BR /&gt;$Struct-&amp;gt;array=\@another_array)&lt;BR /&gt;which is not good!! since I need to clean '@another_array' from values, using refrences is not good for me...&lt;BR /&gt;Help me ppl!&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2006 09:36:53 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821833#M100308</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T09:36:53Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821834#M100309</link>
      <description>$Struct-&amp;gt;array = [ @another_array ]&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Jul 2006 09:40:13 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821834#M100309</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-07-12T09:40:13Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821835#M100310</link>
      <description>it doesn't work :(&lt;BR /&gt;I receive the following error - &lt;BR /&gt;root@troya: perl DrpMan.pl&lt;BR /&gt;Can't modify non-lvalue subroutine call at DrpMan.pl line 219, &lt;SYMDEV&gt; line 149&lt;BR /&gt;.&lt;BR /&gt;and line 219 -&lt;BR /&gt;$returnArray[$DiskCount]-&amp;gt;Fa=[@Fa];&lt;BR /&gt;can I insert scalars values using the same syntax?&lt;/SYMDEV&gt;</description>
      <pubDate>Wed, 12 Jul 2006 10:00:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821835#M100310</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T10:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821836#M100311</link>
      <description>&lt;!--!*#--&gt;I don't know what that struct module does, and why you would need it.&lt;BR /&gt;&lt;BR /&gt;if you have an array&lt;BR /&gt;&lt;BR /&gt;my @disks = qw( /dev/dsk/c1t2d0 /media/usbdisk );&lt;BR /&gt;&lt;BR /&gt;putting @disks in square brackets creates an array reference to a list of copies of the elements in @disks&lt;BR /&gt;&lt;BR /&gt;lt09:/home/merijn 101 &amp;gt; perl -MData::Dumper -e'@x=qw(foo bar);print Dumper@x'&lt;BR /&gt;$VAR1 = 'foo';&lt;BR /&gt;$VAR2 = 'bar';&lt;BR /&gt;lt09:/home/merijn 102 &amp;gt; perl -MData::Dumper -e'@x=qw(foo bar);print Dumper\@x'&lt;BR /&gt;$VAR1 = [&lt;BR /&gt;          'foo',&lt;BR /&gt;          'bar'&lt;BR /&gt;        ];&lt;BR /&gt;lt09:/home/merijn 103 &amp;gt;&lt;BR /&gt;&lt;BR /&gt;You could play with Data::Dumper and see what it expects&lt;BR /&gt;&lt;BR /&gt;Still, why the need for struct?&lt;BR /&gt;&lt;BR /&gt;my $ref = (&lt;BR /&gt;    Array   =&amp;gt; [ qw( foo bar ) ],&lt;BR /&gt;    Count   =&amp;gt; 2,&lt;BR /&gt;    Info    =&amp;gt; {&lt;BR /&gt;        Author  =&amp;gt; "Tux",&lt;BR /&gt;        Company =&amp;gt; "PROCURA",&lt;BR /&gt;        ID      =&amp;gt; "BR41967",&lt;BR /&gt;        Number  =&amp;gt; 42,&lt;BR /&gt;        List    =&amp;gt; [ 1 .. 16 ],&lt;BR /&gt;        },&lt;BR /&gt;    Valid   =&amp;gt; 1,&lt;BR /&gt;    );&lt;BR /&gt;&lt;BR /&gt;if ($ref-&amp;gt;{Info}{Author} eq "Tux" &amp;amp;&amp;amp;&lt;BR /&gt;    $ref-&amp;gt;{Array}[1] eq "bar"     &amp;amp;&amp;amp;&lt;BR /&gt;    $ref=&amp;gt;{Info}{List}[2] == 2) {&lt;BR /&gt;        print "See, it's that simple!&lt;BR /&gt;        $ref-&amp;gt;{Extra_Info}{Age}[24] = 42;&lt;BR /&gt;        }&lt;BR /&gt;    }&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Jul 2006 10:17:47 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821836#M100311</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-07-12T10:17:47Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821837#M100312</link>
      <description>thanks,&lt;BR /&gt;I need to design a utility to hold a lot of data on real time (not on any kind of third party database) regrading to my storage enviorment. I need to make some queires against this 'database' (we'll use that on a crisis, when we'll have to establish a DRP site ). I started writing this proggram and I came out with some complex data holders such as three dimensional arrays of hashes, I'm looking for a better way, that is easier to manage.&lt;BR /&gt;I didn't understand if the soultion u've wrote is an explantion of how using structure or if it's an alternative soultion.&lt;BR /&gt;thanks!&lt;BR /&gt;itai</description>
      <pubDate>Wed, 12 Jul 2006 14:27:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821837#M100312</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T14:27:15Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821838#M100313</link>
      <description>what is MData::Dumper by the way? I couldn't find a module named that way...&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2006 14:33:26 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821838#M100313</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T14:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821839#M100314</link>
      <description>Data::Dumper is a core module that shows you the real contrent of data structures. See 'man Data::Dumper' for more details.&lt;BR /&gt;&lt;BR /&gt;the M comes from the command line option -M, which is a shorthand for "use Module"&lt;BR /&gt;see "man perlrun" for more details.&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Wed, 12 Jul 2006 14:36:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821839#M100314</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-07-12T14:36:55Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821840#M100315</link>
      <description>He showed you that you don't need the struct module(whatever it does) for what you are trying to use to accomplish. &lt;BR /&gt;&lt;BR /&gt;By putting your array in [ ] creates an array reference list of copies of your arrays elements. &lt;BR /&gt;&lt;BR /&gt;It sounds confusing buts its really not. &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2006 14:40:24 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821840#M100315</guid>
      <dc:creator>Marvin Strong</dc:creator>
      <dc:date>2006-07-12T14:40:24Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821841#M100316</link>
      <description>Hi:&lt;BR /&gt;&lt;BR /&gt;use Data::Dumper&lt;BR /&gt;&lt;BR /&gt;...its a module in your core distribution used to "dump" (show) data.&lt;BR /&gt;&lt;BR /&gt;# perldoc Data::Dumper&lt;BR /&gt;&lt;BR /&gt;...will show you details.&lt;BR /&gt;&lt;BR /&gt;The use of:&lt;BR /&gt;&lt;BR /&gt;# perl -MData::Dumper -e ' ... '&lt;BR /&gt;&lt;BR /&gt;...says to use the (M)odule whose name follows, just like 'use Data::Dumper;'.&lt;BR /&gt;&lt;BR /&gt;Regards!&lt;BR /&gt;&lt;BR /&gt;...JRF...</description>
      <pubDate>Wed, 12 Jul 2006 14:40:40 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821841#M100316</guid>
      <dc:creator>James R. Ferguson</dc:creator>
      <dc:date>2006-07-12T14:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821842#M100317</link>
      <description>thanks ppl,&lt;BR /&gt;I would love not to use that complicated module, but I still don't see how can I do that otherwise.(I understood how can I copy a whole array, but I need more than that)&lt;BR /&gt;by 'sturct' I mean Data Structure, like what we had on C, before we had C++/Java objects - &lt;BR /&gt;in C - for instnace - If I want to describe a person, that has a name,an age and an ID -&lt;BR /&gt;typedef struct person&lt;BR /&gt;{&lt;BR /&gt;  char* name;&lt;BR /&gt;  float age;&lt;BR /&gt;  int id;&lt;BR /&gt;}PERSON;&lt;BR /&gt;&lt;BR /&gt;and then acessing to data for read and write is very easy using the '-&amp;gt;' operator, it's like a primitive object. I can also make an array of structures)&lt;BR /&gt;I just need a solution for complex data structures, variables with fixed attributs, like forms. (varibles that can be consist of strings, arrays and hashes, the same time to be a value of one array cell, I can acehive it by doing arrays of hashes, but it's not that easy to manage)&lt;BR /&gt;&lt;BR /&gt;thanks&lt;BR /&gt;Itai.&lt;BR /&gt;</description>
      <pubDate>Wed, 12 Jul 2006 23:10:03 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821842#M100317</guid>
      <dc:creator>itai weisman</dc:creator>
      <dc:date>2006-07-12T23:10:03Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821843#M100318</link>
      <description>Those are all builtin perl features. No need for a module there.&lt;BR /&gt;&lt;BR /&gt;What you /can/ do is build your own module, and give it an OO look, so you can do exactly as you say.&lt;BR /&gt;If you are seriously going to convert C++ to perl on a larger scale, I'd advice you to read Damien Conway's "Object Oriented Programming in Perl" from Manning books.&lt;BR /&gt;&lt;BR /&gt;For the shor term, perl comes with quite a lot of on-line documentation about this.&lt;BR /&gt;&lt;BR /&gt;Data Structure Cookbook:&lt;BR /&gt;# perldoc perldsc&lt;BR /&gt;&lt;BR /&gt;Perl Objects&lt;BR /&gt;# perldoc perlobj&lt;BR /&gt;&lt;BR /&gt;Beginner's Object-Oriented Tutorial&lt;BR /&gt;# perldoc perlboot&lt;BR /&gt;&lt;BR /&gt;Tom's object-oriented tutorial for perl&lt;BR /&gt;# perldoc perltoot&lt;BR /&gt;&lt;BR /&gt;Tom's OO Tutorial for Class Data in Perl&lt;BR /&gt;# perldsc perltooc&lt;BR /&gt;&lt;BR /&gt;You can also use man on most systems&lt;BR /&gt;# man perldsc&lt;BR /&gt;&lt;BR /&gt;Enjoy, Have FUN! H.Merijn</description>
      <pubDate>Thu, 13 Jul 2006 01:18:49 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821843#M100318</guid>
      <dc:creator>H.Merijn Brand (procura</dc:creator>
      <dc:date>2006-07-13T01:18:49Z</dc:date>
    </item>
    <item>
      <title>Re: using structure on perl scripts</title>
      <link>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821844#M100319</link>
      <description>If it's only a C like struct that you want&lt;BR /&gt;then there's really no need for the module you chose to import.&lt;BR /&gt;Since the transition from Perl4 to Perl5 Perl got references which let you build up even deeply nested LoLs on the fly.&lt;BR /&gt;Besides, refernces are the main feature how Perl implements OO.&lt;BR /&gt;Unlike other languages Perl's has no formal OO constructs (the widespread "new" for a class method or constructor is merely a convention to make life easier for C++ hackers).&lt;BR /&gt;In Perl you only need to "bless" any type of variable reference (it even works with filehandles) into a package (which is only the class'es namespace).&lt;BR /&gt;Because of this liberty (which follows Perl's TIMTOWTDI motto) it can make it a bit difficult for programmers comming from more formal OO languages, to whom it may look quite chaotic.&lt;BR /&gt;That's why there are modules like Class::Struct.&lt;BR /&gt;Although I have never used this module (and haven't read its POD yet) I assume that it merely acts as a nicer interface to creating  class data than the rugged Perlish way of creating and initiating a hasref (usually called $self, but that's only another liberal convention) in the class constructor.&lt;BR /&gt;If you don't plan to write an OO module than I think Class::Struct isn't of much use for you.&lt;BR /&gt;A simple C struct translates to a hash in Perl.&lt;BR /&gt;If you need a nested struct then the values of the hash simply need to become references to lists, either arrayrefs (designated by angular brackets []), or hashrefs (designated by curly brackets {}).&lt;BR /&gt;You should have a deko at the perldocs procura gave you.&lt;BR /&gt;As far as OO programming in Perl is concerned  I would aggree that probably the best reference material (apart from perldocs like perlboot, perltoot, perltooc) is the mentioned book by Damian Conway.&lt;BR /&gt;Also looking at the implementation of modules by CPAN authors like Damian is very instructive.&lt;BR /&gt;</description>
      <pubDate>Thu, 13 Jul 2006 04:51:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-linux/using-structure-on-perl-scripts/m-p/3821844#M100319</guid>
      <dc:creator>Ralph Grothe</dc:creator>
      <dc:date>2006-07-13T04:51:15Z</dc:date>
    </item>
  </channel>
</rss>

