Template

2001-03-23 Thread Nikola Knezevic

Hi,
I'm doing some page generation. In that page would be some (HTML) SELECT
fields, whose contents would be pulled from database.
I've decided to use Template module and to make whole job as elegant as it
can be.

The table from which the data is pulled looks something like this
TABLE kategorija
 katid CHAR[4]
 name  VARCHAR[20]

*
I can create SELECT object simply by fetching whole table, generating an
array of katid's and hash of katid => name pairs.
Then I can simply pass to $query-scrolling_list() reference to the first
array, and a hash. And the pass the result to template.
This isn't very memory savvy alghorhytm, but what to do...

**
Then I make everything little trickier. What if there is an error in users
input. The page has to be shown again, indicating where the error is, AND
leaving everything else intact, just to save the users from retyping.
This is simple, just fetch with $query->param users's choices in that SELECT
field, and pass reference to that array to scrolling_list() method of CGI.
After that, the resulting construct can be passed to Template module.

Both of these look somewhat clumsy and plain, eating much memory...

So for the * I came to another idea:
to use Template plugin DBI.
So, after fetching one row, build OPTION field, et voila:
 [% arr.1 %]
etc.

But how can I set preselected fields as described in **???

Another question:
If I write at the script's begining:
use CGI;
use Template;

and in template file:
[% USE CGI %]
would CGI module be loaded twice?


-- 
...  Kako jogurt moze da bude topli obrok?

     - --- -- ---=- --==---===-[Nikola Knezevic]---===+
+- -=- -==--=- -=-- --- -- - http://users.hemo.net/indy --- -- -



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: viewing PODs

2001-03-08 Thread Nikola Knezevic

Dana 07.03.01, [EMAIL PROTECTED] napisa:

> Next, you can update the ActiveState TOC file like so
> >perl -MActivePerl::DocTools -e"ActivePerl::DocTools::WriteTOC()"
> - it will pick up newly added html file(s).

That's what I was searching for.
Many, many thanks.
And now, just to check it, but I'll have to wait. Next 3 weeks I'll be
without my home system, just linux && terminals...

-- 
... /\/\/\/\/\/\/\/\/\/\/\/\  <- Zavijajuci tag u trajanju od 60 sek.

     - --- -- ---=- --==---===-[Nikola Knezevic]---===+
+- -=- -==--=- -=-- --- -- - http://users.hemo.net/indy --- -- -


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: viewing POD

2001-03-07 Thread Nikola Knezevic

>> >AS Perl ships with POD in HTML format. PPM installs POD in HTML
>> >format.
>> Yes it does. But, it can't convert allready installed PODs to HTML
>> (installed without PPM).

>ok then, last suggestion (the brute force method): instead of
installing
>modules with nmake install, create the html pod (pod2html), make a
>blib/html/lib/site (site/lib for 5.6 builds) dir, move the html files
there
>and build a PPM distro of the module then install that (or do a
minimal
>pod2html and figure out how PPM gets that into the html reference).

And that I'll do (the last part). I'll write what I discovered and
managed to do...

t

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: viewing POD

2001-03-07 Thread Nikola Knezevic

>> I think that I'll need to fire up VC++ and write something that will
do
>> what I need.
>overkill. Think Perl (you can't possibly be the first to want this).

Nope. What I need cannot be done in perl (well, it can, but I have to
use Tk and similar).
And I'm familiar with MFC and C++, so...

>> Quick question follows:
>> How to do this > order perldoc not to output in plaintext, rather in
>> HTML??
>> I'll then just set PAGER to opera, and everything is OK... (for
now).

>AS Perl ships with POD in HTML format. PPM installs POD in HTML
format.
Yes it does. But, it can't convert allready installed PODs to HTML
(installed without PPM).

>perldoc perldoc | perl -MPod::Html -e
>"pod2html(\"--outfile=$ENV{TEMP}/pod.html\");system \"Start
>$ENV{TEMP}/pod.html\";unlink \"$ENV{TEMP}./pod.html\";"

Nice, but it doesn't work on Win95 command prompt... w/ or w/o DosKey.



___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: viewing PODs

2001-03-06 Thread Nikola Knezevic

>> And now the next QOD:)
>> Does anyone knows an utility suitable for viewing POD files. perldoc
is
>> good, but is there somehing which works in win32 GUI???
>Look in the .../perl/bin dir for some bat files that start with
pod2... 
>That should give you some ideas.

pod2html and brothers:)

I'm using pod2html, but it isn't god as real pods are. pod2html doesn't
always produce a nice html as it should, and links may be corupted. So,
pods are IN. I want to view pod, but in windows, not in a dos prompt
(it hard to read in that dark:))

Someone mentioend www.perldoc.com. Thats OK, but I cant allwaysgo
online just to see sam man page. (but I cant download whole site) :)
ActiveState documentation is good, and extends when you add new modue
through PPM. But I don't want to use PPM, it much comfortable to go
standard way. Doing this installs new documentation in pod style, but
doesn't add html pages:(


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



RE: creating unique ID's

2001-03-05 Thread Nikola Knezevic

>If this is just for a SQL database it is MUCH more efficient to use an
>integer as a unique ID.  If you're using MS SQL Server and don't care
about
>portability just take advantage of the IDENTITY property of a table.
SQL
>itself will ensure a unique, auto-incrementing primary key without the
id
>needing to be manually specified while inserting data.  On the off
hand you
>need to generate a unique id within Perl itself (for session states,
etc),
>another non-portable approach is to call CoCreateGUID using
Win32::API.

The sad part of the story is that it has to be portable. And the target
DBMS is MySQL.
Nice idea about using integer which is much faster, but I still to
check for existance of that UID in the DB.
Thanks.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: creating unique ID's

2001-03-05 Thread Nikola Knezevic

>> Does anyone knows a better way to accomplish the same thing, and
which
>> would be faster and more perlish?

>I'm not sure if my proposed solution is more perlish or not but
>it seems to me that UID is not a very good way to identify individual
>e-mails. That is unless the rule is each user is only allowed one
>e-mail. I think a better unique e-mail identifier would be the
>Message-ID: header value. That item is supposed to be unique over
>all e-mails. 

One user = one email. As I've said before, when I started creating
database, I took email as a primary key. It is unique in the database,
only problem is that it is to long.
Message-ID is a nice solution, but its (again) to long. 16 chars to 6
chars...
Also, I forgot to say, there would be less than 200.000 emails.

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



creating unique ID's

2001-03-05 Thread Nikola Knezevic

Hi,
I'm still wondering about compiling problems, but today's question is
totally different.

I'm creating a database which would contain many emails (that should be
unique). In that database would be 4-5 tables, and every one's primary
key should have a reference to 'the main table' which primary key is
email. But, emails can be very long, so having emails as part of
primary key is complete waste of time & space. So I want to assign UID
to every email. I gave a fixed length of 6 to every UID, and used this
simple way to generate it:

input is email as string

my $lett = substr($email, 0, 2);
my $num = fill_to_4_fields(0); #also truncates to len 4

my $sth = $dbh->prepare('SELECT COUNT(*) FROM email_table WHERE email =
?');

$sth->execute($lett.$num);
$cnt = 0;

while (scalar $sth->fetchrow_array()) {
if ($num = ) {
$ka = '';

$lett =~ s{([a-z0-9])$}{ $ka = $1; $ka =~ tr/0-9a-z/1-9ab-z0/;
$ka;}e;
$cnt++;
if ($cnt == 37**2) die('cannot create UID');

if ($cnt % 36 == 0) {
$lett =~ s{^([a-z0-9])}{ $ka = $1; $ka =~ tr/0-9a-z/1-9ab-z0/;
$ka;}e;
}
}
$num = fill_to_4_fields($num+1);
$sth->execute($lett.$num);
}   

But this seems a little bit slow and not so elegant. And it fails after
37**2 * 1 users that should be enough. Only pitfall is 37**2 *1
requests to DB:(

Does anyone knows a better way to accomplish the same thing, and which
would be faster and more perlish?

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Problems with instalation of XML::Parser 2.30

2001-02-04 Thread Nikola Knezevic

Dana 04.02.01, David LaPointe napisa:

> If the goal is to just get PPM fixed, there may be a faster way to do that.
> Why not just try using the MSI installer to uninstall Perl and then
> re-install it? I've done that a couple of times in the last couple of weeks,
> and it seems to work pretty well. Back up your C:\Perl\site\lib\ppm.xml so
> you won't loose the list of installed modules, but otherwise it should be
> O.K. See if that repairs the problem. If it works, it will have been a lot
> faster than trying to wade through all those compiler errors. No?

Nope, First of all, I'm using Perl 5.005. Second of all, there are many
modules installed 'by hand', without using ppm, but they were without c
parts. Third of all, I'm on 486 (yeees, that exists), so, any reinstalling
would be very painfull and lasting operation.
But, thanks for suggestion.

My goal is to find why @@@!#!!$%!$ expat won't compile, and how to do that
kind (with c parts) of module installation by hand.

-- 
... Dete je naslo kutiju sibica. I bi svetlost!

 - --- -- ---=- --==---===-[Nikola Knezevic]---===+
+- -=- -==--=- -=-- --- -- - http://users.hemo.net/indy --- -- -


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: file-uploads send as attachments

2001-01-31 Thread Nikola Knezevic

Dana 30.01.01, Paul Popour napisa:

> > > But, what to do if there are more file-upload fields???
> > > Simple solution is to repeat above algorhythm for every file. No so
> > > elegant... Is there a better way to accomplish the same thing

> I believe the proper format for multi-file attachments in Mail::Sender is
> $output = "$file1, $file2, $file3";
>  ref ($sender = new Mail::Sender({from => $from,
>  smtp => $smtp})) or die "$Mail::Sender::Error\n";
>  (ref ($sender->MailFile({to =>$recipients, subject => $subject,  msg =>
> $msg,  file => $output }))
>and print "Mail sent OK.\n") or die "$Mail::Sender::Error\n";
>  }


OK, I know that. But the problem is (once more):
CGI passes file-handle to file that is uploaded (and I expect it isn't on
the systems' file-system. Mail::Sender expects filename. How to connect
these two?? Option is to create tempfile, flush from the filehandle to
tempfile and finally add that file to message. Then, repeat this for every
file. (message than has mult attachments). But, I want to skip 'flush from
filehandle to tempfile' and pass FH directly to Mail::Sender::SendFile.

BTW, is there some module for creating temp files. (something like mk_temp
in linux)???
-- 
... Vriste mala deca na haubi moga keca.

 - --- -- ---=- --==---===-[Nikola Knezevic]---===+
+- -=- -==--=- -=-- --- -- - http://users.hemo.net/indy --- -- -


___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users



Re: Regular Expression question

2000-10-05 Thread Nikola Knezevic

> I am curious, why does this exact same question keep showing up, from
> different people (I believe) and with a spaced regularity over and over
> again?

I don't know, but you are right.
The most FAQ is : How to send attachments?
The second place is reserved to: How to fetch rows?
The third : How to split line?

This is due to lack of proper (or any) search capability in mail
archive.
I wonder will there be any??

Why doesn't someone write a FAQ regarding all questions (and answers)
that pops up every week or two? this will bring a great relief to
everyone.
And then the guys from ActiveState should insert notification for
newcomers to check the FAQ first.


-- 
"If you were supposed to understand it,
we wouldn't call it code."
  -=- Knezevic Nikola -=-

___
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
http://listserv.ActiveState.com/mailman/listinfo/perl-win32-users