[6377] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 24 08:17:21 1997

Date: Mon, 24 Feb 97 05: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           Mon, 24 Feb 1997     Volume: 8 Number: 2

Today's topics:
     Re: [Q] Perl in win3.11? (Ric Harwood)
     Re: Append to 1st line only variable (Honza Pazdziora)
     Control character question <pd34+@andrew.cmu.edu>
     Re: debugger question (Ilya Zakharevich)
     Re: Difference between use and require? (Brian L. Matthews)
     Re: Extensions: run-time or compile-time??? (Malcolm Beattie)
     Re: futur de perl et java-script <twpierce+usenet@mail.bsd.uchicago.edu>
     Re: futur de perl et java-script (Tung-chiang Yang)
     Re: Hash key created by subroutine call? (Dave Thomas)
     Re: Hash key created by subroutine call? <roderick@gate.net>
     Re: Help on Win NT Perl configuration (Jarle Aasland)
     Re: How to control attempt to download (Brian L. Matthews)
     Re: How to control attempt to download (Jarle Aasland)
     How to create a file... (Dico Reyers)
     Re: How to create a file... (Honza Pazdziora)
     problems with oraperl <jtzhou@post1.com>
     Re: Reading files (Honza Pazdziora)
     References_>Faster? <maitkin@teleport.com>
     Re: Running other program .. (Honza Pazdziora)
     Re: Setuid scripts and $0 - Arg! <roderick@gate.net>
     Re: The Disappearing DOS box and cmd32.exe <griffithss@entcf1.agw.bt.co.uk>
     Re: tied filehandle - 'file control' how to? <roderick@gate.net>
     using chat2.pl <daftary@ecn.purdue.edu>
     Re: What happens if you use a -l switch without -[np]? (Brian L. Matthews)
     Re: What happens if you use a -l switch without -[np]? (Tom Grydeland)
     Which one is the best (pattern matching) <b.leguen@ctr.renault.fr>
     YANQ (yet another newbie question) (Peter Petto)
     Re: YANQ (yet another newbie question) (Andrew M. Langmead)
     Yet another desirable pack format: (was re: Strange pac (Jonathan King)
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: Mon, 24 Feb 1997 11:31:12 GMT
From: ric@discoveryinternational.com (Ric Harwood)
Subject: Re: [Q] Perl in win3.11?
Message-Id: <331162ed.1998281@news.demon.co.uk>

In comp.lang.perl.misc, on 22 Feb 1997 20:55:05 GMT
ilya@math.ohio-state.edu (Ilya Zakharevich), wrote:

>> >As I mentioned it in another post today, unless you install sh.exe
>> >from sh_dos.zip, and set PERL_SH_DIR according to the docs, you are
>> >not going to have backticks and pipes working.

'According to the docs' just says:

=head2 C<PERL_SH_DIR>

Specific for OS/2. Gives the directory part of the location for
F<sh.exe>.

But not it seems where or how to set this [for dos/w3.11]. Unless I
am loooking in the wrong place?

>> I have not been able to find this, could I have a URL please?
>Sorry, this is in README.os2 in newer Perls, but not in the older
>binary release:
>	ftp://ftp.math.ohio-state.edu/pub/users/ilya/os2/sh_dos.zip

Thanks I have it now.

>> [I'm still trying to get the emx+rsx]
>
>This _is_ in README.os2. Btw, a newer version of RSX is reported to
>jump into existence. 

I had found emx on cdrom.com, but could not get into my local mirror,
so with 0.8kps transfere I had to batchftp it. This was OK though.
Ta.
Ric.

-- 
"Big whorls have little whorls that feed on their velocity, 
and little whorls have lesser whorls and so on to viscosity."
                                          -- L.F.Richardson
PGP id:0766ABE5  http://www.discoveryinternational.com/ric/


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

Date: Mon, 24 Feb 1997 08:43:04 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Append to 1st line only variable
Message-Id: <adelton.856773784@aisa.fi.muni.cz>

cpayne@xmission.xmission.com (Carl Payne) writes:

> I have a file.  Let's say it charts the snacks I sell each day, and it looks
> like this:
> 
> 17,18,19,20,21	#these are the days the file covers
> 5,2,1,383	#the # of apples, cakes, pies and Jolts sold on the 17th
> 13,0,1,426	#18th
> 8,2,2,0,360	#and so on
> 2,1,5,1,225
> 9,0,1,2,135

[...]

> each day, append today's number to the end of the first line of the file.
> As long as perl can handle it, this line can go on ad nauseum.  While the
> datA lines in my example will always be 5 fields long, the datE line can be
> 45, 60, however many fields.
> 
> The end result is that I will have a routine that can tell me how many of
> what snack were sold on what day.  I think I can handle that part.  What has
> me stuck is opening the file, appending the day (with a comma) to that one
> line, adding that day's totals (the way it already does) to the end of the
> file and closing the file without harming all that data.
> 
> Would something like this work:
> {
> open(SNACKFILE," >$snackdata");
> 	$newdline=$firstline,$currdate(day)
> 	print SNACKFILE <<EOF;
> 	$newdline;
> 	$the_rest_of_snackdata_without_the_first_line;
> 	$todaysnacks;
> EOF
> }
> 
> What is that variable I don't yet know?  If $1 is the first field, what is
> the first line? 
> $^ 		??  
> $seen{$^}  	??

It is named $. because man page says it's the current input line number
of the last filehandle that was read.

So the routine may read as

open OUT, ">$snackdata" or die "Error writing $snackdata": $!";
while (<>)		# here I read from stdin, and maybe you will
	{		# also be writing to stdout?
			# so now we have the line in $_ (from <>)
	if ($. == 1) {
		chomp;
		$_ .= ",$currdate\n";
		}
			# if this is the first line, we add the $currdate
			# note that yours $currdate(day) is probably
			# not what you wanted; it's probably one of
			# currdate($day), &currdate($day), $currdate[$day]
			# or $currdate{$day}
	print OUT $_;	# print it out
	}
			# input file ended, so we add our new line
print OUT "$todaysnacks\n";

You can also get along without testing $. Just do

$firstline = <>;		# first line
chomp $firstline;
print "$firstline, $currdate\n";
while (<>)			# rest of input
	{ print; }
print "$todaysnacks\n";

This example writes to stdout, add filehandle after each print to
write to some file.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 24 Feb 1997 04:55:55 -0500
From: Pierre Darbouze <pd34+@andrew.cmu.edu>
Subject: Control character question
Message-Id: <sn4KKfu00YUy0AOnw0@andrew.cmu.edu>

How do I "trap" a control character?  For example, suppose I am running
a script, but I don't want the script to be terminated by a Ctrl-C, but
rather I just want ^C printed to the screen.  How could I accomplish
this?  Thanks for any help.

                                        Pierre
                                        pd34@andrew.cmu.edu



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

Date: 24 Feb 1997 06:24:11 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: debugger question
Message-Id: <5erc6b$6ca$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Mike Bartolone 5-4266 
<bartolonem@med.ge.com>],
who wrote in article <330DCDAF.2781@med.ge.com>:
> If any of you use the built-in perl debugger, can you tell me if
> there is a command to list the current values of all of the currently
> defined variables?

When the debugger starts, it prints

	Enter h or `h h' for help.

Why do you think it does it?

Ilya


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

Date: 23 Feb 1997 23:16:43 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: Difference between use and require?
Message-Id: <5erf8r$r4f$1@halcyon.com>
Keywords: module library use require

In article <5eo9m9$ksc@lori.albany.net>,
Thomas A. Bennedum <tab@albany.net> wrote:
|What is the difference?

Being you're writing some modules, one must assume you've read perlmod,
which means you saw the following:

	use Module;
    or
	use Module LIST;
    This is exactly equivalent to
	BEGIN { require "Module.pm"; import Module; }
    or
	BEGIN { require "Module.pm"; import Module LIST; }

That seems pretty clear, so maybe if you explain what parts you
don't understand, we can be of more help.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 24 Feb 1997 11:07:38 GMT
From: mbeattie@sable.ox.ac.uk (Malcolm Beattie)
Subject: Re: Extensions: run-time or compile-time???
Message-Id: <5erspq$104@news.ox.ac.uk>

In article <856482562.20958@dejanews.com>,  <eric@mindvox.com> wrote:
> I'm using the perl compiler to generate 'bytecode' and I want to have
>all of my methods and variables ready to use at compile-time so they'll
>actually make it into the bytecode. Everything pretty much works, except
>for a few methods from a particular extension.
>
> I assume that since this extension is bootstrapped, methods aren't
>looked up until run-time. My question is, Is there ANY way to look these
>methods up at compile-time? I tried building a new perl with the
>extension linked statically but that didn't seem to work. Do I have to
>change the syntax of the module ( bootstrap($module) ) to something else?
>
> Am I misunderstanding the way extensions work? Is it impossible to
>achieve this?

The bytecode backend ought to write out code to re-bootstrap the
necessary extensions. XSUB support is not good in alpha3 and it's
worse for -MO=Bytecode then it is for -MO=C and -MO=CC. Off the top
of my head, you could try putting explicit calls to bootstrap at the
top of your program. The proper solution is probably for me to add
new bytecode instructions to bytecode.pl to do what DynaLoader does
(for dynamic extensions) and to re-bootstrap modules. The extra
compiler support in 5.005 may mean it's nicer to add RESTART{}
support to DynaLoader.pm instead though.

--Malcolm

-- 
Malcolm Beattie <mbeattie@sable.ox.ac.uk>
Oxford University Computing Services
"Widget. It's got a widget. A lovely widget. A widget it has got." --Jack Dee


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

Date: Mon, 24 Feb 1997 05:19:47 GMT
From: Tim Pierce <twpierce+usenet@mail.bsd.uchicago.edu>
Subject: Re: futur de perl et java-script
Message-Id: <E63DGz.Coz@midway.uchicago.edu>

In article <5eqbmr$3p0$1@csnews.cs.colorado.edu>,
Tom Christiansen  <tchrist@mox.perl.com> wrote:

>How many rec.humor.funny postings to see in Swahili?  Ever wonder why?
>Because the goal of Usenet is communication.  If you aren't understood,
>then you've failed.

This post is altogether quite accurate, very practical, and
altogether irrelevant, if not actually offensive.  Surely you
don't think it's news that English is the dominant language on
Usenet?  Someone who posts here in French is unlikely to do so out
of ignorance for that fact, but more probably for a more practical
reason, such as not knowing English.  (Shame on them, what?)  If
they're not understood, it's their business, IMNSFHO.

A corollary to your final observation.  If the state of affairs on
Usenet is that only people who know English can use it to any
effectiveness, then Usenet has failed by any useful definition of
``communication.''  Surely you don't define operational success as
``being able to communicate with Americans?''  If we have reached
the point where it is not necessary to know English in order to
use the net productively, then I contend that the grand experiment
has been an unconditional success.

Speaking for myself, a monoglot, I would far rather see people
hold conversations regularly in languages I do not know, than see
one more fucking CGI question.  If you asked me, which you have
not, I would recommend evaluating the priorities of your battles
more carefully.

-- 
Support the Hawaii Equal Rights Marriage Project: call 1-900-97-MARRY ($5/call)


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

Date: Mon, 24 Feb 1997 07:37:50 GMT
From: tcyang@netcom.com (Tung-chiang Yang)
Subject: Re: futur de perl et java-script
Message-Id: <tcyangE63Jv2.K42@netcom.com>

I am never a Perl guru and never a hacker for Perl like Randal, but I
feel like saying something here :)  It has been raised again and again
for English vs. German and/or French posting issues in other groups.

I hope we can divert this to other more general newsgroups like we
recommend those about CGI questions.

P.S. Maybe in Perl6 we can attempt to include some function names based
     on French, German or Spanish :)

--
Tung-chiang Yang                       tcyang@netcom.com

soc.culture.taiwan, soc.culture.china (by SCC FAQ Team) FAQ's:
   http://clever.net/tcyang/Taiwan_faq.shtml, China_faq.html


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

Date: 24 Feb 1997 04:59:11 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: Hash key created by subroutine call?
Message-Id: <slrn5h27s1.7h3.dave@fast.thomases.com>

On Sat, 22 Feb 1997 21:47:52 -0800, Rick Smith <ricks@sd.znet.com> wrote:

> &test($val = $hash{"No key created here\n"});
> &test($hash{"Created this hash key\n"});

Subroutine parameters are actually lvalues, and therefore Perl has to create
the slot to hold whatever you may choose to store there. 

Dave

-- 

 _________________________________________________________________________
| Dave Thomas - Dave@Thomases.com - Unix and systems consultancy - Dallas |
 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


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

Date: 24 Feb 1997 00:46:25 -0500
From: Roderick Schertler <roderick@gate.net>
To: ricks@sd.znet.com
Subject: Re: Hash key created by subroutine call?
Message-Id: <pzbu9an4jb.fsf@eeyore.ibcinc.com>

On Sat, 22 Feb 1997 21:47:52 -0800, Rick Smith <ricks@sd.znet.com> said:
> 
> # If a hash val is first copied to a variable, and that
> # variable gets passed to a subroutine, no key gets created.
> 
> # However, if a hash val is passed to a subroutine directly,
> # and the key is non existent, it gets created.
> 
> &test($val = $hash{"No key created here\n"});
> &test($hash{"Created this hash key\n"});

This is really the difference between

    print $hash{$key};		# doesn't create $hash{$key}
    $hash{$key} = "value";	# does

The second call to &test puts $hash{$key} in an lvalue context, so it
creates the entry if it's missing.  The first call to &test isn't in an
lvalue context, so it doesn't.

The tricky thing which is going on is that

    &function($scalar);

puts $scalar in a lvalue context.  This is what allows &function to
modify its arguments in place (like

    $ perl -lwe '
	sub modify {
	    $_[0] = "modified value";
	}
	$x = "hi mom";
	modify $x;
	print $x;'
    modified value

).  Perl functions are really pass-by-reference when it comes to scalar
values, it's only the usual copying of the args from @_ which makes them
pass-by-value.

-- 
Roderick Schertler
roderick@gate.net


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

Date: Mon, 24 Feb 1997 10:22:45 GMT
From: sajaa@sn.no (Jarle Aasland)
Subject: Re: Help on Win NT Perl configuration
Message-Id: <33116aed.8339932@news.eunet.no>

The IIS/NT defaults SSI pages to an *.stm -extension. All pages which
you want to include some other file must have this extension (to
change it you must edit the registry).  

You include the other document using  <!--#include file="value"-->

Check the documentation which comes with the server (included as
html-documents).

Good luck.

Jarle Aasland,
NORWAY		

>>I'm having trouble configuring Perl5 for Win NT.  I got everything else
>>working.. but I can not configure my IIS to perform Server Side Include...
>>Does any body have any idea?  Is it possible?

>>Charles
>



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

Date: 23 Feb 1997 23:19:38 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: How to control attempt to download
Message-Id: <5erfea$r8q$1@halcyon.com>

In article <3310AA63.3493@cyber2.servtech.com>,
Valeri  <valeri@cyber2.servtech.com> wrote:
|Have a question - is it possible to control somehow attempt to download
|images or just pages by user from my web site ?

It depends. It's all up to the server you're using and how that server
is configured. Neither has anything to do with perl, so you'll probably
have more luck asking in one of the comp.infosystems.www.* newsgroups.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: Mon, 24 Feb 1997 12:39:08 GMT
From: sajaa@sn.no (Jarle Aasland)
Subject: Re: How to control attempt to download
Message-Id: <33138abc.16483852@news.eunet.no>

I don't quite understand your question...

If you're talking about web-pages (as in html-documents) or images (as
in gif and jpeg) you have the choice not to put them on a web-server
at all.

If you have put them on a server for people to view, there is no way
you can prevent them from saving them locally.

If you ask how to control the access to those pages, configure your
server with password protection of neccessary directories.

Greetings,
Jarle Aasland
NORWAY

>Have a question - is it possible to control somehow attempt to download
>images or just pages by user from my web site ?
>
>If yes - how to write a perl script to to do this work ?



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

Date: Mon, 24 Feb 1997 05:06:01 GMT
From: dico@isn.net (Dico Reyers)
Subject: How to create a file...
Message-Id: <33112142.17364451@nntp.uunet.ca>

Hello.

I have a question that I know people here can answer.

How can I create a file with perl.

say that a user submits a form and their name is "ELMO".
How can I get perl to create an emply file called "ELMO".  I don't
want anything in the file... just an empty file.

Thanks...

Dico

dico@isn.net


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

Date: Mon, 24 Feb 1997 08:37:55 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: How to create a file...
Message-Id: <adelton.856773475@aisa.fi.muni.cz>

dico@isn.net (Dico Reyers) writes:

> Hello.
> 
> I have a question that I know people here can answer.
> 
> How can I create a file with perl.
> 
> say that a user submits a form and their name is "ELMO".
> How can I get perl to create an emply file called "ELMO".  I don't
> want anything in the file... just an empty file.

There may be a better way, but this works happily:

open A, ">ELMO";
close A;

Hope this helps.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: Mon, 24 Feb 1997 15:22:06 -0800
From: Mr Jiangtao Zhou <jtzhou@post1.com>
Subject: problems with oraperl
Message-Id: <3312229D.5F33@post1.com>

Hi,

I'm using oraperl to fetch something from a synonym pointing to a DB2
table linked through gateway. I always encounter a fetch error
of 100007 why trying to fetch some values. However, the data is there
if doing the samething in SQLPlus. Anyone experienced this and
what is the error code 100007 stands for?

Thanks in advance,

JT


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

Date: Mon, 24 Feb 1997 09:17:42 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: Reading files
Message-Id: <adelton.856775862@aisa.fi.muni.cz>

galoi@sdcc13.ucsd.edu (Greg Aloi) writes:

>   I want to be able to read in a file filled with strings in the
> following form
> 
> 	string1
> 	string2
> 	string3
> 	string4
> 	string5
> 	string6
> 	  .
> 	  .
> 	  .

This is fine.

> I want to be able to read in the strings line by line and either
> make an assignment to them or skip over them.  One method that I

You can't really do an assignment to a string. You can assign to
scalar variable or to elements of an array or hash, or to whole array
or hash. What you take depends on what you try to do.

> thought might work was to assign diferent variables to each string
> as I read them in
> 
> for example
> 
>     while(<DATA_IN>)
>     {
> 	$string1 = $_;

Here you assing the whole line to a variable named $string1.

> 	$string2 = $2;

Here you assing to $string2 the value of $2. But $2 has never
been assigned. It gets assigned when you do a match over a string
(see perlop man page).

>     }
> 
> but this does not get me the desired effect.  

Try to write once more what the desired action is. What you try to do.
The piece of code you gave us does what you told it to do, but we
can't help if you do not say what you would like you script to
output.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 24 Feb 1997 09:02:25 GMT
From: Marc The Arc  <maitkin@teleport.com>
Subject: References_>Faster?
Message-Id: <5erlf1$jdr$1@nadine.teleport.com>



	Simple question probably already answered but...
Since PERL runs via a virtual machine of sorts, I am curious as to 
whether creating and explicitly using references is a resource-save,
or does the VM do this implicitly anway?  

wondering.
marc a

-- 


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

Date: Mon, 24 Feb 1997 09:25:32 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
To: meory@seas.gwu.edu
Subject: Re: Running other program ..
Message-Id: <adelton.856776332@aisa.fi.muni.cz>

meory@seas.gwu.edu (Meor Yahaya) writes:

> I wrote the following script:
> #!/usr/local/bin/perl
> 
> $m=2;
> $y=1997;
> 
> @zzz = `/some/c/program `, $m, $y;
> 
> The problem is it does not pass the correct argument to the program. The
> following line works, but I read somewhere that it is not secure
> especially running as suid script. Any solution?
> 
> @zzz = `/usr/orson/2/www/student/meory/pray $m $y`;

The first can work. $m and $y are not inside of the `` operator. The
problem with safeness is that the arguments are parsed by shell. So if
your argument reads as `rm -r *`, you will get your data lost just as
a side effect before running you program. Read the perlipc man page,
here I will only include example from there:

Here's a safe backtick or pipe open for read: 

    # add error processing as above
    $pid = open(KID, "-|");
    if ($pid) {   # parent
        while (<KID>) {
            # do something interesting
        }         
        close(KID) || warn "kid exited $?";
    } else {      # child
        ($EUID, $EGID) = ($UID, $GID); # suid only
        exec($program, @options, @args)
            || die "can't exec program: $!";
        # NOTREACHED
    } 

The whole secret is in passing more arguments to exec. These are not
subject to shell metacharacters checking and expansion.

Hope this helps.

Cc'ed to meory@seas.gwu.edu.

--
------------------------------------------------------------------------
 Honza Pazdziora | adelton@fi.muni.cz | http://www.fi.muni.cz/~adelton/
                   I can take or leave it if I please
------------------------------------------------------------------------


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

Date: 24 Feb 1997 00:36:35 -0500
From: Roderick Schertler <roderick@gate.net>
To: chris@ixlabs.com
Subject: Re: Setuid scripts and $0 - Arg!
Message-Id: <pzene6n4xl.fsf@eeyore.ibcinc.com>

On Fri, 21 Feb 1997 14:06:20 -0800, Chris Schoenfeld <chris@ixlabs.com> said:
> 
> Unfortunately, $0 gets boned (/dev/fd4?? - what does it think it's a
> floppy drive?) when running setuid on Solaris, [...]

The /dev/fd directory hasn't anything to do with floppy drives, it's a
way to refer to file descriptors via the file system.  Your system
should have a man page which explains it, it might be called fd(4).

Perl is saying that $0 is /dev/fd/4 because $0 really is /dev/fd/4,
that's how the kernel is invoking perl.

> This is a big time bug [...]

Hardly.

> it would seem like $0 should be false or undefined if Perl can't
> figure out it's scriptname.

What's to figure out?  For all practical purposes your script really is
named /dev/fd/4.

The /dev/fd mechanism is the only way setuid #! scripts can be used
safely, though it would be a hassle to explain why.  Perhaps the Perl or
comp.unix.questions FAQs explain it.  The comp.unix.questions certainly
explains the difficulty of turning a file descriptor into a file name,
basically it can't be generally done.

-- 
Roderick Schertler
roderick@gate.net


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

Date: Mon, 24 Feb 1997 12:56:03 +0000
From: Simon Griffiths <griffithss@entcf1.agw.bt.co.uk>
Subject: Re: The Disappearing DOS box and cmd32.exe
Message-Id: <33118FE3.23AB@entcf1.agw.bt.co.uk>

Gregory Goodwin wrote:
> 
> The problem though is that the DOS box disappears too fast to read.  I
> can add a sleep command, but that only works ............

You may like to try Alan Phillips' excellent Programmer's File Editor
available from http://www.lancs.ac.uk/people/cpaap/pfe/. This has an
option which allows perl to be run in a DOS window whilst all terminal
output is collected. After the run is complete the editor also open a
new edit window and displays the command output. 

PFE seems to me to be an excellent MS-windows editor and I use it
constantly to write perl, java, SQL and much else. I use it on NT 3.51,
Windows95 and Win3.11.

Simon.


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

Date: 24 Feb 1997 00:56:25 -0500
From: Roderick Schertler <roderick@gate.net>
To: jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch)
Subject: Re: tied filehandle - 'file control' how to?
Message-Id: <pz914en43p.fsf@eeyore.ibcinc.com>

On 14 Feb 1997 10:56:26 GMT, jarausch@numa1.igpm.rwth-aachen.de (Helmut Jarausch) said:
> 
>   tie *GIN,'Numeric_Input',"Geometry.dat";
> 
> anywhere later I would like to invoke MyFCTL with the object ref that
> has been returned by TIEHANDLE when it has been invoked.  So
> 
> (what must be in here)->MyFCTL

One way is to save the return value from tie and to use that.

    $object = tie *GIN, 'Numeric_Input', 'Geometry.dat';
    [...]
    $object->MyFcntl("args");

Alternately you can use the tied() function to extract the reference
later

    $object = tied *GIN;
    $object->MyFcntl("args");

(or simply

    tied(*GIN)->MyFcntl("args");

).

-- 
Roderick Schertler
roderick@gate.net


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

Date: Mon, 24 Feb 1997 03:02:44 -0500
From: "Kuntal M. Daftary" <daftary@ecn.purdue.edu>
Subject: using chat2.pl
Message-Id: <Pine.SOL.3.91.970224030009.15055A-100000@purcell.ecn.purdue.edu>


someone told me that chat2.pl is to perl as expect is to tcl/tk

if thats is true how can i use cht2.pl ??

i wasnt able to find anything in the man pages

my expect script is something like this:

spawn some_program
expect some_string
exp_send some_command

simple and straight forward.

how wud a translation in perl using chat2.pl loook like?

thnx
kuntal


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

Date: 23 Feb 1997 23:11:07 -0800
From: blm@halcyon.com (Brian L. Matthews)
Subject: Re: What happens if you use a -l switch without -[np]?
Message-Id: <5ereub$quo$1@halcyon.com>

In article <ofbd8tse6ax.fsf@geronimo.uit.no>,
Tom Grydeland  <tom@geronimo.uit.no> wrote:
|while (defined($a = <>))
|[vs.]
|while ($a = <>)
|Now, "0\n" is true, so the input lines have to be chomped for that to
|be true, right?

No. While most text files do end in a newline (or the appropriate line
terminator(s)), there's nothing that says they have to. If the final
characters in a file are something that look like a numeric zero, and
they aren't followed by a newline, the two while's above will terminate
differently.

Brian
-- 
Brian L. Matthews				Illustration Works, Inc.
	For top quality, stock commercial illustration, visit:
		  http://www.halcyon.com/artstock


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

Date: 24 Feb 1997 08:55:18 GMT
From: tom@palver.nospam.eiscat.no (Tom Grydeland)
Subject: Re: What happens if you use a -l switch without -[np]?
Message-Id: <TOM.97Feb24095518@palver.nospam.eiscat.no>

I previously asked:
> |while (defined($a = <>))
> |[vs.]
> |while ($a = <>)
> |Now, "0\n" is true, so the input lines have to be chomped for that to
> |be true, right?

Then, in article <5ereub$quo$1@halcyon.com>,
blm@halcyon.com (Brian L. Matthews) replied:

> No. While most text files do end in a newline (or the appropriate line
> terminator(s)), there's nothing that says they have to. If the final
> characters in a file are something that look like a numeric zero, and
> they aren't followed by a newline, the two while's above will terminate
> differently.

Right, so the only problem could be a "0" on a final line all by
itself (without the "\n" at the end of the line)

But that still doesn't explain my mysterious output.

> Brian L. Matthews				Illustration Works, Inc.

--
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address
-- 
//Tom Grydeland <Tom@nospam.eiscat.no>  # delete 'nospam.' for valid address


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

Date: Mon, 24 Feb 1997 13:05:26 +0100
From: Bertrand Le Guen <b.leguen@ctr.renault.fr>
Subject: Which one is the best (pattern matching)
Message-Id: <33118406.41C6@ctr.renault.fr>

to do a pattern matching in a string i use

if ($page !~ m/\.html/g) {
}

or 

if (index($page,".html") == -1) {
}

which one is the faster or best way to do this ??

thanks
-- 
Bertrand Le Guen
CAD/CAM & SGI/Unix Admin 
Web Master (Intranet)
mailto:b.leguen@ctr.renault.fr


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

Date: Sun, 23 Feb 1997 21:13:13 GMT
From: ppetto@apk.net (Peter Petto)
Subject: YANQ (yet another newbie question)
Message-Id: <3311b130.17071788@news.apk.net>

I'm just getting started with Perl and want to write some directory
synchronization routines peculiar to my needs.

I'm looking for the best way to read the output of a (DOS) system
directory command such as

   system("dir \\synchdir");

directly into an array, without having to create/delete an
intermediate file.

I'd appreciate any and all advice. I will summarize & repost any I
receive by email here.

aTdHvAaNnKcSe


Peter Petto         |       ppetto@apk.net
Bay Village, Ohio   |   PGP public key available


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

Date: Mon, 24 Feb 1997 12:35:03 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: YANQ (yet another newbie question)
Message-Id: <E63xMF.Hq8@world.std.com>

ppetto@apk.net (Peter Petto) writes:

>I'm just getting started with Perl and want to write some directory
>synchronization routines peculiar to my needs.

>I'm looking for the best way to read the output of a (DOS) system
>directory command such as

>   system("dir \\synchdir");

>directly into an array, without having to create/delete an
>intermediate file.

Some will tell you to use backquotes, like:

   @files = `dir \\synchdir`;

or to use the piped open command like:

  open(DIR, "dir \\synchdir |") or die "Can't run dir: $!\n";
  while(<DIR>) {
    chomp;
    push @files, $_;
  }
  close DIR or die "Error running dir: $!\n";

But, since MS-DOS, (even with its Windows operating environment
extensions) can't create pipes between processes, it will be faked
with temporary files anyway.

That still makes it convenient for you the programmer, it just doesn't
make it any faster. (If that is important.)

You might want to take a look at the opendir/readdir/closedir
functions (and maybe the lesser used telldir/seekdir/rewindir) and
avoid running COMMAND.COM entirely.

If your task involves running through directories recursively, you
might also want to look at the File::Find module.

-- 
Andrew Langmead


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

Date: 24 Feb 1997 09:02:56 GMT
From: king@cogsci.ucsd.edu (Jonathan King)
Subject: Yet another desirable pack format: (was re: Strange pack/unpack...)
Message-Id: <5erlg0$m8n@news1.ucsd.edu>

In article <Pine.GSO.3.95q.970223134151.18178I-100000@kelly.teleport.com>
Tom Phoenix <rootbeer@teleport.com> writes:
>On Sat, 22 Feb 1997, Craig Votava wrote:
>>
[deleted, it was about 'pack("B2", "10")'] etc.

>It's not too hard to find out how many padding bits to add, as you show in
>your workaround. So, we probably don't need to add something to pack. And
>besides, some would say that pack and unpack have too many formats
>already! 

Well, it certainly has some formats I would never dream of
using. :-) But it would be kinda cool if it had signed versions of
"n" and "v", which are big- and little-endian respectively.  There's
lots of (scientific) data out there in binary datafiles where you
know that the bytes in the file are in one order or another, and
they are signed.  (Think massaged output from an a/d converter, if
you like).  But when you run your perl script, you neither know or
care much about how that machine's endianosity, but still want to
read the data correctly.  I'd love to be wrong about this, but the
only portable=platform-ignorant way is to unpack the short as "v" or
"n" to get the bytes right and tweak the result to get the correct
sign.  (Same goes for longs, I suppose.)

That's okay if you're just doing a couple of these, but when you've
got thousands or millions of them...it's a bore.  Probably also a
reason to use PerlDL, at least in the long run.  The Blue Camel sort
of recognizes the issue, and the text it uses might have
(unintentionally) seemed, uh, "funny" to other people, too:

    Packing your shorts doesn't imply that you're portable. (p. 196)

Any chance of seeing signed and ordered shorts after 5.004?  Any
better chance if I provided a nifty patch? :-)

jking




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

Date: 8 Jan 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Jan 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.

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

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