Advertisement

11.06.2003 at 12:14AM PST, ID: 20789531
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

Perl: Need to break STDIN while loop from within an if statement within another if statement.
Tags: perl, break, loop, while
While reading STDIN I need to be able to break out of the while loop and stop the STDIN from reading the rest of the file if a condition is met. This has to be done from an if statment imbedded in another if statement...   see below:


while(<STDIN>){

if(something){do soemthing}

if(something else){do somethingelse}

if(something here)
{
do stuff

   if(code is true)
   {
   break the while loop and stop the STDIN from continuing.
   }

do other stuff

}

I want to end up down here....    to continue the script after breaking the loop.




Any information would be much appreciated. Thanks :)

Start your free trial to view this solution
Question Stats
Zone: Programming
Question Asked By: dr34m3rs
Solution Provided By: kandura
Participating Experts: 3
Solution Grade: A
Views: 423
Translate:
Loading Advertisement...
11.06.2003 at 02:02AM PST, ID: 9693082

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 11:40AM PST, ID: 9696320

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 12:33PM PST, ID: 9696664

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 12:42PM PST, ID: 9696713

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 12:42PM PST, ID: 9696716

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 12:48PM PST, ID: 9696749

Rank: Sage

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
11.06.2003 at 01:17PM PST, ID: 9696951

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
09.27.2004 at 01:38PM PDT, ID: 12164108

All comments and solutions are available to Premium Service Members only.

Start your 7 day free trial and see for yourself why Experts Exchange is the easiest and most proven technology resource in the world. Get Started

Already a member? Login to view this solution.

 
 
Loading Advertisement...
Microsoft
  • Internet Protocols
  • Applications
  • Development
  • OS
  • Hardware
  • Windows Security
Apple
  • Operating Systems
  • Hardware
  • Programming
  • Networking
  • Software
Internet
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Spy / Ad Blockers
  • Web Browsers
  • New Net Users
  • Web Development
  • Chat / IM
  • Anti Spam
  • Web Servers
  • Anti-Virus
  • Email Clients
Gamers
  • Tips
  • Online / MMORPG
  • Puzzle
  • Emulators
  • Action / Adventure
  • Role Playing
  • Consoles
  • Game Programming
  • Strategy
  • Sports
  • Misc
  • Computer Games
Digital Living
  • Hardware
  • New Net Users
  • New Users
  • Software
  • Digital Music
  • Gaming World
  • Home Security
  • Apple
  • Networking Hardware
Virus & Spyware
  • Vulnerabilities
  • IDS
  • Encryption
  • Anti-Virus
  • Operating Systems Security
  • Software Firewalls
  • WebApplications
  • Cell Phones
  • Operating Systems
  • Internet
  • Hardware Firewalls
Hardware
  • Handhelds / PDAs
  • Displays / Monitors
  • Components
  • Networking Hardware
  • Peripherals
  • Laptops/Notebooks
  • Storage
  • Servers
  • Desktops
  • New Users
  • Misc
  • Apple
Software
  • System Utilities
  • Industry Specific
  • Network Management
  • Photos / Graphics
  • Page Layout
  • VMWare
  • Misc
  • Web Development
  • OS
  • CYGWIN
  • Voice Recognition
  • Message Queue
  • Quality Assurance
  • Security
  • Firewalls
  • MultiMedia Applications
  • Development
  • Database
  • Office / Productivity
  • Business Management
  • OS/2 Apps
  • Server Software
  • Internet / Email
ITPro
  • OS
  • Storage
  • Encryption
  • Operating Systems Security
  • Apple Hardware
  • Laptops & Notebooks
  • Servers
  • Networking Hardware
  • Peripherals
  • Devices
  • Displays / Monitors
  • WebTrends / Stats
  • Search Engines
  • Firewalls
  • WebApplications
  • IDS
  • Vulnerabilities
  • Email Clients
  • File Sharing
  • Spy / Ad Blockers
  • Web Browsers
  • Web Servers
  • Networking
  • Anti-Virus
  • Chat / IM
  • Anti Spam
Developer
  • Web Servers
  • Web Browsers
  • Game Programming
  • Dev Tools
  • Industry Specific
  • Office / Productivity
  • Database
  • CYGWIN
  • Web Development
  • Search Engines
  • File Sharing
  • WebTrends / Stats
  • Programming
  • Content Management
  • Application Servers
  • Protocols
Storage
  • Removable Backup Media
  • Storage Technology
  • Servers
  • Grid
  • Remote Access
  • Backup / Restore
  • Misc
  • Hard Drives
OS
  • Miscellaneous
  • Security
  • Development
  • Linux
  • VMWare
  • MainFrame OS
  • Unix
  • Apple
  • OS / 2
  • AS / 400
  • BeOS
  • Microsoft
  • VMS / OpenVMS
Database
  • Oracle
  • Miscellaneous
  • MySQL
  • Software
  • Sybase
  • Contact Management
  • PostgreSQL
  • Data Manipulation
  • Clarion
  • InterSystems Cache
  • Siebel
  • MUMPS
  • OLAP
  • SQLBase
  • SAS
  • GIS & GPS
  • 4GL
  • Berkeley DB
  • DB2
  • Informix
  • Interbase / Firebird
  • FoxPro
  • Reporting
  • LDAP
  • Filemaker Pro
  • MS SQL Server
  • dBase
  • MS Access
Security
  • Misc
  • Web Browsers
  • Software Firewalls
  • Operating Systems Security
  • File Sharing
  • Spy / Ad Blockers
  • Vulnerabilities
  • WebApplications
  • IDS
  • Anti-Virus
  • Encryption
  • Anti Spam
  • Email Clients
  • VPN
  • Chat / IM
Programming
  • Editors IDEs
  • Installation
  • Handhelds / PDAs
  • Multimedia Programming
  • System / Kernel
  • Algorithms
  • Game
  • Signal Processing
  • Project Management
  • Open Source
  • Database
  • Misc
  • Languages
  • Processor Platforms
  • Theory
Web Development
  • Scripting
  • Blogs
  • Web Servers
  • Software
  • Search Engines
  • Web Graphics
  • Images
  • Internet Marketing
  • Images and Photos
  • Components
  • Document Imaging
  • Web Languages/Standards
  • Illustration
  • WebApplications
  • Fonts
  • WebTrends / Stats
  • Authoring
  • Digital Camera Software
  • Miscellaneous
Networking
  • Protocols
  • Apple Networking
  • Network Management
  • Message Queue
  • Application Servers
  • Content Management
  • File Servers
  • Email Servers
  • Misc
  • Java Editors & IDEs
  • Wireless
  • Networking Hardware
  • Backup / Restore
  • System Utilities
  • ISPs & Hosting
  • Web Servers
  • Storage Technology
  • Removable Backup Media
  • Servers
  • Broadband
  • Grid
  • OS / 2
  • Novell Netware
  • Unix Networking
  • Windows Networking
  • Security
  • Telecommunications
  • Operating Systems
  • Linux Networking
Other
  • Community Advisor
  • Lounge
  • Community Support
  • New Net Users
  • Philosophy / Religion
  • Math / Science
  • Miscellaneous
  • URLs
  • Expert Lounge
  • Politics
  • Puzzles / Riddles
Community Support
  • Suggestions
  • New to EE
  • New Topics
  • Community Advisor
  • CleanUp
  • Announcements
  • General
  • Feedback
  • Input
  • EE Bugs
 
11.06.2003 at 02:02AM PST, ID: 9693082

Rank: Sage

Use 'last' keyword to do that. It will take you outside the enclosing loop.

Note that if you have another loop inside the outer loop, then last takes you outside the inner loop.
If you want to jump outside the outer loop, use a label just before the outer loop, and call 'last LABEL;' to jump out of the outside loop.

See the perlfunc manpage for a better description, but here's an example:

OUTER:                                  # a label for the outer loop
while($something) {
    # ... do stuff

     while($inner) {
         # ... do stuff
          last if $cond1;               # this will take you to COND1

          last OUTER if $cond2;    # this will take you to COND2
     }
     # COND1
     # do more stuff in outer loop
}
# COND2

HTH,
Kandura
 
11.06.2003 at 11:40AM PST, ID: 9696320
The label worked kandura, however it did not break the STDIN loop until after STDIN was finished reading the incoming data...

Basically my script reads the incoming data from an uploading file, finds out what the filename is and if a checkbox named overwrite was checked. If the filename exists and the overwrite box was not checked, I need to exit the STDIN loop before the upload data is read to 100%...    I don't want to keep people waiting around for an hour for their upload to finish, only to find out it already exists. ;)

Code as it is now::

OUTER;

while(<STDIN>){

         if(this exists){dothis}

         if(this exists){dothis}

         if(this is true && this is true)
         {
         &call_file_exists_sub;
         last OUTER;                       ### break to OUTER label, doesn't break STDIN data read though...
         }

}

I have add points on this question...
 
11.06.2003 at 12:33PM PST, ID: 9696664
Please describe what you are trying to accomplish by while(<STDIN>).  As you may be needing a different call as STDIN is buffered.
 
11.06.2003 at 12:42PM PST, ID: 9696713
I am capturing HTML upload from an HTML form. I am able to manipulate the upsteam while it's uploading, I just am unable to break out of the upload without closing/stopping the browser itself from uploading the data...
 
11.06.2003 at 12:42PM PST, ID: 9696716
upstream**
 
11.06.2003 at 12:48PM PST, ID: 9696749

Rank: Sage

Well, the loop has been exited, meaning that your script won't read more from STDIN unless you do that somewhere else.
What this doesn't do is tell the browser (or whoever is on the other end), that they should stop sending data.

Which, in general, you can't do.

You might try to close STDIN, but then you're no longer able to read from cliient request.
You might try to close STDOUT, but then you're no longer able to send data to the client.

The safest way is to call exit() , and be done with it altogether. Your script is done, and the webserver will tell the client that
no more data is needed, or going to arrive.

So try

    close STDIN;
    last OUTER;

and see how that works.

Else, print out anything you might still want to send to the client, and call exit().

Let us know...
Accepted Solution
 
11.06.2003 at 01:17PM PST, ID: 9696951
Kandura,

You are 100% right. The problem isn't the script, it's the browser.

Close STDIN didn't do anything for the browser...

The browser has no idea what is going on...   and just keeps sending data. So, I am going to give you the points, because now I understand it enough to be able to come up with a solution...   I hope. :)

I am thinking something with a javascript and flash combo always checking a server side file to see if code was written to it, and if the code is true, force browser to finish...    not sure though.

Any ideas?

Thanks  for all your help kandura :)
 
09.27.2004 at 01:38PM PDT, ID: 12164108
last OUTER will not work,  use  goto OUTER. By the way you can use exit. That will solve the purpose simply

 
 
20080236-EE-VQP-29