Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re: glob quietly fails

by RichardK (Vicar)
on Oct 15, 2012 at 18:08 UTC ( #999146=note: print w/ replies, xml ) Need Help??

in reply to glob quietly fails

What are you expecting the first code example to do?

As it is, it creates an array of 2 strings each 129 characters long and then glob returns them. Which is working just fine for me ;)

UPDATE : Ah! your calling glob in scalar context! try a list context instead.

for my $g (glob(...) ) { }

Comment on Re: glob quietly fails
Download Code
Replies are listed 'Best First'.
Re^2: glob quietly fails
by remiah (Hermit) on Oct 15, 2012 at 20:06 UTC

    Hello RichardK.

    glob fails silently as QM saids with my perl. How does this code say with your platform?

    for (my $q =1; $q < 10000; $q++){ my @x = ( 'A' x $q, 'B' x $q ); my $glob = '{' . join(',', @x) . '}'; my $g = join(',', glob($glob)); if (length $g == 0){ print "fail silently, q=$q\n"; last; } }
    Mine stops saying
    fail silently, q=511
    perl -v
    This is perl 5, version 12, subversion 2 (v5.12.2) built for i386-freebsd-thread-multi-64int

Re^2: glob quietly fails
by Anonymous Monk on Oct 15, 2012 at 18:28 UTC

    UPDATE : Ah! your calling glob in scalar context! try a list context instead.

    Both are supposed to work

Re^2: glob quietly fails
by QM (Parson) on Oct 16, 2012 at 12:24 UTC
    As remiah and Anonymous Monk have stated, I expected while and for to behave the same way, and they do for me, on Strawberry Perl v5.16.1:
    #!/usr/env/perl use strict; use warnings; my $q = (shift or 129); # 128 is the largest working value my @x = ( 'A' x $q, 'B' x $q ); my $glob = '{' . join(',', @x) . '}'; while (my $g = glob($glob)) { print "while: $g\n"; } for my $g ( glob( $glob ) ) { print "for: $g\n"; } __EOF__ ################# # result: # while: for:

    Running this with a command line argument of 128 gives the expected output of 2 very long strings for while and 2 for for.

    Quantum Mechanics: The dreams stuff is made of

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2015-11-26 08:49 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (696 votes), past polls