Why can't I force either array ref or scalar to be array in Perl?
$result = [ $result ] if ref($result) ne "ARRAY";
foreach .....
Tags: arrays perl scalar reference
Source: By Rudd Zwolinski as answer to the question
This code snippet was collected from stackoverflow, and is licensed under CC BY-SA 2.5
Related code-snippets:
- How do I unload byteArray with ActionScript3?
- How do I generate a tag cloud from an array using h1 through h6 for sizing?
- Redefining an attribute in Python with an index in array of objects using 'in'. If no object is found in an array of objects then it is not correct.
- Can you iterate through arrays in a classic asp vbscript?
- What's the safest way to iterate through the keys of Perl hash if you are an expert Perl developer?
- How do I remove duplicates from a Perl application?
- What is the best way to create objects in Perl?
- Assignment inside Perl ternary conditional operator problems. Assignment inside Perl ternary conditional operator problems.
- How do you retrieve selected text using Regex in C#?
- How do I get duplicates out of array in C#?
- Is it possible to parse attributes in Perl using regex?
- How do I determine the type of blessed reference in Perl?
- Why are my Perl Maps not returning anything?
- How can I tell if variable has numeric value in Perl?
- PHP: Access Array Value on the Fly (http:access ), the name of an array in PHP.