[7683] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1309 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 12 22:17:06 1997

Date: Wed, 12 Nov 97 19:00:23 -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           Wed, 12 Nov 1997     Volume: 8 Number: 1309

Today's topics:
     Re: (in)efficient memory use--shm reset <dbenhur@egames.com>
     Re: Better Way in Perl (E.None Archibald)
     Re: Better Way in Perl (E.None Archibald)
     Re: CGI Script Permission Problems (Martien Verbruggen)
     Re: CGI Script Permission Problems (Martien Verbruggen)
     Re: COMPILED PERL CODE???POSSIBLE? (Martien Verbruggen)
     Re: Concurrent writes to one named pipe (Martien Verbruggen)
     Re: CPAN confusion (Martien Verbruggen)
     Re: File name problem when using PERL to send binary fi (Martien Verbruggen)
     How to use perl script to download exe file? <mysun@mbox2.singnet.com.sg>
     HTML Forms and Data Storage <tgeorge@twnetwork.com>
     Re: passing C structure to syscall() function in perl?? (Mike Stok)
     Re: Passing Value ?????? (Martien Verbruggen)
     Re: Perl Build Failure (Tye McQueen)
     Re: Problems with system() in a for loop (Jason Gloudon)
     Re: Q: Wierd argument passing, bug? (Henry Gabryjelski)
     Re: Q: Wierd argument passing, bug? (Tad McClellan)
     Re: Split Screen Telnet (Martien Verbruggen)
     Re: Split Screen Telnet <markm@nortel.ca>
     Re: Statistics for comp.lang.perl.misc (Tad McClellan)
     Re: Tainting Question <dagon@halcyon.com>
     Re: What's wrong w/this picture? (Tad McClellan)
     Re: What's wrong w/this picture? (Mike King)
     Re: What's wrong w/this picture? (Tad McClellan)
     Re: What's wrong w/this picture? <markm@nortel.ca>
     Re: Will pay $$ for FORM-to-DBASE perl script (Martien Verbruggen)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 12 Nov 1997 17:43:09 -0800
From: Devin Ben-Hur <dbenhur@egames.com>
To: Edward Henigin <ed@texas.net>
Subject: Re: (in)efficient memory use--shm reset
Message-Id: <346A5B2D.422E@egames.com>

[mail&post]
Edward Henigin wrote:
>         To zero out the shared memory segment, I was first planning
> on doing this:
> $DATUMSIZE = length(pack("LL",0));
> $MAXCOUNT  = 64 * 1024;
> 
> my $ps = "c" x ($DATUMSIZE * $MAXCOUNT);
> my @pa = (0) x ($DATUMSIZE * $MAXCOUNT);
> my $zerostring = pack($ps, @pa);
[snip complaint and another approach]

>         So I'm thinking, this approach isn't going to work very well
> at all.  But I'd like to be able to do something like
> 
> shmwrite($ID, $zerostring, 0, $DATUMSIZE * $MAXCOUNT);
> 
>         Can anyone suggest any other way to zero out the shared
> memory segment? 

A quick look at the pack() section of the Camel (pg 195-197) yields
several possibilities for making your zerostring:

1) use the "a" format (ASCII string, null filled). eg:
  $length = ($DATUMSIZE * $MAXCOUNT)
  $zerostr = pack("a$length", "");

2) use the "x" format (null byte)
  $zerostr = pack("x$length");

3) use the "@" format (null fill to absolute position)
  $zerostr = pack("@$length");

I have no idea which of these is fastest or least mem-intensive, but I
suspect they're all better then the approaches you were trying because
they avoid the $something x 64K repeat operation.

I tried this one liner with perl/Win95 on a P166 and it was nearly
instant:  perl -e "print length pack('x1000000')"

HTH
--
Devin Ben-Hur     <dbenhur@egames.com>
eGames.com, Inc.  http://www.egames.com/  The Ultimate Game Store
"Dark is the suede that mows like a harvest" -- Martian Ambassador




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

Date: 13 Nov 1997 01:41:19 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: Better Way in Perl
Message-Id: <64dlrv$b16$1@tepe.tezcat.com>

ls|perl -ne 's/(.*)\.cin$/`mv $& $1`/e' (tied at 38 characters)

however, there is no need for a space after the -e argument:

ls|perl -ne's/(.*)\.cin$/`mv $& $1`/e' (tied at 37 characters, omitting the
                                        same space)

--eugene

Walker Curtis <curtis@ei.kodak.com> wrote:
: It would be correct behavior for 6.cin.cin to be renamed
: to 6.cin.  Sorry if this wasn't clear originally.

: So far I see

: perl -e 'map{`mv $_ $\``if/\.cin$/}<*>' (39 characters, perl 5.002 or
: later)

: ls|perl -ne '`mv $\`$& $\``if/\.cin$/' (38 characters)

: ls|perl -ne '/\.cin$/&&`mv $\`$& $\``' (38 characters)

: ls *.cin|sed 's/\(.*\)\..*/mv & \1/'|sh (39 characters)


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

Date: 13 Nov 1997 01:56:28 GMT
From: yevgene@xochi.tezcat.com (E.None Archibald)
Subject: Re: Better Way in Perl
Message-Id: <64dmoc$b37$1@tepe.tezcat.com>

Oops!

Just after i posted this i figured out a 35/36 character one:

ls|perl -nle'/\.cin$/&&`mv $_ $\``'  (35)
ls|perl -nle '/\.cin$/&&`mv $_ $\``' (36)

--eugene

E.None Archibald <yevgene@xochi.tezcat.com> wrote:
: ls|perl -ne 's/(.*)\.cin$/`mv $& $1`/e' (tied at 38 characters)

: however, there is no need for a space after the -e argument:

: ls|perl -ne's/(.*)\.cin$/`mv $& $1`/e' (tied at 37 characters, omitting the
:                                         same space)

: --eugene

: Walker Curtis <curtis@ei.kodak.com> wrote:
: : It would be correct behavior for 6.cin.cin to be renamed
: : to 6.cin.  Sorry if this wasn't clear originally.

: : So far I see

: : perl -e 'map{`mv $_ $\``if/\.cin$/}<*>' (39 characters, perl 5.002 or
: : later)

: : ls|perl -ne '`mv $\`$& $\``if/\.cin$/' (38 characters)

: : ls|perl -ne '/\.cin$/&&`mv $\`$& $\``' (38 characters)

: : ls *.cin|sed 's/\(.*\)\..*/mv & \1/'|sh (39 characters)


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

Date: 13 Nov 1997 00:56:12 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CGI Script Permission Problems
Message-Id: <64dj7c$c8j$4@comdyn.comdyn.com.au>

In article <3468B0ED.F9A62C5A@bridge.bellsouth.com>,
	Brad Bradley <brad.bradley@bridge.bellsouth.com> writes:
> I have an HTTP File Upload program that runs with webserver permissions.
> (very low, for security purposes.) I need it to access different
> directories on the shared server with much higher permissions. One of

Have a look at the perl security page (perldoc perlsec) and the
wrpasuid and suidperl programs in the eg directory of your perl
distribution.

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


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

Date: 13 Nov 1997 01:50:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CGI Script Permission Problems
Message-Id: <64dmca$cp9$1@comdyn.comdyn.com.au>

In article <3468B0ED.F9A62C5A@bridge.bellsouth.com>,
         Brad Bradley <brad.bradley@bridge.bellsouth.com> writes:
> I have an HTTP File Upload program that runs with webserver permissions.
> (very low, for security purposes.) I need it to access different
> directories on the shared server with much higher permissions. One of

Have a look at the perl security page (perldoc perlsec) and the
wrapsuid and suidperl programs in the eg directory of your perl
distribution.

Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

Date: 13 Nov 1997 01:54:35 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: COMPILED PERL CODE???POSSIBLE?
Message-Id: <64dmkr$cp9$3@comdyn.comdyn.com.au>

In article <64an9u$298$1@goanna.cs.rmit.edu.au>,
	exalter@yallara.cs.rmit.edu.au (Hafeezhussein Hatimabana ) writes:

> Is is possible it write perl scripts scuh that your code is not visible?e.g
> for instance,the perl interpreter compiles the code before it is
> interpreted..sort of a temporary compiltion..but this state is not
> preserved.Is there a way around it such that code remains unseen?

perldoc perlfaq3
How can I compile my Perl program into byte-code or C?

> I would also like to know where the FAOS for this news group and anyother
> perl rnews groups are kept,

Excellent question!

http://www.perl.com/
http://language.perl.com/info/documentation.html
http://language.perl.com/faq/index.html

The faq's should also be available with your distribution (through
perldoc). Try

perldoc perlfaq
perldoc perl

> 
> Thanks in advance,

No problem.
Martien

-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | We are born naked, wet and hungry. Then
Commercial Dynamics Pty. Ltd.       | things get worse.
NSW, Australia                      | 


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

Date: 13 Nov 1997 01:26:50 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Concurrent writes to one named pipe
Message-Id: <64dl0q$chq$1@comdyn.comdyn.com.au>

In article <64aps9$t7g@bgtnsc03.worldnet.att.net>,
	"Alan Fahrner" <sherlock.holmes@worldnet.att.net> writes:

> Below is the "unclean" test code I'm writing.  Any suggestions.

Implement some file locking. Have a look at
http://www.stonehenge.com/merlyn/WebTechniques/col04.html. If flock
doesn't work for named pipes (does it?) You might want to try
implementing your own locking mechanism.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.       | again. Then quit; there's no use being
NSW, Australia                      | a damn fool about it.


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

Date: 13 Nov 1997 00:45:25 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: CPAN confusion
Message-Id: <64dij5$c8j$1@comdyn.comdyn.com.au>

In article <64acnr$7q42@holly.colostate.edu>,
	Andrea Beam <abeam@holly.ColoState.EDU> writes:
> Martien Verbruggen <mgjv@comdyn.com.au> wrote:
> 
>: No one is forcing you to use CPAN. You could always just write all the
>: modules yourself.
> 
> He didn't complain about the quality of the modules.  He complained
> about the layout of CPAN.  How would writing all the modules himself
> solve that?

He wouldn't have to look them up. My point was that if he finds
looking up modules too hard, he can always write them himself. 

As a comparison, before the CPAN days, you had to actually almost know
where to go to to find code that you could reuse. A script to do this
could be found at that ftp server, a script to do that at that other
one. CPAN just was meant to get all of the reusable code in one place,
neatly organised. Before CPAN, a lot of people DID end up rewriting
code, because they simply didn't know it already existed. Now it takes
about five minutes to find out if it has already been done.

>: If you are going to request a change, I would suggest that you change
>: your tone of voice a bit. I for one (and obviously others) found it at
>: least slightly on the offensive side.
> 
> Wow.  If something is a pain in the ass why beat around the bush?  Why
> don't you spare us all the parenting bit, and come back when you've grown a
> thicker skin.

Now, now. how did my reply warrant that sort of nastiness? it doesn't
have much to do with thick skin, but more with a basic politeness that
I feel is owed to someone who provides a free service, and has
invested a lot of time in this service. You will notice, if you take
the time to find out, that being rude doesn't nearly get you as many
results as being nice about things. Phrasing a complaint in a nice way
can be lots more effective than phrasing it in a demanding, offensive
way.

The original poster of this thread realised that as well, and admitted
that, which I think is a great thing, and very commendable.

Since this really hasn't anything to do with perl anymore, I think we
should just forget it. if you think I am too 'parenting', fine. I am
really not too worried about that. All I was worried about was a
general politeness and niceness which can make this newsgroup a better
place.

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: 13 Nov 1997 00:53:32 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: File name problem when using PERL to send binary files over CGI
Message-Id: <64dj2c$c8j$3@comdyn.comdyn.com.au>

In article <01bcef17$73e36560$511e09a8@weixiao>,
	"David" <mysun@mbox2.singnet.com.sg> writes:

> while (<STDOUT>){

You mean

while (<DOWNFILE>)

right?

> But when I use a browser to access this script, the browser asks me to save
> file as script name Send.???,not actual file name(aa.exe, bb.doc or
> cc.txt).

Please use a search engine like Dejanews or Altavista to find previous
answers to this question. In short: You need to do something like:

http://www.server/cgi-bin/this_is_my_script/file_name_to_save

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


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

Date: 13 Nov 1997 02:43:06 GMT
From: "David" <mysun@mbox2.singnet.com.sg>
Subject: How to use perl script to download exe file?
Message-Id: <01bcefdd$c784a0a0$511e09a8@weixiao>

Hi, all there,

I try to use perl script to let client browser to download various kinds of
files such as .exe, .doc, .txt, .zip and so on.

My simplified perl script likes as follows:
print "Location: http://www.mysite.com/pub/$filename\n\n";	# $filename may
be file.exe, file.doc, file.txt or file.zip

This script works fine with .doc,.txt and .zip, but not .exe file. The
reason is that .exe file is interpreted as CGI script.

any suggestions will be appreciated.

Thanks




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

Date: Wed, 12 Nov 1997 17:31:53 -0800
From: Thomas George <tgeorge@twnetwork.com>
Subject: HTML Forms and Data Storage
Message-Id: <346A5889.B835D3DC@twnetwork.com>

Does anyone have a simple script for storing/appending data from
web-based forms in an ascii file?

It doesn't seem like it would be difficult, but I have not yet had the
time to learn the perl coding for such a task.

Any assistance would be greatly appreciated.

--
Thomas George




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

Date: 13 Nov 1997 02:35:07 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: passing C structure to syscall() function in perl???
Message-Id: <64dp0r$n2h@news-central.tiac.net>

In article <64dhfk$a4i$1@NNTP.MsState.Edu>,
Salman Mughal <msm6@Ra.MsState.Edu> wrote:
>
>Hi there!
>
>I am trying to call setitmer() routine from a perl script:
>
>                syscall(&SYS_setitmer, ......);
>
>C prototype looks like this:
>
>int setitimer(int which, const struct itimerval *value,
>                               struct itimerval *ovalue);
>
>Passing integer is not a problem ofcourse but it's the itmerval
>structure which has me baffled.  The typedef for it looks:
>
>struct timeval {
>        long    tv_sec;         /* seconds */
>        long    tv_usec;        /* and microseconds */
>};
>
>struct  itimerval {
>        struct  timeval it_interval;    /* timer interval */
>        struct  timeval it_value;       /* current value */
>};
>
>How do I pass a pointer to itimerval structure in syscall() ?
>Thanks for any help!

On my linux system the longs in an itimerval are all packed together end
to end with no padding, so you can use pack with a template of 'llll' (4
longs) to pack a scalar with the appropriate byte sequence e.g.

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

require 'sys/syscall.ph';

$tiValTemplate = 'l l l l';

$ovalue = pack $tiValTemplate, 0, 0, 0, 0;
$value  = pack $tiValTemplate, 0, 0, 5, 0;

$start = localtime;

$ret = syscall (&SYS_setitimer (), 0, $value, $ovalue);
print "setitimer syscall returned $ret\n";

sleep 2;

$ret = syscall (&SYS_getitimer, 0, $value);
print "getitimer syscall returned $ret\n";

@values = unpack $tiValTemplate, $value;
print "values are @values\n";

eval {
  local ($SIG{'ALRM'}) = sub {die "ring\n"};
  sleep;
};

$finish = localtime;

print "done : $@";
print "$start to $finish\n";

__END__

prints

setitimer syscall returned 0
getitimer syscall returned 0
values are 0 0 3 0
done : ring
Wed Nov 12 21:33:23 1997 to Wed Nov 12 21:33:28 1997

on my system.  The pstruct program which comes with perl may help you
check how the structure's laid out e.g.

$ pstruct -sitimerval /usr/include/sys/times.h 
struct itimerval {
  struct timeval     itimerval.it_interval      0       8
    int              itimerval.it_interval.tv_sec      0       4
    int              itimerval.it_interval.tv_usec      4       4
  struct timeval     itimerval.it_value         8       8
    int              itimerval.it_value.tv_sec      8       4
    int              itimerval.it_value.tv_usec     12       4
}

Hope this helps,

Mike
-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: 13 Nov 1997 02:27:08 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Passing Value ??????
Message-Id: <64dohs$d0u$1@comdyn.comdyn.com.au>

In article <3469ae85.7593210@news.jaring.my>,
	bslee@pl.jaring.my (B.S.LEE) writes:
> How can I pass data/value from a perl script to a C/C++ programme, to
> let the C|C++ programme process the data/value, then return to Perl
> script ??????????

If it is a program, you will need to write the program in such a way
that it allows command line parameters. If you have the source code,
and you want to write a C interface for a perl module, have a look at

perldoc perlxs
perldoc perlxstut
perldoc perlguts

> email: bslee@pl.jaring.my

yes, the From: field did mention that as well.

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


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

Date: 12 Nov 1997 18:24:05 -0600
From: tyde@medtrodnet.cdom (Tye McQueen)
Subject: Re: Perl Build Failure
Message-Id: <64dhb5$orh@fiinix.metronet.com>

) (Jonathan B. Joseph) wrote:
) > I am trying to build perl 5.004_04 for Unixware 2.1.2.  I obtained it
) > from ftp.perl.org and downloaded latest.tar.gz.
) >
) > My build attempt is crashing during the linker stage and I get the
) > following message:
) >
) >    dynamic linker : ./miniperl : error opening libperl.so
) >    Killed

neilb@zetnet.co.uk (Neil Briscoe) writes:
) Yup, do a make realclean - and then re-run sh Configure.
) 
) When it asks you if you want to build a dynamically linked perl library,
) answer in the negative - then it will build a libperl.a instead and all
) should be well.  Just means a much larger perl binary.  Ah well.

Or just notice that Configure tells you:

    If you wish to use dynamic linking, you must use 
	    LD_LIBRARY_PATH=`pwd`; export LD_LIBRARY_PATH
    or
	    setenv LD_LIBRARY_PATH `pwd`
    before running make.


Yes, it would be nice if it didn't have to tell you that
and you didn't have to do it.  Feel free to fix it.  See
http://www.metronet.com/~tye/perlsvr4.html for more hints
that haven't been updated but still seem to apply.
--
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)
       Remove d's from address to reply (sorry for the inconvenience).


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

Date: 13 Nov 1997 02:36:44 GMT
From: jgloudon@bbn.remove.com (Jason Gloudon)
Subject: Re: Problems with system() in a for loop
Message-Id: <64dp3s$dpa$1@daily.bbnplanet.com>

jmack@p3.net wrote:
: I'm having problems with a variable I pass into a system() call.  I need
: to grep a months worth of log files for 2 particular pages to make a new
: log file for just these 2 pages.  Our logs get big, so they are zipped at
: the end of each day.  So these zipped files  need to be copied (for
: safety, plus I don't own them), unzipped, egreped, and deleted.

If you are using Perl5 the Compress::Zlib module would greatly simplify
this task.

Jason Gloudon


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

Date: 13 Nov 1997 00:52:53 GMT
From: henryg@ernie.WPI.EDU (Henry Gabryjelski)
Subject: Re: Q: Wierd argument passing, bug?
Message-Id: <64dj15$1ag$1@bigboote.WPI.EDU>

brian d foy <comdog@computerdog.com> wrote:
>henryg@ernie.WPI.EDU (Henry Gabryjelski) wrote:
>>TestArgs(   $key++,   $key   ); # Case 1
>>TestArgs(   $key,     $key++ ); # Case 2
--! SNIP !--
>with these rules:
>
>   * all pre-increments and pre-decrements are done before
>   any values are added to the argument list.
>
>   * post-increments and post-decrements can occur as soon as
>   the value is used (as normal) - meaning that as soon as
>   the value is added to the argument list, it can be 
>   modified.
--! SNIP !--
>   1.  $key is added to the list and then post incremented.  it
>   has a value immediately because the post-increment is post
>   :) then the next argument is $key, which is now the
>   incremented value.
>   
>   2.  $key is post-incremented in the second argument, which
>   had an immediate value of zero.  the first argument is then
>   the incremented value.
--! SNIP !--

Wow! This is highly contorted, and certainly not what I expected to
occur.  My previous experience with arguments is that evaluation done
left-to-right (as Perl, I once thought, is) would evaluate the
arguments independently one at a time before adding to the stack.
Hence my expectation is that Case 1 and Case 2 would be getting the
lists qw(lab1, lab2) and qw(lab1, lab1) respectively.  After all,
left-to-right evaluation says that the left argument must be evaluated
before the second-to-left argument is evaluated. <etc.>

But it still boggles my mind that the lists passed are:
qw( lab1, lab2 ) and qw( lab2, lab1 ) for case 1 and 2.

Henry
(Not JAPH yet, apparently)


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

Date: Wed, 12 Nov 1997 19:20:41 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Q: Wierd argument passing, bug?
Message-Id: <9lkd46.rp.ln@localhost>

brian d foy (comdog@computerdog.com) wrote:
: In article <64dbjl$v6o$1@bigboote.WPI.EDU>, henryg@ernie.WPI.EDU (Henry Gabryjelski) wrote:


: >Help? Tom? Larry?

: they don't live here anymore.


Shouldn't this part be a followup to the 
"Statistics for comp.lang.perl.misc" thread?

;-(


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 13 Nov 1997 01:00:19 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Split Screen Telnet
Message-Id: <64djf3$c8j$5@comdyn.comdyn.com.au>

In article <346918BC.1D9C@cs.purdue.edu>,
	David Corcoran <corcordt@cs.purdue.edu> writes:
> Does anyone know how to split a telnet screen in Perl ????

There isn't really such a thing as a 'telnet screen'. You're working
on a terminal. Have a look at the Term::* modules on CPAN. Maybe one
of those allows you to do what you want. (http://www.perl.com/CPAN)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: 12 Nov 1997 21:29:53 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Split Screen Telnet
Message-Id: <lq13el134ri.fsf@bmers2e5.nortel.ca>

mgjv@comdyn.com.au (Martien Verbruggen) writes:
> In article <346918BC.1D9C@cs.purdue.edu>,
> 	David Corcoran <corcordt@cs.purdue.edu> writes:
> > Does anyone know how to split a telnet screen in Perl ????
> 
> There isn't really such a thing as a 'telnet screen'. You're working
> on a terminal. Have a look at the Term::* modules on CPAN. Maybe one
> of those allows you to do what you want. (http://www.perl.com/CPAN)

As well i believe there is a freely available program named "splitvt"
that does exactly this. telnet? yes... but actually it puts a shell
in each window... just a tad more useful. It splits your vt100 on the
line of your choice and contains one program in the top and one in the
bottom. I've used it before and it's pretty stable/easy to use.

mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: Wed, 12 Nov 1997 19:02:20 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Statistics for comp.lang.perl.misc
Message-Id: <sijd46.9o.ln@localhost>

Eli the Bearded (usenet-tag@qz.little-neck.ny.us) wrote:
: Tad McClellan <tadmc@flash.net> wrote:

: > I swear, close to 50% of the posts are such a beast. Couldn't
: > they just try and look them up, like the conscientious 'net
: > citizens do, before they post the same question yet again?

: You assume they aspire to be conscientious.


There is my mistake (compounded by my inability to ignore them,
as they deserve. For some reason that I cannot explain, even to
myself, I insist on trying to help even them).


I am an idiot.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 12 Nov 1997 17:33:35 -0800
From: Mark Rafn <dagon@halcyon.com>
Subject: Re: Tainting Question
Message-Id: <64dldf$u4$1@halcyon.com>

vwilding@mib.nbs.gov (Vince Wilding) arranged electrons in a pattern like this:
>I have a CGI-script that needs to allow users to generate a file in a
>world-writable directory and write to it.  When I run with -T, it
>complains, I would suppose, about the world-writable directory. 

Don't suppose.  What error is generated?  Perl is much nicer than most
languages about helping you to diagnose your mistakes.  Let it.

>Is there a way around this, i.e. WRITING to a world writable directory and
>still pass the taint check?

Taint checking doesn't prevent you from creating or writing to a file in
a world-writable directory.  Try this:
  #!/usr/bin/perl -Tw
  open(OUTPUT, '>/tmp/myfileXX') || die "oops: $!";
  print OUTPUT "this is a test\n";
  close OUTPUT;
Works, right (if you have world-writable /tmp, that is)?  

I suspect, just because this is what I usually forget, that you either
haven't sanitized your environment ($ENV{'PATH'} and $ENV{'IFS'}) or
you're trying to use a variable that is passed to the form without first
untainting it.  Perl's error will give you a very good idea which one it
is.

If all else fails, re-post your question, including the exact error
message and a very small but complete script (should be under 20 lines)
that makes the error occur.
--
#!/usr/bin/perl -- # Mark Rafn   dagon@halcyon.com
&ja('&*MQ))U=@','&*HBM4E90','&JDCK4G1@','&1,BI(E=0');&ja('&SLBD:NP`',
'&K*BJC,H`','&R,CNBHP`','&CJRJ:NH`');sub ja{for$c(@_){$d=unpack('B48',
unpack('u',$c));$d=~tr/10/@ /;print"$d\n"}print"\n"}


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

Date: Wed, 12 Nov 1997 19:53:21 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: What's wrong w/this picture?
Message-Id: <himd46.st.ln@localhost>

Kenneth McNamara (quetzl@earthlink.net) wrote:
: Am I way off or what?

You are way off   ;-)


: 	I want to open the @ARGV directory, put the files in @files and print

What's an @ARGV directory?

@ARGV is an array.


: out the first three lines of each file. (My assignment is to use define
: to include files named 0, but I haven't got to that yet).


I think you mean defined() there.

Perl does not have a function or operator named 'define'


: 	I beseech the Perl Gods to enlighten me.


They write documentation to enlighten folks.

They ship that documentation with every proper perl distribution.

They do not read this newsgroup anymore (probably because folks won't
read that documentation).



: (Start Mangle-O-Script)

Excellent name for its current form  ;-)


: =======================================================
: #!/usr/local/bin/perl5.00401


You have a modern version of perl. That is Good.

You are not using the -w switch. That is Bad.

   #!/usr/local/bin/perl5.00401 -w


: $dirname = shift;

Q: What will your script do if the user forgets to provide an argument?

A: bad stuff


   die "USAGE Mangle-O-Script <directory name>\n" unless @ARGV == 1;

(put that before the shift() above)


: opendir(DIR, $dirname);


Q: What will your script do if the directory could not be opened successfully?

A: bad stuff

   opendir(DIR, $dirname) || die "could not opendir() for '$dirname'";


: @files = readdir(DIR);
   ^^^^^

@files may contain a bunch of stuff that are not files, like directories
and pipes and symbolic links.

Change the name of the array (@dir_entries maybe?), or change your
code to get _only_ filenames in it:

   @files = grep -f, readdir(DIR);


: closedir(DIR);

There is a line that looks OK as is  ;-)



: while (@files) {

Q: When will this loop terminate?

A: When the @files array contains no elements.


Q: When will the @files array contain no elements?

A: Never. (therefore the while() loop will run for a really, really
           long time)
          (assuming there is at least one file in the directory)


   foreach (@files) {

or, do away with the temporary @files array altogether:

   foreach (grep -f, readdir(DIR)) {


: $files = chomp;

Since you have provided no VARIABLE or LIST to chomp, it will default
to chomping $_.

$_ has not been assigned a value. The -w switch would have warned
you about this.


: print $files;
: open(FILENAME, $files) || die "No way, Jose! because: $!";
: @lines = <FILENAME>
: print $lines[0..2], "\n";
: close(FILENAME);
: }


Indent your code!

It helps in understanding your code.


I don't think I would read all (potentially thousands, millions?)
the lines in the file if I only wanted the first three lines.

I think I would only read the first three lines if I only wanted
the first three lines  ;-)


   open(FILENAME, $files) || die "No way, Jose! because: $!";
   print scalar(<FILENAME>);
   print scalar(<FILENAME>);
   print scalar(<FILENAME>);
   close(FILENAME);


That won't work too well if there are less than three 
lines in the file though...


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: Thu, 13 Nov 1997 02:11:20 GMT
From: m.king.garbage@praxa.garbage.com.au (Mike King)
Subject: Re: What's wrong w/this picture?
Message-Id: <346a614f.597943857@news.ozemail.com.au>

On Wed, 12 Nov 1997 16:01:05 -0800, Kenneth McNamara
<quetzl@earthlink.net> wrote:

>Am I way off or what?
>	I want to open the @ARGV directory, put the files in @files and print
>out the first three lines of each file. (My assignment is to use define
>to include files named 0, but I haven't got to that yet).
>	I beseech the Perl Gods to enlighten me.
>
>(Start Mangle-O-Script)
>=======================================================
>
>#!/usr/local/bin/perl5.00401
>
>$dirname = shift;
>opendir(DIR, $dirname);
>@files = readdir(DIR);
>closedir(DIR);
>
>while (@files) {
>$files = chomp;
>print $files;
>open(FILENAME, $files) || die "No way, Jose! because: $!";
>@lines = <FILENAME>
>print $lines[0..2], "\n";
>close(FILENAME);
>}


Try this :-

#!/usr/local/bin/perl

$dirname = shift;
opendir(DIR, $dirname);
@files = readdir(DIR);
closedir(DIR);

foreach $this_file (@files)
	{
	if ($this_file =~ !/^./)
		{
		$this_file = "$dirname/$this_file";
		print "processing file $this_file\n";
		open(FILENAME, "<$this_file") || die "No way, Jose!
because: $! \n";
		for ($i=0;$i<2;$i++)
			{
			print <FILENAME>;
			}
		close(FILENAME);
		}
	}

You might also want to filter out directories - I'll leave that bit to
you.

Mike


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

Date: Wed, 12 Nov 1997 20:34:00 -0600
From: tadmc@flash.net (Tad McClellan)
Subject: Re: What's wrong w/this picture?
Message-Id: <ouod46.p21.ln@localhost>

Mike King (m.king.garbage@praxa.garbage.com.au) wrote:
: On Wed, 12 Nov 1997 16:01:05 -0800, Kenneth McNamara
: <quetzl@earthlink.net> wrote:

: >Am I way off or what?
: >	I want to open the @ARGV directory, put the files in @files and print
: >out the first three lines of each file. (My assignment is to use define
: >to include files named 0, but I haven't got to that yet).
: >	I beseech the Perl Gods to enlighten me.
: >
: >(Start Mangle-O-Script)
: >=======================================================
: >
: >#!/usr/local/bin/perl5.00401
: >
: >$dirname = shift;
: >opendir(DIR, $dirname);
: >@files = readdir(DIR);
: >closedir(DIR);
: >
: >while (@files) {
: >$files = chomp;
: >print $files;
: >open(FILENAME, $files) || die "No way, Jose! because: $!";
: >@lines = <FILENAME>
: >print $lines[0..2], "\n";
: >close(FILENAME);
: >}


: Try this :-


Did *you* try this?

I doubt it...


: #!/usr/local/bin/perl

No -w switch?

: $dirname = shift;

No test to see if $dirname is now defined()?

: opendir(DIR, $dirname);

No test to see if the directory was really opened?

: @files = readdir(DIR);

Put directory names in an array named @files?

: closedir(DIR);

: foreach $this_file (@files)
: 	{
: 	if ($this_file =~ !/^./)


Now the script will not do the Right Thing for the '.newsrc' file...

Ignoring the fact that the dot was not escaped, so the if() test
will *never* be true...


I think it is easier to see what is being done if you write it this way:

   if ($this_file !~ /^\./)


And, since the if() is the only thing in the foreach() block,
why not combine them?

   foreach $this_file (grep $_ !~ /^\./, @files)


: 		{
: 		$this_file = "$dirname/$this_file";
                              ^^^^^^^^

There is one very good piece of advice that I missed in my followup.


: 		print "processing file $this_file\n";
: 		open(FILENAME, "<$this_file") || die "No way, Jose!
: because: $! \n";
: 		for ($i=0;$i<2;$i++)
: 			{
: 			print <FILENAME>;
                        ^^^^^^^^^^^^^^^^

print() provides a list context, so ALL lines will be printed on
the first iteration. Nothing will be printed on the second and
third iterations...


: 			}
: 		close(FILENAME);
: 		}
: 	}

: You might also want to filter out directories - I'll leave that bit to
: you.


--
    Tad McClellan                          SGML Consulting
    tadmc@flash.net                        Perl programming
    Fort Worth, Texas


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

Date: 12 Nov 1997 21:26:43 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: What's wrong w/this picture?
Message-Id: <lq167px34ws.fsf@bmers2e5.nortel.ca>

Kenneth McNamara <quetzl@earthlink.net> writes:
> Am I way off or what?
> 	I want to open the @ARGV directory, put the files in @files and print
> out the first three lines of each file. (My assignment is to use define
> to include files named 0, but I haven't got to that yet).
> 	I beseech the Perl Gods to enlighten me.
> =======================================================
> #!/usr/local/bin/perl5.00401
> $dirname = shift;
> opendir(DIR, $dirname);
> @files = readdir(DIR);
> closedir(DIR);

Ok so far... no error checking... but assuming a good directory.. ok.. (yuck)

> while (@files) {
> $files = chomp;
> print $files;
> open(FILENAME, $files) || die "No way, Jose! because: $!";
> @lines = <FILENAME>
> print $lines[0..2], "\n";
> close(FILENAME);
> }

Uhhh... chomp? why chomp? *quizical look* I suggest you read the documentation
for chomp() more closely. 

HINT: chomp(ARRAY) does a chomp(SCALAR) on each element of the array.
      What you probably want is:
         foreach $file (@files) {
            ...
         }
      And i suggest that for your own safety you do more error checking, like
      the return code for opendir(). As well, why are you reading the whole
      file when all you want is the first three lines? Ooops.. there's
      another minor problem... "print $files"... i think you want a "\n"
      in there somewhere so that your output looks ok.

good luck... (and try reading the docs)
mark

--                                                  _________________________
 .  .  _  ._  . .   .__    .  . ._. .__ .   . . .__  | Northern Telecom Ltd. |
|\/| |_| |_| |/    |_     |\/|  |  |_  |   |/  |_   | Box 3511, Station 'C' |
|  | | | | \ | \   |__ .  |  | .|. |__ |__ | \ |__  | Ottawa, ON    K1Y 4H7 |
  markm@nortel.ca  /  al278@freenet.carleton.ca     |_______________________|


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

Date: 13 Nov 1997 00:50:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Will pay $$ for FORM-to-DBASE perl script
Message-Id: <64dirp$c8j$2@comdyn.comdyn.com.au>

In article <3468A3D9.167E@pubgroup.com>,
	"Kelvin D. Olson" <kelvin@pubgroup.com> writes:

[SNIP]

Read the answer I gave in the other thread you started, with the title
'HTML FORM POST to DBASE'

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Begin at the beginning and go on till
Commercial Dynamics Pty. Ltd.       | you come to the end; then stop.
NSW, Australia                      | 


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

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

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