- Community Home
- >
- Servers and Operating Systems
- >
- Operating Systems
- >
- Operating System - Linux
- >
- using structure on perl scripts
Categories
Company
Local Language
Forums
Discussions
Forums
- Data Protection and Retention
- Entry Storage Systems
- Legacy
- Midrange and Enterprise Storage
- Storage Networking
- HPE Nimble Storage
Discussions
Discussions
Discussions
Forums
Forums
Discussions
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
- BladeSystem Infrastructure and Application Solutions
- Appliance Servers
- Alpha Servers
- BackOffice Products
- Internet Products
- HPE 9000 and HPE e3000 Servers
- Networking
- Netservers
- Secure OS Software for Linux
- Server Management (Insight Manager 7)
- Windows Server 2003
- Operating System - Tru64 Unix
- ProLiant Deployment and Provisioning
- Linux-Based Community / Regional
- Microsoft System Center Integration
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Discussion Boards
Community
Resources
Forums
Blogs
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-11-2006 07:14 PM
тАО07-11-2006 07:14 PM
I'm trying to write a perl script using structure. (using Class::Struct)
the structure is defined as follows:
struct DiskAllocation =>
[
Disk => '$',
Fa => '@',
];
I'm using the following method to update the array (see also the function below)-
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.
I have two problems (so far...)
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
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)
Can't call method "Disk" on unblessed reference at DrpMan.pl line 219.
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.
this is the function I use to read/write the structure -
attched the section from the script, with the struct defintion and function
Solved! Go to Solution.
- Tags:
- Perl
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 02:36 AM
тАО07-12-2006 02:36 AM
Re: using structure on perl scripts
but the biggest problem remains -
I can't assign an Array to structure array -
(by $Struct->new (array => @another_array
only by
$Struct->array=\@another_array)
which is not good!! since I need to clean '@another_array' from values, using refrences is not good for me...
Help me ppl!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 02:36 AM
тАО07-12-2006 02:36 AM
Re: using structure on perl scripts
but the biggest problem remains -
I can't assign an Array to structure array -
(by $Struct->new (array => @another_array
only by
$Struct->array=\@another_array)
which is not good!! since I need to clean '@another_array' from values, using refrences is not good for me...
Help me ppl!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 02:40 AM
тАО07-12-2006 02:40 AM
Re: using structure on perl scripts
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 03:00 AM
тАО07-12-2006 03:00 AM
Re: using structure on perl scripts
I receive the following error -
root@troya: perl DrpMan.pl
Can't modify non-lvalue subroutine call at DrpMan.pl line 219,
.
and line 219 -
$returnArray[$DiskCount]->Fa=[@Fa];
can I insert scalars values using the same syntax?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 03:17 AM
тАО07-12-2006 03:17 AM
Re: using structure on perl scripts
if you have an array
my @disks = qw( /dev/dsk/c1t2d0 /media/usbdisk );
putting @disks in square brackets creates an array reference to a list of copies of the elements in @disks
lt09:/home/merijn 101 > perl -MData::Dumper -e'@x=qw(foo bar);print Dumper@x'
$VAR1 = 'foo';
$VAR2 = 'bar';
lt09:/home/merijn 102 > perl -MData::Dumper -e'@x=qw(foo bar);print Dumper\@x'
$VAR1 = [
'foo',
'bar'
];
lt09:/home/merijn 103 >
You could play with Data::Dumper and see what it expects
Still, why the need for struct?
my $ref = (
Array => [ qw( foo bar ) ],
Count => 2,
Info => {
Author => "Tux",
Company => "PROCURA",
ID => "BR41967",
Number => 42,
List => [ 1 .. 16 ],
},
Valid => 1,
);
if ($ref->{Info}{Author} eq "Tux" &&
$ref->{Array}[1] eq "bar" &&
$ref=>{Info}{List}[2] == 2) {
print "See, it's that simple!
$ref->{Extra_Info}{Age}[24] = 42;
}
}
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 07:27 AM
тАО07-12-2006 07:27 AM
Re: using structure on perl scripts
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.
I didn't understand if the soultion u've wrote is an explantion of how using structure or if it's an alternative soultion.
thanks!
itai
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 07:33 AM
тАО07-12-2006 07:33 AM
Re: using structure on perl scripts
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 07:36 AM
тАО07-12-2006 07:36 AM
Re: using structure on perl scripts
the M comes from the command line option -M, which is a shorthand for "use Module"
see "man perlrun" for more details.
Enjoy, Have FUN! H.Merijn
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
тАО07-12-2006 07:40 AM
тАО07-12-2006 07:40 AM
Re: using structure on perl scripts
By putting your array in [ ] creates an array reference list of copies of your arrays elements.
It sounds confusing buts its really not.