Copyright © tutorialspoint.com

PERL each Function


Syntax

each HASH


Definition and Usage

When called in list context, returns a 2-element list consisting of the key and value for the next element of a hash, so that you can iterate over it. When called in scalar context, returns only the key for the next element in the hash.

Return Value

  • See definition

Example

Following are the usage...This will print out all the environment variables.

    while (($key,$value) = each %ENV) {
	print "$key=$value\n";
    }

Copyright © tutorialspoint.com