[6307] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 929 Volume: 7

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Feb 11 20:18:12 1997

Date: Tue, 11 Feb 97 17: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           Tue, 11 Feb 1997     Volume: 7 Number: 929

Today's topics:
     Re: Capturing system output (Jot Powers)
     Re: Capturing system output (Jot Powers)
     Re: Copying files in Pel (Bennett Todd)
     Re: Copying files in Pel <dennerbw@lmco.lmtas.com>
     Re: File Tests for Directory not working under NT4.0 (Jeff Stampes)
     Re: FTP Client <andy@wonderworks.co.uk>
     getting STDERR from `backtick_exec` <dipasquo@tc.cornell.edu>
     Re: getting STDERR from `backtick_exec` (Nathan V. Patwardhan)
     How do you write to seperate frames? <jdmartin@glue.umd.edu>
     Re: how to change of a given string? <rootbeer@teleport.com>
     Re: How to run shell program in perl with --date  'one  (Dave Thomas)
     Re: How to tell if Perl is run in debug mode (Charles DeRykus)
     Re: How to tell if Perl is run in debug mode <rootbeer@teleport.com>
     Re: initialization of hash while resolving? (Dave Thomas)
     log10 <Y_Hu@fccc.edu>
     Re: log10 <rootbeer@teleport.com>
     Looking for Perl Binary for HP-UX 9.00 <peterg@enterprise.net>
     Re: Loops in perl (Clay Irving)
     Multi-line Comments??? (Pete Holsberg)
     Re: Multi-line Comments??? (Mike Heins)
     optimization of binary data operations. (Richard J. Duncan)
     Re: Perl rand() function on solaris SPARC (Jot Powers)
     Re: Perl rand() function on solaris SPARC <rootbeer@teleport.com>
     Re: space stripping (Michael Shields)
     Subroutine Prototypes, Hard References and Maintainable <franko@sequent.com>
     Re: Sybperl & group by query <mpeppler@mbay.net>
     Re: WIN32-Perl-script loops and wait for a file <bmehling@uci.edu>
     Digest Administrivia (Last modified: 8 Jan 97) (Perl-Users-Digest Admin)

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

Date: 11 Feb 1997 22:31:58 GMT
From: jot.feb97@tmp.medtronic.com (Jot Powers)
Subject: Re: Capturing system output
Message-Id: <5dqs0u$n8@gazette.medtronic.com>

[ My apologies in advance.  Mail to me, from you will not get through as I
  have blocked your domain from my system because att.net can't seem to 
  figure out how to setup their mail systems so people can't just bounce
  spam off of them.  I'll read the post if you follow up. ]

In article <3301790c.3931432@netnews.worldnet.att.net>, bfb@worldnet.att.net writes:
>
>How can I capture the output of a system call
>to an array?
>
>Something like:
>
>@arry = system('cat myfile');

This is not getting the output of a "system" call, it's returning the 
exit status of the program (Programming Perl, 2nd Ed pg 230).

To get the file into the array simply do:

@arry = `cat myfile`);  # Note it's backticks (`) not quotes (')

-- 
Jot Powers  jot.feb97@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: 11 Feb 1997 22:37:08 GMT
From: jot.feb97@tmp.medtronic.com (Jot Powers)
Subject: Re: Capturing system output
Message-Id: <5dqsak$n8@gazette.medtronic.com>


>@arry = `cat myfile`);  # Note it's backticks (`) not quotes (')
                     ^

 ...without the obvious extra )  :)

[*smack*  proofread before you hit deliver Jot ] 
-- 
Jot Powers  jot.feb97@tmp.medtronic.com
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: Tue, 11 Feb 1997 21:43:27 GMT
From: bet@nospam.interactive.net (Bennett Todd)
Subject: Re: Copying files in Pel
Message-Id: <slrn5g1pvv.7ba.bet@onyx.interactive.net>

On Tue, 11 Feb 1997 20:36:08 GMT, Niksun <niksun@lconn.net> wrote:
>Is there a way to copy a file in Perl - other than reading a file and
>then writing to another like this?: [...]

Yes.

In fact, there's more than one. Consider the merits and demerits of the
following ways to copy "foo" to "bar". Note that some will be faster than
others for certain sizes of file and speeds of media, and slower for others
(untested):

1)	system 'cp foo bar';

2)	use File::Copy;
	copy 'foo', 'bar';

3)	use IO::File;
	use Fatal qw(IO::File::new IO::File::read IO::File::DESTROY);
	{
		my($fi) = new IO::File '<foo';
		my($fo) = new IO::File '>bar';
		while ($fi->read(my($buf), 7 '*' 8192)) {
			$fo->print($buf);
		}
	}

I will generally lean towards solution #2, myself.

-Bennett


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

Date: Tue, 11 Feb 1997 16:16:12 -0600
From: Brett Denner <dennerbw@lmco.lmtas.com>
Subject: Re: Copying files in Pel
Message-Id: <3300EFAC.446B@lmco.lmtas.com>

Niksun wrote:
> 
> Is there a way to copy a file in Perl - other than reading a file and
> then writing to another like this?:

use File::Copy; # Standard Perl Library

copy "src_file", "dst_file";


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

Date: 11 Feb 1997 23:09:36 GMT
From: stampes@xilinx.com (Jeff Stampes)
Subject: Re: File Tests for Directory not working under NT4.0
Message-Id: <5dqu7g$69v@neocad.xilinx.com>

Nathan V. Patwardhan (nvp@shore.net) wrote:
: $sharename = "C:\\";

>From within perl, go ahead and use:

$sharename = "C:/";

It should work and keeps things portable...

Cheers,

Jeff

--
Jeff Stampes -- Xilinx, Inc. -- Boulder, CO -- jeff.stampes@xilinx.com


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

Date: Tue, 11 Feb 1997 21:30:50 +0000
From: Andy Armstrong <andy@wonderworks.co.uk>
Subject: Re: FTP Client
Message-Id: <G5w7UHAKUOAzEwWM@wndrwrks.demon.co.uk>

In article <32F96619.3830@amagicstore.com>, A MAGIC STORE
<max@amagicstore.com> writes
>I've programmed a couple of scripts in Perl, I've uploaded them to my
>server (UNIX) but they are not working. My server said that there is a
>^M (new line) at the end of each line. I'm using Win95 Notepad.
>Does anybody know any FTP client or other program that transform MS-DOS
>based text files into UNIX text files (basically without the ^M at the
>end of each line)??

As other posters have noted you can do the job very nicely with Perl.
You can also validate your links, add the dimensions of any GIFs or JPGs
etc etc.

You might also like to consider ditching Notepad and using something
more salubrious. Textpad (inexpensive shareware) is my choice. It'll
allow you to create and edit files with 'unix' line termination so the
problem won't even arise in the first place.

-- 
http://www.wonderworks.co.uk --> Motion Picture Image Capture System
Andy Armstrong, WonderWorks


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

Date: Tue, 11 Feb 1997 15:52:25 -0500
From: "Daniel M. DiPasquo" <dipasquo@tc.cornell.edu>
Subject: getting STDERR from `backtick_exec`
Message-Id: <3300DC09.167E@tc.cornell.edu>

Is there a way to grab the STERR of a command exec'd in backticks?  For
example:

$output = `touch /some/place/i/dont/have/permissions/file`

$output should be "touch: ... cannot create", which is usually sent
along STDERR and seemingly not captured

Thanks,

Dan


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

Date: 11 Feb 1997 22:45:42 GMT
From: nvp@shore.net (Nathan V. Patwardhan)
Subject: Re: getting STDERR from `backtick_exec`
Message-Id: <5dqsqm$g93@fridge-nf0.shore.net>

Daniel M. DiPasquo (dipasquo@tc.cornell.edu) wrote:
: Is there a way to grab the STERR of a command exec'd in backticks?  For
: example:

: $output = `touch /some/place/i/dont/have/permissions/file`

Ooo, a job for the FAQ!  Check out http://www.perl.com/perl.
You'll need to use: 2>&1.

--
Nathan V. Patwardhan
nvp@shore.net
"send me mail"
	--Jamie Zawinski


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

Date: Tue, 11 Feb 1997 17:01:47 -0500
From: "Joel D. Martinsen" <jdmartin@glue.umd.edu>
Subject: How do you write to seperate frames?
Message-Id: <3300EC4A.4E39@glue.umd.edu>


------------16B93C2973A30
Content-Transfer-Encoding: 7bit
Content-Type: text/plain; charset=us-ascii

I have a program that outputs some formated data from a database.  I
want to know how I can send the output to a seperate frame in the
netscape window that the frame the cgi script was called from.  If any
one can help I'd greatly appreciate it

thanks,
Sean Holman
sholman@wam.umd.edu

------------16B93C2973A30
Content-Transfer-Encoding: 7bit
Content-Type: text/html; charset=us-ascii

<HTML><BODY>

<DT>I have a program that outputs some formated data from a database.&nbsp;
I want to know how I can send the output to a seperate frame in the netscape
window that the frame the cgi script was called from.&nbsp; If any one
can help I'd greatly appreciate it</DT>

<DT>&nbsp;</DT>

<DT>thanks,</DT>

<DT>Sean Holman</DT>

<DT>sholman@wam.umd.edu&nbsp;</DT>

</BODY>
</HTML>
------------16B93C2973A30--



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

Date: Tue, 11 Feb 1997 16:05:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: luis@ged.com
Subject: Re: how to change of a given string?
Message-Id: <Pine.GSO.3.95q.970211155910.23091F-100000@julie.teleport.com>

On Mon, 10 Feb 1997 luis@ged.com wrote:

> 	I need to change the Case of a string that a client inputs for
> instance ibm would be IBM, apple would be Apple.  

How will your code know which strings to change, and which letters should
be capitalized in them? You haven't given us the rule, so it's hard to
write code. Or, rather, it's easy to write code, but it probably won't do
what you really want:

    s/\b(i\w{2})\b/\U$1/gi;
    s/\b(a\w{4})\b/\u\L$1/gi;

Let us know when you know what rules to use, and we can try helping you
again. :-)

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 11 Feb 1997 23:55:03 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: How to run shell program in perl with --date  'one month ago' +%b    options
Message-Id: <slrn5g21hg.8er.dave@fast.thomases.com>

On 11 Feb 1997 19:13:53 GMT, Brooks Davis <brdavis@orion.ac.hmc.edu> wrote:
> Brian Freeze (freezeb@deltastar.nb.ca) wrote:
> : Greetings
> : 
> : I am trying to write a small perl script and have run into this problem. I am 
> : trying to call "/bin/date --date 'one month ago' +%b"  into a perl script. I 
> : assign this to a variable as follows:
> : 
> : $date_exe="/bin/date";
> : $date='$date_exe --date '1 month ago' +"%b"';
> 
> Since it appears that you only want the month you could use:
> 
> $lastmonth =
>     (Jan,Feb,Mar,Apr,May,Jun,Juil,Aug,Sep,Oct,Nov,Dec)[(localtime)[4]-1];
> 

Shouldn't that be

 $lastmonth =
     (Dec,Jan,Feb,Mar,Apr,May,Jun,Juil,Aug,Sep,Oct,Nov)[(localtime)[4]];
     
Otherwise it won't work in January.

Dave


-- 

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


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

Date: Tue, 11 Feb 1997 23:29:02 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: How to tell if Perl is run in debug mode
Message-Id: <E5Gp8E.K2n@bcstec.ca.boeing.com>

In article <3300A3EF.167E@lmco.lmtas.com>,
Brett Denner  <dennerbw@lmco.lmtas.com> wrote:
 > I would like to add some code to my perl script that is executed only
 > when perl is started with the -d flag (either via the command line or
 > the #!/usr/bin/perl line).  I envision something like this:
 > 
 > if ($DEBUG_MODE)
 >     {
 >     # do something
 >     }
 > 
 > where $DEBUG_MODE (or some other such variable) is true only in debug
 > mode.
 > 
 > Does such a variable exist?  Is there another way to tell if my script
 > is being run in debug mode?
 > 

I don't know if there's an accessible variable to do this.  

Not ideal but perhaps you could set a variable depending on
the presence of the DB package: 


BEGIN { $DEBUG_MODE = defined %DB:: ? 1 : 0 } 


HTH,

--
Charles DeRykus
ced@carios2.ca.boeing.com


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

Date: Tue, 11 Feb 1997 16:22:14 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Brett Denner <dennerbw@lmco.lmtas.com>
Subject: Re: How to tell if Perl is run in debug mode
Message-Id: <Pine.GSO.3.95q.970211162026.23091I-100000@julie.teleport.com>

On Tue, 11 Feb 1997, Brett Denner wrote:

> I would like to add some code to my perl script that is executed only
> when perl is started with the -d flag (either via the command line or
> the #!/usr/bin/perl line).  

I believe you're looking for the $^P variable, documented in perlvar. Hope
this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 12 Feb 1997 00:06:57 GMT
From: dave@fast.thomases.com (Dave Thomas)
Subject: Re: initialization of hash while resolving?
Message-Id: <slrn5g227q.8er.dave@fast.thomases.com>

On Tue, 11 Feb 1997 17:32:51 +0100, Sven Akkermans <sa@denkart.be> wrote:
> Hello,
> 
> take a look at this program.
> 
> #!/users/sa/mrperl/bin/perl
> use strict;
> 
> my(%SGS,$x);
> 
> $SGS{AB} = 13;
> 
> if( exists($SGS{SE}))
> {
>     print "SE exists from the first time on\n";
> }
> 
> $x = $SGS{SE}{X};
> 
> if( exists($SGS{SE}))
> {
>     print "SE exists from the second time on\n";
> }
> 
> Surprisingly to me, this prints "SE exists from the second
> time on". This means that SE exists after the assignment to
> $x.

Its the autovivification feature - Perl automatically creates the
intermediate structures when you have a nested data structure like this. If
you look at the actual value of SGS{SE} you'll find its an empty hash.

Dave



-- 

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


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

Date: Tue, 11 Feb 1997 16:43:19 -0500
From: Ying Hu <Y_Hu@fccc.edu>
Subject: log10
Message-Id: <3300E7F7.41C6@fccc.edu>

Hello,

Is there is log10 function in PERL? 

Thank u !

Ying


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

Date: Tue, 11 Feb 1997 16:33:36 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: Ying Hu <Y_Hu@fccc.edu>
Subject: Re: log10
Message-Id: <Pine.GSO.3.95q.970211163022.23091K-100000@julie.teleport.com>

On Tue, 11 Feb 1997, Ying Hu wrote:

> Is there is log10 function in PERL? 

If that's all you need, here it is. Hope this helps!

    sub log10 ($) { log($_[0]) / log(10) }

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 11 Feb 1997 22:57:11 GMT
From: "Peterg" <peterg@enterprise.net>
Subject: Looking for Perl Binary for HP-UX 9.00
Message-Id: <01bc186e$f37a9ee0$dac548c2@host.enterprise.net>

Does anyone know where I can access a precompiled version of perl suitable
for HP-UX 9.00. I've tried a 9.05 binary which core dumps whenever its
called.  I have no access to a compiler (unless anyone knows of a source
for a HP-UX 9.00 compatible, pre-compiled compiler!). 

Any advice on this greatly appreciated 



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

Date: 11 Feb 1997 19:34:11 -0500
From: clay@panix.com (Clay Irving)
Subject: Re: Loops in perl
Message-Id: <5dr363$bjr@panix.com>

In <5dnl9t$okb@dismay.ucs.indiana.edu> bdwheele@indiana.edu (Brian Wheeler) writes:
>In article <5dnf43$ktv$1@ftp.ampersand.com>,
>	jason@ampersand.com (Jason Brazile) writes:
>>In article <5dj1ls$1p4$1@newshound.csrv.uidaho.edu>,
>>Thomas Patrick Bailey <baile934@harrier.csrv.uidaho.edu> wrote:
>>> I am fairly new to perl, but I have been doing ok in it.  What I need to
>>> know is how to do a simple loop.  
>>>
>>> A simple example would be very helpful.
>>
>>No problem. Loops are pretty simple in perl:

Heh. Too ugly... How about:

         #!/usr/local/bin/per5
         for (1 .. 5) {
           print "hello world\n";
         }


>	Oh, for the love of God, are you a scheme programmer?  :)

>	seems alot easier to do:

>	#!/usr/bin/perl
>	for($i=1;$i<6;$i++) {
>		print "hello, world\n";
>	}

>	than to do 

>>
>>	#!/usr/bin/perl
>>
>>	use strict;
>>
>>	sub simple_loop
>>	{
>>		my ($lcv, $code) = @_;
>>
>>		($lcv) && (&$code, &simple_loop($lcv - 1, $code));
>>	}
>>	sub main
>>	{
>>		#
>>	 	# print "hello, world\n" 5 times
>>		#
>>		&simple_loop(5, sub {print "hello, world\n"});
>>	}
>>
>>	&main;
>>
>>---
>>Jason Brazile
>>Ampersand, Inc
>>Billerica, MA

>-- 
>Brian Wheeler
>bdwheele@indiana.edu
-- 
See the happy moron,                             
He doesn't give a damn,                                    Clay Irving N2VKG  
I wish I were a moron,                                        clay@panix.com
My God! Perhaps I am!                             http://www.panix.com/~clay


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

Date: Tue, 11 Feb 1997 22:00:11 GMT
From: pjh@mccc.edu (Pete Holsberg)
Subject: Multi-line Comments???
Message-Id: <3301ebb8.88015401@newsserver.mccc.edu>

Is there any easy way to "comment out" a section of a perl script? 

Thanks,
Pete


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

Date: 11 Feb 1997 22:46:45 GMT
From: mheins@prairienet.org (Mike Heins)
Subject: Re: Multi-line Comments???
Message-Id: <5dqssl$spv@vixen.cso.uiuc.edu>

=head1 Commented out

Pete Holsberg (pjh@mccc.edu) wrote:
: Is there any easy way to "comment out" a section of a perl script? 
: 
: Thanks,
: Pete

=cut

Your post is now commented out.

-- 
Regards,                                                      ___       ___
Mike Heins     [mailed and posted]  http://www.iac.net/~mikeh|_ _|____ |_ _|
                                    Internet Robotics         | ||  _ \ | |
This post reflects the              Oxford, OH  45056         | || |_) || | 
opinion of my employer.             <mikeh@iac.net>          |___|  _ <|___|
                                    513.523.7621 FAX 7501        |_| \_\   



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

Date: 11 Feb 1997 18:36:18 -0600
From: duncan@isip05 (Richard J. Duncan)
Subject: optimization of binary data operations.
Message-Id: <ua4tfic131.fsf@isip05.i-have-a-misconfigured-system-so-shoot-me>

I am trying to do some really simple DSP in a perl script. It requires
the swapping of word order for a stream of data. My current pathetic
approach is:

	while(($len = sysread(PIN,$_,4))>0){
		if (/(..)(..)/) {
			syswrite(POUT,"$2$1",$len);
		}
}

Where PIN and POUT are input/output file handles, respectively.

This is dog slow, I would like to be able to work on 8k of data at a
time in a memory buffer. Does Perl have anything like a pointer for
memory?

My config: Perl 5.0/Solaris 2.5.1

Thanks for any help,

+-------------------------------------------<duncan@isip.msstate.edu>-+
| Richard Jennings Duncan               http://www.gtlug.org/~rduncan |
| U-grad research assistant      Institute for Signal and Info. Proc. |
| Mississippi State University                   Computer Engineering |
|         'if you really want a challenge,                            |
|                    just deal with yourself' - Tori Amos             |
+---------------------------------------------------------------------+
--
Opinions expressed above are mine, and may not reflect those of my employer.


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

Date: 11 Feb 1997 22:17:46 GMT
From: jot.feb97@tmp.medtronic.com (Jot Powers)
Subject: Re: Perl rand() function on solaris SPARC
Message-Id: <5dqr6a$n8@gazette.medtronic.com>

In article <5dq00c$frg@tst.hk.super.net>, silee@news.hk.super.net (Mr Simon Lee) writes:
>Thomas J. Forbes (tforbes@ix.netcom.com) wrote:
>: I have the same problem - when I run:
>
>: srand();
>
>: $num = int(rand(7)); # Pick a Random Number
>
>Actually I have the same problem on Solaris 2.x machine when I compiled Perl 
>5 and did make test. only this function failed.......

[ Hey, how about the old 70 character width thing? ]

You have one of 2 problems:

1) Your perl is not installed correctly.
2) You have another problem, and you have incorrectly assumed
   this is your problem, and you have a problem elsewhere.

Below is the program that I spit out real quick to show that
I can not duplicate your problem with 5.003 under Solaris 2.5.1

#!/usr/local/bin/perl
srand();
 
for($i=0;$i<=30;$i++) {
  $num = int(rand($i));
  print "For $i num = $num\n";
}


node127% perl /tmp/rand.pl
For 0 num = 0
For 1 num = 0
For 2 num = 1
For 3 num = 0
For 4 num = 2
For 5 num = 2
For 6 num = 3
For 7 num = 6
For 8 num = 1
For 9 num = 5
For 10 num = 3
For 11 num = 7
For 12 num = 8
For 13 num = 2
For 14 num = 4
For 15 num = 1
For 16 num = 5
For 17 num = 7
For 18 num = 13
For 19 num = 18
For 20 num = 10
For 21 num = 6
For 22 num = 2
For 23 num = 20
For 24 num = 12
For 25 num = 13
For 26 num = 21
For 27 num = 8
For 28 num = 11
For 29 num = 5
For 30 num = 16

node127% perl -V
Summary of my perl5 (5.0 patchlevel 3 subversion 0) configuration:
  Platform:
    osname=solaris, osver=2.5.1, archname=sun4-solaris
    uname='sunos node125 5.5.1 generic sun4u sparc sunw,ultra-1 '
    hint=recommended, useposix=true, d_sigaction=define
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.7.2
    cppflags='-I/usr/local/include -I/opt/local/include'
    ccflags ='-I/usr/local/include -I/opt/local/include'
    stdchar='unsigned char', d_stdstdio=define, usevfork=false
    voidflags=15, castflags=0, d_casti32=define, d_castneg=define
    intsize=4, alignbytes=8, usemymalloc=y, randbits=15
  Linker and Libraries:
    ld='gcc', ldflags =' -L/usr/local/lib -L/opt/local/lib'
    libpth=/usr/local/lib /opt/local/lib /lib /usr/lib /usr/ccs/lib
    libs=-lsocket -lnsl -ldb -ldl -lm -lc -lcrypt
    libc=/lib/libc.so, so=so
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=, ccdlflags=' '
    cccdlflags='-fpic', lddlflags='-G -L/usr/local/lib -L/opt/local/lib'
 
@INC: /usr/local/lib/perl5/sun4-solaris/5.003 /usr/local/lib/perl5 /usr/local/lib/perl5/site_perl/sun4-solaris /usr/local/lib/perl5/site_perl .


-- 
Jot Powers jot.feb97@tmp.medtronic.com (email address valid until end of month)
Unix System Administrator, Medtronic Micro-Rel
"Subtlety is the art of saying what you think and getting out of the way
before it is understood."




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

Date: Tue, 11 Feb 1997 15:54:57 -0800
From: Tom Phoenix <rootbeer@teleport.com>
To: "Thomas J. Forbes" <tforbes@ix.netcom.com>
Subject: Re: Perl rand() function on solaris SPARC
Message-Id: <Pine.GSO.3.95q.970211153653.23091E-100000@julie.teleport.com>

On Sun, 9 Feb 1997, Thomas J. Forbes wrote:

> I have the same problem - when I run:
> 
> srand();
> 
> $num = int(rand(7)); # Pick a Random Number
> 
> print "$num\n";
> 
> I get back numbers like 56,798
>  WHY IS THIS????????

Almost certainly your perl binary was (mis)compiled with the wrong value
for randbits. To be certain, use this command to see what it was set to,
and check your rand function's docs to see whether it really returns that
many bits. (I'd guess that you have a 31-bit function, while your randbits
is set to 15 or 16, but that's just a guess.)

    perl -MConfig -e 'print $Config{randbits},$/'

To fix things, ask your admin to rebuild perl with the proper value, then
'make test' to see that everything works before re-installing the fixed
perl binary. 

Hope this helps!

-- Tom Phoenix        http://www.teleport.com/~rootbeer/
rootbeer@teleport.com   PGP  Skribu al mi per Esperanto!
Randal Schwartz Case:     http://www.lightlink.com/fors/



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

Date: 11 Feb 1997 22:14:35 -0000
From: shields@crosslink.net (Michael Shields)
Subject: Re: space stripping
Message-Id: <5dqr0b$5ge@daedalus.crosslink.net>

In article <6li8d5.q05.ln@localhost>, Tad McClellan <tadmc@flash.net> wrote:
> I've checked for it several times at Borders and Book Stop. Neither
> even could tell that it was a book in print...

It's too new to be in Books in Print but if you bring the ISBN from
ora.com, any bookstore worth shopping at will be able to order it for you.
-- 
Shields, CrossLink.


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

Date: Tue, 11 Feb 1997 14:12:38 -0800
From: Frank Opila <franko@sequent.com>
Subject: Subroutine Prototypes, Hard References and Maintainable Code: take 2
Message-Id: <3300EED6.585B@sequent.com>

I submitted this problem earlier, using quick and dirty examples.
It was pointed out that I had coding errors.  I have cleaned them up and
made examples that run successfully with perl version 5.003.
Sorry if I wasted anyone's time with this.

My main concern is developing Perl code that can be maintained without
too much difficulty by other programmers who are very good C
programmers, but may not be Perl guru's.

Given this, here are several examples dealing with the use of
subroutine prototypes for routines, which each have a parameter which
is a hard reference to a hash.  Example 1 is an introduction and 
the remaining examples describe the real issue.  The examples are not
examples of a real problem which needs to be solved, but are only
intended as illustrations.


#!/usr/local/bin/perl -w
#-------------------------------------------------------------------
#
#  Example 1.
#
#  The MAIN block calls routine1, passing a hard reference to a hash.
#  Routine1 then calls routine2.
#  In order for routine1 to pass the same hard reference to routine2, 
#  it MUST pass it as a scalar.

use English;

#  Subroutine Prototypes

sub routine1(\%);
sub routine2($$);

MAIN: {
    my (%hash1);
    %hash1 = (
        'a' => 'a_value',
        'b' => 'b_value',
        'c' => 'c_value',
    );
    routine1(%hash1);
}

sub routine1 {
    my ($hash_ref) = @ARG;
    $hash_ref->{'d'} = 'd_value';
    routine2($hash_ref, 'b');
}    

sub routine2 {
    my ($hash_ref, $var) = @ARG;
    if ($hash_ref->{$var}) {
        print "var=$var  value=$hash_ref->{$var}\n";
    }
    else {
        print "var=$var is not in hash\n";
    }
}

#!/usr/local/bin/perl -w
#-------------------------------------------------------------------
#
#  Example 2.
#
#  Now, in addition to calling routine1, let's say that the MAIN block
#  also needs to calls routine2, again passing a hard reference to a
hash.
#  This code looks confusing since routine1 and routine2 are called
#  differently, even though the same hard reference is passed as a
#  parameter.

use English;

#  Subroutine Prototypes

sub routine1(\%);
sub routine2($$);

MAIN: {
    my (%hash1);
    %hash1 = (
        'a' => 'a_value',
        'b' => 'b_value',
        'c' => 'c_value',
    );
    routine1(%hash1);
    routine2(\%hash1, 'd');
}

sub routine1 {
    my ($hash_ref) = @ARG;
    $hash_ref->{'d'} = 'd_value';
    routine2($hash_ref, 'b');
}    

sub routine2 {
    my ($hash_ref, $var) = @ARG;
    if ($hash_ref->{$var}) {
        print "var=$var  value=$hash_ref->{$var}\n";
    }
    else {
        print "var=$var is not in hash\n";
    }
}


#!/usr/local/bin/perl -w
#-------------------------------------------------------------------
#
#  Example 3.
#
#  Now make the calls to the routines consistent.
#  Both routines now accept a scalar, which is really a
#  hard reference to a hash.
#  Note that the code for routine1 and routine2 does not change at all. 
#  
#  My complaint about this example is that we are no longer making
#  significant use of Perl's type checking with the prototypes.
#  Also, this calling scheme is inconsistent with the way that
#  built-in Perl functions are called.
#

use English;

#  Subroutine Prototypes

sub routine1($);
sub routine2($$);

MAIN: {
    my (%hash1);
    %hash1 = (
        'a' => 'a_value',
        'b' => 'b_value',
        'c' => 'c_value',
    );
    routine1(\%hash1);
    routine2(\%hash1, 'd');
}

sub routine1 {
    my ($hash_ref) = @ARG;
    $hash_ref->{'d'} = 'd_value';
    routine2($hash_ref, 'b');
}    

sub routine2 {
    my ($hash_ref, $var) = @ARG;
    if ($hash_ref->{$var}) {
        print "var=$var  value=$hash_ref->{$var}\n";
    }
    else {
        print "var=$var is not in hash\n";
    }
}


#!/usr/local/bin/perl -w
#-------------------------------------------------------------------
#
#  Example 4.
#
#  Now, let's make the calling method consistent from MAIN.
#  Let's make 2 versions of routine2: routine2 and routine2_r:
#    routine2   would accept a hard reference to a hash as its 1st
argument.
#    routine2_r would accept a scalar as its 1st argument.
#  routine2 would always call routine2_r.
#
#  Yuk!

use English;

#  Subroutine Prototypes

sub routine1(\%);
sub routine2(\%$);
sub routine2_r($$);

MAIN: {
    my (%hash1);
    %hash1 = (
        'a' => 'a_value',
        'b' => 'b_value',
        'c' => 'c_value',
    );
    routine1(%hash1);
    routine2(%hash1, 'd');
}

sub routine1 {
    my ($hash_ref) = @ARG;
    $hash_ref->{'d'} = 'd_value';
    routine2_r($hash_ref, 'b');
}    

sub routine2 {
    my ($hash_ref, $var) = @ARG;
    routine2_r($hash_ref, $var);
}

sub routine2_r {
    my ($hash_ref, $var) = @ARG;
    if ($hash_ref->{$var}) {
        print "var=$var  value=$hash_ref->{$var}\n";
    }
    else {
        print "var=$var is not in hash\n";
    }
}


#-------------------------------------------------------------------

Any suggestions?


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

Date: Mon, 10 Feb 1997 16:43:31 -0800
From: Michael Peppler <mpeppler@mbay.net>
To: Sivakumar <sivakumar.shanmugasundaram@eng.sun.com>
Subject: Re: Sybperl & group by query
Message-Id: <32FFC0B3.45B2@mbay.net>

Sivakumar wrote:
> 
> Hi,
> 
> I have a query which has formatted headings and group by, computed by
> clauses. I dont want to do any processing in perl. just want to dump
> the output in the same format as returned by the query (thru isql).
> i tried using 'sql()' fn. the heading is gone and the formatting is
> lost. only option is to run the whole query thru isql. is there any
> other way using Sybperl (perl5/sybperl 2.06). thanks

The query you're running is it a stored proc or straight sql?

In any case, it may be easier for you to pass this off to isql and
let it worry about headers, etc.

In Sybperl, you'd have to get the headers (for example using
dbcolname())
and then format the output yourself.

That's the price one has to pay for flexibility, sometimes :-)
-- 
Michael Peppler, Data Migrations Inc.
mpeppler@mbay.net or mpeppler@bix.com



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

Date: Tue, 11 Feb 1997 15:37:50 -0800
From: Ben Mehling <bmehling@uci.edu>
To: Elfriede Heilmeier <elfriede.heilmeier@urz.uni-bamberg.de>
Subject: Re: WIN32-Perl-script loops and wait for a file
Message-Id: <330102CE.47BB@uci.edu>

Elfriede Heilmeier wrote:

> Because the Perl-Script is looping for ever if the C-Program was not
> started, I want to insert some lines in the Perl-Script that test
> the existance of the C-Program in the task list.

How about getting a process list (shell command) and parsing it for the
particular process?  You can use some of the tools included in the
ntreskit or try the UNIX package available here: 	
	
	http://www.itribe.net/virtunix/

There is a 95/NT UNIX util package which includes "ps.exe" which will
give you a process listing.

Ben


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

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 V7 Issue 929
*************************************

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