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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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

 



regex2012
User

Dec 19, 2016, 8:52 AM

Post #1 of 3 (5237 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?


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



FishMonger
Veteran / Moderator

Dec 19, 2016, 9:21 AM

Post #2 of 3 (5232 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.


FishMonger
Veteran / Moderator

Dec 19, 2016, 9:26 AM

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

This statement might be where it's hanging.

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

Code
$|++;

or add a line terminator to the statement.

Code
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