Click to See Complete Forum and Search --> : perl PRINT and FOREACH command


druss
01-20-2003, 10:06 PM
ok heres the deal.
a have a @html variable and i need it to be printed on one line within decrypt()


since javascript cannot have enters in its functions it make life hard for me.

Here is an example:

print "<script>decryptform(@html)</script>";

however the problem is that @html gets printed with enters when i need it to be on the same line.

This is what happens:

<script>decryptform(<html>
<body>
</body>
</html)</script>

when i need it to end up like this:

<script>decryptform(<html><body></body></html>)</script>


Thanks
Goran

jeffmott
01-20-2003, 10:48 PM
Assuming you havn't modified the list separator predefined variable, the values of @html must have line breaks in them.

# if \n is only at the end of each element
chomp @html;

# if \n is in varying positions in varying elements
tr/\n//d for @html;

druss
01-21-2003, 12:02 AM
neither of them worked.

This is my code, cant figure out the problem?

---------------------------------------------------
open(list,"$details[0]/$details[1].crypt");
@html = <list>;
close(list);

foreach $slot (@html) {

for ($i = 0; $i <= 25; $i++) {
$slot =~ s/$letters[$i]/$randalpha[$i]/g;
}
}

chomp @html;

print "<script>decryptform(@html)</script>";

exit;
---------------------------------------------------

Thanks
Goran

jeffmott
01-21-2003, 10:32 AM
Was the file you're reading from created on a different system than the script is running on? Since line terminators are different across platforms, that's the only reason I can come up with why neither one would work. Try this then:

tr/\x0a\x0d//d for @html;

If that doesn't work then either the system the program is running on doesn't use an ASCII compatable character encoding, or the new lines are created elsewhere.