[15535] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2945 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 4 06:10:27 2000

Date: Thu, 4 May 2000 03:10:16 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <957435016-v9-i2945@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 4 May 2000     Volume: 9 Number: 2945

Today's topics:
    Re: more CGI.pm questions .. tables with nested foreach <nospam@devnull.com>
    Re: more CGI.pm questions .. tables with nested foreach <nospam@devnull.com>
    Re: more CGI.pm questions .. tables with nested foreach <nospam@devnull.com>
    Re: more CGI.pm questions .. tables with nested foreach (Neil Kandalgaonkar)
        Newbie needs help splitting file (Anamarija Kruljac)
    Re: printing to a jetdirect device from perl -- help <gellyfish@gellyfish.com>
        Problems with installing/making and recognising Perl mo <miles@explorer.demon.co.uk>
    Re: Q: search/replace and pattern matching <gellyfish@gellyfish.com>
    Re: Regex for not matching a particular string <eedjoes@eed.ericsson.se>
    Re: web page mailer exhacker@my-deja.com
    Re: web page mailer <billy@arnis-bsl.com>
    Re: where is the getopt::Std module <gellyfish@gellyfish.com>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 4 May 2000 07:43:29 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: more CGI.pm questions .. tables with nested foreach loops .. how?
Message-Id: <8er9n1$9as$1@216.155.32.166>

In article <MPG.137abc6da7bd33a498a9f2@nntp.hpl.hp.com>, Larry Rosler 
<lr@hpl.hp.com> wrote:

 | In article <8er2em$i1k$0@216.155.32.166> on 4 May 2000 05:39:34 GMT, The 
 | WebDragon <nospam@devnull.com> says...
 | > this is making me crazy : )
 | > 
 | > print table,
 | > foreach my $key (keys %scoresG) {
 | >     print tr;
 | >     print td({-align=>'right'}, textfield(-name=>"$key", 
 | > -default=>"$scoresG{$key}", -size=>'3');
 | >     print td({-align=>'left'}, " Enter your score for 
 | >     $namesList{$key}");
 | > };
 | > 
 | > 
 | > gives me a syntax error 'near foreach'
 | 
 | Statements end in semicolons, not commas.
 | 
 |   print table;
 | 
 | But even then, there will be another, subtler error, because 'tr' is a 
 | Perl keyword.  You will need to use:
 | 
 |       print Tr;
 | 
 | instead.


DOH DOH DOH so THAT's what's been screwing me up.. *sigh* wish the error 
messages were more succinct! GAH! 1000 thanks!!!!!!

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 4 May 2000 07:49:25 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: more CGI.pm questions .. tables with nested foreach loops .. how?
Message-Id: <8era25$9as$2@216.155.32.166>

In article <slrn8h27ke.cq9.efflandt@efflandt.xnet.com>, 
efflandt@xnet.com wrote:

 | On 4 May 2000 05:39:34 GMT, The WebDragon <nospam@devnull.com> wrote:
 | >this is making me crazy : )
 | 
 | You cannot put perl commands within a table(), but the table rows are a
 | list, so you can easily push dynamic rows to a list and then print the
 | table:
 | 
 | foreach my $key (keys %scoresG) {
 |     push @rows, td({-align=>'right'}, textfield(-name=>"$key", 
 |     -default=>"$scoresG{$key}", -size=>'3'),
 |     td({-align=>'left'}, " Enter your score for $namesList{$key}");
 | };
 | print table(Tr([@rows]));

looks good but generates : 

# syntax error, near ");"
File 'Primus 8.5GB:Web Pages:cgi-scripts:testform2.cgi'; Line 73
# Uncaught exception from user code:
# Primus 8.5GB:Web Pages:cgi-scripts:testform2.cgi had compilation 
errors.

I'm really clueless on this one.. I triple-checked the braces and 
brackets and parens here. *sigh* 

/me smacks his perl script around a bit with a large sumo wrestler

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 4 May 2000 08:21:41 GMT
From: The WebDragon <nospam@devnull.com>
Subject: Re: more CGI.pm questions .. tables with nested foreach loops .. how?
Message-Id: <8erbul$iha$0@216.155.32.166>

In article <slrn8h27ke.cq9.efflandt@efflandt.xnet.com>, 
efflandt@xnet.com wrote:

 | foreach my $key (keys %scoresG) {
 |     push @rows, td({-align=>'right'}, textfield(-name=>"$key", 
 |     -default=>"$scoresG{$key}", -size=>'3')),
 |     td({-align=>'left'}, " Enter your score for $namesList{$key}");
 | };
 | print table(Tr([@rows]));

I found a missing ) after -size=>'3')), which is what generated the 
syntax error, however the html this produces is less than optimal 

I get
 
        |box|
description
        |box|
description
        |box|
description

etc etc etc

instead of 

|box| description
|box| description
|box| description

any idea why?

-- 
send mail to mactech (at) webdragon (dot) net instead of the above address. 
this is to prevent spamming. e-mail reply-to's have been altered 
to prevent scan software from extracting my address for the purpose 
of spamming me, which I hate with a passion bordering on obsession.  


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

Date: 4 May 2000 08:33:18 GMT
From: nj_kanda@alcor.concordia.ca (Neil Kandalgaonkar)
Subject: Re: more CGI.pm questions .. tables with nested foreach loops .. how?
Message-Id: <8ercke$8v8$1@newsflash.concordia.ca>

In article <8era25$9as$2@216.155.32.166>,
The WebDragon  <nospam@devnull.com> wrote:
>In article <slrn8h27ke.cq9.efflandt@efflandt.xnet.com>, 
>efflandt@xnet.com wrote:
>
> | foreach my $key (keys %scoresG) {
> |     push @rows, td({-align=>'right'}, textfield(-name=>"$key", 
                      ^
> |     -default=>"$scoresG{$key}", -size=>'3'),
> |     td({-align=>'left'}, " Enter your score for $namesList{$key}");
> | };
> | print table(Tr([@rows]));

>I'm really clueless on this one.. I triple-checked the braces and 
>brackets and parens here. *sigh* 

I think you missed one. The first td is not closed.

This worked for me, without any intermediate steps. However, this
sort of statement can be tough to debug -- maybe you might want
to just put in the raw HTML string equivalents.

I'm sure everyone will hate the way I indent this, but it seems
to help me. 


 ------------------------------
#!/usr/bin/perl -w

use strict;
use CGI qw(:standard);

my %scoresG = ( a => 1, b => 2, c => 3.141592 );
my %nameList = ( a => "Who", b => "What", c => "I.Dunno" );

print header();
print start_html();

print qq{<FORM ACTION="whatever.pl" METHOD="POST">};

print table ({-border=>1},
  TR([
    map {
      td({-align => 'right'}, 
        textfield ({-name => $_, -default => $scoresG{$_}, -size => 3})
      ) 
      . # concat so TR does right thing.
      td({-align => 'left'},
        "Enter your score for $nameList{$_}"
      )
    } keys %scoresG      
  ])
);

print qq{</FORM>};

print end_html();

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

HTH


-- 
Neil Kandalgaonkar
neil@brevity.org


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

Date: 4 May 2000 08:35:15 GMT
From: akruljac@rudjer.irb.hr (Anamarija Kruljac)
Subject: Newbie needs help splitting file
Message-Id: <8erco3$gh$1@bagan.srce.hr>

Can you give me an example script for the following problem or at least
point me where should I look for more info on how to do something like that? 
Thank you in advance!

I have something like a flatfile database, an large file with lots of
records. Something like:

--START LINE--
Key1: apple
Key2: green
Key3: sky
Key4: high
 .
 .
 .
--END LINE--
--START LINE--
Key1: banana
 .
 .
 .

I'd like to select records from original file, based on different key
values, and transfer those records to another file. For example, I want all
records where Key1 contains "apple" and Key2 does not contain "blue" in
another file. Original files are preety big, in range from 300Mb to 1Gb, so
I probably couldn't just put whole file into array.


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

Date: Thu, 04 May 2000 09:44:34 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: printing to a jetdirect device from perl -- help
Message-Id: <6EbQ4.66$a2.13693@news.dircon.co.uk>

On Wed, 03 May 2000 13:28:33 -0700, Aaron Wrote:
> 
> Tom Phoenix wrote:
> 
>> On Tue, 2 May 2000, Aaron wrote:
>>
>> > Can someone give me an example of how to print to a jetdirect device?
>>
>> You'll almost certainly need to find out what protocol the device desires
>> that you use when you speak to it. Once you do, though, there are modules
>> on CPAN for many common protocols, or you can make your own. You may wish
>> to search for the docs, FAQs, and newsgroups about your hardware. Cheers!
>>
> 
> Thanks Tom, I guess I was a little vague in my original post.  The
> HP-Jetdirect box is setup for TCP/IP
> communications and is connected to a line printer.  I searched the CPAN site
> as you suggested, but found
> nothing regarding printing protocols.  I guess I'm just not as good at
> searching as some of the rest of you.
> If you could find it in your heart to give me a little more specifics on
> where I might search or read about
> how to make perl talk to a jetdirect box over tcp/ip I would be very
> grateful.
> 

I would imagine that you can use the LPD protocol as discussed in RFC1179
(see <ftp://ftp.isi.edu/in-notes/rfc1179.txt> ) however I dont believe that
there is currently a module that implements this protocol.  Once you have
read the RFC perhaps you might write one and submit it to CPAN ;-}

/J\


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

Date: Thu, 4 May 2000 11:07:32 +0100
From: "Miles Davenport" <miles@explorer.demon.co.uk>
Subject: Problems with installing/making and recognising Perl modules
Message-Id: <957434281.8673.0.nnrp-12.d4e4dc01@news.demon.co.uk>

I have been having real problems with installing CPAN perl modules on my
solaris box running Perl 5.

I have unpacked them, checked and run the makefile (making sure that paths
are correct).  I then have something like:

#!/usr/bin/perl -- -*-perl-*-

$version = '0.1';

use lib '/users/perl/modules';  ## this is where all my modules go

use XML::Parse

--------
Where modules will contain a sub directory like XML, and then Parse.pm.  I
have also tried require, adding the full path to @INC - but PERL will not
pick up the new module (I don't think Perl likes the /users/perl/modules).

I think I am missing a really easy step, but can't find it.

Can someone give me an idiots :) guide to doing this - OR just tell me what
i'm doing wrong.

thanks

Miles.





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

Date: 4 May 2000 09:04:10 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: Q: search/replace and pattern matching
Message-Id: <8eratq$p26$1@orpheus.gellyfish.com>

On Wed, 03 May 2000 09:15:17 -0500 Brock Gunter-Smith wrote:
> I'm trying to write a VERY basic routine to parse a file of e-mail
> addresses, clean up the addresses and discard addresses that are an invalid
> format...but I'm having trouble. When I read in each line I do:
> 
>     $address =~ s/[^\w\.-@]//g;

So you dont think that my colleague £@gellyfish.com should get any mail then ?

/J\
-- 
Whenever Marge turns on one of her non-violent programs, I take a walk. I
go to a bar, I pound a few, then I stumble home in the mood for looooove.
-- 
fortune oscar homer


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

Date: Thu, 04 May 2000 09:55:27 +0200
From: Joern Stein <eedjoes@eed.ericsson.se>
Subject: Re: Regex for not matching a particular string
Message-Id: <39112CEF.55B0FF12@eed.ericsson.se>

Mitesh Desai wrote:
> 
> Okay, my problem is to check if the url contains http://,
> and if it contains, check if it contains a particular
> host, say www.cnn.com. Let us say it contains
> www.yahoo.com as the host, then my problem is to
> insert a www.mysite.com/redirect? before it, to get
> 
> http://www.mysite.com/redirect?www.yahoo.com
> 
> I donot think the if not match would work, since it
> would even replace ftp://www.somesite.com.
Hi,

how about this substitution:

s#(http://)(.*)#$1www.mysite.com/redirect?$2# if $2;

Would that help?


-- 
Cheers
Joern Stein
-----------------------------t--h--e--r--e--i--s--n--o--s--p--o--o--n-
http://www.palmobil.de


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

Date: Thu, 04 May 2000 08:05:36 GMT
From: exhacker@my-deja.com
Subject: Re: web page mailer
Message-Id: <8erb08$80n$1@nnrp1.deja.com>

In article <8eqsgk$nub$1@nnrp1.deja.com>,
  ryanhca@my-deja.com wrote:
> Does anyone know of a script out there that can find a grab a web page
> (even over SSL) and then mail it to an email address?
>
> I could write it myself, but don't have time, and I think I'd be
> reinventing the wheel... not that novel a concept :)
>
> Any help out there?
>
> Thanks
>
> Ryan Huff
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>

# You will need the LWP Module installed to use this.
# Under Windows, I would suggest ActiveState ActivePerl
# http://www.activestate.com/ActivePerl/
use LWP::Simple;
$htmlpage = get "http://www.yahoo.com:80/" or die "No can do\n";
open(MAIL,`| /usr/lib/sendmail -t -oi`);

print MAIL <<EOF;
To: nobody\@server.com
From: somebody\@host.com
Subject: Yahoo Download
Hello World!
$htmlpage
EOF

close MAIL;

# if you don't have UNIX sendmail, you can use the Mail::Mailer module.
# DynamicState offers an MS-DOS command line SendMail...
# http://www.dynamicstate.com/sendmail.htm

Hope this helps (-:
exhacker


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 04 May 2000 09:01:12 GMT
From: Ilja <billy@arnis-bsl.com>
Subject: Re: web page mailer
Message-Id: <8ere8i$bbh$1@nnrp1.deja.com>

In article <8erb08$80n$1@nnrp1.deja.com>,
  exhacker@my-deja.com wrote:
> In article <8eqsgk$nub$1@nnrp1.deja.com>,
>   ryanhca@my-deja.com wrote:
> > Does anyone know of a script out there that can find a grab a web page
> > (even over SSL) and then mail it to an email address?
> >
>
> # You will need the LWP Module installed to use this.
> # Under Windows, I would suggest ActiveState ActivePerl
> # http://www.activestate.com/ActivePerl/
> use LWP::Simple;
> $htmlpage = get "http://www.yahoo.com:80/" or die "No can do\n";
> open(MAIL,`| /usr/lib/sendmail -t -oi`);

Hm-m, why do you use backticks ... I guess yoy mean quotes ...

>
> print MAIL <<EOF;
> To: nobody\@server.com
> From: somebody\@host.com
> Subject: Yahoo Download
> Hello World!
> $htmlpage
> EOF
>
> close MAIL;

The above *may* work, but to be correct you need an empty line
between messsage header and message body.
And, yes, better use one of Mail:: modules.

 ...skip...

Ilja.




Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 4 May 2000 07:33:10 +0100
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: where is the getopt::Std module
Message-Id: <8er5j6$fhr$1@orpheus.gellyfish.com>

On Wed, 03 May 2000 11:13:45 -0500 Tom Briles wrote:
> vnguyen_1999@my-deja.com wrote:
>> 
>> Hello Everyone,
>> 
>> I want to download the getopt::Std module but could not find in CPAN. 
> 
> I don't know how you missed it on CPAN.  

Probably because the capitalization is wrong - it is Getopt::Std of course.

/J\
-- 
The only thing that the artist cannot see is the obvious. The only thing
that the public can see is the obvious. The result is the Criticism of
the Journalist.
-- 
fortune oscar homer


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

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 2945
**************************************


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