[7432] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1057 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Sep 22 02:07:36 1997

Date: Sun, 21 Sep 97 23:00:23 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 21 Sep 1997     Volume: 8 Number: 1057

Today's topics:
     Re: Animated GIF problem in Perl <m.harding@iname.com>
     Re: Dial-Up Networking with Perl ? (Andrew M. Langmead)
     Re: How to clear the remark of lang C? (Frank Merrow)
     Re: How to clear the remark of lang C? <rpsavage@ozemail.com.au>
     inetd STDIN still open? <Goesta@von.Stebut.org>
     Internet Paging <ppchoa@contact.com.sg>
     Re: Need bulk Unix <-> PC file conversion <rpsavage@ozemail.com.au>
     Re: Need bulk Unix <-> PC file conversion (Dave Schenet)
     Re: Out of memory! while you still have it... <bholzman@mail.earthlink.net>
     Problem subclassing GDBM_File (Kenneth Herron)
     Problems with variables as subs? (Steve Lamb)
     Re: Problems with variables as subs? (Andrew M. Langmead)
     Re: Question about pattern matching! (Tad McClellan)
     Re : Perl and form fields ("Waqar Hafiz")
     Re: Re : Perl and form fields (Jens Heunemann)
     RTR Win95Pak? keng@removethis.wco.com
     Run-time inclusion of Curses module <thomson@zinger.adp.wisc.edu>
     Re: Run-time inclusion of Curses module <rootbeer@teleport.com>
     Re: Run-time inclusion of Curses module (Andrew M. Langmead)
     Re: Setting ENV vars in perl (Gerben Vos)
     Re: Setting ENV vars in perl (Martin Str|mberg)
     Re: Setting ENV vars in perl (Martien Verbruggen)
     Using perl under NT 3.51 mlinvle@inlink.com
     Using the stat function <Daniel.Wu@alcatel.com.au>
     WANT:fast word search in big sorted text file (Shenghuo Zhu)
     Re: WANT:fast word search in big sorted text file (Daniel E. Macks)
     Re: Week of the Year [Was: Re: Calculating the week num <rpsavage@ozemail.com.au>
     Windows GUI program with perl? (CherngJyh Lin)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Mon, 22 Sep 1997 01:17:14 +0100
From: m a r k r h a r d i n g <m.harding@iname.com>
Subject: Re: Animated GIF problem in Perl
Message-Id: <3425B909.72D2@iname.com>

> This works and passes the image back, but if it's an animated gif, it
> only animates one cycle, then stops (NAV3/4) works fine under MSIE.
> 
> Anyone have any idea why NAV3/4 doesn't recognize it as an animated gif,
> and let it loop?

I had a similar problem with animated gifs only playing once instead of
looping in Netscape3/4 recently and the cause of the problem was I had
set the browser cache to zero (I had my reasons). Re-enabling the cache
solved the problem immiediately so maybe checking your cache is enabled
would be somewhere to start...

Mark.
-- 
Mark R Harding
Department of Meteorology
University of Edinburgh
Kings Buildings, Edinburgh. EH9 3JZ

E-mailto:markh@met.ed.ac.uk        URL: http://www.met.ed.ac.uk/~markh


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

Date: Sun, 21 Sep 1997 20:16:00 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Dial-Up Networking with Perl ?
Message-Id: <EGvKAo.45I@world.std.com>

as646@freenet.carleton.ca (batman) writes:

>I would like to use Win95's Dial-Up Networking (DUN) to make a connection 
>to my ISP.  Or if the connection is already up, then tell Perl to use 
>that connection.

According to Microsoft's "Knowledge Base" article Q145740,
<URL:http://www.microsoft.com/kb/articles/q145/7/40.htm> Dialup
Networking can be started on the command line with the command:

       rundll rnaui.dll,RnaDial <connectoid>

where <connectoid> is the name given to your dialup connection.

I guess you could use the output of "route.exe print" to determine if
a connection is already up. There is probably a better way.

The only reason I can see for doing this is if the DUN connection you
want to make is not your usual one. If it is your default, you can
configure Windows '95 to automatically launch a certain dialup
connectoid, see the the "Internet" control panel for details. That
way, you only need to code perl to use networking, and let windows
determine if it is up or not.

-- 
Andrew Langmead


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

Date: 19 Sep 1997 09:35:03 -0700
From: fmerrow@qualcomm.com (Frank Merrow)
Subject: Re: How to clear the remark of lang C?
Message-Id: <5vu9jn$8tr@pure.qualcomm.com>

>: :   Is there more efficient way to clear all the /* ... */ remark
>: : in lang C by using perl language?? Thanks!
>
>: Why do you want to clear comments?  Obfuscation?  I am sure
>: you wouldn't do that -- there must be a good reason. Perhaps
>
>Maybe you want to exclude comments when counting lines of code?

Actually, I would be very interested in this too if it has been
done and in fact might be forced to take the project on myself soon.
The reason is nothing so subversive as Obfuscation!

I want to scan the source for certain variables, #defines and such and
comments are getting in the way.  I don't care about occurances in the
comments, only in the source.  My ideal operator would take an
array with a full C source file and return an array without the C(++)
comments.  In particular, the indexes should be preserved line for line
in both arrays.  I can use the "stripped" version for scanning, but use
the "full" version of printing errors and such.

Frank


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

Date: Mon, 22 Sep 1997 11:22:25 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: How to clear the remark of lang C?
Message-Id: <3425BA41.2410@ozemail.com.au>

Frank Merrow wrote:
> 
> >: :   Is there more efficient way to clear all the /* ... */ remark
> >: : in lang C by using perl language?? Thanks!
> >[snip]

1. Mastering Regular Expressions, Jeffrey Friedl, O'Reilly, 1-56592-257-3, p 292.

2. The Perl package Perceps parses *.h files, & contains comment stripping code. Try:
http://friga.mer.utexas.edu/mark/perl/perceps/.


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

Date: Sun, 21 Sep 1997 22:04:51 +0200
From: Goesta von Stebut <Goesta@von.Stebut.org>
Subject: inetd STDIN still open?
Message-Id: <34257DE3.429D1EF8@von.Stebut.org>

Hi.
I have a problem with testing, if the
STDIN handle is still open. The script is called
by the inetd and I don't know how to test the
connection without reading by $foo=<STDIN>.
In fact, the script doesn't tell me if the
other side just closed the socket and it runs in
a timeout...
Can anybody help me?

bye, Goesta von Stebut.


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

Date: Mon, 22 Sep 1997 12:25:18 +0800
From: Choa Peng Peng <ppchoa@contact.com.sg>
Subject: Internet Paging
Message-Id: <3425F32E.4CD1A5AA@contact.com.sg>

Has anyone tried internet paging using perl? How to do it?

Thanks.


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

Date: Mon, 22 Sep 1997 11:40:20 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <3425BE74.4473@ozemail.com.au>

lynn kasdorf wrote:
> 
> Riddle me this...
> 
> I'm doing perl development on my Windows NT box. I'm testing my perl on
> my local web server, then uploading to the final destination, which is a
> unix server.
> 
> I need to convert the PC style (CR LF) files to unix style (LF) files.
> The text editor I use can do this (UltraEdit32) but it is kinda tedious.
> 
> What is needed is a util for 32 bit Windows that you can drag a tree of
> files onto, and it will convert all text files in that tree to unix
> style, without changing file names. Also a companion that does the
> inverse.

[snip]

1. Wait a few days. Our MS Windows Visual C++ program will be available in source.

2. Wait a few days. My Perl 5 will be posted to this news group.

Q: What to do about keeping passwords secret. I can't get Term::ReadKey to make under WinNT.


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

Date: 22 Sep 1997 02:03:56 GMT
From: shodan@shodan.erols.com (Dave Schenet)
Subject: Re: Need bulk Unix <-> PC file conversion
Message-Id: <604jmc$orv@winter.news.erols.com>

Ron Savage (rpsavage@ozemail.com.au) wrote:

[How do I convert DOS CR-LF to UNIX LF?]


This works for me, and I'm sure there's a more elegant way of
doing it.

open (INPUT, "<dosfile");
open (OUTPUT, ">unixfile");
while (<INPUT>) {
  $_ =~ s/^M//;
  print (OUTPUT $_);
}
close (INPUT);
close (OUTPUT);

The ^M needs to be literal, for example in vi, you would actually
type ^V^M to get a literal ^M. I'm not sure how to accomplish this
in a DOS editor, though. IOW, it's a literal control-m, not a
shift-6 capital-M.

: 1. Wait a few days. Our MS Windows Visual C++ program will be available in source.

: 2. Wait a few days. My Perl 5 will be posted to this news group.

: Q: What to do about keeping passwords secret. I can't get Term::ReadKey to make under WinNT.

--
+----------------------------------+-----------------------------------+
|Dave Schenet - shodan at erols    | Erols Internet Services, INC.     |
|Junior UNIX Developer             | Springfield, VA.                  |
+----------------------------------+-----------------------------------+
| Can't reply by mail? I'm blocking 52 netblocks from sending me mail. |
| I have zero-tolerance for SPAM. One strike and I stop listening. . . |
+----------------------------------------------------------------------+


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

Date: Sun, 21 Sep 1997 17:45:28 -0400
From: Benjamin Holzman <bholzman@mail.earthlink.net>
To: Huajun Wang <hw20@merhaba.cc.columbia.edu>
Subject: Re: Out of memory! while you still have it...
Message-Id: <34259578.662191FF@mail.earthlink.net>

[posted & mailed]

Huajun Wang wrote:
> 
> I am running a perl program that give me this Out of memory! problem.
> Using ps -o rss suggests that the memory used by the program is only
> about 30% of the total physical memory (at all stages) of my machine.
> Basically what I am doing is merging an array of variable length (long)
> strings (I did undef the ones that got merged).
> 
> Could anyone give me some hints as to what I am doing wrong? Is there a
> limit of the length of strings (within an array) or some sort?
> 
> Thanks.
There are no built-in length limits to strings in perl.  If you post
your code, one of the many able & willing experts who prowl this group
may be able to help you optimize its memory usage.

Hope this helps,

Benjamin Holzman


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

Date: 22 Sep 1997 00:16:38 GMT
From: kherron@campus.mci.net (Kenneth Herron)
Subject: Problem subclassing GDBM_File
Message-Id: <604dd6$fen$1@news.campus.mci.net>

Using perl 5.003 here.

We have a database in GDBM format.  I wrote a package to simplify
accessing this db by hiding implementation details (location of the db,
the fact it's gdbm, and some post-processing done on the value part of
each record).  Everything works, but when I call untie() I get well
over a hundred "bad free() ignored" errors.  In fact, I get about 102
of these errors plus 6-8 more for each record retrieved from the
database, possibly significant because each record contains 3-4
name/value pairs that are turned into a hash.  If I don't call untie
(or don't pass the call through to gdbm) I don't get any errors, but of
course the database isn't closed either.

I realize that "bad free()" points to a bug in gdbm or GDBM_File,
but I've never gotten similar errors using GDBM_File directly, and
this seems to be a fairly straightforward wrapper around GDBM_File.
Can anyone kibitz my code?

package CMCI::Userdb;
use Carp;
use GDBM_File;
use Tie::Hash;

@ISA = qw(Tie::Hash);

sub TIEHASH {
	my $type = shift;
	my $file = shift || '/etc/raddb/users.gdbm';
	# kjh -- also tried GDBM_File->new()
	my $db = GDBM_File->TIEHASH($file, &GDBM_READER, 0666);
	$db ? bless {gdbm=>$db}, $type : undef;
}

sub FETCH {
	my $type = shift;
	my $key = shift;
	my($val, %ret);

	$val = $type->{gdbm}->FETCH($key);
	if (!defined $val) {
		undef;
	}
	else {
		# val is three or more 'name = "val"' pairs; turn this into
		# a hash & return a ref to it.
		while (length $val) {
			$val =~ s/^\s+//;
			if ($val =~ /^(\S+)\s?=\s?"([^"]*)"(.*)$/s) {
				$key = lc $1;
				$ret{$key} = $2;
				$val = $3;
			}
			elsif ($val =~ /^(\S+)\s?=\s?(\S+)(.*)$/s) {
				$key = lc $1;
				$ret{$key} = $2;
				$val = $3;
			}
			else {
				last;
			}
		}
		\%ret;
	}
}

[STORE, DELETE, CLEAR, just carp & return, since we're read-only]

sub FIRSTKEY {
	my $type = shift;
	$type->{gdbm}->FIRSTKEY();
}

[NEXTKEY & EXISTS are similar to FIRSTKEY]

sub DESTROY {
	my $type = shift;
	$type->{gdbm}->DESTROY();
}
-- 
Kenneth Herron -- kherron@campus.mci.net
No animals were harmed during the production of this message.


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

Date: 21 Sep 97 22:33:55 GMT
From: morpheus@no-spam.calweb.com (Steve Lamb)
Subject: Problems with variables as subs?
Message-Id: <slrn62b86j.fl2.morpheus@web1.calweb.com>

    'nother newbie question here.  Is there any problems with using
variables to point to a subroutine.  EG:

$subname="bah";
for (1==1)
{
  &$subname;
}

sub bah
{
  print("Bah!\n");
}

    I've tried that and it works and I am planning on using it in a script I
am hammering together.  However, since I'm new to perl I'm just afraid I'm
setting myself up for some stupid problem down the road.

    The only problem I can see, and will avoid, is that somewhere it is
possible to call a sub which is not defined.  I plan to get around that with
an array that holds the registered subroutine names and check the variable
agaist that array before calling the subroutine in the above fashion.  That
way if a problem does come up from a variable calling a sub that does not
exist it will be the fault of the person who did not register the subroutine
correctly into that array.

-- 
             Steve C. Lamb             | Opinions expressed by me are not my
    http://www.calweb.com/~morpheus    | employer's.  They hired me for my
CC: from news not wanted or appreciated| skills and labor, not my opinions!
---------------------------------------+-------------------------------------


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

Date: Mon, 22 Sep 1997 02:59:16 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Problems with variables as subs?
Message-Id: <EGw2ys.4wM@world.std.com>

morpheus@no-spam.calweb.com (Steve Lamb) writes:

>$subname="bah";
>for (1==1)
^^^^^^^^^^^^  ??????
>{
>  &$subname;
>}

>    I've tried that and it works and I am planning on using it in a script I
>am hammering together.  However, since I'm new to perl I'm just afraid I'm
>setting myself up for some stupid problem down the road.

What you are creating is a "symbolic reference" to the subroutine
blah. It works, but if possible, why not create a hard reference instead.

$subname = \&bah;

if(1 == 1) {
  &$subname;
}

>    The only problem I can see, and will avoid, is that somewhere it is
>possible to call a sub which is not defined.

Thats one advantage of the hard reference approach. If you have a hard
reference to the sub, the sub does indeed exist. (even if you do
something really bizarre like "undef &bah" or "*bah = *fooey")

Another thing to point out, is you can use the expresson
"defined(&$subname)" in a conditional expression to test if the
subroutine exists.

Also, a hash of references to subroutines make a really neat name to
subroutine mapping. Anonymous subs can liven the mix too.

    %subs = ( bah => \&bah, foo => \&foo, fooey => sub { &bah;&foo } );
    #
    # time passes
    #
    &$subs{$subname}(@args) if exists $subs{$subname};
-- 
Andrew Langmead


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

Date: Sun, 21 Sep 1997 15:09:09 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Question about pattern matching!
Message-Id: <5tu306.b56.ln@localhost>

Tad McClellan (tadmc@flash.net) wrote:
: Tam, Kai Fai (tam1@uwindsor.ca) wrote:

: : Do you guys have any clue about what the subroutine below
: : is doing?

: : while ($buf =~ /^^(.*)\n\r?([\000-\377]*)$/) 
: : {
: :      $_ = $1;
: :      $buf = $2;
: : }


: while ($buf =~ /^               # match the beginning of the string
:                 ^               # match a literal caret character
                                            ^^^^^^^^^^^^^

As Guy Decoux pointed out to me in email, that is *not* what it is
matching there.

It is matching the beginning of the string again. What purpose that
might serve I cannot imagine...


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


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

Date: Sun, 21 Sep 1997 19:46:17 +0100
From: waqar.hafiz@virgin.net ("Waqar Hafiz")
Subject: Re : Perl and form fields
Message-Id: <19970921185031.AAA19326@p28-barbet-gui.tch.virgin.net>

COWBYS (cowbys@aol.com) wrote:

: Is there a way to use Perl to "pad" input fields from a form once they
are
: parsed, so for example
: If I have a form, and one of its input fields is "Name", with a max input
: lenght of 25, and someone enters a name thats only 16 chars long, I can
pad
: the rest of the field  with 9  zeroes or spaces or something so that its
: always 25 chars long regardless of the number of chars entered?

: I ask this becuz I am outputting "Name" and other fields to a txt file
: which I intend to read later, and I need to know that Name and the other
: fileds are always going to be the same length, so I can use seek and read
: to pull the values out of this file, always from the same position.

A slightly long-winded way would be:

for ($length = length($form{'name'}); $length <= 25; $length++)
	{
		$form{'name'} = "$form{'name'}" . "0";   # pad with a zero
	}



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

Date: Sun, 21 Sep 1997 23:32:21 GMT
From: jens.heunemann@stud.uni-muenchen.de (Jens Heunemann)
Subject: Re: Re : Perl and form fields
Message-Id: <3426ae59.1989701@news.lrz-muenchen.de>

On Sun, 21 Sep 1997 19:46:17 +0100, waqar.hafiz@virgin.net ("Waqar
Hafiz") wrote:

>COWBYS (cowbys@aol.com) wrote:
>
>: Is there a way to use Perl to "pad" input fields from a form once they
>are
>: parsed, so for example
>: If I have a form, and one of its input fields is "Name", with a max input
>: lenght of 25, and someone enters a name thats only 16 chars long, I can
>pad
>: the rest of the field  with 9  zeroes or spaces or something so that its
>: always 25 chars long regardless of the number of chars entered?
>
>: I ask this becuz I am outputting "Name" and other fields to a txt file
>: which I intend to read later, and I need to know that Name and the other
>: fileds are always going to be the same length, so I can use seek and read
>: to pull the values out of this file, always from the same position.
>
>A slightly long-winded way would be:
>
>for ($length = length($form{'name'}); $length <= 25; $length++)
>	{
>		$form{'name'} = "$form{'name'}" . "0";   # pad with a zero
>	}

Sorry I replied to the reply, have not found the original message

A short version is:
$in{"Name"} .= "0" x (25 - length $in{"Name"});
#          ^^^^^^^^^ Don't forget the dot before the =
substring( $in{"Name"},25 ) = ""; # Just in case you are paranoid 
			# and want to avoid that someone starts your script
			# "by Hand" with parameters longer than 25 chars.

( Didn't test the substring thing, but the first part works )

HTH

Jens




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

Date: 22 Sep 1997 03:13:25 GMT
From: keng@removethis.wco.com
Subject: RTR Win95Pak?
Message-Id: <604nol$jsn$1@news.wco.com>

Hello All.

This may be slightly off topic, but has anyone been using "Ready to
Run" Software's Win95Pak?  I am interested in using it for working
with the Perl/Win32 port.  I appreciate any opinions anyone cares to
offer.  Please post here and/or email me at keng@wco.com.

Thanks!



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

Date: 21 Sep 1997 17:30:23 -0500
From: Don Thomson <thomson@zinger.adp.wisc.edu>
Subject: Run-time inclusion of Curses module
Message-Id: <tzvhzufgg0.fsf@zinger.adp.wisc.edu>

I often pull in modules at run-time with a 'require' and 'import'
rather than a compile-time 'use' if I'm interested in fast start-up
time and the routines in the module may or may not be invoked,
depending on choices made by the script user.  This has worked well
for me with the exception of the Curses module, where I always seem to
run into problems.

For instance, I'm currently using Steven L. Kunz's very useful
'perlmenu.pm' module, which I can invoke successfully within a single
script with:

	BEGIN { $Curses::OldCurses = 1; }
	use Curses;  
	use perlmenu;

But if I try and package the above instead into a separate module
which is itself then pulled into my main script at run-time with a
'require' and 'import', the routines in that module that use Curses
complain about not finding 'getcap', which is clearly exported in the
Curses module.  Presumably if I include the exact same lines as above
in the separate module, its namespace should contain the exact same
Curses symbols after run-time compilation invoked by the main script
as the main namespace would have when I did the above directly in the
main script.  I've tried importing Curses symbols into the main script
itself, which also doesn't work, but doesn't seem like it should be
needed anyway, since the routines using them exist in the module
package namespace.  Even putting a require and import of Curses in the
main script when needed at run-time, followed by pulling my own
routines from a '.pl' file rather than a module package, therefore
presumably running in the same namespace, also produces the same
problem.  

This is one example of a problem I've run into with several other
attempts to pull in Curses at run-time in other situations.  Any hints
on run-time inclusion of this particular module that has worked for
anyone else?  Is there an easy namespace issue here that I'm somehow
overlooking?

-- 

----- Don Thomson ----- DoIT (Division of Information Technology) -------
thomson@doit.wisc.edu  (608) 262-0007  1210 W. Dayton, Madison, WI  53706


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

Date: Sun, 21 Sep 1997 16:29:51 -0700
From: Tom Phoenix <rootbeer@teleport.com>
To: Don Thomson <thomson@zinger.adp.wisc.edu>
Subject: Re: Run-time inclusion of Curses module
Message-Id: <Pine.GSO.3.96.970921162243.29448M-100000@julie.teleport.com>

On 21 Sep 1997, Don Thomson wrote:

> I'm currently using Steven L. Kunz's very useful 'perlmenu.pm' module,
> which I can invoke successfully within a single script with:
> 
> 	BEGIN { $Curses::OldCurses = 1; }
> 	use Curses;  
> 	use perlmenu;
> 
> But if I try and package the above instead into a separate module which
> is itself then pulled into my main script at run-time with a 'require'
> and 'import', the routines in that module that use Curses complain about
> not finding 'getcap', which is clearly exported in the Curses module. 

Do you mean that the above code works in your main program, and you can
subsequently call getcap(), but that this code below (as a require'd
library) can't find getcap()?

    BEGIN { $Curses::OldCurses = 1; }
    use Curses;
    use perlmenu;
    BEGIN {
        if (defined &getcap) {
	    print "getcap() exists\n";
	} else {
	    print "getcap() not found\n";
	    print "%INC has:\n", map "  $_\n", keys %INC;
	}
    }

Hope this helps!

-- 
Tom Phoenix           http://www.teleport.com/~rootbeer/
rootbeer@teleport.com  PGP   Skribu al mi per Esperanto!
Randal Schwartz Case:  http://www.rahul.net/jeffrey/ovs/
              Ask me about Perl trainings!



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

Date: Mon, 22 Sep 1997 02:45:51 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Run-time inclusion of Curses module
Message-Id: <EGw2CG.LEM@world.std.com>

Don Thomson <thomson@zinger.adp.wisc.edu> writes:
>Any hints
>on run-time inclusion of this particular module that has worked for
>anyone else?  Is there an easy namespace issue here that I'm somehow
>overlooking?

Just to check, are you calling getcap as a list operator without
parenthesis?

    $escstring = getcap $str;

If so, you may be getting hung up on the fact that when you "use" the
module, you are having perl load the subroutine definitions before it
starts compiling your script. The forward declaration allows perl to
use the subroutine as a list operator without parenens. If you say
"require" and "import" at runtime, then perl has no knowledge of the
subroutine getcap, and needs the name either followed by arguments
inside parenthesis or the name preceded by "&" or "do" to correctly
parse the word "getcap" as a subroutine invocation.
-- 
Andrew Langmead


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

Date: 21 Sep 1997 18:50:10 GMT
From: gerben@cs.vu.nl (Gerben Vos)
Subject: Re: Setting ENV vars in perl
Message-Id: <603q92$sqr$1@star.cs.vu.nl>

Michael Powe writes:

>BTW, I mentioned this possibility in another newsgroup & was told 
>that "no program can alter its own environment" -- !!  But we 
>know that you can do <anything> with perl!  ;-)

Well, a program can alter its own environment. It can't alter that
of its parent, however, and your csh is the parent of any Perl program
you run in .login .

Unfortunately, perl is subject to the laws of the operating system,
like any program. So no, it can't be done.

g e r b e n @ c s . v u . n l . . . . . . . . . . . . G e r b e n   V o s   <><
Join the Coalition Against Unsolicited Commercial Email!  http://www.cauce.org/
Phevbfvgl xvyyrq gur png.


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

Date: 21 Sep 1997 16:49:50 GMT
From: ams@ludd.luth.se (Martin Str|mberg)
Subject: Re: Setting ENV vars in perl
Message-Id: <603j7e$2fi$1@news.luth.se>

Michael Powe (looie@teleport.com) wrote:
: This is a general question -- before I set off trying to do 
: something that can't be done!  ;-)
: 
: I want to set an env var that I can't set automatically from 
: within my shell via a script or shell command.  Specifically, I 
: can't get csh to set a HOST var via the 'hostname' command.  So, 
: my question is, can I use perl to get the value of 'hostname' and 
: create/setenv HOST with that value (by using %ENV, e.g.).

Sure you can, try "$ENV{HOST} = 'yabba-yabba';".


Right,

							MartinS


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

Date: 22 Sep 1997 02:02:40 GMT
From: mgjv@mali.comdyn.com.au (Martien Verbruggen)
Subject: Re: Setting ENV vars in perl
Message-Id: <604jk0$sc1$1@comdyn.comdyn.com.au>

In article <MPG.e8edf675e6fd2ce98968f@news.teleport.com>,
	looie@teleport.com (Michael Powe) writes:
> 
> I want to set an env var that I can't set automatically from 
> within my shell via a script or shell command.  Specifically, I 
> can't get csh to set a HOST var via the 'hostname' command.  So, 

<OFF TOPIC>

that's odd..

setenv HOST `hostname`

or

setenv HOST `/bin/hostname`

don't work? Isn't HOST already set if you do nothing? You might want
to do this at the end of your .login, because other parts of your
login might be trying to set HOST as well. Try something like:

setenv TEMP_HOST `hostname`

to see if that's set after login.

</OFF TOPIC>

> my question is, can I use perl to get the value of 'hostname' and 
> create/setenv HOST with that value (by using %ENV, e.g.).

short answer: perlfaq8

longer:

I {changed directory, modified my environment} in a perl script.
How come the change disappeared when I exited the script? How
do I get my changes to be visible? 

Unix 
	  In the strictest sense, it can't be done -- the script executes
	  as a different process from the shell it was started from.
	  Changes to a process are not reflected in its parent, only in
	  its own children created after the change. There is shell magic
	  that may allow you to fake it by evaling the script's output in
	  your shell; check out the comp.unix.questions FAQ for details. 

VMS 
      Change to %ENV persist after Perl exits, but directory changes do not. 


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


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

Date: Mon, 22 Sep 1997 00:08:34 GMT
From: mlinvle@inlink.com
Subject: Using perl under NT 3.51
Message-Id: <3425b696.9932637@news.inlink.com>

I'd like to experiment with Perl.  I'm now using NT 3.51 (build 1057).
My question is, which perl should I be using?  Win-32 of the perl from
the MS site?  Also, should I try rebuilding perl myself?  I've got
Watcom' 10.6 compiler.

Thanks in advance.


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

Date: Mon, 22 Sep 1997 11:54:59 +1000
From: Daniel Wu <Daniel.Wu@alcatel.com.au>
Subject: Using the stat function
Message-Id: <3425CFF3.41C67EA6@alcatel.com.au>

Hi,

I have the following piece of code which doesn't quite work and I am
hoping that
someone can help me:

Basically I a trying to get the file size using the file handle, but
passing the file variable "FILE" into the function doesn't seem to work.

	sub func {
  	   local($fd) = @_;

		# print "Handle=", $fd, "\n";
 	
	   @fileInfo = stat($fd);
   	   print "Size = ", $fileInfo[7], "\n";

   	   # code continues ...

	}
 
	open(FILE, "tmp");
	&func(FILE);

the print line gives Handle=FILE, so I think it is passed into the
function
correctly. Seems a little strange ...

Thanks for your comments.

Daniel


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

Date: Mon, 22 Sep 1997 02:35:27 GMT
From: zsh@cs.rochester.edu (Shenghuo Zhu)
Subject: WANT:fast word search in big sorted text file
Message-Id: <1997Sep22.023527.15547@cs.rochester.edu>


Once I read a script of perl which is used to 
search word in a big sorted text file.
Anyone knows this script?

please mail me.
Thank you in advance

-- 
:----------------------------------------------------------------------:
CPU Box 272914            | Office: (716)275-5377, (716)275-9499
University of Rochester   | Home  : (716)785-2759  
Rochester, NY 14627-2914  | http://www.cs.rochester.edu/u/zsh


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

Date: 22 Sep 1997 04:17:57 GMT
From: dmacks@sas.upenn.edu (Daniel E. Macks)
Subject: Re: WANT:fast word search in big sorted text file
Message-Id: <604rhl$b61$1@netnews.upenn.edu>

Shenghuo Zhu (zsh@cs.rochester.edu) said:
: 
: Once I read a script of perl which is used to 
: search word in a big sorted text file.
: Anyone knows this script?

You mean something like the Search::Dict module?

[posted and mailed]

dan
-- 
Daniel Macks
dmacks@a.chem.upenn.edu
dmacks@netspace.org
http://www.netspace.org/~dmacks



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

Date: Mon, 22 Sep 1997 11:15:07 +1100
From: Ron Savage <rpsavage@ozemail.com.au>
Subject: Re: Week of the Year [Was: Re: Calculating the week number]
Message-Id: <3425B88B.5D4@ozemail.com.au>

Dan Kogai wrote:
[snip]
>   Remember a week starts on Sunday, not an arbitrary day
> of the week like Wednesdey?   Here is a correct and inproved[snip]

Weeks start on Monday, thank you comrade 8-), for common-or-garden usage.

And Gerben Vos's reply tells you how to define things mathematically if you should wish to be so fussy.


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

Date: Mon, 22 Sep 1997 03:07:50 GMT
From: a00lcj00@mail.dt.nchc.gov.tw (CherngJyh Lin)
Subject: Windows GUI program with perl?
Message-Id: <3425dd9f.175978411@netnews.nchc.gov.tw>

Hello, everybody:
   I like perl language because it's so powerful!
But I seldom saw this language with any GUI interface.
Is it possible to embed or be embedded with other 
windows languages? Does there exist any solution to
do this? Please inform me if you ever do this kind
of job. Thanks in advance.



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

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

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