Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

linkable data

Status
Not open for further replies.

Learningone

Technical User
Jan 18, 2003
2
US
OK here We go I have a script


sub mydata {
while (<DTA>) {
chomp;
my ($data)= split(/\t/,$_,2);
}

}


close(DTA);

#miles down

open (DTA, &quot;/MYPATH/dat.txt&quot;);
mydata;
print &quot; <a href=
is there a way to make mydata; print up and link to the set page?


:)
 
sub mydata {
while (<DTA>) {
chomp;
my ($data)= split(/\t/,$_,2);
###??? What are you doing here? Do you mean my @data
### also why ,2. Can you show an example of the line you are
### parsing and the eresult you want

}

}

Second, what do you mean make mydata? You call the subroutine It will do what you want
Next what is print up? You can have mydata print to where you want, no??

svar
 
sub mydata {
open (DTA, &quot;/MYPATH/dat.txt&quot;);

while (<DTA>) {
chomp;
my (@data)= split(/\t/,$_,2);
}
close (DTA);
open (FILE, &quot;>/Pathto/mydatapage.html&quot;);
#set the default end of line to undef
local $/;
#slurp the entire file into a scalar
$pagetomanipulate = <FILE>;
$final_page = tr/<%%sometaginthefile%%>/$data[0]/;
print FILE &quot;$final_page&quot;;
close (FILE);
}
Based on what you have given me this will open file dat.txt and split up the line passed.
Then open the target file. Match a tag you place like <%%sometaginthefile%%> and replace it with
the content in the first position of the line.
To call the mydata routine:
mydata();

OK we have a few problems here?? First we need to be clear on what we need to do. Where do you want to put the contents of dat.txt? Are they being printed to the screen another file? Be more specific on what your purpose.

I think I have read your mind. Let us know. We need to see the file format of the file you are reading.
 
First, try faq452-3023

I'm not exactly sure what you're asking, but if dat.txt contains properly formatted HTML, then...
Code:
print &quot;Content-type:text/html\n\n&quot;;
my $file = &quot;/MYPATH/dat.txt&quot;;
open (DTA, $file) || die &quot;Could not open $file: $!&quot;;
while (<DTA>) {print;}
Sincerely,

Tom Anderson
CEO, Order amid Chaos, Inc.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top