Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: glob quietly fails

by RichardK (Parson)
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(...) ) { }

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
    
    regards.

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.

    -QM
    --
    Quantum Mechanics: The dreams stuff is made of

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://999146]
help
Chatterbox?
[thepkd]: some guy was suggesting $aohoaoh[0]->{'foo '}[0]->{}. This wouldnt work.
[GotToBTru]: you're mixing notation there I think
[GotToBTru]: $aohoaoh->[0] is a hash reference, so $aohoaoh->[0]->{ key1} would work
[1nickt]: If 1nickt is the some guy, that's not what he said.
[GotToBTru]: thepkd might not know about last hour of cb
[1nickt]: my $x = $aohoaoh->[0]->{' foo'}->[0]->{'bar' }; should work
[thepkd]: its not $aohoaoh->[0]. its $aohoaoh[0]->{'foo '}. Tried it. Its working. Thnaks

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (12)
As of 2016-12-06 13:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:













    Results (105 votes). Check out past polls.