473,387 Members | 1,575 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Extracting values from a text file

2
(perl)

hi guys,

ive searched many places for a solution and cant find one.

problem:

i need to extract information about an image that is stored in a text file.

this information and the image is displayed on a html paged created by the same program.

i managed to create brokencar.html, and insert the image in.

this is just a small portion of my program

perl:

open HTML2, ">c:/cygwin/home/nife/$imageName.html";
print HTML2 "<head><title>$imageName.html</title></head>";
print HTML2 "<tr><td><center><img src='$imagesPath$images'></center></td></tr>";
close HTML2;


brokencar.txt:

Dimensions=> 800x600
Title=> Broken Car
Thu Nov 20 21:50:00 WST 2007=> "How shall I ever get home!


how do i grab "800x600", "Broken Car".
and display the comments, which may be multiple.

edit: i believe that the use of match & split maybe necessary.

please advice. time is of the essence.


thanks & cheers
May 23 '07 #1
1 1230
nife
2
no worries guys,

i think ive got it.

Expand|Select|Wrap|Line Numbers
  1. open (INFO, "$captionsPath$imageName.txt") or die "SCREWED!!!";
  2.  
  3. while ($thisLine = <INFO>) {
  4.     if ($thisLine =~ /Dimensions=>/){
  5.         ($garbage,$picSize) = split(/>/,$thisLine);
  6.         ($width,$height) = split(/x/,$picSize);
  7.  
  8.     } elsif ($thisLine =~ /Title=>/){
  9.         ($garbage,$title) = split(/>/,$thisLine);
  10.         print HTML2 "<body><center><H1>$title</H1>";
  11.  
  12.     } else{
  13.         print HTML2 "$thisLine\n";
  14.     }
  15. }
  16.  
needs some tweaking though, please excuse the "messiness"
May 23 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: lecichy | last post by:
Hello Heres the situation: I got a file with lines like: name:second_name:somenumber:otherinfo etc with different values between colons ( just like passwd file) What I want is to extract...
5
by: Michael Hill | last post by:
Hi, folks. I am writing a Javascript program that accepts (x, y) data pairs from a text box and then analyzes that data in various ways. This is my first time using text area boxes; in the past,...
7
by: nephish | last post by:
Hey there, i have a text file with a bunch of values scattered throughout it. i am needing to pull out a value that is in parenthesis right after a certain word, like the first time the word...
0
by: Bubbles | last post by:
Hello. New to ASP.NET and struggling on this one. I have a text file with a bunch of text in it. Throughout the file words followed by a ":" will appear. I need to pull every such string out...
2
by: Kevin K | last post by:
Hi, I'm having a problem with extracting text from a Word document using StreamReader. As I'm developing a web application, I do NOT want the server to make calls to Word. I want to simply...
16
by: Preben Randhol | last post by:
Hi A short newbie question. I would like to extract some values from a given text file directly into python variables. Can this be done simply by either standard library or other libraries? Some...
3
by: Clarisa | last post by:
Hello Folks I am working on extracting lines of data in a text file based on the string it contains. This is the text file called info.txt:
6
by: Werner | last post by:
Hi, I try to read (and extract) some "self extracting" zipefiles on a Windows system. The standard module zipefile seems not to be able to handle this. False Is there a wrapper or has...
1
by: TYR | last post by:
I have a large dump file that originated in a MySQL db; I need to get it into an SQLite file. Various options are suggested around the web; none of them seem to work (most failing to import the...
6
by: geegeegeegee | last post by:
Hi All, I have come across a difficult problem to do with extracting UniCode characters from RTF strings. A detailed description of my problem is below, if anyone could help, it would be much...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.