CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner:
pattern with join hangs when printing



Dec 19, 2016, 8:52 AM

Post #1 of 3 (6057 views)
pattern with join hangs when printing Can't Post

This is my first experience using join and I'm wondering why this hangs. If I write it to a file handle, instead of an array it does not hang.
$pattern hangs after it prints out. If I wanted to stop it from hanging and return to command prompt, what is the best way?

my @bfilearr = `$bcmd`; 
print "This is @bfilearr";
my $pattern = join '|', @bfilearr;
print "THIS is $pattern\n";

Veteran / Moderator

Dec 19, 2016, 9:21 AM

Post #2 of 3 (6052 views)
Re: [regex2012] pattern with join hangs when printing [In reply to] Can't Post

What command are you running in $bcmd?

What happens when you run that same exact command from the command line instead of the script? Does it wait for user input?

There's nothing about the join statement that would cause the script to hang. Something else is causing it to hang.

Please post a short but complete test script that demonstrates the problem so that we can test it and try to duplicate the problem. If you do that, you will most likely learn the true cause of it hanging while writing that test script.

Veteran / Moderator

Dec 19, 2016, 9:26 AM

Post #3 of 3 (6051 views)
Re: [regex2012] pattern with join hangs when printing [In reply to] Can't Post

This statement might be where it's hanging.

print "This is @bfilearr";

Since the last element in the array does not contain a line terminator, you are probably "suffering from buffering". Turn of buffering by adding this above that code.


or add a line terminator to the statement.

print "This is @bfilearr\n";

(This post was edited by FishMonger on Dec 19, 2016, 9:29 AM)


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives