$key = "a";
$value = "hello";
%myhash = {} ;
push @{ myHash{$key} }, $hello;
print $myHash{$key}."\n";
this script prints
"hello" but has following error message.
Reference found where even-sized list expected at ./test line 5.
can any one help me to fix this problem?? (3 Replies)
I have two arrays
@nextArray contains some files like
\main\1\Xul.xml@@\main\galileo_integration_sjc\0
\main\1\PortToStorageDialog.xml@@\main\galileo_integration_sjc\0
.
.
.
\main\1\PreferencesDialog.xml@@\main\galileo_integration_sjc\0
@otherArray contains some files like
... (2 Replies)
Hi All,
I'm writing a nagios check that will see if our ldap servers are in sync...
I got the status data into a nested array, I would like to search key of each array and if "OK" is NOT present, echo other key=>values in the current array to a variable
so...eg...let take the single array... (1 Reply)
#!/usr/bin/perl
my @arr=("hello", "how", "are", "you");
$l=length(@arr);
print $l;
This print 1.Why?
How can i print the array size = 4?
I want to store these in an array.
hello
how
are
you
And then i want to access these element through indexing.
How can i do this? (4 Replies)
How can I nest substitutions ? My solution just seems cheap ...
sample data
Cisco Catalyst Operating System Software, Version 235.5(18)
Cisco Catalyst Operating System Software, Version 17.6(7)
Cisco Catalyst Operating System Software, Version 19.6(7)
Cisco Catalyst Operating System... (1 Reply)
Hi,
I have a strange problem with arrays in Perl.
That is to say, for me it is strange and perhaps there is a special reason for it that I do not know of.
Not a real Perl Ace.
This is the program, as an example:
#!/usr/bin/perl -w #-d
use strict;
my $pu;
my $pu_list_cmd;
my... (2 Replies)
I'm just having a bit of trouble running this code. It tells me that there's a syntax error on line 29. Any help appreciated.
#!/usr/bin/perl
#
# Phone Book Application
#
%phonebook = (
"Wayne", '34687368',
"Home", '378643287',
"Work", '017374637',
"School",... (2 Replies)
Hello,
I'm quite new to perl so my question is rather basic and I know there is probably a simple way around it but I can't seem to find it.
I have a medium-length code and there is a part that works with a nested for loop:
foreach my $j(@primpiddelta){
for (my $k=1;... (0 Replies)
I want to pass this array as a parameter.
IFS=$'\n'
fortune_lines=($(fortune | fold -w 30 ))
Inside of this line
screen -p 0 -S ${SCREEN_SESSION} -X stuff "`printf "say ${fortune_lines}\r"`"
And I am lost at this point.
I am thinking something like this?
Then make it loop..
... (7 Replies)
Hello,
I'm looking at simplfying a function that flattens an array, it uses recursion and filters objects by type but this seems to be a waste of resources to me at least, using conditionals like this seems like a bad idea.
The array can be a generic type, int, string, float but not some... (2 Replies)
Discussion started by: f77hack
2 Replies
LEARN ABOUT DEBIAN
lfc_perl
lfc_perl(3) Perl Programmers Reference Guide lfc_perl(3)NAME
lfc - Perl interface to the LFC
SYNOPSIS
use lfc;
printf "CNS_LIST_BEGIN is %d
", $lfc::CNS_LIST_BEGIN;
DESCRIPTION
The lfc module permits you to access the LFC client interface from perl programs. The lfc module is a swig wrapping of the standard C
interface. For detailed descriptions of each function see the individual man page of each function.
There follows a series of examples of how to use selected functions and how to retrieve the information returned by them: Examples are
finding the GUID of an existing entry, listing the replicas of a given GUID and setting and retrieving the comment associated with an
entry.
EXAMPLE
#!/usr/bin/perl -w
use strict;
use lfc;
# stat an existing entry in the LFC and print the GUID
my ($name,$stat,$guid,$res);
$name = "/grid/dteam/my.test";
$stat = lfcc::new_lfc_filestatg();
$res = lfc::lfc_statg($name,undef,$stat);
if ($res == 0) {
$guid = lfcc::lfc_filestatg_guid_get($stat);
print "The GUID for $name is $guid
";
} else {
my $err_num = $lfc::serrno;
my $err_string = lfc::sstrerror($err_num);
print "There was an error while looking for $name: Error $err_num ($err_string)
";
exit(1);
}
lfcc::delete_lfc_filestatg($stat);
EXAMPLE
#!/usr/bin/perl -w
use strict;
use lfc;
# list the replicas of a given entry, starting from the GUID
my ($guid,$listp,$flag,$num_replicas);
$guid = "6a3164e0-a4d7-4abe-9f76-e3b8882735d1";
$listp = lfcc::new_lfc_list();
$flag = $lfc::CNS_LIST_BEGIN;
print "Listing replicas for GUID $guid:
";
$num_replicas=0;
while(1) {
my $res = lfc::lfc_listreplica(undef,$guid,$flag,$listp);
$flag = $lfc::CNS_LIST_CONTINUE;
if (!defined $res) {
last;
} else {
my $rep_name = lfcc::lfc_filereplica_sfn_get($res);
print "Replica: $rep_name
";
$num_replicas++;
}
}
lfc::lfc_listreplica(undef,$guid,$lfc::CNS_LIST_END,$listp);
lfcc::delete_lfc_list($listp);
print "Found $num_replicas replica(s)
";
EXAMPLE
#!/usr/bin/perl -w
use strict;
use lfc;
# setting and retrieving a comment on a file
my ($file,$res,$bufspec,$buffer,$comment);
$file = "/grid/dteam/my.test";
$comment = "MyComment";
$res = lfc::lfc_setcomment($file,$comment);
if ($res != 0) {
my $err_num = $lfc::serrno;
my $err_string = lfc::sstrerror($err_num);
print "Problem while setting comment for $file: Error $err_num ($err_string)
";
exit(1);
}
$bufspec = "x".($lfc::CA_MAXCOMMENTLEN+1);
$buffer = pack($bufspec);
$res = lfc::lfc_getcomment($file,$buffer);
if ($res != 0) {
my $err_num = $lfc::serrno;
my $err_string = lfc::sstrerror($err_num);
print "Problem while reading the comment for $file: Error $err_num ($err_string)
";
exit(1);
}
$comment = unpack("Z*", $buffer);
print "Read back comment $comment
";
NOTES
The current interface to the lfc_getcomment(3), lfc_getcwd(3), lfc_readlink(3), lfc_seterrbuf(3) requires the passing of a suitably allo-
cated buffer (in a similar way to the C functions). However this is rather non standard in PERL. A future version of lfc perl interface may
do away with the need to setup the buffer before the call and to explicitly unpack the result afterwards.
SEE ALSO
LFC C interface man pages
LFC $Date: 2007/02/23 10:03:07 $ lfc_perl(3)