Loop through scalar?

From: Jason Kinkade (jkinkade_at_datashelter.net)
Date: 09/28/04


Date: 28 Sep 2004 00:02:16 -0700

I have a scalar/variable ($var) that looks like:

Line1
Line2
Line3
Line4
etc.

Theres obviously a new line after each Line#. I would like to loop
through this variable line by line with something like

foreach ($var)
{
   print "Current Line: $_";
}

This reads the entire $var in. I want it line by line instead.

Any idea?
Thanks.



Relevant Pages

  • Re: slowing a script down
    ... When I add an alert to check it for each step of the loop, ... var stringWidth = new String; ... panelwidth = the character position where the string px is first found? ... can be re-used to animate any panel. ...
    (microsoft.public.scripting.jscript)
  • Re: Illegal LOOP usage?
    ... | reason would they even mention the WITH clause there? ... On the next iteration the loop variable would be bound with WITH to ... the constructs collect and collecting collect ... The argument var is set to the ...
    (comp.lang.lisp)
  • Dynamically generated functions not behaving as expected...
    ... that existed in the last iteration of the loop to all previous ... var ary = new Array; ... affect -- creating dymamic functions with varied data while iteration ...
    (comp.lang.javascript)
  • wait for event
    ... carry out a loop. ... var XYZDlg = function{ ... // This fires when the load event is initiated ...
    (comp.lang.javascript)
  • Re: How to "freeze" a constant into a closure?
    ... var x = new Object; ... function objects created in the same environment would share their ... above each iteration of the loop results in the creation of two function ... things could be re-used memory use for execution ...
    (comp.lang.javascript)