[24085] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6279 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Mar 19 14:05:43 2004

Date: Fri, 19 Mar 2004 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 19 Mar 2004     Volume: 10 Number: 6279

Today's topics:
    Re: Accessing a SQL Server Database from a Perl Script  <s.patterson@freeuk.com>
        AppConfig <Mark.Fenbers@noaa.gov>
    Re: chm decompiler <ksflock@yahoo.com>
        Compare elements of 2D arrays. <jcanfield@tshmail.com>
    Re: Compare elements of 2D arrays. <ittyspam@yahoo.com>
    Re: Compare elements of 2D arrays. <matternc@comcast.net>
    Re: Compare elements of 2D arrays. <roel-perl@st2x.net>
    Re: Compare elements of 2D arrays. ctcgag@hotmail.com
    Re: count unique values in array ctcgag@hotmail.com
    Re: dollar sign and spaces from a string <noreply@gunnar.cc>
    Re: dollar sign and spaces from a string <jurgenex@hotmail.com>
    Re: dollar sign and spaces from a string <mr@sandman.net>
    Re: dollar sign and spaces from a string <sbryce@scottbryce.com>
    Re: dollar sign and spaces from a string (Anno Siegel)
    Re: dollar sign and spaces from a string (Anno Siegel)
    Re: dollar sign and spaces from a string <noreply@gunnar.cc>
    Re: dollar sign and spaces from a string ctcgag@hotmail.com
    Re: dollar sign and spaces from a string ctcgag@hotmail.com
    Re: dollar sign and spaces from a string <noreply@gunnar.cc>
    Re: Help: Deleting Entries in Flat File Database <jwillmore@remove.adelphia.net>
    Re: How to reset a POP3 session <wherrera@lynxview.com>
        need help with if then statement <dannywork5@hotmail.com>
    Re: need help with if then statement <nobull@mail.com>
    Re: need help with if then statement <roel-perl@st2x.net>
    Re: need help with if then statement <jwillmore@remove.adelphia.net>
    Re: need help with if then statement <dannywork5@hotmail.com>
    Re: Newbie: Problem w/ increasing memory allocation <jwillmore@remove.adelphia.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 19 Mar 2004 18:22:04 GMT
From: Stephen Patterson <s.patterson@freeuk.com>
Subject: Re: Accessing a SQL Server Database from a Perl Script on Linux
Message-Id: <slrnc5meic.17p.s.patterson@bloodnok.localdomain>

On Fri, 19 Mar 2004 04:04:50 GMT, Bob Walton wrote:
>     use DBI;

With DBD::Sybase - we use this at work for some daily reports.

-- 
Stephen Patterson http://patter.mine.nu/
steveSPAM@.patter.mine.nu  remove SPAM to reply        
Linux Counter No: 142831 GPG Public key: 252B8B37        
Caution: breathing may be hazardous to your health.


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

Date: Fri, 19 Mar 2004 10:12:49 -0500
From: Mark J Fenbers <Mark.Fenbers@noaa.gov>
Subject: AppConfig
Message-Id: <405B0DF1.5CF2007E@noaa.gov>

This is a multi-part message in MIME format.
--------------0A302517031316146B1AC4E4
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

I'm trying to use AppConfig::File for the first time.  I am having
trouble and don't understand its complaint.

#!/usr/bin/perl -w

use strict;
use AppConfig::File;

my $state = AppConfig::State->new( { GLOBAL => {ARGCOUNT => 1 } } );
my $cfgfile = AppConfig::File->new($state, "/home/oper/.my.cfg");

exit;

The contents of /home/oper/.my.cfg are :

baseDir  = "/web/scripts"
destDir = "/ohrfc/AHPS/hopper"

and the error I get (from last code line before 'exit') is

basedir: no such variable at /home/oper/.my.cfg line 1
destdir: no such variable at /home/oper/.my.cfg line 2

What is this trying to tell me?

Mark


--------------0A302517031316146B1AC4E4
Content-Type: text/x-vcard; charset=us-ascii;
 name="Mark.Fenbers.vcf"
Content-Transfer-Encoding: 7bit
Content-Description: Card for Mark J Fenbers
Content-Disposition: attachment;
 filename="Mark.Fenbers.vcf"

begin:vcard 
n:Fenbers;Mark
tel;work:937-383-0430
x-mozilla-html:TRUE
org:National Weather Service;Ohio River Forecast Center
adr:;;;;;;
version:2.1
email;internet:Mark.Fenbers@noaa.gov
title:Sr. HAS Meteorologist
fn:Mark J Fenbers
end:vcard

--------------0A302517031316146B1AC4E4--



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

Date: Fri, 19 Mar 2004 03:14:34 +0100
From: Uten Navn <ksflock@yahoo.com>
Subject: Re: chm decompiler
Message-Id: <al1qi1-9as.ln1@lexholm.no>

meneerjansen wrote:

> Greetings,
> I'm looking for a Perl script (or a platform-independent exe outputting to
> STDOUT) that converts chm (HTML Help) files to text or HTML.
> Does anyone know if such program exists?
> 
> Thanks for your time,
> Janssen

Search for xchm. If I recal right the lib (don't recal the name, sorry..:o)
used explanes howto do this.

Best Regards
Uten




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

Date: Fri, 19 Mar 2004 09:01:09 -0600
From: "Jim Canfield" <jcanfield@tshmail.com>
Subject: Compare elements of 2D arrays.
Message-Id: <105m2pmastu5if7@corp.supernews.com>

Greetings,

I have two 2 demensional arrays.

@array1 : Contians $ids and $values
@array2: Contains $ids and $maxvalues

How can I compare matching $ids and check to see if they have exceeded the
$maxvalues?

I'm not even sure where to start in this one.  Any help would be greatly
appreciated.




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

Date: Fri, 19 Mar 2004 10:20:07 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: Compare elements of 2D arrays.
Message-Id: <20040319101335.D21521@dishwasher.cs.rpi.edu>

On Fri, 19 Mar 2004, Jim Canfield wrote:

> Greetings,
>
> I have two 2 demensional arrays.
>
> @array1 : Contians $ids and $values
> @array2: Contains $ids and $maxvalues
>
> How can I compare matching $ids and check to see if they have exceeded the
> $maxvalues?
>
> I'm not even sure where to start in this one.  Any help would be greatly
> appreciated.


assuming @array1 contains something like...

@array1 = (
	[$id0val0, $id0val1, $id0val2, ...],
	[$id1val0, $id1val1, $id1val2, ...],
	...
	)

and @array2 is similarly structured, this should work (untested):

for $id (0..$#array1){
	for $value (0..$#{$array1[$id]}){
		if ($array1[$id][$value] > $array2[$id][$value]) {
			print "Id $id, value $value exceeds max value\n";
			print "Value: $array1[$id][$value]\n";
			print "Max: $array2[$id][$value]\n";
		}
	}
}

Paul Lalli


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

Date: Fri, 19 Mar 2004 10:21:24 -0500
From: Chris Mattern <matternc@comcast.net>
Subject: Re: Compare elements of 2D arrays.
Message-Id: <F4ednczJNqJrksbdRVn-vw@comcast.com>

Jim Canfield wrote:

> Greetings,
> 
> I have two 2 demensional arrays.
> 
> @array1 : Contians $ids and $values
> @array2: Contains $ids and $maxvalues
> 
> How can I compare matching $ids and check to see if they have exceeded the
> $maxvalues?
> 
> I'm not even sure where to start in this one.  Any help would be greatly
> appreciated.

You should be using hashes, not arrays.

if ($value{$id} > $maxvalue{$id}) {
  # do something
}
-- 
             Christopher Mattern

"Which one you figure tracked us?"
"The ugly one, sir."
"...Could you be more specific?"


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

Date: 19 Mar 2004 15:28:07 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: Compare elements of 2D arrays.
Message-Id: <slrnc5m4c1.25o.roel-perl@localhost.localdomain>

On Fri, 19 Mar 2004 at 15:01 GMT, Jim Canfield <jcanfield@tshmail.com> wrote:
> Greetings,
> 
> I have two 2 demensional arrays.
> 
> @array1 : Contians $ids and $values
> @array2: Contains $ids and $maxvalues
> 
> How can I compare matching $ids and check to see if they have exceeded the
> $maxvalues?
> 
> I'm not even sure where to start in this one.  Any help would be greatly
> appreciated.
> 
> 

#!/usr/bin/perl
use strict;
use warnings;

my @val_arr=(
  [qw/id1 id2 id3 id4 id5 Id6/],
  [qw/10  20  30  40  50  60 /],
);
my @max_arr=(
  [qw/id1 id2 id3 id4 id5 id6/],
  [qw/100 2   30  400 5   60 /],
);


# first transform the arrays into hashes
# (could even use one hash with a two-element anonymous array as values
# if preferred, but I leave that as an exercise)
#
my (%val_hash, %max_hash);
@val_hash{ @{$val_arr[0]} } = @{$val_arr[1]};
@max_hash{ @{$max_arr[0]} } = @{$max_arr[1]};


# now it's trivial -- just an example...
#
while (my ($key, $val) = each %val_hash ) {

  if ( exists $max_hash{$key} ) {
    if ( $val > $max_hash{$key} ) {
      print "Key >>$key<< has exceed maximum value: $val > $max_hash{$key}\n";
    }
  }
  else {
    warn "Key >>$key<< not found in list of maximums.\n";
  }

}

__END__


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

Date: 19 Mar 2004 17:21:31 GMT
From: ctcgag@hotmail.com
Subject: Re: Compare elements of 2D arrays.
Message-Id: <20040319122131.430$Me@newsreader.com>

"Jim Canfield" <jcanfield@tshmail.com> wrote:
> Greetings,
>
> I have two 2 demensional arrays.
>
> @array1 : Contians $ids and $values

What do you mean?  @array1 contains a list of pairs, or a pair of lists?

> @array2: Contains $ids and $maxvalues
>
> How can I compare matching $ids and check to see if they have exceeded
> the $maxvalues?
>
> I'm not even sure where to start in this one.  Any help would be greatly
> appreciated.

I'd start with hashes rather than arrays.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 19 Mar 2004 18:07:29 GMT
From: ctcgag@hotmail.com
Subject: Re: count unique values in array
Message-Id: <20040319130729.273$I1@newsreader.com>

Don Stefani <nospam_007@yahoo.com> wrote:
> Greetings,
>
> My quest:
> Using the results of a query in the form of an array, I'd like to find...
> - The number of unique values
> - The number of times that each unique value is repeated in the array
>
> Current solution:
> To do this I am doing two queries, on for the DISTINCT values
> and one for all of the values in bulk

Since you are describing this in a SQLish way, why don't you just rewrite
the original SQL to return what you want directly?
"select value, count(*) from ..... group by value"

But if you can't do that:

> my @array1 = qw(12 20 30); # sample distinct query results
> my @array2 = qw(12 12 20 30 20 20 20); # sample query results in bulk
> my %cnt_hash;

Get rid of @array1, and replace your foreach loop with:

$cnt_hash{$_}++ foreach @array2;

> ### check it
> foreach my $key (sort keys %cnt_hash)
> {
>     print "$key => $cnt_hash{$key}\n";
> }

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 19 Mar 2004 14:57:41 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: dollar sign and spaces from a string
Message-Id: <c3euqh$25dad2$1@ID-184292.news.uni-berlin.de>

Jürgen Exner wrote:
> Bill wrote:
>> 
>> print "Content-type: text/html\n\n";
> 
> What does this line have to do with your problem? It just produces 
> spurious output.

You know very well the probable reason why it's there, Jürgen. Is
there anything wrong with running a Perl program via CGI?

To OP: You should follow Jürgen's advice to enable strictures and
warnings. If you run your program as a CGI script, it's convenient to
include these lines at the beginning of the script as long as you are
developing the program:

     use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

     warningsToBrowser(1); # This line should come after printing
                           # of the content-type header.

Doing so will display fatal errors directly, and warnings will be
written as comments in the HTML source.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 19 Mar 2004 15:14:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: dollar sign and spaces from a string
Message-Id: <J7E6c.226$VV1.71@nwrddc01.gnilink.net>

Gunnar Hjalmarsson wrote:
> Jürgen Exner wrote:
>> Bill wrote:
>>>
>>> print "Content-type: text/html\n\n";
>>
>> What does this line have to do with your problem? It just produces
>> spurious output.
>
> You know very well the probable reason why it's there, Jürgen. Is
> there anything wrong with running a Perl program via CGI?

Nothing wrong with that at all.
But printing this line doesn't contribute anything to explain what the
problem is or to find a solution for the problem. It is just noise and thus
useless at best, and confusing and irritating at worst.

jue




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

Date: Fri, 19 Mar 2004 17:20:51 +0100
From: Sandman <mr@sandman.net>
Subject: Re: dollar sign and spaces from a string
Message-Id: <mr-F859BC.17205119032004@news.fu-berlin.de>

In article <J7E6c.226$VV1.71@nwrddc01.gnilink.net>,
 "Jürgen Exner" <jurgenex@hotmail.com> wrote:

> Gunnar Hjalmarsson wrote:
> > Jürgen Exner wrote:
> >> Bill wrote:
> >>>
> >>> print "Content-type: text/html\n\n";
> >>
> >> What does this line have to do with your problem? It just produces
> >> spurious output.
> >
> > You know very well the probable reason why it's there, Jürgen. Is
> > there anything wrong with running a Perl program via CGI?
> 
> Nothing wrong with that at all.
> But printing this line doesn't contribute anything to explain what the
> problem is or to find a solution for the problem. It is just noise and thus
> useless at best, and confusing and irritating at worst.

Newbies just can't win - if they post a part of their code they will be slammed 
for not submitting the entire script, and if they do they will be slammed for 
submitting parts of the script not relevant to the problem they are having. :)

-- 
Sandman[.net]


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

Date: Fri, 19 Mar 2004 09:29:25 -0700
From: Scott Bryce <sbryce@scottbryce.com>
Subject: Re: dollar sign and spaces from a string
Message-Id: <105m7us4rfd2256@corp.supernews.com>

Sandman wrote:
> Newbies just can't win - if they post a part of their code they will be slammed 
> for not submitting the entire script, and if they do they will be slammed for 
> submitting parts of the script not relevant to the problem they are having. :)

Unless they follow the posting guidelines.



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

Date: 19 Mar 2004 16:42:49 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dollar sign and spaces from a string
Message-Id: <c3f7u9$4uo$1@mamenchi.zrz.TU-Berlin.DE>

Jürgen Exner <jurgenex@hotmail.com> wrote in comp.lang.perl.misc:
> Anno Siegel wrote:
> > Bill <bill@hotmail.com> wrote in comp.lang.perl.misc:
> [...]
> >> $weight = "8.5 + $10.00";
> >> $weight =~ s/ \$//g;
> >>
> >> print "$weight";
> >
> >     $weight =~ tr/ $//d;
> 
> Nice idea, but won't solve his problem. His original string doesn't contain
> a dollar sign to begin with.

It's unlikely, but we don't know that.

    ( '$10' x 10)  =~ /@{ [ '(...)' x 10 ]}/;
    print "8.5 + $10.00\n";
    __END__
    8.5 + $10.00

:)

Anno


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

Date: 19 Mar 2004 16:54:44 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: dollar sign and spaces from a string
Message-Id: <c3f8kk$4uo$2@mamenchi.zrz.TU-Berlin.DE>

Sandman  <mr@sandman.net> wrote in comp.lang.perl.misc:

> Newbies just can't win -  ...

Right.  You're new, you make mistakes, you're criticized.  You leave
or you learn.  Anything wrong with that?

Anno


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

Date: Fri, 19 Mar 2004 18:00:58 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: dollar sign and spaces from a string
Message-Id: <c3f9ig$272mrf$1@ID-184292.news.uni-berlin.de>

Anno Siegel wrote:
> Sandman  <mr@sandman.net> wrote in comp.lang.perl.misc:
>> 
>> Newbies just can't win -  ...
> 
> Right.  You're new, you make mistakes, you're criticized.  You
> leave or you learn.  Anything wrong with that?

No.

But demanding that every single line of code in a posted program
contributes "to explain what the problem is" is unreasonable, and not
required by the posting guidelines. I can think of a few other lines
that also don't contribute to that, such as:

     #!/usr/bin/perl
     use strict;
     use warnings;

The posting guidelines suggest that you post a small program that
people can copy and run, and that illustrates the problem. If somebody
is working on a CGI script, such a small program will typically
include the printing of a content-type header.

Anything wrong with that?

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: 19 Mar 2004 17:37:41 GMT
From: ctcgag@hotmail.com
Subject: Re: dollar sign and spaces from a string
Message-Id: <20040319123741.569$Ge@newsreader.com>

Sandman <mr@sandman.net> wrote:
> >
> > Nothing wrong with that at all.
> > But printing this line doesn't contribute anything to explain what the
> > problem is or to find a solution for the problem. It is just noise and
> > thus useless at best, and confusing and irritating at worst.
>
> Newbies just can't win - if they post a part of their code they will be
> slammed for not submitting the entire script, and if they do they will be
> slammed for submitting parts of the script not relevant to the problem
> they are having. :)

There is something to be said for the fact that those unable to identify
the problem will often also be unable to identify which part of the code
contains the problem.

However, mostly this just indicates a lack of serious effort to solve the
problem oneself before posting here.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: 19 Mar 2004 18:00:04 GMT
From: ctcgag@hotmail.com
Subject: Re: dollar sign and spaces from a string
Message-Id: <20040319130004.234$t7@newsreader.com>

Gunnar Hjalmarsson <noreply@gunnar.cc> wrote:
> Anno Siegel wrote:
> > Sandman  <mr@sandman.net> wrote in comp.lang.perl.misc:
> >>
> >> Newbies just can't win -  ...
> >
> > Right.  You're new, you make mistakes, you're criticized.  You
> > leave or you learn.  Anything wrong with that?
>
> No.
>
> But demanding that every single line of code in a posted program
> contributes "to explain what the problem is" is unreasonable, and not
> required by the posting guidelines. I can think of a few other lines
> that also don't contribute to that, such as:
>
>      #!/usr/bin/perl
>      use strict;
>      use warnings;
>
> The posting guidelines suggest that you post a small program that
> people can copy and run, and that illustrates the problem. If somebody
> is working on a CGI script, such a small program will typically
> include the printing of a content-type header.
>
> Anything wrong with that?

Yes.  It implies they couldn't be bothered to try debugging it on the
command line before coming here for help.  That's just insulting.  "use
strict" and "use warnings" have more respectful implications.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service                        $9.95/Month 30GB


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

Date: Fri, 19 Mar 2004 19:48:11 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: dollar sign and spaces from a string
Message-Id: <c3ffrp$26ldgv$1@ID-184292.news.uni-berlin.de>

ctcgag@hotmail.com wrote:
> Gunnar Hjalmarsson wrote:
>> If somebody is working on a CGI script, such a small program will
>> typically include the printing of a content-type header.
>> 
>> Anything wrong with that?
> 
> Yes.  It implies they couldn't be bothered to try debugging it on
> the command line before coming here for help.  That's just
> insulting.

You make the printing of a content-type header a symbol for all kinds
of questions that are posted without having been preceded by
reasonable efforts by the poster to solve the problem. Doing so is not
fair. It rather indicates a negative attitude to people who use Perl
for CGI apps.

> "use strict" and "use warnings" have more respectful implications.

Assuredly.

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Fri, 19 Mar 2004 10:04:46 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Help: Deleting Entries in Flat File Database
Message-Id: <pan.2004.03.19.15.04.44.520581@remove.adelphia.net>

On Thu, 18 Mar 2004 16:37:54 -0500, TP wrote:

> Hi all, i am a newbie in Perl and have been playing around with FFD,

FFD ... no, I don't think that's a real term - at least in the context you
meant :-)

[ ... ]

Just a suggestion ... you may want to think about using the DBI module and
the DBD::CSV (or DBD::SQLite) module to interact with your file. 
You could then use SQL statements instead of going through the exercise of
parsing the file by hand.  As an added benefit, you won't need to alter
the code that much if you decide latter to use a "real" database :-)

Again, just a suggestion.

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
Famous, adj.:  Conspicuously miserable.   -- Ambrose Bierce 




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

Date: Fri, 19 Mar 2004 07:11:18 -0700
From: Bill <wherrera@lynxview.com>
Subject: Re: How to reset a POP3 session
Message-Id: <G6ydnffJoIE4YsfdRVn-vg@adelphia.com>

James Taylor wrote:
> Hi guys,
> 
> I'm using the Net::POP3 module and would like to know how to use its
> reset() method properly. There ought to be a way to issue the POP3
> RESET command and know whether it succeeded, but I can't see how.
> Has anyone else managed to use the Net::POP3 module for this?
> Please advise me if you can; I'm very stuck. Thanks.
> 
> PS. You might find further background to the problem over here:
> http://groups.google.com/groups?th=1ed4ebecbab686f7
> 

you could try
my $pop = new Net::POP3 ...
 ....
$pop->_RSET or warn "Reset did not succeed";

But be aware this does not reset the POP module's internal error strings
the way reset() does. There is a bit of a bug in the reset() method in 
this regard. You could do your own patch by adding
return 1;

to the end of sub reset  { ... }  in the module, I guess, and then use that.





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

Date: Fri, 19 Mar 2004 17:31:32 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: need help with if then statement
Message-Id: <U7G6c.31068$E8.7078476@news4.srv.hcvlny.cv.net>

Can this be done?
I am trying to generate dynamic pages using cgi.  How can I store the html
code portions into a string
like around the single or double qoutes.  It doesnt seem to like it but this
below

$html1 = '<DIV ALIGN="center">
  <CENTER>
  <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
'


but it likes it this way....


use CGI;

$co = new CGI;

$search = $co->param('search');

print $co->header,

$co->start_html
(
    -BGCOLOR=>'white',
    -LINK=>'blue',
 -VLINK=>'blue',
 -ALINK=>'blue',
    -TopMargin=>5,
),


'<DIV ALIGN="center">
  <CENTER>
  <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
',
;

then more cgi,

'
then more code
',
;

etc etc




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

Date: 19 Mar 2004 17:51:05 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: need help with if then statement
Message-Id: <u91xnohgja.fsf@wcl-l.bham.ac.uk>

"Danny" <dannywork5@hotmail.com> writes:

> Subject: need help with if then statement

There are no if statements in the code you post.

Please put the subject of your post in the Subject of your post.  If
in doubt try this simple test.  Imagine you could have been bothered
to have done a search before you posted.  Next imagine you found a
thread with your subject line.  Would you have been able to recognise
it as the same subject?

> I am trying to generate dynamic pages using cgi.  How can I store
> the html code portions into a string like around the single or
> double qoutes.  It doesnt seem to like it but this below
> 
> $html1 = '<DIV ALIGN="center">
>   <CENTER>
>   <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
> '

Well it's ugly but perfectly valid Perl.

There's probably something else wrong in your script. (Like maybe a
missing semicolon).

Perhaps you should generate a _minimal_ but _complete_ script that
Perl "doesn't seem to like" and post it here.

Have you see the posting guidelines?

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 19 Mar 2004 17:59:27 GMT
From: Roel van der Steen <roel-perl@st2x.net>
Subject: Re: need help with if then statement
Message-Id: <slrnc5md7p.284.roel-perl@localhost.localdomain>

On Fri, 19 Mar 2004 at 17:31 GMT, Danny <dannywork5@hotmail.com> wrote:
> Can this be done?
> I am trying to generate dynamic pages using cgi.  How can I store the html
> code portions into a string
> like around the single or double qoutes.  It doesnt seem to like it but this
> below
> 
> $html1 = '<DIV ALIGN="center">
>  <CENTER>
>  <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
> '
<lines of ugly illegible code snipped> 

First of all I would not recommend mixing literal HTML and HTML code
genereated by CGI. It clobbers your script. Secondly I don't see what
you want to achieve, but for what it's worth: you may be looking for
the "here document" quoting style.

  perldoc perlop

and search for "Quote and Quote-like Operators".


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

Date: Fri, 19 Mar 2004 13:10:51 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: need help with if then statement
Message-Id: <pan.2004.03.19.18.10.49.354076@remove.adelphia.net>

On Fri, 19 Mar 2004 17:31:32 +0000, Danny wrote:

> Can this be done?
> I am trying to generate dynamic pages using cgi.  How can I store the html
> code portions into a string
> like around the single or double qoutes.  It doesnt seem to like it but this
> below
> 
> $html1 = '<DIV ALIGN="center">
>   <CENTER>
>   <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
> '
 [ ... ]

Try a heredoc :-)

my $html1 =<<END;
<DIV ALIGN="center">
    <CENTER>
       <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
END

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
The IQ of the group is the lowest IQ of a member of the group
divided by the number of people in the group. 



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

Date: Fri, 19 Mar 2004 18:54:32 GMT
From: "Danny" <dannywork5@hotmail.com>
Subject: Re: need help with if then statement
Message-Id: <IlH6c.31760$E8.7292280@news4.srv.hcvlny.cv.net>


"Danny" <dannywork5@hotmail.com> wrote in message
news:U7G6c.31068$E8.7078476@news4.srv.hcvlny.cv.net...
> Can this be done?
> I am trying to generate dynamic pages using cgi.  How can I store the html
> code portions into a string
> like around the single or double qoutes.  It doesnt seem to like it but
this
> below
>
> $html1 = '<DIV ALIGN="center">
>   <CENTER>
>   <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
> '
>
>
> but it likes it this way....
>
>
> use CGI;
>
> $co = new CGI;
>
> $search = $co->param('search');
>
> print $co->header,
>
> $co->start_html
> (
>     -BGCOLOR=>'white',
>     -LINK=>'blue',
>  -VLINK=>'blue',
>  -ALINK=>'blue',
>     -TopMargin=>5,
> ),
>
>
> '<DIV ALIGN="center">
>   <CENTER>
>   <TABLE BORDER="0" cellpadding="0" CELLSPACING="0" WIDTH="750">
> ',
> ;
>
> then more cgi,
>
> '
> then more code
> ',
> ;
>
> etc etc
>
>


Hello
sorry abou leaving out the 'if then'
I attached a bit of code below that works.
Do you se where I put the 3 blocks of html for the table?  That is what i
want to insert based on conditional if then instead of having it be
duplicated througought.

But how can I do it?
can I store a variable like this
table 1 =  '
<table width="75%" border="1" cellpadding="1">
  <tr>
    <td>table 1</td>
  </tr>
</table>
<p>&nbsp;</p>
'

it doenst seem to work if I store this variable to this string.
Thanks for any help.




code:
---------------
#!/usr/local/bin/perl


use CGI;

$co = new CGI;

$search = $co->param('search');
$hello = "hello";

print $co->header,

$co->start_html
(
    -title=>'Test',
    -BGCOLOR=>'white',
    -LINK=>'blue',
 -VLINK=>'blue',
 -ALINK=>'blue',
    -TopMargin=>5,
),


'
<BODY LEFTMARGIN="10" LINK="#663399" TOPMARGIN="5">
<table width="75%" border="1" cellpadding="1">
  <tr>
    <td>table 1</td>
  </tr>
</table>
<p>&nbsp;</p>

'
;

print $hello,




'
<table width="75%" border="1" cellpadding="1">
  <tr>
    <td>table 2</td>
  </tr>
</table>
<p>&nbsp;</p>

'
;
print $hello,


'
<table width="75%" border="1" cellpadding="1">
  <tr>
    <td>table 3</td>
  </tr>
</table>
<p>&nbsp;</p>

'
;



print $co->hr;

print $co->end_html;




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

Date: Fri, 19 Mar 2004 09:45:46 -0500
From: James Willmore <jwillmore@remove.adelphia.net>
Subject: Re: Newbie: Problem w/ increasing memory allocation
Message-Id: <pan.2004.03.19.14.45.44.167989@remove.adelphia.net>

On Thu, 18 Mar 2004 02:39:06 -0600, Samuel H Roseman wrote:

> OS:            SuSE Linux 8.1
> Version:    Summary of my perl5 (revision 5.0 version 8 subversion 0)
> Problem:    Processing output from "tcpdump" cause increasing memory 
> allocation.
>                   I have to stop and restart to release the memory.
> Question:    What am I doing wrong in my script? THANKS

[ ... ]

I'm not 100% sure what the end result of your exercise is supposed to be,
but might I suggest you take a look at snort (http://www.snort.org/).  It
seems like your trying to do packet logging and analysis, which is what
snort is good for :-)

I don't want to steer you away from doing what you're doing, but it would
be, IMHO, better to use something that works and works well instead of
trying to 'roll your own'.

HTH

-- 
Jim

Copyright notice: all code written by the author in this post is
 released under the GPL. http://www.gnu.org/licenses/gpl.txt 
for more information.

a fortune quote ...
"There's nothing wrong with teenagers that reasoning with them
won't aggravate." 



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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V10 Issue 6279
***************************************


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