Thank you,
with all your help I have found the issue is the HTML file I am reading does not have unix lineends.
That is the problem.


Thanks again!

Albert

On Jan 5, 2005, at 3:14 PM, Albert Kaltenbaeck wrote:
I am having problems with the substr command.
It appears under OSX Perl the length value is being ignored.
This code worked under MacPerl with the old open statement being "open (THEFILE ,"<::clientd.html");".
All I changed was the open statement with a new path.
When I ask Perl OSX to print $line (the full string) I get the following...


<html>

<head>
<meta http-equiv="content-type" content="text/html;charset=ISO-8859-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="description" Content="Offline">
<title>P a u s e d</title>
<meta name="generator" content="Albert Kaltenbaeck">
<meta http-equiv="refresh" content="15">
<title>O f f l i n e</title>
</head>
<body bgcolor="#000000">
<IMG SRC="D:\offline.gif" WIDTH=400 HEIGHT=300 ALIGN=bottom>
</body>
</html>

Great! it is reading the file correctly. But when I ask Perl to print $playing (using the substr command) I get the following...

ntent-type" content="text/html;charset=ISO-8859-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="description" Content="Offline">
<title>P a u s e d</title>
<meta name="generator" content="Albert Kaltenbaeck">
<meta http-equiv="refresh" content="15">
<title>O f f l i n e</title>
</head>
<body bgcolor="#000000">
<IMG SRC="D:\offline.gif" WIDTH=400 HEIGHT=300 ALIGN=bottom>
</body>
</htm

It is starting at the beginning of the file and not the 6th line.
Using MacPerl I get the word "Offline" in the sixth line and hacking off the three characters on the end. (what I want)
I have tried using 167 as the offset and -3 as the length.
When I do this the starting point is correct but it does not seem to acknowledge the length value because I get the rest of the entire string.
Is there an issue now because I am using Unix line breaks and not Macintosh?


here is how I am using substr.

$. = 0;
open (THEFILE,"<../../../../Documents/ge/ClientD.html") or die "Line 96 " . (localtime) . " " . $! . "\n\n\n";
do {$line =<THEFILE>} until $. == 6 || eof;
close (THEFILE);
$playing = substr($line,35,-3);


Albert
Albert Kaltenbaeck
15324 West 144th Terrace
Olathe, Kansas 66062
(913) 780-3835 Home
(913) 206-4579 Cell



Reply via email to