Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Reading from an array using angle brackets

by thundergnat (Deacon)
on Jan 23, 2013 at 21:58 UTC ( #1015036=note: print w/ replies, xml ) Need Help??


in reply to Reading from an array using angle brackets

The array inside the angle brackets is a glob, (see perldoc -f glob) and while you probably could get away with using that for an array of alpha-numeric strings, things will behave much differently if there are any shell expansion metacharacters in it.

You probably will not get what you expect if you use anything more complicated than a single array of alpha-numeric strings.

use strict; use warnings; my @A = qw/a b c/; my @B = qw/1 2 3/; print "$_\n" for <@A,@B>; print '*' x 10, "\n"; print "$_\n" for (@A,@B);
a
b
c,1
2
3
**********
a
b
c
1
2
3

So,

  1. Yes it is documented
  2. Yes, there are gotchas, especially if you are abusing it for the wrong reasons.
  3. Yes, I have used globs in several scripts, though I used them for their correct purpose, not for their side effects


Comment on Re: Reading from an array using angle brackets
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1015036]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-09-22 08:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (185 votes), past polls