[8326] in Perl-Users-Digest
Perl-Users Digest, Issue: 1943 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 20 17:07:49 1998
Date: Fri, 20 Feb 98 14:00:30 -0800
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, 20 Feb 1998 Volume: 8 Number: 1943
Today's topics:
Re: Attatching files with sendmail (John D Groenveld)
Re: Avoiding $` (Tom Grydeland)
Re: call URL from perl? (Mikael Skogstrom)
CGI scripts and frames? (Mikael Skogstrom)
Comm.pl(ftp) examples wanted! (Yongyan Wang)
Re: Control a serial device with Perl oritech@mindspring.com
Re: Glob Problems (Jonathan Feinberg)
Re: HELP! exec doesn't work properly! (Tom Grydeland)
Re: HELP! exec doesn't work properly! (Ernest Axelbank)
Re: HELP! exec doesn't work properly! <cmargoli@world.northgrum.com>
Is this a bug? (Mikael Skogstrom)
Re: KERMIT <mesuess@execpc.com>
Re: KERMIT (Matthew H. Gerlach)
Re: NEWBIE: .= <cybercomm@flinet.com>
Re: Out of memory <mishra.aditya@emeryworld.com>
Re: p5p mail2news gateway dead? (was: Don't use signal (John D Groenveld)
Re: PATH_INFO in perl for nt (Jonathan Feinberg)
Re: Pipe wierdness irishman@technologist.com
Re: Referencing data in an array of arrays <norman.bunn@mci.com>
Re: Referencing data in an array of arrays <sgordon@athena.lbl.gov>
Re: Referencing data in an array of arrays <norman.bunn@mci.com>
Re: Referencing data in an array of arrays <cmargoli@world.northgrum.com>
Re: script incombatibility. (Jonathan Feinberg)
Re: Sendmail with Perl (John D Groenveld)
Re: Sendmail with Perl (Jon Bell)
Re: split on ':', but not '\:' <sami@ehdo.ton.tut.fi>
ts: how to parse embedded commas tsatan@hotmail.com
URL returned in HTML form from script concantenates in <cybercomm@flinet.com>
where is GDBM_File? <lukas@cs.wisc.edu>
Re: WWW form <cybercomm@flinet.com>
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 20 Feb 1998 15:10:12 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Attatching files with sendmail
Message-Id: <6cknv4$gcs$1@tholian.cse.psu.edu>
In article <34ED785B.14CCB406@net7.co.uk>,
Robert Barker <billy@net7.co.uk> wrote:
>Can u attatch files with sendmail???
Use Mime::* to build the message and then Mail::Send to send it.
See CPAN for details.
John
groenveld@acm.org
------------------------------
Date: 20 Feb 1998 19:49:38 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: Avoiding $`
Message-Id: <slrn6ernii.5pv.Tom.Grydeland@mitra.phys.uit.no>
On 20 Feb 1998 13:40:14 -0500,
uri@sysarch.com <uri@sysarch.com> wrote:
> > > /^(.+?)(a+)(.+?)$/
> > surely you mean
> > /^(.*?)(a+)(.*?)$/s
> >
> > //Tom Grydeland <Tom.Grydeland@phys.uit.no>
>
> he never showed the data string. i assumed a single line for
> simplicity. your addition may be more correct but doesn't address the
> original problem (unless it is multiline).
Note that I changed the original +es to *s.
No, you're wrong. Unless you've specified -l to perl, your trailing
newline (or whatever your record separator is) will be in $', but not in
$3 unless you've included /s. Dot won't match newline. Behold:
% perl -ne '/^(.*?)(a+)(.*)/ && print "<$1:$2:$3>\n"'
asdf
<:a:sdf>
% perl -ne '/^(.*?)(a+)(.*)/s && print "<$1:$2:$3>\n"'
asdf
<:a:sdf
>
%
(Apart from that, the other responder is of course correct in that the
last ? is superfluous and should be removed.)
So my final suggestion is:
/^(.*?)(a+)(.*)$/s
^^ insert your regex here
> Uri Guttman SYStems ARCHitecture and Software Engineering
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Fri, 20 Feb 1998 21:51:18 +0100
From: mikael@techtalk.se (Mikael Skogstrom)
Subject: Re: call URL from perl?
Message-Id: <B113AB5696682583A@du142-3.ppp.algonet.se>
In article <34eca394.1095132@208.149.121.250>,
stevenchan69@hotmail.com (stevenchan) wrote:
>>Hello. I noticed an old posting and tried to repeat your advice.
>>
>>I did:
>>
>>#!/my/perl5/path
>>
>>$URL="http://www.yahoo.com";
>>print "Content-Type: text/plain\n\n";
>>print "Location: $URL\n";
>>exit 0;
>>
>>...all this does is actually "print" Location: http://www.yahoo.com on my
>>screen and doesn't actually "go" there. Please advise.
What you should do is to omit the first Mime command and only include:
print "Location: URL \n\n";
Note that there has to be two linefeeds after the command.
Mikael
------------------------------
Date: Fri, 20 Feb 1998 21:51:14 +0100
From: mikael@techtalk.se (Mikael Skogstrom)
Subject: CGI scripts and frames?
Message-Id: <B113AB5296682571F@du142-3.ppp.algonet.se>
It's quite allright to use the HTML tag:
<A HREF="mypage.html" TARGET="MainFrame">This page</A>
Consequently it should be possible to code it this way:
<A HREF="mypage.cgi" TARGET="MainFrame">This page</A>
Where the page is generated dynamically by a script. But when I do this,
the browser wipes away all the frames and starts writing on a new page. Is
there some sort of Mime header I need to include, apart from the
traditional "Content-type: text/html \n\n"?
Mikael
------------------------------
Date: 20 Feb 1998 20:38:10 GMT
From: ywang@news (Yongyan Wang)
Subject: Comm.pl(ftp) examples wanted!
Message-Id: <6ckpji$mts@myst.plaza.ds.adp.com>
--
Yongyan Wang
Automatic Data Processing (ADP) | Email: ywang@plaza.ds.adp.com
ADP Plasa |
2525 SW First Avenue |
Portland, OR 97201 USA | Office (503) 402-3882
------------------------------
Date: Fri, 20 Feb 1998 14:41:50 -0600
From: oritech@mindspring.com
Subject: Re: Control a serial device with Perl
Message-Id: <6ckpqe$ofs$1@nnrp1.dejanews.com>
I too find myself stuck in finding an elegant solution to serial
communications with perl.
Here's what I have:
Digital Unix 3.2G on a Dec Alpha 2100
Perl 5.004_04
I simply wish to capture a 1200 baud data stream that is coming in on
/dev/tty01 (1200,N,8,1) and use perl to parse the stream for various things.
Yes, I have read the perlfaq8 section you referenced below... Plus scoured
the 5 camel book, three other perl programming books i own and visited every
website that has perl and serial on the same page. I am still stuck.
I have tried every variation of open and sysopen, read and sysread that I
thought might work.
This rather ugly method does work, but I would rather not rely on an external
program to do my dirty work:
#!/usr/bin/perl -w
$|=1;
open(TTYSTREAM,"tip tty1|"); #- tty1 being a line in /etc/remote that has
#- term settings for /dev/tty01
select TTYSTREAM;
while(){ hack hack hack print print print etc }
So to save me from eternal damnation, can you Mr. Christiansen or another
UeberGuru, please just give me an small code snippet of how to open that
/dev/tty01 port so I can just read it like any other filehandle!
Please!?!?
Thank you.
In article <6bqupm$4gp$5@csnews.cs.colorado.edu>,
tchrist@mox.perl.com (Tom Christiansen) wrote:
>
> [courtesy cc of this posting sent to cited author via email]
>
> In comp.lang.perl.misc, "Muriel & Dirk O. Wolbeck" <Wolbeck@WriteMe.com>
writes:
> (or was that dirk@wolbeck.de ?)
>
> :I want control a serial device (connected to my Linux box) with Perl. I
> :heard that all I have to do is to open the device as a file and use write
> :and read operations to access the serial device like a modem.
>
> Did you read the faq entry about this?
>
> % man perlfaq8
> How do I read and write the serial port?
>
> --tom
> --
> Tom Christiansen tchrist@jhereg.perl.com
> If you want to see useful Perl examples, we can certainly arrange to have
> comp.lang.misc flooded with them, but I don't think that would help the
> advance of civilization. :-) --Larry Wall in
<1992Mar5.180926.19041@netlabs.com>
>
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 20 Feb 1998 16:48:48 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: Glob Problems
Message-Id: <MPG.f57c44bd4e6d58d989718@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
machak@nas.nasa.gov said...
: I'm having a problem with the Glob function. I have a script that uses
: glob, and it works fine when run from the shell. However, when its
: called from a C++ program using fork() and execl(), the glob function
: does not work, even though the rest of the script appears to run fine.
Could you give us a leeeetle more of a clue about what you mean by "does not
work?" Like, for example, a brief code fragment, the intended output, the
actual output, and error messages? Hmm?
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 20 Feb 1998 20:10:04 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Re: HELP! exec doesn't work properly!
Message-Id: <slrn6eroos.5pv.Tom.Grydeland@mitra.phys.uit.no>
On Fri, 20 Feb 1998 13:49:07 -0500,
Lance <lsj@bnl.gov> wrote:
> Hi,
>
> I have the following lines in a perl script on HP-UX:
>
> open(jj,">junk") || die "Couldn't open junk: $!\n";
> print jj <<EOF; # line A
> 1
> 1
> 0
> 4
> 0
> 5
> 0
> 0
> EOF
close jj;
> exec "trans.x < junk"; # line B
And take a look at perlstyle. Filehandles really ought to be in
uppercase.
> Lance
--
//Tom Grydeland <Tom.Grydeland@phys.uit.no>
------------------------------
Date: Fri, 20 Feb 1998 19:56:44 GMT
From: ernie@law.harvard.edu (Ernest Axelbank)
Subject: Re: HELP! exec doesn't work properly!
Message-Id: <34eddff7.6817053@fas-news.harvard.edu>
Did you try closing the file after printing the lines to it??
print jj << EOF;
text to file goes here
EOF
close(jj);
On Fri, 20 Feb 1998 13:49:07 -0500, "Lance" <lsj@bnl.gov> wrote:
>Hi,
>
> I have the following lines in a perl script on HP-UX:
>
> open(jj,">junk") || die "Couldn't open junk: $!\n";
> print jj <<EOF; # line A
>1
>1
>0
>4
>0
>5
>0
>0
>EOF
>exec "trans.x < junk"; # line B
>
>Note: "trans.x" is a Fortran executable file which uses "junk" as a
>redirected input file
>But it just doesn't work! line A does generate the file "junk", but line B
>not only doesn't recognize "junk" but also makes it null.
>
>If I comment line B and run the rest. It generates "junk". And then I
>uncomment line B and comment the rest of it. (so "junk" already exits) and
>run it. Line B works! I don't understand why they can't work together.
>
>Since I'm new in Perl Programming, this could be a dumb question.
>Any advice will be greatly appreciated!
>
>
>--
>Regards,
>Lance
>lsjATbnl.gov
>
>
------------------------------
Date: Fri, 20 Feb 1998 20:22:12 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: HELP! exec doesn't work properly!
Message-Id: <34EDE5F4.1343@world.northgrum.com>
Lance wrote:
>
> I have the following lines in a perl script on HP-UX:
>
> open(jj,">junk") || die "Couldn't open junk: $!\n";
> print jj <<EOF; # line A
> 1
> 1
> 0
> 4
> 0
> 5
> 0
> 0
> EOF
> exec "trans.x < junk"; # line B
>
> Note: "trans.x" is a Fortran executable file which uses "junk" as a
> redirected input file
> But it just doesn't work! line A does generate the file "junk", but line B
> not only doesn't recognize "junk" but also makes it null.
>
> If I comment line B and run the rest. It generates "junk". And then I
> uncomment line B and comment the rest of it. (so "junk" already exits) and
> run it. Line B works! I don't understand why they can't work together.
>
> Since I'm new in Perl Programming, this could be a dumb question.
The vocabulary word is 'buffering'. For efficiency, the characters
are not actually written to file 'junk' right away; they are saved
in memory and written when a block of suitable size is filled up
or when the file is closed. Using exec terminates the perl program
without flushing the current buffer.
The solution here is to close the filehandle jj before doing the exec.
For more complex applications there are ways of forcing the
buffer to be flushed after each line is printed.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: Fri, 20 Feb 1998 21:51:29 +0100
From: mikael@techtalk.se (Mikael Skogstrom)
Subject: Is this a bug?
Message-Id: <B113AB61966825ACB@du142-3.ppp.algonet.se>
Hi,
I've been working on a script in which I call some subroutines stored in a
separate library. The main code looks like this:
require "/export/www/cgi-bin/my_lib.pm";
use CGI;
&initialize();
$p = new CGI;
The subroutine "initialize" is stored in the file 'my_lib.pm'. When I write
the code as above the lib is skipped, resulting in an error message where
I'm told the routine hasn't been declared.
When I comment all references to the CGI module, the lib is entered
correctly.
When I comment all references to the lib, the CGI module is entered
correctly.
Finally I solved the problem by coding the following way:
push(@INC, "/export/www/cgi-bin/");
require "my_lib.pm";
use CGI;
But that shouldn't be neccessary. According to the manuals, it's allright
to include the path information with the require command.
Mikael
------------------------------
Date: Fri, 20 Feb 1998 14:12:33 -0600
From: Michael Suess <mesuess@execpc.com>
Subject: Re: KERMIT
Message-Id: <6cko3m$1u9@newsops.execpc.com>
Hey Patrick...
IF you get ANY responses..PLEASE, PLEASE inform me...
Also, would you happen to know if there are ANY other serial protocols
in perl script, again PLEASE let me know...
Thanks!!
<Michael>
mesuess@execpc.com
On Wed, 4 Feb 1998, Patrick Husi wrote:
> Does anybody know how I can send a file in my perl script with KERMIT.
> Is there a KERMIT library in perl?
>
> Patrick
>
>
>
------------------------------
Date: Fri, 20 Feb 1998 20:24:08 GMT
From: gerlach@netcom.com (Matthew H. Gerlach)
Subject: Re: KERMIT
Message-Id: <gerlachEop208.M3p@netcom.com>
I have UNIX perl scripts that access the serial port by "talking" to the
ckermit program. On can control the ckermit program to tell it to
transfer files using the kermit protocol or any external protocol you
choose (e.g. X or Z modem). Check the following for some of my example
code:
ftp://www.smallplanetbrewery.com/users/coralie/perl_serial_example
Now if you are on a PC, I would have you perl program call a kermit
script to do the serial work.
Matthew
In article <6cko3m$1u9@newsops.execpc.com> Michael Suess <mesuess@execpc.com> writes:
>Hey Patrick...
>
>IF you get ANY responses..PLEASE, PLEASE inform me...
>
>Also, would you happen to know if there are ANY other serial protocols
>in perl script, again PLEASE let me know...
>
>Thanks!!
>
> <Michael>
> mesuess@execpc.com
>
>
>On Wed, 4 Feb 1998, Patrick Husi wrote:
>
>> Does anybody know how I can send a file in my perl script with KERMIT.
>> Is there a KERMIT library in perl?
>>
>> Patrick
>>
>>
>>
>
------------------------------
Date: Thu, 19 Feb 1998 11:07:35 -0500
From: Michael Telep <cybercomm@flinet.com>
To: seth@e-zcomputer.com
Subject: Re: NEWBIE: .=
Message-Id: <34EC58C6.CB4FB4B9@flinet.com>
Seth wrote:
The book doesn't explain well what .= does; it just compares to +=.
I am guessing this concatinates strings. Am I close?
+= is used with integers ie. $num +=7 is equivalent to $num = $num +7
as are x=, -=, *=, /=
.= is for character (or non integer) strings. ie. $verb = $verb . 's' is
equivalent to $verb .= 's'
It appends the character 's' to the end of $verb.
Note the integer version operate on the $. (with the exeption of x= ,
which appends the number minus 1 to the string.)
try the the different integer operators in this code:
#!usr/bin/perl
print 'Pick a number ';
$num = <>;
chomp $num;
print "\n\n";
$num x=3; #change this to try the different operators.
print"$num";
If $num=5 the x=3 will return 555.
to see how .= work try this code:
#!usr/bin/perl
print 'Type a Verb ';
$verb = <>;
chomp $verb;
print "\n\n";
$verb .= s; #'this appends an 's' to the verb.
print"$verb";
Michael Telep
Cyber Communications, Inc.
West Palm Beach, FL cybercomm@flinet.com
Try Not! Do or do not. There is no try.
------------------------------
Date: Fri, 20 Feb 1998 11:05:06 -0800
From: "Mishra, Aditya" <mishra.aditya@emeryworld.com>
Subject: Re: Out of memory
Message-Id: <6cki52$1ih8@ljcqs003.cnf.com>
>The Perl-script crashes round record nr 640 000 with 'out of memory'.
>Solaris 2.5.1, 512MB memory and 2 GB swap.
Hmmm...seems like you are reading the entire contents of the file into
memory
------------------------------
Date: 20 Feb 1998 15:32:23 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: p5p mail2news gateway dead? (was: Don't use signal handlers)
Message-Id: <6ckp8n$ghe$1@tholian.cse.psu.edu>
In article <link-3101981518460001@news.uit.no>,
Terje Bless <link@tss.no> wrote:
>[This isn't modules material so Followup-To is set accordingly]
>Which reminds me; whatever happened to the p5p mail2news gateway at
>genetics.upenn.edu? From what I can tell it's dead (and has been for quite
>some time).
Check the archive :) The server was moved.
news://cor.newman.upenn.edu/perl.porters-gw
------------------------------
Date: Fri, 20 Feb 1998 16:17:48 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: PATH_INFO in perl for nt
Message-Id: <MPG.f57bd03f82e18c9989716@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
jhedy@racingschools.com said...
: Is there something that needs to be done to get these environment variables
: functioning in Perl in the NT IIS environment? I was considering installing
: Perl for ISAPI to see if this might fix the problem.
:
: Any help is appreciated.
You will find that help in some of the internet resources that deal with your
subject: CGI, and server administration. Unfortunately, this newsgroup does
not.
[This list courtesy of Tom Christiansen.]
CGI FAQ
http://www.webthing.com/page.cgi/cgifaq
The CGI Newsgroup (NOT THIS ONE):
comp.infosystems.www.authoring.cgi
CPAN's Web-related modules in Perl:
http://www.perl.com/CPAN/modules/by-category/15_World_Wide_Web_HTML_HTTP_CGI/
The Idiot's Guide to solving Perl/CGI problems
http://www.perl.com/perl/faq/idiots-guide.html
Perl FAQs
http://www.perl.com/CPAN/doc/FAQs/
Perl Manpages (old)
http://www.perl.com/CPAN/doc/manual/html/
WWW Security FAQ
www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
Web FAQ
http://www.boutell.com/faq/
HTTP Spec
http://www.w3.org/pub/WWW/Protocols/HTTP/
HTML Spec
http://www.w3.org/pub/WWW/MarkUp/
CGI Spec
http://hoohoo.ncsa.uiuc.edu/cgi/interface.html
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: Fri, 20 Feb 1998 15:19:20 -0600
From: irishman@technologist.com
Subject: Re: Pipe wierdness
Message-Id: <6cks0o$r52$1@nnrp1.dejanews.com>
OK I figured it out - I was using $SIG{CHLD} = \&REAPER; just like in the man
page, but that isn't what I wanted. I changed it to:
$SIG{CHLD} = sub {logmsg "Got a pipe signal"};
I would cancel the original article only Dejanews won't let me - but hopefully
this will be of use to someone else.
Steve
-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/ Now offering spam-free web-based newsreading
------------------------------
Date: Fri, 20 Feb 1998 20:16:06 GMT
From: "Norman Bunn" <norman.bunn@mci.com>
Subject: Re: Referencing data in an array of arrays
Message-Id: <awlH.6389$Di1.282713@news.internetMCI.com>
Charles Margolin wrote in message <34EDCEF6.6FD6@world.northgrum.com>...
>Norman Bunn wrote:
>>
>> Need some help referencing data in an array of arrays.
>>
>> Here's the code fragment:
>>
>> $counter3 = 0;
>> print hr;
>> while ($counter3 <= @profileHolder)
>> {
>> @temp = split(/:/,$profileHolder[$counter3]);
>> $profiles[$counter3] = @temp;
> ... code skipped ...
>>
>> It appears that $profiles[$counter3[3]] is returning the array size and
not
>> the array entry value. There's probably a simple explanation for this,
>> right? Like references?
>
>Yes. Saying
> $profiles[$counter3] = @temp;
>is using the array @temp in a scalar context, so the length is assigned
>rather than the array contents. What you need to do is store
>a reference to a copy of @temp. Don't store a reference to @temp
>since you are re-using @temp on each iteration.
>
>For example:
> $profiles[$counter3] = [@temp];
>would create an anonymous array and assign the reference.
>
But it doesn't give the contents. The output is now:
Description is: Hewlett-Packard DeskJet 890Cxi and ARRAY(0xff4298)
----------------------------------------------------------------------------
----
SKU is: ?????? and ARRAY(0xff4298)
----------------------------------------------------------------------------
----
Price is: 111.11 and ARRAY(0xff4298)
----------------------------------------------------------------------------
----
Part Number is: C4555A#ABA and ARRAY(0xff4298)
----------------------------------------------------------------------------
----
Quantity is: 10 and ARRAY(0xff4298)
Norman
------------------------------
Date: Fri, 20 Feb 1998 12:28:00 +0000
From: Shawn Gordon <sgordon@athena.lbl.gov>
To: Norman Bunn <norman.bunn@mci.com>
Subject: Re: Referencing data in an array of arrays
Message-Id: <34ED76CF.3A4A044B@athena.lbl.gov>
First and foremost, you need take some time to learn about
arrays and references - I could see several serious errors in
what your (I think) trying to do.
I include my comments below:
> $counter3 = 0;
$counter3 is a scalar - it is not an array or a reference to an array.
> print hr;
> while ($counter3 <= @profileHolder)
> {
> @temp = split(/:/,$profileHolder[$counter3]);
> $profiles[$counter3] = @temp;
Here @temp is treated as a scalar and returns the number of elements
(4). What
you want is: $profiles[$counter3] = [@temp];
This creates an anonymous array with values @temp and assigns the
reference to $profiles[$counter3].
Access each element via: $profiles[$i][$j].
> It appears that $profiles[$counter3[3]] is returning the array size
> and not
> the array entry value. There's probably a simple explanation for
> this,
> right? Like references?
You got it - check out perlref or you friendly camel book.
good luck
shawn
------------------------------
Date: Fri, 20 Feb 1998 20:43:22 GMT
From: "Norman Bunn" <norman.bunn@mci.com>
Subject: Re: Referencing data in an array of arrays
Message-Id: <KVlH.6900$Di1.306582@news.internetMCI.com>
Opps!
Never mind. I had the multidimensional array as [0[0]] and not [0][0]. My
bad.
Norman Bunn wrote in message ...
>
>Charles Margolin wrote in message <34EDCEF6.6FD6@world.northgrum.com>...
>>Norman Bunn wrote:
>>>
>>> Need some help referencing data in an array of arrays.
>>>
>>> Here's the code fragment:
>>>
>>> $counter3 = 0;
>>> print hr;
>>> while ($counter3 <= @profileHolder)
>>> {
>>> @temp = split(/:/,$profileHolder[$counter3]);
>>> $profiles[$counter3] = @temp;
>> ... code skipped ...
>>>
>>> It appears that $profiles[$counter3[3]] is returning the array size and
>not
>>> the array entry value. There's probably a simple explanation for this,
>>> right? Like references?
>>
>>Yes. Saying
>> $profiles[$counter3] = @temp;
>>is using the array @temp in a scalar context, so the length is assigned
>>rather than the array contents. What you need to do is store
>>a reference to a copy of @temp. Don't store a reference to @temp
>>since you are re-using @temp on each iteration.
>>
>>For example:
>> $profiles[$counter3] = [@temp];
>>would create an anonymous array and assign the reference.
>>
>
>
>But it doesn't give the contents. The output is now:
>
>Description is: Hewlett-Packard DeskJet 890Cxi and ARRAY(0xff4298)
>---------------------------------------------------------------------------
-
>----
>SKU is: ?????? and ARRAY(0xff4298)
>---------------------------------------------------------------------------
-
>----
>Price is: 111.11 and ARRAY(0xff4298)
>---------------------------------------------------------------------------
-
>----
>Part Number is: C4555A#ABA and ARRAY(0xff4298)
>---------------------------------------------------------------------------
-
>----
>Quantity is: 10 and ARRAY(0xff4298)
>
>Norman
>
>
------------------------------
Date: Fri, 20 Feb 1998 21:15:48 GMT
From: Charles Margolin <cmargoli@world.northgrum.com>
Subject: Re: Referencing data in an array of arrays
Message-Id: <34EDF284.6492@world.northgrum.com>
Norman Bunn wrote:
>
> Charles Margolin wrote in message
> >For example:
> > $profiles[$counter3] = [@temp];
> >would create an anonymous array and assign the reference.
> >
>
> But it doesn't give the contents. The output is now:
>
> Description is: Hewlett-Packard DeskJet 890Cxi and ARRAY(0xff4298)
> ----------------------------------------------------------------------------
> ----
> SKU is: ?????? and ARRAY(0xff4298)
> ----------------------------------------------------------------------------
> ----
> Price is: 111.11 and ARRAY(0xff4298)
> ----------------------------------------------------------------------------
> ----
> Part Number is: C4555A#ABA and ARRAY(0xff4298)
> ----------------------------------------------------------------------------
> ----
> Quantity is: 10 and ARRAY(0xff4298)
>
> Norman
Okay. Sorry, I wasn't responding to the whole problem, just setting up
the reference. The subscripting when use you use the array has to be
different too: $profiles[$counter3][3] which is short for
$profiles[$counter3]->[3] or ${$profiles[counter3]}[3].
In other words, @profiles is, like all Perl arrays, a one-dimensional
array. $counter3 is a scalar. $profiles{$counter3] is one (scalar)
element of that array and it would contain a reference to the anonymous
data array. A reference is a scalar value.
@{$profiles[$counter3]} is one of several notations for that data array.
Then you have to subscript the elements of that array.
--
Charles G. Margolin DSSD Internal Information Services
cmargoli@world.northgrum.com Northrop Grumman Corp. 0624/23
margolin@acm.org Hawthorne, California 90250-3277
------------------------------
Date: Fri, 20 Feb 1998 16:36:12 -0500
From: jdf@pobox.com (Jonathan Feinberg)
Subject: Re: script incombatibility.
Message-Id: <MPG.f57c15aabfec260989717@news.concentric.net>
[courtesy cc of this posting sent to cited author via email]
paul@netmagic.net said...
: A lot of the warnings recieved during debugging are 'uninitialized
: values'.
Paul, it seems like you need to learn some Perl fundamentals before you tackle
modifying someone else's code. Have you read "Learning Perl," or taken a
course? We cannot configure that script for you. You'll either have to learn
enough Perl to do it yourself, or hire someone who can. I say this not to be
harsh, but so that you'll understand that programming in Perl is a technical
discipline that requires some study.
I'm also guessing that you need to learn a bit more about what CGI is, and how
it relates to this script you're dealing with. You'll find pointers to CGI
resources at Yahoo.
It's rather difficult to understand exactly which problems you're running
into. Did you put a backslash before *all* of the @'s? If so, you've
neutered all of the array variables. If you want more detailed diagnostics,
then put
use diagnostics;
in the source.
: $mailProp=$FORM{'bb_email'};
:
: open (MAIL, "|$mailprog $mailProp") || die "Can't open $mailprog!\n";
I'm no security expert, but this looks horribly wrong to me. It appears that
you're taking a parameter from an HTML form and throwing it into a system call
without untainting it. Anyone else care to comment on this?
Good luck.
--
#!/usr/bin/perl -w -- Just another Perl hacker,
(open 0),$_=<0>,s,.*- +,,,chop;for(split?@*?){($$_++or$}=$_,y,y \,\
y,<STDIN>,,$$=~s\^\"sub $_ {print'$}'};7"\ee),y,} \,},>STDOUT,,&$_}
# Jonathan Feinberg jdf@pobox.com Sunny Brooklyn, NY
------------------------------
Date: 20 Feb 1998 14:54:57 -0500
From: groenvel@cse.psu.edu (John D Groenveld)
Subject: Re: Sendmail with Perl
Message-Id: <6ckn2h$gas$1@tholian.cse.psu.edu>
In article <6ckjjl$e16@panix.com>, David Staschover <das@panix.com> wrote:
>We are using Perl to send mail to a fairly large distribution list. The
>list is Bcc'ed.. I have a few questions..
Don't do that. Use Mail::Send which will use Mail::Mailer and properly exec
sendmail or if you must go low level, you can use Net::SMTP.
See the MailTools and libnet tarballs from CPAN.
John
groenveld@acm.org
------------------------------
Date: Fri, 20 Feb 1998 20:09:12 GMT
From: jtbell@presby.edu (Jon Bell)
Subject: Re: Sendmail with Perl
Message-Id: <Eop1BD.H6I@presby.edu>
David Staschover <das@panix.com> wrote:
>
>We are using Perl to send mail to a fairly large distribution list. The
>list is Bcc'ed.. I have a few questions..
They look like sendmail questions to me... try asking in
comp.mail.sendmail.
--
Jon Bell <jtbell@presby.edu>
------------------------------
Date: 20 Feb 1998 22:42:35 +0200
From: Sami Sandqvist <sami@ehdo.ton.tut.fi>
Subject: Re: split on ':', but not '\:'
Message-Id: <m3n2fm1004.fsf@ehdo.ton.tut.fi>
jdf@pobox.com (Jonathan Feinberg) writes:
> That doesn't quite work.
Oh shit. Of course it doesn't. I had a funny feeling when I posted
that. I should have tested it more. The mistake was obvious. Time to
re-read Friedl's book. I apologise for the erraneous posting.
Sami
--
#!/bin/perl -w
$_="wee buvkz\nucy!xrtashnpm lrkeprr qloejhithognfaajdtcs";
s$([jp])$\u\$1$g;s;(.)(\n|.);${lc$1}=$2;eg;print map{$$_}("a".."z");
#Sami Sandqvist - samiss@cc.tut.fi - Finger for PGP key.
------------------------------
Date: 20 Feb 1998 20:57:46 GMT
From: tsatan@hotmail.com
Subject: ts: how to parse embedded commas
Message-Id: <6ckqoa$jsq$1@orthanc.reference.com>
** Using the split function or Text::ParseWords won't work here **
Suppose a line of variables has this format:
var1, var2, var3,var4
But sometimes variables are computed and have an alias:
sum(var1, var2) as var3
or even:
sum(sum(var1, var2), sum(var3, sum(var4, var5))) as var6
So how does one parse the following line to get the variable
names var1, var2, and var3:
$x= "var1,var2, sum(sum(i,j), sum(k, sum(l, m))) as var3";
Is there an easier way than iterating over the string char by
char and keeping track of the depth of parenthesis?
groetjes,
ts
--------------------------------------------------------------------
Posted using Reference.COM http://WWW.Reference.COM
FREE Usenet and Mailing list archive, directory and clipping service
--------------------------------------------------------------------
------------------------------
Date: Thu, 19 Feb 1998 10:29:47 -0500
From: Michael Telep <cybercomm@flinet.com>
Subject: URL returned in HTML form from script concantenates in browser.
Message-Id: <34EC4FEA.6A87CB1E@flinet.com>
This one is a puzzler. I'm returning an URL
print<<"EOP" ;
Content-text/html\n\n
<HTML><BODY>
<A HREF="http://www.domain.com">GO HERE</A>
</BODY></HTML>
EOP
When the link is clicked on the returned page, the URL is added to the
URL of the cgi-bin and script the page was returned from. Obviously you
can't link this way.
Anyoene ever deal with this or know how to fix it?
Mike
------------------------------
Date: Fri, 20 Feb 1998 14:51:55 -0600
From: Christopher Lukas <lukas@cs.wisc.edu>
Subject: where is GDBM_File?
Message-Id: <34EDECEB.86E93A83@cs.wisc.edu>
This sounds like a dumb question, but I can't find the GDBM_File module
anywhere. I looked on CPAN and every other perl place I could find and
all I could find were references to it, but not code.
Can someone please tell me where to find it? I have gdbm, just not the
perl module. Please e-mail me as well as post because there's a lot of
messages here to wade through to find your answer.
Thanks.
- Chris Lukas
------------------------------
Date: Thu, 19 Feb 1998 11:30:42 -0500
From: Michael Telep <cybercomm@flinet.com>
To: harry.mj@SPAM_FILTERget2net.dk
Subject: Re: WWW form
Message-Id: <34EC5E30.53CE1BCF@flinet.com>
Your perl script seems to be mailing you the information encoded. You need to
take a look at the script to see if it is using the Perl MAIL format. An
example would be:
print MAIL "Reply-to: $recipient\n";
print MAIL "From : $FORM{'email'}\n";
print MAIL "Subject: $FORM{'subject'}\n"; etc.
where the $FORM{'email'}, $FORM{'subject'} is the information input on your
forms.
efternavn=Andersen means that Andersen was input in the form field named
efternavn
& seperates the fields info. + seperates the words within a field or equals a
space. the % comes before some character if they need to be handled differently
by the http.
If you don't know how to do this ask someone who does.
&e-mail=Birger_rytcher.Andersen@sas.se& means Andersens email address is:
Birger_rytcher.Andersen@sas.se
Michael Telep
Cyber Communications, Inc.
West Palm Beach, FL cybercomm@flinet.com
Harry M. Jensen wrote:
> In our bicycle-club we have a www page with a form wich are e-mailed to me.
> My problem is that I recieve it just like the following:
>
> ------CUT-----------------
> efternavn=Andersen&fornavn=Birger+Rytcjer&gade=St%F8vringvej&husnr=1
> &by=Vanl%F8se&postnr=2720&telefon-hjem=38744223
> &e-mail=Birger_rytcher.Andersen@sas.se&telefon-arb=5685
> &foedselsdag=26sep57&afdeling=cphvk-b&ansat=01jul90&personalenr=29621
> &infomail=cphvk%2Fbga&ita=105001&default=vaeddeloeb&default=store
> %0Amotionsloeb&default=foraarstur
> &kommentar=Hej+Harry+%0D%0A%0D%0AHermed+en+lille+test+%0D%0A%0D%0A
> Ville+det+ikke+v%E6re+en+god+ide+at+l%E6gge+det+%0D%0A
> sidste+%E5rs+baghjul+ind+p%E5+hjemmesiden.+%0D%0A%0D%0A%0D%0Amvh+Biger+
> ------------CUT-----------------
>
> Is there a hint with a Perl script which can make it human readable ??
>
> I have Perl (5.0004)installed on my Linux machine, but thats all I know
> about Perl.
>
> Can anyone advice me with a short hint, or a script ;-)).
>
> Thanks in advance.
>
> --
> Brgds. Harry / Denmark
> ------------------------------------
> Remove SPAM_FILTER from addresses.
> WWW: http://hjem.get2net.dk/harry.mj
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
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.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
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 V8 Issue 1943
**************************************