CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
Inserting data from a tag

 



fds
Novice

May 9, 2012, 2:22 PM

Post #1 of 6 (7893 views)
Inserting data from a tag Can't Post

Hi, I am looking to inserting live data into the middle of a text field in a flat file database. I'll try to explain what I've done so far.

Text

Code
aaaa aaaa aaaa 
bbb bbb bbb bbb
<!-- ABC -->
ccccc ccccc ccc
ddd dd ddd dddd

The tag gets picked up by a read script and its sub routine fine. I can see the correct data, but it is after all the text, not in the middle of it. What I'm aiming for it for the data to be anywhere that tag is, regardless. If a tag is not there, the text reads as normal. This is to be part of my blog script, so I have to keep it as fast as I can.

This is the code I'm using in the sub that's called if the tag is there.

Code
if ($field[3] =~ m/<!-- ABC -->/ ) {require "abc.pl";} else {}

(abc.pl just has a call to the sub that reads the data file - that works fine)

Hope I've explained it right, kind of trial and erroring this 'cuz I'm outta my depth on it. I'm trying not to use a module if I can.

Hope someone can help.

Thanks - Ted
----------------------------------------------
fdsaadsfdsaf


FishMonger
Veteran / Moderator

May 10, 2012, 6:53 AM

Post #2 of 6 (7612 views)
Re: [Ted] Inserting data from a tag [In reply to] Can't Post


Quote
I'm trying not to use a module if I can.

Why?

Using a placeholder tag like that indicates that you probably should be using one of the template modules. If that really is a flat file database, then using a placeholder tag makes absolutely no sense.

It's not clear, but presumably you have multiple placeholder tags and that if block is being done in a loop which makes putting that require statement in there pretty odd and vary inefficient.


(This post was edited by FishMonger on May 10, 2012, 6:53 AM)


fds
Novice

May 10, 2012, 9:54 AM

Post #3 of 6 (7523 views)
Re: [FishMonger] Inserting data from a tag [In reply to] Can't Post


Quote
makes putting that require statement in there pretty odd and vary inefficient

Yeah it is, isn't it. Instead of the require I've a sub call.

It's all inside a FFDB. SSI's are used to access the data from static HTML pages, so that way I don't have to rewrite the actual files, which is why I don't use a template module. I just use a one very small template file from which the static file is produced with the correct SSI code for that record - works out about a 500 times smaller than a module. Only use them when it's absolutely necessary.

The whole thing is just an idea (early in the morning :-) ). So if I say have data that changes, then it does the work and I don't have to edit the record. That data could come from anywhere.
----------------------------------------------
fdsaadsfdsaf


FishMonger
Veteran / Moderator

May 10, 2012, 10:10 AM

Post #4 of 6 (7514 views)
Re: [Ted] Inserting data from a tag [In reply to] Can't Post

Using a proper template module and a mysql (or similar) db would be far more efficient and easier to maintain.

If you need help fixing the parsing and substitution of the tag elements, then you'll need to show us the code that you're currently using.


fds
Novice

May 10, 2012, 10:47 AM

Post #5 of 6 (7493 views)
Re: [FishMonger] Inserting data from a tag [In reply to] Can't Post

I'm gonna jump on that.

MYSQL is huge, complicated and overkill for most of the situations that people "think" they need to use it for. Yeah it's fine for Gigabytes of data, but some other platforms are better.

Your average blog will probably never exceed 10mb of data (always text) in many years. So I use 2 FFDBs and relate them (via ID) in a few lines of code. Maybe 10-15 years ago single FFDB's were slow, but they were peripheral bound - like 90% of all computing equipment. Nowadays with dual and quad core processors and 7500 - 15,000 rpm drives, means you can process a small FFDB (10mb or less) a ton faster than having to invoke a massive engine like MYSQL. It is plain just not needed except to feed programming arrogance and it is time we got off our high horses and recognized the fact.

If I'd wanted to use SQL, it'd have been SQLite as it is faster, smaller and does everything needed for a blog (even Movable Type does that) - but is still overkill for my purposes.

I came with a simple question and as always with most of these types of forums, it was a waste of time.

No more.

If you want to over complicate things, that's your problem and I'm not wasting another second here. I got better things to do.

PS, No doubt people will add furtive little comments, but that's just proving the programming arrogance point I have already made.
----------------------------------------------
fdsaadsfdsaf


FishMonger
Veteran / Moderator

May 10, 2012, 11:13 AM

Post #6 of 6 (7478 views)
Re: [fds] Inserting data from a tag [In reply to] Can't Post

Why are jumping off the deep end and being so upset?

I'm offering to help you with your current parsing and file updating, but can't do that without seeing what you're currently doing.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives