[7848] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1473 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 14 21:07:21 1997

Date: Sun, 14 Dec 97 18:00:19 -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           Sun, 14 Dec 1997     Volume: 8 Number: 1473

Today's topics:
     Re: @a = m// bug in 5.004_04? (Martien Verbruggen)
     Re: Another Sort problem, this time with numbers (Martien Verbruggen)
     Re: Embedding Perl In A C++ Program (Greg Teets)
     Re: Example on Sending E-Cards with Perl (Martien Verbruggen)
     Re: how can I fork a process from the Web.. (Martien Verbruggen)
     Re: Improve my Perl Loop (Martien Verbruggen)
     PERL 5.004_04 Compilation Errors Under IRIX 6.3 <bugaj@bell-labs.com>
     Re: perl puzzler (Martien Verbruggen)
     Re: pgp encrypion via perl script nospam@minivend.com
     Re: pgp encrypion via perl script nospam@minivend.com
     Re: pgp encrypion via perl script (Michael Budash)
     Problem with getc? <ivan@ultimatech.com>
     Socket Programming Sample in Perl: Telnet.pl <hkchang@netsgo.com>
     Re: text wrap (Michael Budash)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 15 Dec 1997 00:18:09 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: @a = m// bug in 5.004_04?
Message-Id: <671t01$gpq$1@comdyn.comdyn.com.au>

In article <s3p90toejof.fsf@sandpiper.lcs.mit.edu>,
	dmjones@theory.lcs.mit.edu (David M. Jones) writes:

>     if (@a = "a" =~ /b/) {
>         print "TRUE\n";
>     } else {
>         print "FALSE\n";
>     }

> produces the following
> 
>     TRUE

perldoc perlop:

If used in a context that requires a list value, a pattern match
returns a list consisting of the subexpressions matched by the
parentheses in the pattern, i.e., ($1, $2, $3...). (Note that here $1
etc. are also set, and that this differs from Perl 4's behavior.) If
the match fails, a null array is returned.  If the match succeeds, but
there were no parentheses, a list value of (1) is returned.

> According to Devel::Peek, @a is set to ("") rather than (), 
> as I would expect,

Hmmm... The documentation clearly states that a failed match should
return a null array. It doesn't in this case. Now the question is if
this is a bug in perl, or in the documenation?

> and as an old version of perl4 does.

I wouldn't rely on a test with perl4 to always give the same results
as a test in perl5.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
NSW, Australia                      | 


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

Date: 15 Dec 1997 00:34:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Another Sort problem, this time with numbers
Message-Id: <671tvh$gpq$3@comdyn.comdyn.com.au>

In article <34946f73.0@news3.paonline.com>,
	Tom <beans@bedford.net> writes:

> You can provide a routine that uses "<" instead of "lt"
> to change the sort from lexical to numeric...

I think you mean 'uses <=> instead of cmp' :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Mon, 15 Dec 1997 00:39:51 GMT
From: teetshd@email.uc.edu (Greg Teets)
Subject: Re: Embedding Perl In A C++ Program
Message-Id: <34947b8c.25128386@news.ececs.uc.edu>

On Sun, 14 Dec 1997 12:52:56 -0800, Tom Phoenix
<rootbeer@teleport.com> wrote:

The entire information on the referenced page:
NAME 

perlembed - how to embed perl in your C or C++ app 



DESCRIPTION 

Look at perlmain.c, and do something like that. 

Thinking that I might have perlmain.c somewhere, I did a serch on my
hard drive.  Alas, the file was not found.  Perhaps you could direct
me to where to find the file or perhaps where I could find even more
information.

Thanks again.
Greg

>There's a man page called 'perlembed'. Does that point you in the right
>direction? Hope this helps!
>
>-- 
>Tom Phoenix           http://www.teleport.com/~rootbeer/
>rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
>Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
>              Ask me about Perl trainings!
>



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

Date: 15 Dec 1997 00:37:24 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Example on Sending E-Cards with Perl
Message-Id: <671u44$gpq$4@comdyn.comdyn.com.au>

In article <671p0k$m5r$1@zingo.tninet.se>,
	"Andrei Ignat" <t-n-g@algonet.se> writes:

> If you can, please help me find a example on how to send electronic post
> cards using Perl.

What are electronic post cards? If you mean mass emails to people from
a certain lists: there are tons of tools out there to do that. I doubt
that anyone will want to go through the trouble of actually writing yet
another one.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I took an IQ test and the results were
Commercial Dynamics Pty. Ltd.       | negative.
NSW, Australia                      | 


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

Date: 15 Dec 1997 01:20:57 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: how can I fork a process from the Web..
Message-Id: <6720lp$h34$2@comdyn.comdyn.com.au>

In article <01bd08d0$a18c7b00$67638ccf@thestevens>,
	"The Stevens" <thestevens@kih.net> writes:
> I'm trying to something similar using Oracle's WebServer on NT.  My script
> works from the command line, but when it is submitted via the Web the
> background process cranks and then dies immediately.   Does fork() work
> with Perl for Win32......I haven't been able to get it to.

Hmmm, let's see.. Win32, perl.. Maybe there is something in the Perl
for Win32 FAQ!

http://www.perl.com/CPAN/doc/FAQs/nt/Perl_for_Win32_FAQ.html

question 5.1: 
       Function X doesn't seem to work on Perl for Win32. Why not?
	
and fork() is mentioned there. Go figure.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Very funny Scotty, now beam down my
Commercial Dynamics Pty. Ltd.       | clothes.
NSW, Australia                      | 


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

Date: 14 Dec 1997 23:50:00 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Improve my Perl Loop
Message-Id: <671rb8$gmf$1@comdyn.comdyn.com.au>

In article <3491BE27.635DDC94@lach.net>,
	Lachlan Dunlop <lach@lach.net> writes:

>         @ln =
> (aa,9,ab,6,ac,10,ad,16,ae,22, [snip ...] );

You didn't use perl -w, did you? It should have warned you not to use
unquoted strings...

You could use a hash table for this array. That will make it at least
more readable.

%ln = ( 'aa' => 9, 'ab' => 6 .....);

or even, with minimal reformatting:

%ln = ('aa', 9, 'ab', 6, 'ac', 10, 'ad' ... );

Since they are in sorted order, you could use a foreach loop with a
sort on the keys further down.

[SNIP]

>         while (($name=shift(@e)) ne "") {
>                 $len = shift(@e);
>                 $result{$name} = substr($value, $startpos, $len);
>                 $startpos += $len;
>         }

If you have a hash here:

foreach $name (sort keys %ln)
{
	$len = $ln{$name};
	$result{$name} = substr($value, $startpos, $len);
	$startpos += $len;
}

Wether this is actually faster, you'd need to find out with the
Benchmarking stuff. It is, IMO, a lot more readable though :)

But.. the question is, why do you use those names at all? If I
understand correctly, all you use the names for is to store part of
the string in a hash. Unless those names (aa, ab, etc) actually mean
anything, I would probably just store the result in an array.

define an array with lengths

@ln = (9, 6, 10, 16, ...);

[other code]

foreach $len (@ln)
{
	push(@results, substr($value, $startpos, $len));
	$startpos += $len;
}

@results will now contain the substrings in the order they appeared in
the line.

I think this last one is probably most efficient, but again, it needs
a bit of benchmarking to be sure.

If you really need those names aa .. bv, I think that you will find
that the array

( 'aa' .. 'bv' )

will give them to you at any time you need them :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Little girls, like butterflies, need no
Commercial Dynamics Pty. Ltd.       | excuse - Lazarus Long
NSW, Australia                      | 


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

Date: Sun, 14 Dec 1997 20:29:32 -0500
From: Stephan Vladimir Bugaj <bugaj@bell-labs.com>
Subject: PERL 5.004_04 Compilation Errors Under IRIX 6.3
Message-Id: <349487FB.8034D879@bell-labs.com>

I was doing an install Bundle::CPAN using perl -MCPAN -e shell
interactively, and it wanted to
update my PERL to 5.004_04, which was fine with me.  I tried compiling a
dynamic libperl.so
using the system malloc() so I could start using JPL, however this got
the compiler into an infinite
loop (the loop output is copied below).  The compiler is SGI, not Gnu,
and the machine is an IP33
IRIX 6.3 O2 AND this also happened on an IP22 IRIX 6.2 Indy.  However,
both machines build
static PERL 5.004_04 using the PERL malloc() just fine.   (Which is what
I'm now using...)

Any suggestions?

I'd like to be able to use JPL, so getting the dynamic version compiling
properly under IRIX would
be pretty useful to me.

Thanks.

LL+P,
Stephan


This Output Looped:

 ...
ld32: WARNING 134: weak definition of memalign in
/usr/lib32/libmalloc.so preempts that weak definition in
/usr/lib32/libc.so.
 5179:./miniperl: rld: Fatal Error: cannot successfully map soname
'libperl.so' under any of the filenames
/usr/lib32/libperl.so:/lib32/libperl.so:/usr/libn32/libperl.so:/libn32/libperl.so:

        `sh  cflags libperl.so miniperlmain.o`  miniperlmain.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so perl.o`  perl.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so gv.o`  gv.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so toke.o`  toke.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
"toke.c", line 1115: warning(1048): cast between pointer-to-object and
          pointer-to-function
      IoDIRP(datasv) = (DIR*)funcp; /* stash funcp into spare field */
                       ^

"toke.c", line 1134: warning(1048): cast between pointer-to-object and
          pointer-to-function
      if (IoDIRP(FILTER_DATA(0)) == (void*)funcp){
                                    ^

"toke.c", line 1134: warning(1042): operand types are incompatible ("DIR
*"
          and "void *")
      if (IoDIRP(FILTER_DATA(0)) == (void*)funcp){
                                 ^

"toke.c", line 1194: warning(1048): cast between pointer-to-object and
          pointer-to-function
      funcp = (filter_t)IoDIRP(datasv);
              ^

        `sh  cflags libperl.so perly.o`  perly.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so op.o`  op.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so regcomp.o`  regcomp.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so dump.o`  dump.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so util.o`  util.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so mg.o`  mg.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so hv.o`  hv.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so av.o`  av.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so run.o`  run.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so pp_hot.o`  pp_hot.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so sv.o`  sv.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so pp.o`  pp.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so scope.o`  scope.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so pp_ctl.o`  pp_ctl.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
"pp_ctl.c", line 915: warning(1116): non-void function
"Perl_block_gimme"
          (declared at line 897) should return a value
  }
  ^

        `sh  cflags libperl.so pp_sys.o`  pp_sys.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C
-DHAS_TELLDIR_PROTOTYPE -O3
        `sh  cflags libperl.so doop.o`  doop.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so doio.o`  doio.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so regexec.o`  regexec.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so taint.o`  taint.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so deb.o`  deb.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so universal.o`  universal.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so globals.o`  globals.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        `sh  cflags libperl.so perlio.o`  perlio.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
        ld -n32 -shared -L/usr/local/lib -L/usr/lib32 -L/lib32
-L/usr/gnu/lib -o libperl.so perl.o  gv.o toke.o perly.o op.o regcomp.o
dump.o util.o mg.o hv.o av.o run.o pp_hot.o sv.o pp.o scope.o pp_ctl.o
pp_sys.o doop.o doio.o regexec.o taint.o deb.o universal.o globals.o
perlio.o
        cc -n32  -L/usr/local/lib -L/usr/lib32 -L/lib32 -L/usr/gnu/lib
-o miniperl miniperlmain.o libperl.so -lmalloc -lm -lc
ld32: WARNING 85: definition of _calloc in /usr/lib32/libmalloc.so
preempts that definition in /usr/lib32/libc.so.
ld32: WARNING 85: definition of _malloc in /usr/lib32/libmalloc.so
preempts that definition in /usr/lib32/libc.so.
ld32: WARNING 85: definition of _realloc in /usr/lib32/libmalloc.so
preempts that definition in /usr/lib32/libc.so.
ld32: WARNING 85: definition of _free in /usr/lib32/libmalloc.so
preempts that definition in /usr/lib32/libc.so.
ld32: WARNING 134: weak definition of cfree in /usr/lib32/libmalloc.so
preempts that weak definition in /usr/lib32/libc.so.
ld32: WARNING 85: definition of _cfree in /usr/lib32/libmalloc.so
preempts that definition in /usr/lib32/libc.so.
ld32: WARNING 134: weak definition of calloc in /usr/lib32/libmalloc.so
preempts that weak definition in /usr/lib32/libc.so.
ld32: WARNING 134: weak definition of malloc in /usr/lib32/libmalloc.so
preempts that weak definition in /usr/lib32/libc.so.
ld32: WARNING 134: weak definition of realloc in /usr/lib32/libmalloc.so
preempts that weak definition in /usr/lib32/libc.so.
ld32: WARNING 134: weak definition of free in /usr/lib32/libmalloc.so
preempts that weak definition in /usr/lib32/libc.so.
ld32: WARNING 134: weak definition of memalign in
/usr/lib32/libmalloc.so preempts that weak definition in
/usr/lib32/libc.so.
 5379:./miniperl: rld: Fatal Error: cannot successfully map soname
'libperl.so' under any of the filenames
/usr/lib32/libperl.so:/lib32/libperl.so:/usr/libn32/libperl.so:/libn32/libperl.so:

        `sh  cflags libperl.so miniperlmain.o`  miniperlmain.c
          CCCMD =  cc -n32 -DPERL_CORE -c -D_BSD_TYPES -D_BSD_TIME -woff
1009,1110,1184 -OPT:Olimit=0 -I/usr/local/include -DLANGUAGE_C -O3
 ...



--
                        "Do computers think?"
------------------------------------------------------------------------
Stephan Vladimir Bugaj                               bugaj@bell-labs.com
Member of Technical Staff                                 (908) 949-3875
Multimedia Communication Research Dept.              Rm. 4F-601, Holmdel
Bell Labs of Lucent Technologies            www.multimedia.bell-labs.com
PGP Key available from www.pgp.net/wwwkeys.html or your local keyserver.
Non-Lucent personal website located at www.cthulhu-dynamics.com/stephan.
------------------------------------------------------------------------
 STANDARD DISCLAIMER:  My opinions are NOT necessarily those of LUCENT.
------------------------------------------------------------------------
                "Do submarines swim?" - E.W. Dijkstra





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

Date: 15 Dec 1997 01:11:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: perl puzzler
Message-Id: <67203n$h34$1@comdyn.comdyn.com.au>

In article <349193A5.58A26270@ti.com>,
	Max Luther Tuinstra <tuinstra@ti.com> writes:

> Why does $var have the value undef rather than "tarzan" in the print
> statement below?  I understand that the "my" declaration in the "if
> (0)" condition is the

I think you'll find that you are using perl 5.003 of some sorts.
Upgrading to perl 5.004 will most likely get rid of the problem.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | I'm desperately trying to figure out
Commercial Dynamics Pty. Ltd.       | why kamikaze pilots wore helmets - Dave
NSW, Australia                      | Edison 


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

Date: 14 Dec 97 23:38:58 GMT
From: nospam@minivend.com
Subject: Re: pgp encrypion via perl script
Message-Id: <34946e12.0@news.one.net>

brian d foy <comdog@computerdog.com> wrote:
> In article <349435f5.0@news.one.net>, nospam@minivend.com wrote:

>> Especially when it is so easy to fix:
>> 
>>   open(PGP, "| pgpe -atr $recipient > /tmp/pgp_encrypted.$$")
>>         or die "creat: $!\n";
>>   print PGP $unencrypted_data;
>>   close PGP;
>>   die "PGP error" if $?;
>> 
>> Now only PGP encrypted data is stored to disk. Not nearly as unsecure,
>> though you would like to overwrite even that for best security.
>> 
>> I did come in late, so I suppse the question might have been
>> how to do this without creating a disk file. Well, without IPC::Open3
>> or the like you can't with PGP. Not portable. The above is
>> portable to most OSes.

> i'm a bit confused by that last statement.  are you asserting that:

>    * the snippet you gave is portable to most OSes
>       *a) OSes == Unix
>       *b) OSes include the MacOS, for instance, which doesn't
>       know about > or |

c) OSes include Win95/NT, UNIX, and I would presume VMS and plan9 and
QNX -- in other words, any OS supported by standard Perl. I was given to
understand that there was some shell emulation in MacOS. If not then of
course the above will not work.  I know it works on UNIX and Win95/NT,
for I have done it.  I am afraid because I have no Mac and no incentive
to port my app, I cannot say with any confidence. VMS I can't be sure
about either.

>    * IPC::Open3 is portable

No, it is not. That (AFAIK) is UNIX only, which is why I wouldn't
consider it portable.

Regards,
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
There ain't nothin' in this world   131 Willow Lane, Floor 2  | ||  _ \
that's worth being a snot over.     Oxford, OH  45056         | || |_) |
--Larry Wall                        <mikeh@minivend.com>     |___|  _ <
                                    513.523.7621 FAX 7501        |_| \_\


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

Date: 14 Dec 97 23:44:06 GMT
From: nospam@minivend.com
Subject: Re: pgp encrypion via perl script
Message-Id: <34946f46.0@news.one.net>

Michael Budash <mbudash@sonic.net> wrote:

> So I guess the questions are:

>  - can echo prompt in the script I gave as an example, and

No.

>  - can the $unencrypted_data show in a "ps" if the "ps"er was lucky
> enought to execute the "ps" in the partial-second it could even _be_
> available

Yes -- details are OS-dependent.

Regards,
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
"The U.S. Senate -- white           131 Willow Lane, Floor 2  | ||  _ \
male millionaires working           Oxford, OH  45056         | || |_) |
for YOU!" -- Dave Barry             <mikeh@minivend.com>     |___|  _ <
                                    513.523.7621 FAX 7501        |_| \_\


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

Date: Sun, 14 Dec 1997 16:54:54 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: pgp encrypion via perl script
Message-Id: <mbudash-1412971654550001@d108.pm3.sonic.net>

In article <671d0v$35p@bgtnsc02.worldnet.att.net>, comdog@computerdog.com
(brian d foy) wrote:

>> i'm sory, i thought you were trying to get the data off disk and had
>> used echo by mistake. 

nope. said echo and meant echo.

>> you didn't show anything that prepared the data
>> to be echo-ed (there are embedded characters that will give you
>> trouble), or any sanitizing of data being sent to the shell.

what chars are those (that would give my statement trouble if they were in
$unencrypted_data?

>> it seems like a long way to go to open a pipe to a process though, 
>> which perl does inherently with open(). 

yes, perl does give great pipe...but i needed to pipe data into the pgp
binary, _and_ get the data from the same binary's stdout. the
bidirectional open originally mentioned in this thread (Open3?) works, but
is more trouble than i had in mind. so...i used what i used and i have no
regrets, apart from the potential problems mentioned by others in earliest
posts to this thread.

>> avoid backticks whenever possible.

i do.

thanks to all, and still awaiting answers to my questions,
Michael

-- 
                   _____________________________

                       Michael Budash, Owner
                     Michael Budash Consulting
                           707-255-5371
                        707-258-7800 x7736
                   http://www.sonic.net/~mbudash
                         mbudash@sonic.net
                   _____________________________


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

Date: 14 Dec 1997 16:22:10 -0800
From: Ivan Kourtev <ivan@ultimatech.com>
To: ivan@ultimatech.com
Subject: Problem with getc?
Message-Id: <ybbtyj3171.fsf@hector.ultimatech.com>

Hello, everybody,

I am new to perl and trying to write a simple program that reads a
file one character at a time---using the 'getc' function---and copies
it to another file specified by me (reading a line at a time works
just fine, but I need a character at a time).  However, depending on
what file I am reading, my program dies at some point before the end
of the input file.  Here's the script---can anybody tell me what am I
doing wrong?

I've also enclosed what appears to be written to the output file when
I run the script on itself as well as the terminal output.  Thanks a
lot for any suggestions!

-
ivan.

*********** Script text ****************
#!/usr/local/bin/perl -w

print "Name of file to read from > "; # prompt user
$InFile = <STDIN>;                    # get a filename
print "Name of file to write to > ";  # prompt user
$OutFile = <STDIN>;                   # get a filename

open (INFILE, $InFile) or die "Can't read $InFile\n";
open (OUTFILE, ">$OutFile") or die "Can't write $OutFile\n";

$line_no = 0;                         # initialize line counter
$char_no = 0;                         # initialize character counter

printf(OUTFILE "%5d: ", ++$line_no);      # print $line_no
while ($Char = getc INFILE) {
    ++$char_no;
    if ($Char eq "\n") {
	printf(OUTFILE "\n%5d: %s", ++$line_no, $Line);
    }
    else {
	printf(OUTFILE $Char);
    }
}
printf("Read %d lines and %d characters\n", $line_no, $char_no);


*********** Output file when script above is run on itself ***********
    1: #!/usr/local/bin/perl -w
    2: 
    3: print "Name of file to read from > "; # prompt user
    4: $InFile = <STDIN>;                    # get a filename
    5: print "Name of file to write to > ";  # prompt user
    6: $OutFile = <STDIN>;                   # get a filename
    7: 
    8: open (INFILE, $InFile) or die "Can't read $InFile\n";
    9: open (OUTFILE, ">$OutFile") or die "Can't write $OutFile\n";
   10: 
   11: $line_no = 

*********** Console output ***********
#154 > my1
Identifier "main::Line" used only once: possible typo at my1 line 18.
Name of file to read from > my1
Name of file to write to > my1.5
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Use of uninitialized value at my1 line 17, <STDIN> line 2.
Read 11 lines and 368 characters

#155 >


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

Date: Mon, 15 Dec 1997 09:40:46 +0900
From: "CHANG" <hkchang@netsgo.com>
Subject: Socket Programming Sample in Perl: Telnet.pl
Message-Id: <ybsXnHPC9GA.248@newsfeed.netsgo.com>

This is a multi-part message in MIME format.

------=_NextPart_000_007B_01BD093D.85BCF450
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_007C_01BD093D.85C1AF40"


------=_NextPart_001_007C_01BD093D.85C1AF40
Content-Type: text/plain;
	charset="euc-kr"
Content-Transfer-Encoding: quoted-printable

I've tested well known socket programming sample, telnet.pl. For your =
information, I'll attach it at the end of this question.=20

Q: I try to connect tcp port # 21(ftp), 23(telnet), 80(http) using =
telnet.pl by changing tcp port argument on Unix and Win NT. And I hope =
to get a response from these server(ftp, telnet, http). It works well in =
case of ftp and http, but telnet server does't give any response. I have =
same result on Unix and NT. I don't know why it doesn't work only for =
Telnet service. Please give any comments about this!!!=20

Thanks in advance.=20

Here's sampel source of telnet.pl:=20
--------------------------------------------------------=20
Telnet.pl=20

#tcp-client=20
( $them, $port ) =3D @ARGV;=20

$port =3D 23 unless $port;=20
$them =3D 'localhost' unless $them;=20
$AF_INET =3D 2;=20
$SOCK_STREAM =3D 1;=20

$SIG{'INT'} =3D 'dokill';=20
sub dokill {=20
 kill 9,$child if $child;=20
}=20

$sockaddr =3D 'S n a4 x8';=20

#chop($hostname =3D `hostname`);=20
($name,$aliases,$proto) =3D getprotobyname('tcp');=20
($name,$aliases,$port) =3D getservbyname($port,'tcp')=20
 unless $port =3D~ /^\d+$/;;=20
($name,$aliases,$type,$len,$thisaddr) =3D=20
gethostbyname($hostname);=20
($name,$aliases,$type,$len,$thataddr) =3D gethostbyname($them);=20

$this =3D pack($sockaddr, $AF_INET, 0, $thisaddr);=20
$that =3D pack($sockaddr, $AF_INET, $port, $thataddr);=20

if (socket(S, $AF_INET, $SOCK_STREAM, $proto)) {=20
 print "socket ok\n";=20
}=20
else {=20
 die $!;=20
}=20

if (bind(S, $this)) {=20
 print "bind ok\n";=20
}=20
else {=20
 die $!;=20
}=20

if (connect(S,$that)) {=20
 print "connect ok\n";=20
}=20
else {=20
 die $!;=20
}=20

select(S); $| =3D 1; select(STDOUT);=20
$a=3D<S>;print "$a";=20
while( $b=3D<STDIN> ) {=20
print S "$b\n";=20
$a=3D<S>;print "$a";=20
}=20
exit 1 ;=20


------=_NextPart_001_007C_01BD093D.85C1AF40
Content-Type: text/html;
	charset="euc-kr"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">
<HTML>
<HEAD>

<META content=3D"text/html; charset=3Dks_c_5601-1987" =
http-equiv=3DContent-Type>
<META content=3D'"MSHTML 4.72.2106.11"' name=3DGENERATOR>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D+1>I've tested well known socket programming sample, =
telnet.pl.=20
For your information, I'll attach it at the end of this question. =
<BR><BR>Q: I=20
try to connect tcp port # 21(ftp), 23(telnet), 80(http) using telnet.pl =
by=20
changing tcp port argument on Unix and Win NT. And I hope to get a =
response from=20
these server(ftp, telnet, http). It works well in case of ftp and http, =
but=20
telnet server does't give any response. I have same result on Unix and =
NT. I=20
don't know why it doesn't work only for Telnet service. Please give any =
comments=20
about this!!! <BR><BR>Thanks in advance. <BR><BR>Here's sampel source of =

telnet.pl: <BR>--------------------------------------------------------=20
<BR>Telnet.pl <BR><BR>#tcp-client <BR>( $them, $port ) =3D @ARGV; =
<BR><BR>$port =3D=20
23 unless $port; <BR>$them =3D 'localhost' unless $them; <BR>$AF_INET =
=3D 2;=20
<BR>$SOCK_STREAM =3D 1; <BR><BR>$SIG{'INT'} =3D 'dokill'; <BR>sub dokill =
{ <BR><IMG=20
alt=3D"   " height=3D1 =
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com"=20
width=3D24> kill 9,$child if $child; <BR>} <BR><BR>$sockaddr =3D 'S n a4 =
x8';=20
<BR><BR>#chop($hostname =3D `hostname`); <BR>($name,$aliases,$proto) =3D =

getprotobyname('tcp'); <BR>($name,$aliases,$port) =3D =
getservbyname($port,'tcp')=20
<BR><IMG alt=3D"   " height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> unless=20
$port =3D~ /^\d+$/;; <BR>($name,$aliases,$type,$len,$thisaddr) =3D=20
<BR>gethostbyname($hostname); <BR>($name,$aliases,$type,$len,$thataddr) =
=3D=20
gethostbyname($them); <BR><BR>$this =3D pack($sockaddr, $AF_INET, 0, =
$thisaddr);=20
<BR>$that =3D pack($sockaddr, $AF_INET, $port, $thataddr); <BR><BR>if =
(socket(S,=20
$AF_INET, $SOCK_STREAM, $proto)) { <BR><IMG alt=3D"   " height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> print=20
&quot;socket ok\n&quot;; <BR>} <BR>else { <BR><IMG alt=3D"   " =
height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> die $!;=20
<BR>} <BR><BR>if (bind(S, $this)) { <BR><IMG alt=3D"   " height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> print=20
&quot;bind ok\n&quot;; <BR>} <BR>else { <BR><IMG alt=3D"   " height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> die $!;=20
<BR>} <BR><BR>if (connect(S,$that)) { <BR><IMG alt=3D"   " height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> print=20
&quot;connect ok\n&quot;; <BR>} <BR>else { <BR><IMG alt=3D"   " =
height=3D1=20
src=3D"cid:007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com" =
width=3D24> die $!;=20
<BR>} <BR><BR>select(S); $| =3D 1; select(STDOUT); =
<BR>$a=3D&lt;S&gt;;print=20
&quot;$a&quot;; <BR>while( $b=3D&lt;STDIN&gt; ) { <BR>print S =
&quot;$b\n&quot;;=20
<BR>$a=3D&lt;S&gt;;print &quot;$a&quot;; <BR>} <BR>exit 1 ;=20
<BR></FONT></DIV></BODY></HTML>

------=_NextPart_001_007C_01BD093D.85C1AF40--

------=_NextPart_000_007B_01BD093D.85BCF450
Content-Type: image/gif
Content-Transfer-Encoding: base64
Content-ID: <007201bd08f2$15083850$48293b9d@hkchang2.vpnisp.com>

R0lGODlhAQABAJH/AP///wAAAMDAwAAAACH5BAEAAAIALAAAAAABAAEAAAICVAEAOw==

------=_NextPart_000_007B_01BD093D.85BCF450--



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

Date: Sun, 14 Dec 1997 16:02:19 -0700
From: mbudash@sonic.net (Michael Budash)
Subject: Re: text wrap
Message-Id: <mbudash-1412971602190001@d108.pm3.sonic.net>

In article <344ae17f.262941158@news.west.net>, name@server.com (Mike
Rambour) wrote:
>> p.s. What I am trying to do is take text from a textarea and save it
>> to a file but I need the output in 70 chars and it comes out as one
>> big line.  From my searching of the web, what I think I need is
>> text:::wrap.

I've had good luck with this in the html, not some perl trick:

<textarea name="body" rows=10 cols=70 wrap="hard">

Michael

-- 
                   _____________________________

                       Michael Budash, Owner
                     Michael Budash Consulting
                           707-255-5371
                        707-258-7800 x7736
                   http://www.sonic.net/~mbudash
                         mbudash@sonic.net
                   _____________________________


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

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

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