[17736] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5156 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 20 06:05:37 2000

Date: Wed, 20 Dec 2000 03:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <977310313-v9-i5156@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 20 Dec 2000     Volume: 9 Number: 5156

Today's topics:
        Antwort: Re: execute a Perl Programm with DBD:DBI - SQL gerhard.hann@generali.at
    Re: beginner question <a.v.a@home.nl>
        File::Find - meaning of 'symlinks'? (Philip Lees)
    Re: File::Find - meaning of 'symlinks'? <timallen449@coldmail.com>
    Re: File::Find - meaning of 'symlinks'? (Eric Bohlman)
        How can I access the checkbox value of a form in Perl? <s997659@ee.cuhk.edu.hk>
    Re: How can I access the checkbox value of a form in Pe (Chris Fedde)
    Re: How can I do this with perl? Tar Tricks (Chris Fedde)
    Re: how to invalidate a hash value during a foreach loo (Philip Lees)
    Re: if i send an e-mail (Martien Verbruggen)
    Re: if i send an e-mail <a.v.a@home.nl>
    Re: if i send an e-mail (Rafael Garcia-Suarez)
    Re: is this bad perl programming habit? <uri@sysarch.com>
    Re: is this bad perl programming habit? (Abigail)
    Re: just mucking about with splits <bart.lateur@skynet.be>
    Re: Language evolution C->Perl->C++->Java->Python (Is P <bart.lateur@skynet.be>
    Re: Language evolution C->Perl->C++->Java->Python (Is P <ulrich.hofstoetter@visualanalysis.com>
        Need a little Help to have a blank space (I am not a pr <jennie_halt@hotmail.com>
    Re: Need a little Help to have a blank space (I am not  (Rafael Garcia-Suarez)
    Re: Need a little Help to have a blank space (I am not  <timallen449@coldmail.com>
        No embeding please! (timothy)
        overriding 'print' (B. Thomas Adler)
        perl DBI <a.v.a@home.nl>
    Re: perl DBI (Rafael Garcia-Suarez)
    Re: perl DBI <a.v.a@home.nl>
    Re: perl DBI <Jerome.Abela@free.fr>
    Re: perl DBI <a.v.a@home.nl>
    Re: perl DBI <johngros@Spam.bigpond.net.au>
    Re: Perl to TCP/IP Connection & Overall Direction Neede mexicanmeatballs@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Wed, 20 Dec 2000 08:59:56 GMT
From: gerhard.hann@generali.at
Subject: Antwort: Re: execute a Perl Programm with DBD:DBI - SQL-Statements in a file
Message-Id: <gy_%5.13$zw5.1943@nreader1.kpnqwest.net>

This is a multipart message in MIME format.
--=_alternative 00317046412569BB_=
Content-Type: text/plain; charset="us-ascii"

the problem is - it is a file delivered from Oracle:
1) there is not just one line per statement
2) there is text with rem inside => perl cannont interpret rem 

thanks for your help
Gerhard Hann
--=_alternative 00317046412569BB_=
Content-Type: text/html; charset="us-ascii"




<br><font size=1 face="sans-serif">the problem is - it is a file delivered from Oracle:</font>
<br><font size=1 face="sans-serif">1) there is not just one line per statement</font>
<br><font size=1 face="sans-serif">2) there is text with rem inside =&gt; perl cannont interpret rem </font>
<br>
<br><font size=1 face="sans-serif">thanks for your help</font>
<br><font size=1 face="sans-serif">Gerhard Hann</font>
--=_alternative 00317046412569BB_=--


------------------------------

Date: Wed, 20 Dec 2000 09:45:23 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: beginner question
Message-Id: <3A408017.1FFEAFC8@home.nl>

Martin Schmidt wrote:

> Hi,
> I'm writing a perl program that uses a few array variables named
> something like
> @array1, @array2, @array3
>
> I want to access them using a variable to represent the number.
> $num = 1;
>
> @array$num            These don't work.
> @array{$num}
> @array${num}
>
> Any idea how to access an array using a scalar as part of the name?
>
> Thanks
> Martin
> mcs2@pitt.edu

---

$array[1]
$array[$num]   these work

---




------------------------------

Date: Wed, 20 Dec 2000 08:09:49 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: File::Find - meaning of 'symlinks'?
Message-Id: <3a40688a.64867214@news.grnet.gr>

The File::Find documentation says, under Bugs:

'There is no way to make find or finddepth follow symlinks.'

Is that why my text search algorithm works fine on the HD but can't
find anything on a CD-ROM?

(Windows NT, I'm afraid)

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


------------------------------

Date: Wed, 20 Dec 2000 12:04:25 +0100
From: "tim allen" <timallen449@coldmail.com>
Subject: Re: File::Find - meaning of 'symlinks'?
Message-Id: <91q32r$8t4$1@diana.bcn.ttd.net>

"Philip Lees" <pjlees@ics.forthcomingevents.gr> wrote in message
news:3a40688a.64867214@news.grnet.gr...
>Is that why my text search algorithm works fine on the HD but can't
>find anything on a CD-ROM?

Philip, can you post the code you are using, or the psuedo code of the
algorithm?  Without those, you probably won't get a good answer.  Take
care. -tim
--
unmunge?cold=hot





------------------------------

Date: 20 Dec 2000 11:02:00 GMT
From: ebohlman@omsdev.com (Eric Bohlman)
Subject: Re: File::Find - meaning of 'symlinks'?
Message-Id: <91q3j8$kmb$3@bob.news.rcn.net>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote:
> The File::Find documentation says, under Bugs:

> 'There is no way to make find or finddepth follow symlinks.'

> Is that why my text search algorithm works fine on the HD but can't
> find anything on a CD-ROM?

> (Windows NT, I'm afraid)

Doubtful, since NT doesn't have symbolic links (a feature found in Unix,
among other, file systems that allows multiple names in
(potentially) multiple directories to all refer to the same physical file
or directory; sort of like shortcuts except that they're implemented at
the file system level rather than the user interface level).



------------------------------

Date: Wed, 20 Dec 2000 13:06:11 +0800
From: Immortal Love <s997659@ee.cuhk.edu.hk>
Subject: How can I access the checkbox value of a form in Perl?
Message-Id: <Pine.GSO.4.05.10012201301530.24493-100000@sparc53.ee.cuhk.edu.hk>

I have a form in html and there is a group of checkbox, say
<input type="checkbox" name="medium" value="internet">Internet<br>
<input type="checkbox" name="medium" value="friends">Friends<br>
<input type="checkbox" name="medium" value="itsc">Activities<br>

then how can i know which one is being checked?

in Perl, i know $FORM{' '} can call a value.

thanks



------------------------------

Date: Wed, 20 Dec 2000 05:33:53 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How can I access the checkbox value of a form in Perl?
Message-Id: <5xX%5.355$B9.189437440@news.frii.net>

In article <Pine.GSO.4.05.10012201301530.24493-100000@sparc53.ee.cuhk.edu.hk>,
Immortal Love  <s997659@ee.cuhk.edu.hk> wrote:
>I have a form in html and there is a group of checkbox, say
><input type="checkbox" name="medium" value="internet">Internet<br>
><input type="checkbox" name="medium" value="friends">Friends<br>
><input type="checkbox" name="medium" value="itsc">Activities<br>
>
>then how can i know which one is being checked?
>
>in Perl, i know $FORM{' '} can call a value.
>
>thanks
>

Read all about CGI.pm at 

    http://theoryx5.uwinnipeg.ca/CPAN/data/CGI.pm/CGI.html

Good luck
-- 
    This space intentionally left blank


------------------------------

Date: Wed, 20 Dec 2000 05:26:08 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: How can I do this with perl? Tar Tricks
Message-Id: <QpX%5.353$B9.189435904@news.frii.net>

In article <91ogji$fnf$1@nnrp1.deja.com>,
Mark Watkins  <mwatkins@lexmark.com> wrote:
>I have a little crontab script which backs up a directory from a server
>to a backup, it looks like this:
>
>#!/bin/ksh
>
>echo $(hostname) backup_Mickey_2_Donald STARTED...$(date) > /tmp/$$
>tar cf - /home | (rsh Donald -l root "cd /; rm -rf /home > /dev/NULL
>2>&1; mkdir /home > /dev/NULL 2>&1; cd /home; tar xf -")
>echo $(hostname) backup_Mickey_2_Donald ENDED...$(date) >> /tmp/$$
>
>mail -s 'Backup Mickey 2 Donald' me@myserver < /tmp/$$
>
>This works just fine, however I would like to re-write it using perl
>and maybe put in some checks to see if it all got there and there were
>no errors.
>

There are something that the shell is just better for than any
other tool.  It turns out that running the kind of command line
that you have here is one of them. Sure it could be translated to
perl, but why bother?  I might be tempted to use 'tar cvf - 2> logfile'
on one end to collect an index of what gets archived then to come
up with some kind of comparison routine.  I might also think about
formating the pipe a bit better.  And maybe going to ssh instead
of rsh.  But I see no reason to go to Perl for this.

    #!/bin/sh

    echo $(hostname) backup_Mickey_2_Donald STARTED...$(date) > /tmp/$$

    tar cvf - /home 2>/tmp/backup.log |
    (
	rsh Donald -l root '
	    cd /;
	    rm -rf /home > /dev/NULL 2>&1;
	    mkdir /home > /dev/NULL 2>&1;
	    cd /home; tar xf -
	'
    )

    echo $(hostname) backup_Mickey_2_Donald ENDED... $(date) >> /tmp/$$

    mail -s 'Backup Mickey 2 Donald' me@myserver < /tmp/$$

    rm /tmp/$$
    exit 0
-- 
    This space intentionally left blank


------------------------------

Date: Wed, 20 Dec 2000 07:32:07 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: how to invalidate a hash value during a foreach loop?
Message-Id: <3a405fda.62643055@news.grnet.gr>

On Tue, 19 Dec 2000 15:18:45 GMT, "Olwynn" <info@jjmackay.ca> wrote:

>I am sure that the problem lies in the line
>
>if(values(%form_results)!='')

For string comparisons, use ne instead of !=.

See perlop for more (Equality Operators).

Phil
--
Philip Lees
ICS-FORTH, Heraklion, Crete, Greece
Ignore coming events if you wish to send me e-mail
'The aim of high technology should be to simplify, not complicate' - Hans Christian von Baeyer


------------------------------

Date: Wed, 20 Dec 2000 16:10:28 +1100
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: if i send an e-mail
Message-Id: <slrn940fq4.8i7.mgjv@martien.heliotrope.home>

On Tue, 19 Dec 2000 15:19:44 -0000,
	carlo costa <carlo@netverk.net> wrote:
> 
>  I am  trying to send a-mail in a perl program,

The Perl FAQ, part 9 talks about this:

=head2 How do I send mail?

The FAQ is installed on any machine that has Perl, and is accessible
with the man or perldoc commands.

Alternatives to the methods discussed in the answer to that question can
be found on CPAN. http://search.cpan.org/

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | Make it idiot proof and someone will
Commercial Dynamics Pty. Ltd.   | make a better idiot.
NSW, Australia                  | 


------------------------------

Date: Wed, 20 Dec 2000 09:43:50 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: if i send an e-mail
Message-Id: <3A407FBA.52E6E115@home.nl>

carlo costa wrote:

> Hi There,
>
>  I am sorry to bother you, but i have a problem and I do not menage to get
> out of it,
>
>  I am  trying to send a-mail in a perl program,
>
>  can you spend few lines to explain me how can I sand an e-mail in a perl
> program (I am looking for a module witch allow me to send without inserting
> any SMPT server)... please, telme where I can find some exemples or
> something to read about .
>
>  I am sorry but I just started programming in perl and I need to solve this
> problem.
>
>  Thanx
>
>  B. W.
>
>  Carlo

----

open (MAIL, "| /usr/lib/sendmail -t") || die "Couldnt open mail: $! ";
print MAIL "To: carlo\@netverk.net\n";
print MAIL "Subject: TEST\n";
print MAIL "From: carlo\@netverk.net\n";
print MAIL "Cc: carlo\@netverk.net\n";
print MAIL "This is a test\n";
print MAIL "to see if this works\n";
close(MAIL);

-----
there you go.



------------------------------

Date: Wed, 20 Dec 2000 09:57:10 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: if i send an e-mail
Message-Id: <slrn9410j1.nt3.rgarciasuarez@rafael.kazibao.net>

AvA wrote in comp.lang.perl.misc:
> carlo costa wrote:
> >  can you spend few lines to explain me how can I sand an e-mail in a perl
> > program (I am looking for a module witch allow me to send without inserting
> > any SMPT server)... please, telme where I can find some exemples or
> > something to read about .
> 
> open (MAIL, "| /usr/lib/sendmail -t") || die "Couldnt open mail: $! ";

You should include the -oi switch, to avoid truncating the message if it
contains a line with a single dot.

By the way, sendmail _is_ an SMTP server. Even if it doesn't run as a
daemon on the machine. And this method works only on UNIX machines with
a properly configured sendmail. There are caveats.

> print MAIL "To: carlo\@netverk.net\n";
> print MAIL "Subject: TEST\n";
> print MAIL "From: carlo\@netverk.net\n";
> print MAIL "Cc: carlo\@netverk.net\n";

A \n is missing here, to separate the headers from the body.

> print MAIL "This is a test\n";
> print MAIL "to see if this works\n";
> close(MAIL);

Always check the return status of close when you have open a pipe.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: Wed, 20 Dec 2000 05:11:47 GMT
From: Uri Guttman <uri@sysarch.com>
Subject: Re: is this bad perl programming habit?
Message-Id: <x7k88vekx8.fsf@home.sysarch.com>

>>>>> "A" == AP  <alex@hoopsie2.com> writes:

  A> sub new {
  A> 	my %args = @_;
  A> 	## bless and other stuff here

  A> 	if ( defined $args{USE_XYZ_FUNCTIONS} ) {

exists is better. you could have passed in a key with the value of undef

  A> 		use MyModules::XYZModule;

that executes at compile time. the if didn't matter. lookup require.

  A> So in effect, if I am not mistaken, the subroutines from XYZModule
  A> will not be loaded if the arg USE_XYZ_FUNCTIONS is not defined.  Am
  A> I wrong?

you are wrong. read perldoc -f use

uri

-- 
Uri Guttman  ---------  uri@sysarch.com  ----------  http://www.sysarch.com
SYStems ARCHitecture, Software Engineering, Perl, Internet, UNIX Consulting
The Perl Books Page  -----------  http://www.sysarch.com/cgi-bin/perl_books
The Best Search Engine on the Net  ----------  http://www.northernlight.com


------------------------------

Date: 20 Dec 2000 09:39:23 GMT
From: abigail@foad.org (Abigail)
Subject: Re: is this bad perl programming habit?
Message-Id: <slrn940vib.u9e.abigail@tsathoggua.rlyeh.net>

AP (alex@hoopsie2.com) wrote on MMDCLXVIII September MCMXCIII in
<URL:news:3A403AC3.5DEF63E2@hoopsie2.com>:
`' I have a 'glue' module which in turn 'use's other modules depending on
`' parameters passed.  So, my code looks something like this:
`' 
`' #------- begin code
`' 
`' package MyModules::Glue  # this isn't the real name =)
`' 
`' sub new {
`' 	my %args = @_;
`' 	## bless and other stuff here
`' 
`' 	if ( defined $args{USE_XYZ_FUNCTIONS} ) {
`' 		use MyModules::XYZModule;
`' 		push ( @MyModules::Glue, 'MyModules::XYZModule' );
`' 	}
`' 
`' #------- end code
`' 
`' So in effect, if I am not mistaken, the subroutines from XYZModule will not
`' be loaded if the arg USE_XYZ_FUNCTIONS is not defined.  Am I wrong?


Yes. "use" is done at compile time. You should be doing:

    if (defined $args{USE_XYZ_FUNCTIONS}) {
	require MyModules::XYZModule;
	MyModules::XYZModule -> import () if
		MyModules::XYZModule -> can ("import");
	push @MyModules::Glue => 'MyModules::XYZModule';
    }


Abigail
-- 
sub A::TIESCALAR{bless\my$x=>'A'};package B;@q=qw/Hacker Perl
Another Just/;use overload'""',sub{pop @q};sub A::FETCH{bless
\my $y=>B};tie my$shoe=>'A';print"$shoe $shoe $shoe $shoe\n";


------------------------------

Date: Wed, 20 Dec 2000 09:34:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: just mucking about with splits
Message-Id: <h5v04t8mnfcbu01micb4jqc0phbl00l6ue@4ax.com>

Igor Aptekar wrote:

>> Try print (split /,/,$a)[1];

>this brings up a lot of errors - no compile

That is because the parentheses make what's between them the arguments
for print(). Putting a '+' in front of the opening paren will change
that. '+' has no other effect, so +"foo" is still "foo". Or, as Richard
Zilavec wrote, stuff the result of the expression into a variable first,
and use that.

-- 
	Bart.


------------------------------

Date: Wed, 20 Dec 2000 09:48:53 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the   ULTIMATE oflanguages??)
Message-Id: <t3014tcrfak5uarmkcmi33iuqomc4d8geu@4ax.com>

Kenny Pearce wrote:

>I haven't used SmallTalk, but from this conversation it seems that the only difference
>between "everything is an object" and having primitives is that the latter requires
>less typing. Ex.
>int x =1;
>as opposed to
>Integer x = new Integer(1);
>
>I can't c y there would be any other difference...

Because now you can easily write functions (oops, "methods") that do
unrelated things for integers and for floats?

-- 
	Bart.


------------------------------

Date: Wed, 20 Dec 2000 08:47:23 +0100
From: Ulrich Hofstoetter <ulrich.hofstoetter@visualanalysis.com>
Subject: Re: Language evolution C->Perl->C++->Java->Python (Is Python the  ULTIMATE oflanguages??)
Message-Id: <3A40640B.F1748A82@visualanalysis.com>

Al Dev wrote:

> o Probably it is impossible to develop a programming language which is
> better
>   than Python. (Is Python the ultimate programming language ????)

There is no ultimate programming language!

A programming language is tool to get the job done. Pick the right tool
for the job and don't make programming some kind of a religious thing.

Uli

--
Dipl.-Inf. Ulrich Hofstötter
Visual Analysis GmbH
Neumarkter Str. 87
D - 81673 München

Tel: (+49)89-431981-38
Fax: (+49)89-431981-1
e-mail: ulrich.hofstoetter@visualanalysis.com
www: http://www.visualanalysis.com




------------------------------

Date: Wed, 20 Dec 2000 00:37:10 -0500
From: "Jennie Haltridge" <jennie_halt@hotmail.com>
Subject: Need a little Help to have a blank space (I am not a programmer)
Message-Id: <vFX%5.14795$xT3.290801@weber.videotron.net>

Hello,
Please can someone tell me what to do exactly here with these instructions:

«You can either write an encoding function that would replace blank space
with some invisible character such as \s using regular expression and
replace it back before output or use a if then statement to replace the
system variable with output that is 2 words.»

My problem: example: "Services Financiers" appear as "Services_Financiers"
on the web but I want to have a blankspace. Thank you for helping me :-)))
Script behind:


# List Categories in your links script

@Categorie =

"Associés\/Franchises\/Occasions d'affaire",
    "Capital Risque & Financement",
    "Cours\/Formation",
    "Divers",
    "Services Financiers",
    "Services Professionnels"
  );

# Define Categorie description

%Categorie_desc =

"Associés\/Franchises\/Occasions d'affaire" => "",
    "Capital Risque & Financement" => "",
    "Cours\/Formation" => "",
    "Divers" => "",
    "Services Financiers" => "",
    "Services Professionnels" => ""
  );







------------------------------

Date: Wed, 20 Dec 2000 07:55:05 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Need a little Help to have a blank space (I am not a programmer)
Message-Id: <slrn940pe4.nkt.rgarciasuarez@rafael.kazibao.net>

Jennie Haltridge wrote in comp.lang.perl.misc:
> Hello,
> Please can someone tell me what to do exactly here with these instructions:
> 
> «You can either write an encoding function that would replace blank space
> with some invisible character such as \s using regular expression and

\s is not a character. It's a pattern to be used in regular expressions.
It matches whitespace characters (like space and tab). If someone gave
you those instructions, he/she should reformulate them.

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: Wed, 20 Dec 2000 10:53:32 +0100
From: "tim allen" <timallen449@coldmail.com>
Subject: Re: Need a little Help to have a blank space (I am not a programmer)
Message-Id: <91puui$176$1@diana.bcn.ttd.net>


"Jennie Haltridge" <jennie_halt@hotmail.com> wrote in message
news:vFX%5.14795$xT3.290801@weber.videotron.net...
>«You can either write an encoding function that would replace blank space
>with some invisible character such as \s using regular expression and
>replace it back before output or use a if then statement to replace the
>system variable with output that is 2 words.»

>My problem: example: "Services Financiers" appear as "Services_Financiers"
>on the web but I want to have a blankspace. Thank you for helping me :-)))
>Script behind:
>@Categorie =
------------> NOTE: you need a ( here !!!!
>"Associés\/Franchises\/Occasions d'affaire",
>    "Capital Risque & Financement",
>    "Cours\/Formation",
>    "Divers",
>    "Services Financiers",
>    "Services Professionnels"
>  );
># Define Categorie description
>%Categorie_desc =
------------> NOTE: you need a ( here !!!!
>"Associés\/Franchises\/Occasions d'affaire" => "",
>    "Capital Risque & Financement" => "",
>    "Cours\/Formation" => "",
>    "Divers" => "",
>    "Services Financiers" => "",
>    "Services Professionnels" => ""
>  );

It sounds like the problem is this:
1) With an array of descriptions
2) find slashes, underscores, and blank spaces
3) and replace them with an HTML non-breaking space (&nbsp;)
Does that sound correct?

If so, try this...------------------
$repl = "&nbsp;";  # change this to " " if not web
foreach (@Categorie) {
  s/(\/|\s|_)/$repl/g;
  print "$_\n";
}
foreach (keys %Categorie_desc) {
  s/(\/|\s|_)/$repl/g;
  print "$_\n";
}
------ or this ---------------------
$repl = "&nbsp;";  # change this to " " if not web
map {s/(\/|\s|_)/$repl/g; print "$_\n"} (@Categorie);
map {s/(\/|\s|_)/$repl/g; print "$_\n"} (keys %Categorie_desc);
------ or even this ----------------
use locale;  # tells perl to respect character conventions in your locale
map {s/(\W+)/$repl/g;print "$_\n"} (@Categorie);
map {s/(\W+)/$repl/g; print "$_\n"} (keys %Categorie_desc);
------------------------------------
To learn how these work, try perlfaq6 - Regexes (perldoc perlfaq6)
The original question is not worded very well-- specifically I don't get
"replace the system variable with output that is 2 words".  Anyway, I hope
that helps.  Bon nadal.
--
unmuck?cold=hot




------------------------------

Date: Wed, 20 Dec 2000 10:52:18 GMT
From: timothy@no.spam.here.aracnet.com (timothy)
Subject: No embeding please!
Message-Id: <3a408f58.48944078@news.aracnet.com>

Hey out there!

Well, I'm creating my first web enabled database and I would rather
avoid embeding my PERL in my HTML or my HTML in my PERL.

I've done forms so I know the basics, but now I'm trying to get some
nice output. I spent hours designing a good table layout with dummy
info and I want to use that html code to display my database info.

The last time I was doing some form output I just made up my own HTML
tags which the browsers are nice enough to ignore, then opened and
parsed the html doc to replace the tags with the appropriate data.

Even though it worked fine, what I didn't like about this was that 1.
I had to continually remind the web designer to leave my tags alone
and 2. I still ended up embeding each HTML container that had my tags
into the CGI. 

Like....

<td mytag></td> 
was in the HTML doc

<td mytag>$somedata</td>
was in my CGI

and then I wrote...
	<td mytag>Some Data</td>
back to the webserver

This is simplified, as I also did the same for changing colors of
cells if the form wasn't complete, etc, etc.

I've looked around for some pointers on displaying formatted data and
haven't really come across anything. Maybe I'm not looking in the
right places?

If anyone can give me a few tips, I'd be much abliged.

Thanks!

- tim


------------------------------

Date: 20 Dec 2000 06:38:27 GMT
From: thumper@alumnae.caltech.edu (B. Thomas Adler)
Subject: overriding 'print'
Message-Id: <91pk53$kb@gap.cco.caltech.edu>

I'm trying to override the 'print' command with one
I've written myself.  I've had good success with this
on other commands (like 'open', and 'chdir'), but 'print'
is not cooperating.  Does anyone know what magic it takes
to override this command?


What I tried was creating a module like:
    package MyPrint;
    use Exporter;
    use vars qw(@ISA @EXPORT);
    @ISA = qw(Exporter);
    @EXPORT = qw(chdir print);

    sub chdir {
        CORE::print "called chdir\n";
    }
    sub print {
        CORE::print "called print\n";
    }


and this works for 'chdir', but not 'print'.  I tried using
prototypes to help it along, but that also fails.

Thanks,
-Bo Adler
 thumper@alumni.caltech.edu



------------------------------

Date: Wed, 20 Dec 2000 09:21:42 GMT
From: AvA <a.v.a@home.nl>
Subject: perl DBI
Message-Id: <3A407A89.C46BAF06@home.nl>

i have a little database (12 rows) for testing (mysql) and i would like
to show its data in 3 rows with each 4 querys in it.
i get to output it in one row or as a single column, then i am stuck.
could anyone have a look at the code and point me in the right
direction?

#!/usr/bin/perl

use DBI;

print "Content-type: text/html\n\n";

print "<body>";

$database = "test";
$username = "*****";
$password = "*****";

$dbh = DBI->connect("DBI:mysql:$database", $username, $password) or die
"unable.....";

$sth = $dbh->prepare("select * from test");
$sth->execute or die "Unable....";

print "<table border=1>";

while (@ary = $sth->fetchrow_array){
        print "<td> $ary[0] : $ary[1] <br>";
}

print "</table>";
$dbh->disconnect;



------------------------------

Date: Wed, 20 Dec 2000 09:49:26 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: perl DBI
Message-Id: <slrn94104i.nt3.rgarciasuarez@rafael.kazibao.net>

Commenting on your code :

AvA wrote in comp.lang.perl.misc:
> 
> #!/usr/bin/perl
> 

You should use "strict":
  use strict;

> use DBI;
> 
> print "Content-type: text/html\n\n";
> 
> print "<body>";
> 
> $database = "test";
> $username = "*****";
> $password = "*****";

Declare all variables with "my" (because you're using "strict"):
  my $database = "test";
  my $username = "*****";
  my $password = "*****";
(same remark for $dbh, $sth and @ary)

> $dbh = DBI->connect("DBI:mysql:$database", $username, $password) or die
> "unable.....";

Include $DBI::errstr in your error messages, this may be useful.

> $sth = $dbh->prepare("select * from test");
> $sth->execute or die "Unable....";
> 
> print "<table border=1>";
> 
> while (@ary = $sth->fetchrow_array){
>         print "<td> $ary[0] : $ary[1] <br>";

Generate proper HTML:
          print "<tr><td> $ary[0] : $ary[1] </td></tr>\n";
or better:
          print "<tr><td>$ary[0]</td><td>$ary[1]</td></tr>\n";

> }
> 
> print "</table>";
> $dbh->disconnect;

Ensure proper disconnection even if the select failed:

  END { $dbh->disconnect if $dbh }

-- 
# Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


------------------------------

Date: Wed, 20 Dec 2000 09:57:41 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: perl DBI
Message-Id: <3A4082F9.23A0F5A1@home.nl>

Rafael Garcia-Suarez wrote:

> Commenting on your code :
>
> AvA wrote in comp.lang.perl.misc:
> >
> > #!/usr/bin/perl
> >
>
> You should use "strict":
>   use strict;
>
> > use DBI;
> >
> > print "Content-type: text/html\n\n";
> >
> > print "<body>";
> >
> > $database = "test";
> > $username = "*****";
> > $password = "*****";
>
> Declare all variables with "my" (because you're using "strict"):
>   my $database = "test";
>   my $username = "*****";
>   my $password = "*****";
> (same remark for $dbh, $sth and @ary)
>
> > $dbh = DBI->connect("DBI:mysql:$database", $username, $password) or die
> > "unable.....";
>
> Include $DBI::errstr in your error messages, this may be useful.
>
> > $sth = $dbh->prepare("select * from test");
> > $sth->execute or die "Unable....";
> >
> > print "<table border=1>";
> >
> > while (@ary = $sth->fetchrow_array){
> >         print "<td> $ary[0] : $ary[1] <br>";
>
> Generate proper HTML:
>           print "<tr><td> $ary[0] : $ary[1] </td></tr>\n";
> or better:
>           print "<tr><td>$ary[0]</td><td>$ary[1]</td></tr>\n";
>
> > }
> >
> > print "</table>";
> > $dbh->disconnect;
>
> Ensure proper disconnection even if the select failed:
>
>   END { $dbh->disconnect if $dbh }
>
> --
> # Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/

im see ur points Rafael and i will take ur advices, but maybe my question
wasnt clear enough.
$ary[0] and $ary[1] come from the same row in the database..so they belong
in one <td>.
my code generates 12 times $ary[0] : $ary[1]  and it should do just that.

what i would like to do is to have it displayed in 3 rows of 4 times $ary[0]
: $ary[1].

if i would use the <tr> as you suggested then i get 12 seperate rows of 1
time $ary[0] : $ary[1].

i hope i made it a bit understandable.



------------------------------

Date: Wed, 20 Dec 2000 10:05:46 GMT
From: Jerome Abela <Jerome.Abela@free.fr>
Subject: Re: perl DBI
Message-Id: <3A4083AC.8855D3BE@free.fr>

AvA wrote:
> 
> i have a little database (12 rows) for testing (mysql) and i would like
> to show its data in 3 rows with each 4 querys in it.
> i get to output it in one row or as a single column, then i am stuck.
> could anyone have a look at the code and point me in the right
> direction?
> 
> while (@ary = $sth->fetchrow_array){
>         print "<td> $ary[0] : $ary[1] <br>";
> }

Just scan your target array with 2 for() loops:

    for($column=0 ; $column<4 ; $column++) {
        print "<td>";
        for($row=0 ; $row<3 ; $row++) {
            @ary = $sth->fetchrow_array;
            print "$ary[0] : $ary[1] <br>";
        }
        print "</td>";
    }


Jerome.


------------------------------

Date: Wed, 20 Dec 2000 10:21:12 GMT
From: AvA <a.v.a@home.nl>
Subject: Re: perl DBI
Message-Id: <3A40887C.593D304A@home.nl>

Jerome Abela wrote:

> AvA wrote:
> >
> > i have a little database (12 rows) for testing (mysql) and i would like
> > to show its data in 3 rows with each 4 querys in it.
> > i get to output it in one row or as a single column, then i am stuck.
> > could anyone have a look at the code and point me in the right
> > direction?
> >
> > while (@ary = $sth->fetchrow_array){
> >         print "<td> $ary[0] : $ary[1] <br>";
> > }
>
> Just scan your target array with 2 for() loops:
>
>     for($column=0 ; $column<4 ; $column++) {
>         print "<td>";
>         for($row=0 ; $row<3 ; $row++) {
>             @ary = $sth->fetchrow_array;
>             print "$ary[0] : $ary[1] <br>";
>         }
>         print "</td>";
>     }
>
> Jerome.

thanks Jerome....it works (ofcourse)



------------------------------

Date: Wed, 20 Dec 2000 10:49:39 GMT
From: "John Boy Walton" <johngros@Spam.bigpond.net.au>
Subject: Re: perl DBI
Message-Id: <79006.26396$xW4.204650@news-server.bigpond.net.au>

 #!/usr/bin/perl
 use strict;
 use DBI;
 print "Content-type: text/html\n\n";

 print "<body>";

 $database = "test";
 $username = "*****";
 $password = "*****";

 my $database = "test";
 my $username = "*****";
 my $password = "*****";
 $dbh = DBI->connect("DBI:mysql:$database", $username, $password) or die
 "unable.....";
 .

$sth = $dbh->prepare("select * from test");
$sth->execute or die "Unable....";
print "<table border=1>";
while (@ary = $sth->fetchrow_array){}
print "<table><tr> "
for ( $i = 0; $i + 2; $i < 10 )
{
    for ( $j = 0; $j ++; $j < 2)
    {
        $k = $i + $j;
        print "<td>$ary[$k]</td><td>$ary[$k+1] </td> ";
    }
    print "</tr>";
}
> print "</table>";
> $dbh->disconnect;
> Ensure proper disconnection even if the select failed:

>   END { $dbh->disconnect if $dbh }


> if i would use the <tr> as you suggested then i get 12 seperate rows of 1
> time $ary[0] : $ary[1].
>
> i hope i made it a bit understandable.

This should display it in a four by three table.
The ten and the two are adjustable in case you want to change the table.
The ten is the rows * 2 + 2 and the two is number of data elements per row -
1.





------------------------------

Date: Wed, 20 Dec 2000 10:33:30 GMT
From: mexicanmeatballs@my-deja.com
Subject: Re: Perl to TCP/IP Connection & Overall Direction Needed
Message-Id: <91q1tr$mao$1@nnrp1.deja.com>

In article <x7zohtdjo5.fsf@home.sysarch.com>,
  Uri Guttman <uri@sysarch.com> wrote:
> >>>>> "EH" == Eric Hilding <eric@hilding.com> writes:
>
>   EH> 1. Connect via Perl with TCP/IP to a remote database.  Is there
>   EH> already some kind of module? I AM CLUELESS ON HOW TO APPROACH
>   EH> THIS.
>
> use IO::Socket
>
I guess the IO::Socket approach is more like the hyperterm access
he described. But, the whole thing sounds more like a DBI job,
obviously that depends on the specifics of the database though..

--
Jon
perl -e 'print map {chr(ord($_)-3)} split //, "MrqEdunhuClqdph1frp";'


Sent via Deja.com
http://www.deja.com/


------------------------------

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V9 Issue 5156
**************************************


home help back first fref pref prev next nref lref last post