[16036] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3448 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jun 21 21:12:29 2000

Date: Wed, 21 Jun 2000 18:10:17 -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: <961636216-v9-i3448@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 21 Jun 2000     Volume: 9 Number: 3448

Today's topics:
    Re: Programming questions (Eric Bohlman)
    Re: q: next pair key in a hash <mhc@Eng.Sun.COM>
    Re: q: next pair key in a hash (Abigail)
    Re: Reading Pine from Perl (brian d foy)
    Re: Simple Reg Expression Question <abe@ztreet.demon.nl>
    Re: SMS help <j@iforgot.net>
    Re: strict and @ISA <abe@ztreet.demon.nl>
    Re: strict and @ISA (Abigail)
        Syntax of Print <<END; ? <gollands@cornell.edu>
    Re: Syntax of Print <<END; ? <tony_curtis32@yahoo.com>
    Re: Syntax of Print <<END; ? <root@gtnorthern.demon.co.uk>
    Re: Syntax of Print <<END; ? <rootbeer@redcat.com>
    Re: Syntax of Print <<END; ? <abe@ztreet.demon.nl>
    Re: using cgi.pm for radio buttons (Mark Badolato)
        Why cant a cgi and module use the same library? <glchyNOglSPAM@cc21.com.sg.invalid>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 22 Jun 2000 00:58:24 GMT
From: ebohlman@netcom.com (Eric Bohlman)
Subject: Re: Programming questions
Message-Id: <8irobg$ler$2@nntp9.atl.mindspring.net>

Steve Lee (beefcakegt@hotmail.com) wrote:
: I want to write a script that will send e-mail to a specific e-mail
: address, and have the results returned to different (reply-to) e-mail
: addresses.  I would also like the script to notify me when those
: specific e-mail clients receive e-mail.

You have three requirements here.  The first one can be handled by 
various Mail::* modules; take a look around on CPAN.  The second is a 
matter of including the appropriate mail header in your messages.  The 
third is impossible to meet.



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

Date: 21 Jun 2000 15:22:55 -0700
From: Mike Coffin <mhc@Eng.Sun.COM>
Subject: Re: q: next pair key in a hash
Message-Id: <8p6hfam8yio.fsf@Eng.Sun.COM>

"Roman Chumakov" <zfido88@zr.ru> writes:

> A little trouble.
> 
> I have a big hash: $hash.
> 
> I have a key for this hash to retrieve: $key
> its value is:
> $keyvalue = $hash{$key}
> 
> But how can I know previous key in a $hash, that is previos $key?
> And also, how to get next key?
> 
> it's like.... i have a book .. I know a page... I need to get next or prev
> page.

First, unless you need random access (by key) you might be better off
with a list instead of a hash. 

If you do need random access and in addition need sequential access,
then you need a slightly more complicated data structure.  E.g.,
assuming a file contains one key/value pair per line, you could do
something like this to build the data structure:

    my $prev_key = undef;
    my %table = ();

    while (<>) {
       my ($key, $value) = split /\s+/, $_;
       $table{$key}{VALUE} = $value;
       $table{$key}{PREV} = $prev_key;
       $table{$key}{NEXT} = undef;

       if ($prev_key) {
         $table{$prev_key}{NEXT} = $key;
       }

       $prev_key = $key;
    }

Then to get the value for $key, you would write

    $table{$key}{VALUE}

To get the previous key, you would write

    $table{$key}{PREV}

There are lots of possible variations. 

-mike


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

Date: 21 Jun 2000 19:29:47 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: q: next pair key in a hash
Message-Id: <slrn8l2l1e.h6u.abigail@alexandra.delanet.com>

Roman Chumakov (zfido88@zr.ru) wrote on MMCDLXXXVI September MCMXCIII in
<URL:news:8iqca6$stn$1@news.sovam.com>:
|| A little trouble.
|| 
|| I have a big hash: $hash.

That's not a hash. This is a hash: %hash.

|| I have a key for this hash to retrieve: $key
|| its value is:
|| $keyvalue = $hash{$key}
|| 
|| 
|| But how can I know previous key in a $hash, that is previos $key?
|| And also, how to get next key?
|| 
|| it's like.... i have a book .. I know a page... I need to get next or prev
|| page.
|| 

A hash isn't like a book. An _array_ is like a book. You can iterate
over the hash, using each(), but there isn't a "next" of "previous"
function. A hash is more like a book with all pages ripped out.



Abigail
-- 
package Just_another_Perl_Hacker; sub print {($_=$_[0])=~ s/_/ /g;
                                      print } sub __PACKAGE__ { &
                                      print (     __PACKAGE__)} &
                                                  __PACKAGE__
                                            (                )


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

Date: Wed, 21 Jun 2000 20:13:03 -0500
From: brian@smithrenaud.com (brian d foy)
Subject: Re: Reading Pine from Perl
Message-Id: <brian-2106002013040001@149.pittsburgh-03-04rs.pa.dial-access.att.net>

In article <8iqhgt$5m0$1@nnrp1.deja.com>, fperkins@my-deja.com wrote:

>Scenario:  Bounced emails are stored in a Pine email account called
>Recipes.  The file that houses all this information [via Pine] can be
>found at /var/mail/recipes.

PINE uses the mbox format, so any of the Mail modules on CPAN that
handle mbox will work for you.

-- 
brian d foy
Perl Mongers <URI:http://www.perl.org>
CGI MetaFAQ 
  <URI:http://www.smithrenaud.com/public/CGI_MetaFAQ.html>



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

Date: Thu, 22 Jun 2000 01:19:21 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Simple Reg Expression Question
Message-Id: <lni2ls8ho7bq6gfaso70u6amg8ofoesrcb@4ax.com>

On Wed, 21 Jun 2000 18:59:57 +0200, Abe Timmerman <abe@ztreet.demon.nl>
wrote:

> #!/usr/bin/perl -w
> use strict;
> 
> my $ID = ' DA86E130-470E-11D4-9F14-0080ADC93510';
> 
> my @hexid = map "0x$_" =>
> 	(unpack 'aa8aa4aa4aa2a2aa2a2a2a2a2a2', $ID)[1,3,5,7,8,10..15];

ok, thanks to Greg for the idea, looks much better this way :-)

(my $id2 = $ID) =~ tr/ -//d;
my @hexid = map "0x$_" => unpack 'a8a4a4a2a2a2a2a2a2a2a2', $id2;

> 	
> my $hex = join ', ', @hexid;
> 
> print "ID: $ID\n";	
> print "Hexadecimal: $hex\n";
> 
> __END__

-- 
Good luck,
Abe


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

Date: Wed, 21 Jun 2000 16:24:48 -0600
From: "Jim" <j@iforgot.net>
Subject: Re: SMS help
Message-Id: <395140bd$0$660@news.denver1.Level3.net>

The easiest way to get SMS to work is to write an app that'll add the
appropriate records to the SMS database.  That way, SMS can manage
replicating the application out to the appropriate site servers and the
like.  Read as much as you can about SMS before you begin, because SMS
(espescially version 1.2) is bad about database inconsistency.

SMS isn't about ports and sockets.  You'll be using ODBC or some other SQL
module (depending in your target platform for this app) to talk to the
database, and that's about it outside of the user interface.

Cheers,
    Jim

"David Fleet" <dfleet@avaterra.com> wrote in message
news:3950df54_2@nnrp1.news.uk.psi.net...
> Thankyou for your quick reply.
>
> Do I need any specific hardware apart from a server, or is it just port
and
> socket programming?
>
>
> "Jim" <j@iforgot.net> wrote in message
> news:3950d20a$0$17334@news.denver1.Level3.net...
> > Yes, it is possible to send SMS jobs through Perl.  Learn more about SMS
> and
> > the solution will present itself.  I can't send you the source I
developed
> > as it belongs to my employer.
> >
> > "David Fleet" <dfleet@avaterra.com> wrote in message
> > news:3950ce63_1@nnrp1.news.uk.psi.net...
> > > Anyone know if it's possible to send SMS by Perl?





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

Date: Thu, 22 Jun 2000 01:24:23 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: strict and @ISA
Message-Id: <sij2ls83bjooioukjodcviqlknaerhpa84@4ax.com>

On 21 Jun 2000 11:05:21 -0700, Andrew Perrin - Demography
<aperrin@davis.DEMOG.Berkeley.EDU> wrote:

> Quick question: what is the proper way to make strict not complain
> about @ISA requiring a package name?  Packages that don't work under
> use strict make me queasy, but @ISA = qw(foo bar) sets off the alarms.

	use base qw(Foo Bar);

perldoc base

-- 
Good luck,
Abe


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

Date: 21 Jun 2000 19:36:03 EDT
From: abigail@delanet.com (Abigail)
Subject: Re: strict and @ISA
Message-Id: <slrn8l2ld6.h6u.abigail@alexandra.delanet.com>

Andrew Perrin - Demography (aperrin@davis.DEMOG.Berkeley.EDU) wrote on
MMCDLXXXVI September MCMXCIII in <URL:news:u5kvgz2kizi.fsf@davis.DEMOG.Berkeley.EDU>:
}} Quick question: what is the proper way to make strict not complain
}} about @ISA requiring a package name?  Packages that don't work under
}} use strict make me queasy, but @ISA = qw(foo bar) sets off the alarms.


use vars qw /@ISA/;
@ISA = qw /foo bar/;


or if you want to pull in modules:


use base qw /foo bar/;


or the snobby:


our @ISA = qw /foo bar/;



Abigail
-- 
perl -e 'for (s??4a75737420616e6f74686572205065726c204861636b65720as?;??;??) 
             {s?(..)s\??qq \?print chr 0x$1 and q ss\??excess}'


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

Date: Wed, 21 Jun 2000 18:12:06 -0400
From: Brian Gollands <gollands@cornell.edu>
Subject: Syntax of Print <<END; ?
Message-Id: <39513DAB.9DDD8E16@cornell.edu>

This may be a newbie question, but I'm having trouble finding
documentation on the usage of END in a print statement, such as:

print <<END;
a line
another line
yet another line
END

I've seen it used and have it working in part of one of my scripts, but
then tried to use it in a foreach loop that causes a syntax error
("...probably a runaway multi-line string..."). I can't find a reference
to the syntax for this anywhere in the Perl docs or books. Is it right
under my nose? Thanks for any help!




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

Date: 21 Jun 2000 17:41:46 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Syntax of Print <<END; ?
Message-Id: <87r99q8xn9.fsf@limey.hpcc.uh.edu>

>> On Wed, 21 Jun 2000 18:12:06 -0400,
>> Brian Gollands <gollands@cornell.edu> said:

> print <<END; a line another line yet another line END

> I've seen it used and have it working in part of one of
> my scripts, but then tried to use it in a foreach loop
> that causes a syntax error ("...probably a runaway
> multi-line string..."). I can't find a reference to the
> syntax for this anywhere in the Perl docs or books. 

Well, post the code, or at least some code showing the
problem.  Perhaps you have spaces after the terminating
END, but it's difficult to suggest anything more...

hth
t

-- 
"Trying is the first step towards failure"
                                           Homer Simpson


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

Date: Thu, 22 Jun 2000 00:10:31 +0100
From: Mike Newman <root@gtnorthern.demon.co.uk>
Subject: Re: Syntax of Print <<END; ?
Message-Id: <Pine.LNX.4.21.0006220008530.2611-100000@gtnorthern.demon.co.uk>

On Wed, 21 Jun 2000, Brian Gollands wrote:

> This may be a newbie question, but I'm having trouble finding
> documentation on the usage of END in a print statement, such as:

[snip here doc example]

> I've seen it used and have it working in part of one of my scripts, but
> then tried to use it in a foreach loop that causes a syntax error
> ("...probably a runaway multi-line string..."). I can't find a reference
> to the syntax for this anywhere in the Perl docs or books. Is it right
> under my nose? Thanks for any help!

Your code snippet appeared correct. The important thing is that the label
at the END (in your case), must be the very first thing on that line. If
you are indenting your code with tabs within the foreach loop, this won't
be the case and you'll generate syntax errors.

Mike



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

Date: Wed, 21 Jun 2000 16:36:45 -0700
From: Tom Phoenix <rootbeer@redcat.com>
Subject: Re: Syntax of Print <<END; ?
Message-Id: <Pine.GSO.4.10.10006211635000.4312-100000@user2.teleport.com>

On Wed, 21 Jun 2000, Brian Gollands wrote:

> This may be a newbie question, but I'm having trouble finding
> documentation on the usage of END in a print statement, such as:
> 
> print <<END;

That's a here-document. It's in the perldata manpage.

> I've seen it used and have it working in part of one of my scripts, but
> then tried to use it in a foreach loop that causes a syntax error
> ("...probably a runaway multi-line string..."). 

Make sure that the END tag is all alone on its line. No whitespace before
or after it, no semicolon after it, just a newline at the end of the line.

Good luck with it!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 22 Jun 2000 01:44:11 +0200
From: Abe Timmerman <abe@ztreet.demon.nl>
Subject: Re: Syntax of Print <<END; ?
Message-Id: <3nk2lsojeoqhhqq9kjgh1mbn8fjj17b0e2@4ax.com>

On Wed, 21 Jun 2000 18:12:06 -0400, Brian Gollands
<gollands@cornell.edu> wrote:

> This may be a newbie question, but I'm having trouble finding
> documentation on the usage of END in a print statement, such as:
> 
> print <<END;
> a line
> another line
> yet another line
> END

try perlfaq4:
	"Why don't my <<HERE documents work?"

-- 
Good luck,
Abe


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

Date: 21 Jun 2000 22:10:50 GMT
From: mbadolato@quepasa.com (Mark Badolato)
Subject: Re: using cgi.pm for radio buttons
Message-Id: <8F5A94B1Ambadolatoquepasacom@206.165.3.70>

[posted and mailed]

dpalmeNOSPAM@unitedtraffic.com (D.W.) wrote in 
<01bfdbc5$1eec34e0$cf0114ac@raptor.unitedtraffic.com>:

>     print radio_group(-name=>"DRIVER",
>          -values=>["S", "T"],
>          -default=>$driver,
>          -labels{"S"=>"Solo", "T"=>"Team"});


my %labels = (
	S => 'Solo',
	T => 'Team',
);

print radio_group(
    	-name=>"DRIVER", 
    	-values=>["S", "T"], 
    	-default => $driver, 
    	-labels => \%labels
);

For reference:

http://stein.cshl.org/WWW/software/CGI/cgi_docs.html


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

Date: Wed, 21 Jun 2000 17:35:05 -0700
From: glchy <glchyNOglSPAM@cc21.com.sg.invalid>
Subject: Why cant a cgi and module use the same library?
Message-Id: <00d14958.b0bbde25@usw-ex0108-063.remarq.com>

Hi,

im baffled! Ive noticed thru testing that a library cannot (!)
be called by both a cgi and module if the module is being called
by the cgi.

A.cgi use mod.pm. Both A.cgi and mod.pm require lib.pl. But if
lib.pl is converted into lib.pm, then thers no problem!

A.cgi
=====
use mod;
require ("lib.pl");
&subroutine_lib;

mod.pm
======
package mod;
require ("lib.pl");
use strict;
use vars qw(
@ISA
@EXPORT
);
@ISA = qw(Exporter);
@EXPORT = qw(&subroutine_mod);
&subroutine_lib;
&subroutine_mod;
sub subroutine_mod {
  print "In subroutine_mod\n";
}
1;

#perl A.cgi
In subroutine_lib
In subroutine_mod
Undefined subroutine &main::subroutine_lib called at a.cgi line
5.

My situation is that some subroutines in a library are used in
cgis while at the same time modules called by those cgis could
be using the same or different subroutines in the same library
file. Converting the libraries into modules is not an option
however.

Any way out??

Help would greatly be appreciated!! I.e im rapidly losing all my
hair!!!

Thanks a bunch.

GC

Got questions?  Get answers over the phone at Keen.com.
Up to 100 minutes free!
http://www.keen.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 3448
**************************************


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