I have to add a variable value to an array, something like this:
......
@my_array_name = $value_of_this_variable;
This doesnt seem to work, any ideas why?
Thanks! (4 Replies)
i have a file called file.txt having the following entries.
2321
2311
2313
4213
i wnat to store these values in a list and i want to iterate the list using loop and store it in another list (1 Reply)
Hi,
Is there an easy way to simulate following Perl code in Bash.
if ( grep {$my_value eq $_} @ARGV ){
print "Do Something\n";
} else {
die "Invalid value";
} (0 Replies)
Hi,
cut -d: -f1,3 /etc/group >rpt.out
I have a doubt in perl. right i am getting list of group user id into rpt.out file. instead i need to store it as an array in perl script. could you please tell me how can i get list of user into an array in perl script..
thanks in advance. (1 Reply)
Hi,
I have 2 arrays:
@names=qw(amith veena chaitra);
@files=qw(file.txt file1.txt file3.txt);
There is one to one relationship between names and files.
There needs to be mapping created between names and files.
The output should be like this:
amith --> file.txt
veena --->... (3 Replies)
Hi,
i want to search and replace array values by using perl
perl -pi -e "s/${d$i]}/${b$j]}" *.xml
i am using while loop for the same. if i excute this,it shows "Substitution replacement not terminated at -e line 1.".
please tell me what's wrong this line (1 Reply)
I have 2 files , i need compare both files field by field, and in the fourth field some value will be interchaged and some value will be **.
ex: file1 john|0.0|4|**:25;JP:50;UY:25
file2 john|0.0|4|JP:50;**:25;UY:25 (4 Replies)
I know that
@food = %fruit;
Works. But how do I assign %fruit and %veggies to @food ? (2 Replies)
Discussion started by: popeye
2 Replies
LEARN ABOUT REDHAT
hash::util
Hash::Util(3pm) Perl Programmers Reference Guide Hash::Util(3pm)NAME
Hash::Util - A selection of general-utility hash subroutines
SYNOPSIS
use Hash::Util qw(lock_keys unlock_keys
lock_value unlock_value
lock_hash unlock_hash);
%hash = (foo => 42, bar => 23);
lock_keys(%hash);
lock_keys(%hash, @keyset);
unlock_keys(%hash);
lock_value (%hash, 'foo');
unlock_value(%hash, 'foo');
lock_hash (%hash);
unlock_hash(%hash);
DESCRIPTION
"Hash::Util" contains special functions for manipulating hashes that don't really warrant a keyword.
By default "Hash::Util" does not export anything.
Restricted hashes
5.8.0 introduces the ability to restrict a hash to a certain set of keys. No keys outside of this set can be added. It also introduces
the ability to lock an individual key so it cannot be deleted and the value cannot be changed.
This is intended to largely replace the deprecated pseudo-hashes.
lock_keys
unlock_keys
lock_keys(%hash);
lock_keys(%hash, @keys);
Restricts the given %hash's set of keys to @keys. If @keys is not given it restricts it to its current keyset. No more keys can be
added. delete() and exists() will still work, but will not alter the set of allowed keys. Note: the current implementation prevents the
hash from being bless()ed while it is in a locked state. Any attempt to do so will raise an exception. Of course you can still bless()
the hash before you call lock_keys() so this shouldn't be a problem.
unlock_keys(%hash);
Removes the restriction on the %hash's keyset.
lock_value
unlock_value
lock_value (%hash, $key);
unlock_value(%hash, $key);
Locks and unlocks an individual key of a hash. The value of a locked key cannot be changed.
%hash must have already been locked for this to have useful effect.
lock_hash
unlock_hash
lock_hash(%hash);
lock_hash() locks an entire hash, making all keys and values readonly. No value can be changed, no keys can be added or deleted.
unlock_hash(%hash);
unlock_hash() does the opposite of lock_hash(). All keys and values are made read/write. All values can be changed and keys can be
added and deleted.
AUTHOR
Michael G Schwern <schwern@pobox.com> on top of code by Nick Ing-Simmons and Jeffrey Friedl.
SEE ALSO
Scalar::Util, List::Util, Hash::Util
perl v5.8.0 2002-06-01 Hash::Util(3pm)