Hi, I have the following javascript file for which I am trying to develop a script to make online changes. The problem I can't follow is that when I do the following lines:
open FILE, "$js" or die $!; flock (FILE, 1) or die "Can't lock dev.js for reading"; my @all = <FILE>; close FILE;
The whole file gets slurped up into $all[0] which prevents me from looping through the array to find the lines I need.

I could presumably split the scalar on new lines, but since I don't understand the reason for it not being split up already I thought I'd hightail it over here and ask.

Thanks for any help given

function init() { menus[0] = new menu(138, "vertical", 14, 132, -2, -2, "#000099", " +#000099", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, "rollover:tr +i.gif:tri.gif", false, true, true, true, 12, true, 4, 4, "black"); menus[0].addItem("", "", 0, "left", "", 0); menus[0].addItem("", "", 22, "left", "", 1); menus[0].addItem("", "", 22, "left", "", 2); menus[0].addItem("", "", 22, "left", "", 3); //Sub Menu for 2nd Main Menu Item ("web building"): menus[1] = new menu(165, "vertical", 0, 0, -5, -5, "#000099", "#00 +0099", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, 62, false, true, fal +se, true, 6, true, 4, 4, "black"); menus[1].addItem("banda.htm", "", 22, "left", "100k - 150k", 0); menus[1].addItem("bandb.htm", "", 22, "left", "150k - 200k", 0); menus[1].addItem("bandc.htm", "", 22, "left", "over 200k", 0); menus[1].addItem("#", "", 22, "left", "", 4); menus[1].addItem("prty.htm", "NEWWIN", 22, "left", "", 0); //Sub Menu for 3rd Main Menu Item ("News"): menus[2] = new menu(165, "vertical", 0, 0, 0, 0, "#000099", "#0000 +99", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, "r +ollover:tri.gif:tri.gif", false, true, false, false, 0, true, 4, 4, " +black"); menus[2].addItem("rices.htm", "", 22, "left", "All Prices", 0); //menus[2].addItem("#", "", 22, "left", "", 5); //Sub Menu for 4th Main Menu Item ("Search"): menus[3] = new menu(165, "vertical", 0, 0, 0, 0, "#000099", "#0000 +99", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, "> +>", false, true, false, false, 0, true, 4, 4, "black"); menus[3].addItem("ntro.htm", "", 22, "left", "Introduction", 0); menus[3].addItem("rices.htm", "", 22, "left", "rices", 0); //menus[3].addItem("#", "", 22, "left", "", 6); //Sub Menu for Sub Menu "Sports News": menus[4] = new menu(135, "vertical", 0, 0, 0, 0, "#000099", "#0000 +99", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, 6 +2, false, true, false, false, 0, true, 4, 4, "black"); menus[4].addItem("ills.htm", "", 22, "left", "ills", 0); //Sub Menu for Sub Menu "Sports News": menus[5] = new menu(135, "vertical", 0, 0, 0, 0, "#000099", "#0000 +99", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, 6 +2, false, true, false, false, 0, true, 4, 4, "black"); menus[5].addItem("ills.htm", "", 22, "left", "ills", 0); //Sub Menu for Sub Menu "Sports News": menus[6] = new menu(135, "vertical", 0, 0, 0, 0, "#000099", "#0000 +99", "Arial", 9, "bold", "bold", "#FFCC00", "white", 1, "gray", 2, 6 +2, false, true, false, false, 0, true, 4, 4, "black"); menus[6].addItem("ills.htm", "", 22, "left", "ills", 0); }

2005-03-16 Janitored by Arunbear - added readmore tags, as per Monastery guidelines


In reply to file not being split at new lines by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.