[9251] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2846 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 11 18:07:18 1998

Date: Thu, 11 Jun 98 15:00:30 -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           Thu, 11 Jun 1998     Volume: 8 Number: 2846

Today's topics:
    Re: [META] hypersensitivity (was: Re: Command line subs (Greg Bacon)
    Re: [META] hypersensitivity (Brand and Karina Hilton)
    Re: access to a hash of lists (Mike Stok)
    Re: accessing a:\ <gnat@frii.com>
    Re: Adding ~/directory to lib path <gabriele@kollwitz.doit.wisc.edu>
    Re: ascii to hex <aqumsieh@matrox.com>
        chopping leading spaces (Phil Taylor)
        Code Generator using Perl <lancew@globalnet.uk.co>
    Re: Command line substitution thru subdirectories (Jonathan Stowe)
    Re: Complete newbie question:  Please help if possible! <angst@scrye.com>
        filehandles <allen@retina.net>
    Re: flock on Win32 (Phil Taylor)
        Forcing a literal " (quote) into a form value field rpearce@my-dejanews.com
    Re: http protocol <barmar@bbnplanet.com>
    Re: I want threads, threads and more threads! (Greg Bacon)
        Newbie Net-DNS problems DerRunt@my-dejanews.com
        Newbie question - password redirection script (Harley Jacoubsen)
    Re: Opening Files <gabriele@kollwitz.doit.wisc.edu>
        Output to file from Web page <aweeksNOSPAM@ilinkusa.net>
    Re: pass the gravy and the hashref, please -- solved (Tye McQueen)
    Re: Perl and Netware and Linux. . .oh my!! (Jason Earl)
        perl math accuracy <djhutchx@co.intel.com>
    Re: PERL syntax <quentin@shaddam.amd.com>
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 11 Jun 1998 20:54:07 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: [META] hypersensitivity (was: Re: Command line substitution thru subdirectories)
Message-Id: <6lpg5f$iju$3@info.uah.edu>

In article <6lp1cs$ls9@mozo.cc.purdue.edu>,
	gebis@albrecht.ecn.purdue.edu (Michael J Gebis) writes:
: By killfilling him, I'm sacrificing more than he (or
: anybody) probably will every realize.

>From Hell's Heart, I strike at thee, Face!!! :-)

What is with the ritualistic announcement that you've killfiled someone
anyway?  It kind of reminds me of the way people strip naked, paint
their faces, dance around, and kill ticks or other parasites they've
removed from their bodies.

Man.  Judge.  Boots.  Mile.

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Thu, 11 Jun 1998 21:42:38 GMT
From: bkhilton@netcom.com (Brand and Karina Hilton)
Subject: Re: [META] hypersensitivity
Message-Id: <bkhiltonEuEpn2.MDB@netcom.com>

In article <35802C15.3D11@min.net>, John Porter  <jdporter@min.net> wrote:
>jimbo@soundimages.co.uk wrote:
>> 
>> For the record, I believe Perl and its documentation ranks as high as
>> it is possible for software and documentation to rank, if there is
>> such a ranking. 
>
>There is a man, whose initials are rms -- a brilliant, pioneering, and
>widely respected computer scientist; he would disagree with you on this
>point.  He attempted to learn Perl from the provided documentation, and 
>gave up in utter frustration.  So how good can the be really?
>
>John Porter
>
>P.s. My experience was not like rms's.

Nor was mine.

I made my debut as a Perl programmer less than two years ago, and 
jumped in with both feet.  My first real program employed a hash of 
arrays of hashes with some heavy-duty regular expression stuff.  I
typically had up to three windows open simultaneously with various 
Perl man pages in them.  Zero complaints.  Well-written and well-
organized.

With all due respect, my guess is that RMS's lack of success with 
the Perl docs was directly related to the fact that Perl is not an
FSF product.  He probably had the same allergic reaction I have to
Windoze help screens :-)

	Brand


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

Date: 11 Jun 1998 21:50:09 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: access to a hash of lists
Message-Id: <6lpjeh$7of@news-central.tiac.net>

In article <3580249C.FDE503EF@wans.net>,
John Cartwright  <jcartwright@wans.net> wrote:
>Hello All,
>
>I am trying to get a list representing the first list element in every
>hash element.  For example, if
>
>%HoL = (
>       "flintstones"        => [ "fred", "barney" ],
>       "jetsons"            => [ "george", "jane", "elroy" ],
>       "simpsons"           => [ "homer", "marge", "bart" ],
>     );
>
>what I would like is a list with ("fred","george","homer")
>
>I have been trying variations on the following statement but without
>success.
>
>@a = @{values %HoL}[0];

  @a = map {$HoL{$_}[0]} keys %HoL;

might be one way to do it.

Hope this helps,

Mike


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


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

Date: 11 Jun 1998 15:52:43 -0600
From: Nathan Torkington <gnat@frii.com>
Subject: Re: accessing a:\
Message-Id: <5qium7mwr8.fsf@prometheus.frii.com>

Jon Drukman <jsd@hudsucker.gamespot.com> writes:
> i wish perl had a way to automatically raise exceptions.  one of my
> favorite things about the DBI module is you can set RaiseError to 1
> and never have to worry about checking returns.  wrap a bunch of
> statements in a block eval and you're good to go.

In 5.005, there's rumoured to be a "use fatals" (or maybe "use Fatals",
I forget) that will do just that.

Nat


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

Date: Thu, 11 Jun 1998 16:24:03 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
To: Rich Bowen <rbowen@databeam.com>
Subject: Re: Adding ~/directory to lib path
Message-Id: <Pine.LNX.3.96.980611162138.1456A-100000@kollwitz.doit.wisc.edu>

On Thu, 11 Jun 1998, Rich Bowen wrote:

If you want all your users to be able to use perl libraries that they
install in, say, a perllib directory in their home directory, then having
the PERLLIB environment variable set to "~/perllib/" for all users should
do the trick. Let me know if it works.

-Gabriele



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

Date: Thu, 11 Jun 1998 16:16:40 -0400
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: ascii to hex
Message-Id: <35803B28.EB65F257@matrox.com>

Jason Oakley wrote:

>         How do i convert eg. "hello21" into it's hex equiv of each
> character?
> ------------
> Jason Oakley - WebMaster & System Administrator
> mailto:tech@comcen.com.au http://jump.to/ozisp
>

Here's a one-liner:

$bit = unpack("H*", pack("A*", "hello21"));

--
Ala Qumsieh             |  No .. not just another
ASIC Design Engineer    |  Perl Hacker!!!!!
Matrox Graphics Inc.    |
Montreal, Quebec        |  (Not yet!)





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

Date: Thu, 11 Jun 1998 21:42:56 GMT
From: phil@ackltd.demon.co.uk (Phil Taylor)
Subject: chopping leading spaces
Message-Id: <35804f17.8960454@news.demon.co.uk>

How do you chop off leading spaces in a string?

How do you test for a string containing spaces as opposed to being
empty?

Thanks

Phil


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

Date: Thu, 11 Jun 1998 21:11:21 -0000
From: "Lance Whittaker" <lancew@globalnet.uk.co>
Subject: Code Generator using Perl
Message-Id: <6lpha8$i4n$1@heliodor.xara.net>

I have posted this message at alt.perl but maybe this group could assist me.
I am a professional software engineer who has been given the enviable task
of writing a code generator which is designed to produce code which has a
syntax simular to C. I have been advised by a friend that using Perl with C
wrappers would be a good method of quickly getting the job done, I am new to
the world of Perl I am not sure whether this rather sweeping statement is
valid. I believe that Perl's string handling capability is superior to C but
have yet to be convinced. Does anyone have any comments, suggestions or
links to www pages where someone has written a C (or basic) code generator
in Perl????

Lance




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

Date: Thu, 11 Jun 1998 21:48:20 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Command line substitution thru subdirectories
Message-Id: <358048a2.14857542@news.btinternet.com>

On Thu, 11 Jun 1998 19:30:49 GMT, David Corcoran wrote :

>-----------
>dir /s/b *.htm >enmase.bat
>vi enmase.bat
>1,$s!^!perl -i.old -p -e "s/foo/bar/g" !
>:wq
>enmase
>-----------

Cheater - you used vi ;-}

you could alternatively try:

dir /s /b *.htm | perl -ne "print qq%perl -i.old -p -e "s/foo/bar/g"
$_%" > enmase.bat

etc

I suppose it should work  Of course I tried it on DOS 6.22 and it
barfed on the inplace edit because of the short filenames ;-{

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 11 Jun 1998 21:18:25 GMT
From: angst <angst@scrye.com>
Subject: Re: Complete newbie question:  Please help if possible!
Message-Id: <6lphj1$f4c$1@jelerak.scrye.com>

F.Quednau <quednauf@nortel.co.uk> wrote:
:> If you don't wish to learn a programming language in order to write a
:> program in that language, you're more than welcome to hire someone to do it
:> for you.  My personal rate is $75/hour.

: That's what you get for programming? See, I am a student and haven't sniffed
: into the programming world that much. Let's see...13'800 $ ??? (8hours a day, 23
: days in a month). I am shocked. That's sort of what I will have earned at my
: placement...in the whole year...Ay, caramba...

No, that's what I get (or rather, the company gets) for consulting.  I don't
do freelance programming work, or at least I don't advertise it normally
(if someone asks, I'll do for money, but it's not really my job).  I have
no idea what the going rate for freelance custom programming is.  If the
original poster is interested, he's more than welcome to haggle.

And if you're doing programming for $13.8K a year, you should seriously
consider looking for a job that pays at least somewhere in the general
neighborhood of the going rate.
Of course, if you're speaking in pounds rather than american dollars (I just
noticed your return address), this may not apply to you...I don't know the
exchange rate either.

-- 
Erik Nielsen <eln@rmci.net>
mail to above (rather than header address) is answered significantly faster.
this post != views of anyone at all, really
"You are like...unix GOD" -- local tech support


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

Date: Thu, 11 Jun 1998 14:02:41 -0700
From: Wirehead <allen@retina.net>
Subject: filehandles
Message-Id: <358045F1.FCCAD5B2@retina.net>

I don't have much experience in perl. Is there an easier way to do this?

#!/usr/local/bin/perl5

print "Please enter the subnet in which you would like to scan:\n";
chomp($_=<STDIN>);
open(FINDIT, "grep $_ /etc/hosts |");
open(FINDOUT, ">temp1");
while (<FINDIT>){
        print FINDOUT "$_";
}
close FINDIT;
close FINDOUT;
exit;

--

thanks.
-J





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

Date: Thu, 11 Jun 1998 21:35:16 GMT
From: phil@ackltd.demon.co.uk (Phil Taylor)
Subject: Re: flock on Win32
Message-Id: <35804bf2.8155816@news.demon.co.uk>

On 11 Jun 1998 18:21:58 GMT, Jouke Visser <jouke@com-bat.nl> wrote:

>Hi,
>
>I noticed that the Win32 port of Perl does NOT support flock(). Does anyone know:
>1. *Why* it is not supported ................
>
I asked this very question last week, in the end I put an OS test
around the flock command (code for checking which OS you are on exists
at the start of CGI.pm. It would have been nice if the OS processing
was available as a method call to make things easier.

Anyway, I got a response from Tom Christiansen on the subject, here is
my question and his response (Although I said NT I'm actually on
WIN95)



****************************************************************************
[courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    phil@ackltd.demon.co.uk (Phil Taylor) writes:
:Is lockf a platform independant perl function? I don't want to use
:flock because although the application will run on a unix server I'm
:developing on NT where flock doesn't work.

*flock* is the platform independent function.

>From /usr/src/perl/pod/perlfunc.c pod:

    =item flock FILEHANDLE,OPERATION

    Calls flock(2), or an emulation of it, on FILEHANDLE.  Returns
TRUE
    for success, FALSE on failure.  Produces a fatal error if used
    on a machine that doesn't implement flock(2), fcntl(2) locking,
    or lockf(3).  flock() is Perl's portable file locking interface,
    although it locks only entire files, not records.

    On many platforms (including most versions or clones of Unix),
locks
    established by flock() are B<merely advisory>.  This means that
files
    locked with flock() may be modified by programs which do not also
use
    flock().  Windows NT and OS/2, however, are among the platforms
which
    supply mandatory locking.  See your local documentation for
details.

>From /usr/src/perl/win32/win32.c:

    /* simulate flock by locking a range on the file */

    #define LK_ERR(f,i)	((f) ? (i = 0) : (errno = GetLastError()))
    #define LK_LEN		0xffff0000

    DllExport int
    win32_flock(int fd, int oper)
    {
	OVERLAPPED o;
	int i = -1;
	HANDLE fh;

	if (!IsWinNT()) {
	    croak("flock() unimplemented on this platform");
	    return -1;
	}
	fh = (HANDLE)_get_osfhandle(fd);
	memset(&o, 0, sizeof(o));

	switch(oper) {
	case LOCK_SH:		/* shared lock */
	    LK_ERR(LockFileEx(fh, 0, 0, LK_LEN, 0, &o),i);
	    break;
	case LOCK_EX:		/* exclusive lock */
	    LK_ERR(LockFileEx(fh, LOCKFILE_EXCLUSIVE_LOCK, 0, LK_LEN,
0, &o),i);
	    break;
	case LOCK_SH|LOCK_NB:	/* non-blocking shared lock */
	    LK_ERR(LockFileEx(fh, LOCKFILE_FAIL_IMMEDIATELY, 0,
LK_LEN, 0, &o),i);
	    break;
	case LOCK_EX|LOCK_NB:	/* non-blocking exclusive lock */
	    LK_ERR(LockFileEx(fh,

LOCKFILE_EXCLUSIVE_LOCK|LOCKFILE_FAIL_IMMEDIATELY,
			   0, LK_LEN, 0, &o),i);
	    break;
	case LOCK_UN:		/* unlock lock */
	    LK_ERR(UnlockFileEx(fh, 0, LK_LEN, 0, &o),i);
	    break;
	default:			/* unknown */
	    errno = EINVAL;
	    break;
	}
	return i;
    }

Now, if what you really want is something that isn't particularly
portable, here you go.  Of course, it won't work on systems with weak
multitasking like Windows, but that's just the testing part.  The
locking
is still relevant.

--tom

    #!/usr/bin/perl -w
    # lktest -- test region locking
    use strict;

    my $FORKS = shift || 1;
    my $SLEEP = shift || 1;

    use Fcntl;
    use POSIX qw(:unistd_h :errno_h);

    my $COLS = 80;
    my $ROWS = 23;

    open(FH, "+> /tmp/lkscreen")            or  die $!;

    select(FH);
    $| = 1;
    select STDOUT;

    for (1..$ROWS) {
	print FH " " x $COLS, "\n";
    } 

    my $progenitor = $$;
    fork while --$FORKS > 0;

    print "hello from $$\n";

    if ($progenitor == $$) {
	$SIG{INT} = \&genocide;
    } else {
	$SIG{INT} = sub { die "goodbye from $$" };
    } 

    while (1) {
	my $line_num = int rand($ROWS);
	my $line;
	my $n;
	seek(FH, $n = $line_num * ($COLS+1), SEEK_SET)              or
next;
	my $place = tell(FH);
	my $him;
	next unless defined($him = lock(*FH, $place, $COLS));
	read(FH, $line, $COLS) == $COLS                             or
next;
	my $count = ($line =~ /(\d+)/) ? $1 : 0;
	$count++;
	seek(FH, $place, 0)                                         or
die $!;
	my $update = sprintf($him 
			    ? "%6d: %d ZAPPED %d" 
			    : "%6d: %d was just here", 
			$count, $$, $him);
	my $start = int(rand($COLS - length($update)));
	die "XXX" if $start + length($update) > $COLS;
	printf FH "%*.*s\n", -$COLS, $COLS, " " x $start . $update; 
	unlock(*FH, $place, $COLS);
	sleep $SLEEP if $SLEEP;
    } 
    die "NOT REACHED";

    sub lock {
	my ($fh, $start, $till) = @_;
	##print "$$: Locking $start, $till\n";
	my $lock = struct_flock(F_WRLCK, SEEK_SET, $start, $till, 0);
	my $blocker = 0;
	unless (fcntl($fh, F_SETLK, $lock)) {
	    die "F_SETLK $$ @_: $!" unless $! == EAGAIN || $! ==
EDEADLK;
	    fcntl($fh, F_GETLK, $lock)          or die "F_GETLK $$ @_:
$!";
	    $blocker = (struct_flock($lock))[-1];
	    ##print "lock $$ @_: waiting for $blocker\n";
	    $lock = struct_flock(F_WRLCK, SEEK_SET, $start, $till, 0);
	    unless (fcntl($fh, F_SETLKW, $lock)) {
		warn "F_SETLKW $$ @_: $!\n";
		return;  # undef
	    }
	} 
	return $blocker;
    } 

    sub unlock {
	my ($fh, $start, $till) = @_;
	##print "$$: Unlocking $start, $till\n";
	my $lock = struct_flock(F_UNLCK, SEEK_SET, $start, $till, 0);
	fcntl($fh, F_SETLK, $lock) or die "F_UNLCK $$ @_: $!";
    }

    BEGIN {
	my $FLOCK_STRUCT = 'S s L L I';
	sub linux_flock {
	    if (wantarray) {
		my ($type, $whence, $start, $len, $pid) =
		    unpack($FLOCK_STRUCT, $_[0]);
		return ($type, $whence, $start, $len, $pid);
	    } else {
		my ($type, $whence, $start, $len, $pid) = @_;
		return pack($FLOCK_STRUCT, 
			$type, $whence, $start, $len, $pid);
	    } 
	} 
    } 

    BEGIN {
	# XXX: should be Q not LL
	my $FLOCK_STRUCT = 'LL LL L l s';

	sub bsd_flock {
	    if (wantarray) {
		my ($xxstart, $start, $xxlen, $len, $pid, $type,
$whence) =
		    unpack($FLOCK_STRUCT, $_[0]);
		return ($type, $whence, $start, $len, $pid);
	    } else {
		my ($type, $whence, $start, $len, $pid) = @_;
		my ($xxstart, $xxlen) = (0,0);
		return pack($FLOCK_STRUCT, 
		    $xxstart, $start, $xxlen, $len, $pid, $type,
$whence);
	    } 
	} 
    } 

    BEGIN { 
	for ($^O) {
	    if    (/bsd/)   { *struct_flock = \&bsd_flock       } 
	    elsif (/linux/) { *struct_flock = \&linux_flock    } 
	    else {
		die "unknown operating system: $!";
	    } 
	} 
    }

    BEGIN { 
	my $called = 0;

	sub genocide {
	    exit if $called++;
	    print "$$: Time to die, kiddies.\n" if $$ == $progenitor;
	    my $job = getpgrp();
	    $SIG{INT} = 'IGNORE';
	    kill -2, $job if $job;  # killpg(SIGINT, job)
	    1 while wait > 0;
	    print "$$: My turn\n" if $$ == $progenitor;
	    exit;
	} 

    }

    END { &genocide } 



I'm getting the flock out of here


Phil


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

Date: Thu, 11 Jun 1998 21:25:29 GMT
From: rpearce@my-dejanews.com
Subject: Forcing a literal " (quote) into a form value field
Message-Id: <6lpi09$klo$1@nnrp1.dejanews.com>

I have a perl script that allows people to update their entry in a directory.
It works fine, but I can't seem to get any quoted text to appear in the entry
form.

If they entered any double-quoted text in a field, the form data stops a the
first quote.  Example:

The perl script creates a form to edit the data.  One line would contain the
following:

<INPUT TYPE=TEXT NAME=whatever VALUE="$array[6]" SIZE=30>

The @array is created from a split() line from a text file database.

If the value of $array[6] is something like:  Just wanted to say "hello" then
the form would just have:  Just wanted to say

I've guessed that's because the " infront of $array sees the next " (infront
of hello) as the end.  But if I don't use a quote in the form line, then I
get only the first word.  Seems to stop at a space.

I've tried converting each " into \" (s/"/\"/), even \\".  Tried using qw() in
the form.  Nothing seems to work.

I ended up just converting the " to a ' (tr/"/'/).  It seems to like that.
Fine, but I'd still like to know how to do that.

Searched the news groups for similar problems and checked the faqs and
perldocs, but it doesn't really address this as it's probably more of an html
problem.  I know this may not be the most appropriate group for this
question, but it is still a perl question.  How do I literalize the " so it
show's up in the field.

Thanks,

Rick...

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 11 Jun 1998 21:39:29 GMT
From: Barry Margolin <barmar@bbnplanet.com>
Subject: Re: http protocol
Message-Id: <l8Yf1.86$Fr5.917505@cam-news-reader1.bbnplanet.com>

In article <6lp68q$j4r$1@news.fsu.edu>,
Breeze Pecorino <bpecorin@mailer.fsu.edu> wrote:
>$proto = getprotobyname('tcp');
>socket(S, AF_INET, SOCK_STREAM, $proto) || die "socket: $!";
>
>($name, $aliases, $port, $proto ) = getservbyname( "www-http", 'tcp' ); 
>($name, $aliases, $type, $len, $thisaddr) = gethostbyname( $hostname );
>($name, $aliases, $type, $len, $thataddr) = gethostbyname( $them ); 
>
>$this = pack($sockaddr, AF_INET, 0, $thisaddr );
>$that = pack($sockaddr, AF_INET, "http", $thataddr );

"http" in there should be $port.

-- 
Barry Margolin, barmar@bbnplanet.com
GTE Internetworking, Powered by BBN, Cambridge, MA
*** DON'T SEND TECHNICAL QUESTIONS DIRECTLY TO ME, post them to newsgroups.


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

Date: 11 Jun 1998 21:02:40 GMT
From: gbacon@cs.uah.edu (Greg Bacon)
Subject: Re: I want threads, threads and more threads!
Message-Id: <6lpglg$iju$4@info.uah.edu>

In article <Pine.LNX.3.96.980611133721.1263A-100000@kollwitz.doit.wisc.edu>,
	"Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu> writes:
: I would like to have treads in a script, but perl does not have any
: built-in support for them,

False.  Dennis and Ken could have added light weight contenders if they
had needed to.  Instead, they did it the right way.  perldoc -f fork

: so child processes are the closest thing,
: right?

fork is superior to threads.  Let the OS do the work.

: (someone stop me if I'm whong).

This is Baba Wawa winging Mistah Whong. :-)

: Alas, child processes cannot modify
: variables in the parent script and well, communication between processes
: is very limited so I would like some suggestions before I scrap the whole
: 15,000 line project and re-do it in in another lang  or some ugly thing
: like that.

I see you haven't seen IPC::Shareable.  Get thee to the CPAN!

    <URL:http://www.perl.com/CPAN/modules/by-module/IPC/>

Greg
-- 
open(G,"|gzip -dc");$_=<<EOF;s/[0-9a-f]+/print G pack("h*",$&)/eg
f1b88000b620f22320303fa2d2e21584ccbcf29c84d2258084
d2ac158c84c4ece4d22d1000118a8d5491000000
EOF


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

Date: Thu, 11 Jun 1998 21:37:56 GMT
From: DerRunt@my-dejanews.com
Subject: Newbie Net-DNS problems
Message-Id: <6lpink$lu1$1@nnrp1.dejanews.com>

I am trying to run the Net-DNS module on a Windows NT 5.00_04 perl
installation.  In the installation notes it tells me to change Config.pm in
the /site/Net sub directory.  I did this and then made the Net-DNS module
with dmake.  I ran all the Net-DNS tests and they worked.  I then try the
demos in Net-DNS sub directory and I receive

query failed: no nameservers

I have been looking all over for where to specify my name server to perl.  My
normal DNS resolution for the web works fine, so I think it is a perl config
issue.  Any help would be appreciated.  Thanks.

Darrin Miller

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Thu, 11 Jun 1998 17:02:44 -0400
From: harley@dreamribbon.com (Harley Jacoubsen)
Subject: Newbie question - password redirection script
Message-Id: <harley-1106981702450001@ppp-5200-0138.tor.total.net>

Hi!

I have a simple password script which redirects users to a specified URL
upon the entry of the correct password.  It works great - except that it
only allows one password, and I would like to have it work with several
passwords.

Here is the first part of the script:
-----------------------------------------------------------
# Change these variables with your own values
  $correctpass = "test";
  $correcturl = "http://www.foo.net/file.html";
  $scriptlocation = "http://www.foo.net/cgi-bin/pwdscript.cgi";

# Read in form data
  &parse_form;

  $password =  $input{'password'};
  $function = $input{'function'};


  if ($function eq "post") {
       if ($password eq $correctpass) {
           &goto_url;
       }
       &badpassword;
   }
-----------------------------------------------------------
Is it possible to just change the first line of the script 
  $correctpass = "test";
to something like
  $correctpass = "test","testing","tested";
or
  $correctpass = "test";
  $correctpass2 = "testing";
  $correctpass3 = "tested";
and the line
       if ($password eq $correctpass) {
to something like
       if ($password eq $correctpass) || ($password eq
$correctpass2)||($password eq $correctpass3){

or a similar "quick fix"?

Regards!

Harley
harley@dreamribbon.com
http://www.dreamribbon.com


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

Date: Thu, 11 Jun 1998 16:27:52 -0500
From: "Gabriele R. Fariello" <gabriele@kollwitz.doit.wisc.edu>
To: tph@rmi.net
Subject: Re: Opening Files
Message-Id: <Pine.LNX.3.96.980611162601.1456B-100000@kollwitz.doit.wisc.edu>

On 11 Jun 1998, Tom Harrington wrote:

> As it happens, Ted doesn't even need the conditional, as long as
> he confines the script to MacPerl.  Macs don't have the Unix "."
> and ".." (though I believe that Perl functions like chdir have been
> hacked to interpret them properly).  It won't hurt to leave them 
> in, though, since I don't think you can legally use either of those 
> as filenames on a Mac.

Actually, it is possible to create a file OR directory named either "." or
".." on a Mac, but this is ill advised and frowned upon. I believe that
MacPerl would have many problems with wich a file.


-Gabriele



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

Date: Thu, 11 Jun 1998 15:30:10 -0500
From: "Alex Weeks" <aweeksNOSPAM@ilinkusa.net>
Subject: Output to file from Web page
Message-Id: <6lpeq0$5it@enews2.newsguy.com>

I have a Perl cgi that is supposed to open an output file, write some stuff
to the file, then send the user off to a web page.

Looks like this:
Some other stuff then .....
----------------
open(OUT0, ">>entry.db") || die "Could not open file >>entry.db";

        print OUT0 time();
        print OUT0 "$name, $street_address, $street2, $city, $state, $zip,
$phone, $fax\n";

print "Location: ", $direct, "\n\n";
-------------

If I execute this from the command prompt everything works great, the info
is printed to entry.db file and the redirect takes place.

If I execute this from a browser the print "Location: $direct\n\n"; works,
but the "print OUT0" stuff does not.

I don't think permissions are the issue.  I set entry.db at 777 and it
didn't make a difference.  Not to mention it would give an error when it
couldn't open the file.

Am I missing something obvious here?  Any ideas.

TIA,
Alex Weeks






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

Date: 11 Jun 1998 16:50:17 -0500
From: tye@fohnix.metronet.com (Tye McQueen)
Subject: Re: pass the gravy and the hashref, please -- solved
Message-Id: <6lpjep$iid@fohnix.metronet.com>

Chris Winters <cwinters@intes.net> writes:
) Okay, I figured this out. I'm breaking the original reference in the
) parent by doing a straight assignment:
) 
) $self->{values} = $href;
) 
) rather than (inefficiently) stepping through the hash and doing the
) assignment
) 
) while ( my ($key, $val) = each %$href ) {
) 	$self->{values}->{$key} = $val;
) }
) 
) which keeps the reference, to which all the children are referring,
) intact.
) 
) Apologies for a big duh on my part

You might want to consider:

    %{$self->{values}}= %$href;

it does the same thing as your while() would do if you preceeded it by:

    %{$self->{values}}= ();
-- 
Tye McQueen    Nothing is obvious unless you are overlooking something
         http://www.metronet.com/~tye/ (scripts, links, nothing fancy)


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

Date: Thu, 11 Jun 1998 14:34:48 -0600
From: jearl@freelance.baf.com (Jason Earl)
Subject: Re: Perl and Netware and Linux. . .oh my!!
Message-Id: <slrn6o0fl5.cot.jearl@freelance.baf.com>

<pearse@mail.shebang.net> wrote:
: Hey all,
: 
: I've got what I "think" is a unique problem. . .

You've got a heterogenous computer environment, and a bit of a sticky
problem getting it all to work together.  Linux excells at this sort of
thing.

: Problem: There is constant stream of doc's piling up on a Netware
: networked drive. I need to put them on a colocated Linux web server.
: Also, there is an Access 2.0 database sitting on the same drive that
: contains data about the docs. (I know, I know. . .but the office is
: still using Win3.X. . .my hands are tied!)

Well you can use the ncpmount (and its friends) to mount the netware drive
under Linux, and you can use perl to dump the info in the Access database
to something else (I like PostgreSql myself).

: Here's what I need done:
:     1) Move the docs to the web server.

Ncpmount will mount those Netware drives without a problem, making them
easy to move.  Depending on what sort of documents they are perhaps this
would be a good time to re-format them to html.

:     2) Grab the data in the Access database and shoot it over to a new
: database on the Linux box

I would probably dump the tables from Access to flat text files, and then
use perl to dump them back into some sort of database.  That's probably
because I don't have any experience with ODBC drivers (and not a whole lot
of desire to learn something like that for a one time program).

Do you plan on using the existing Access Database, or do you just need the
information stored in it?

:     3) Fix existing code to access the database for the docs and data
: instead of hunting in an ASCII file and some directories

Now's the perfect time to use Perl (or PHP) to put a web front end on the
whole smear.

: Yes, a job for Perl. No problem. Using Win32::ODBC to access the data.
: And 'readdir'ing my way all around that drive. (just getting silly with
: it. . .it is fun language).

And very useful.  

: Here comes the Netware stuff (we're using it for printing and file
: sharing.) My Wintel box is acting as a "go between" between the network
: drive and the database. It just seems easier to format my hd and install
: Linux. (I'm prone to rash decisions. . .) But, how do I access the LAN.
: There must be someway to tie a Linux box into a Netware LAN to access
: printers, files, and that Access database.

There is, check out the Mars-Nwe netware server, ncpmount, etc.

: So, I think it breaks down to two problems:
: 
:     1) How do I get access to printers and files on a Netware LAN from a
: Linux box?

Heck, just take a look at the IPX-Howto.  It says it a lot better than I
could.

http://www.linuxresources.com/LDP/HOWTO/IPX-HOWTO.html

:     2) How do access the Access database from Linux using Perl?
: 
: From what little I know about ODBC, I gather that I need a DSN to Access
: the data. Can I put one on the Linux box? Also, I looked at a HOWTO on
: setting up an Intranet for Netware, etc. clients but I'm the client. It
: didn't help much.

I don't know much about ODBC drivers.

: Cheers,
: 
: Robert

Good Luck,
Jason Earl


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

Date: Thu, 11 Jun 1998 13:49:53 -0700
From: Dave Hutchins <djhutchx@co.intel.com>
Subject: perl math accuracy
Message-Id: <358042F1.3E45@co.intel.com>

I can not find any reason why simple operations in perl return
inaccurate results,
such as (12 - 11.96) != 0.04

bc and awk return the correct results:

toybox% bc
scale=20
(12 - 11.96)
 .04
qu
toybox% awk 'BEGIN{ print (12 - 11.96);exit}'
0.04
toybox:

but perl does not
toybox% perl -e 'print (12 - 11.96); print "\n"; exit'
0.0399999999999991
toybox% 

does anyone have a simple answer?

TIA
-- 
David J Hutchins djhutchx@co.intel.com
location:CO5-I3  MS:CO5-114 dept:5946-6
desk: 503.677.6622 fax:  503.677.7648/6943


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

Date: 11 Jun 1998 16:01:15 -0500
From: Quentin  Fennessy <quentin@shaddam.amd.com>
Subject: Re: PERL syntax
Message-Id: <ximn2bjbqlg.fsf@shaddam.amd.com>

>>>>> "reno" == rduyme  <rduyme@ireste.fr> writes:

    reno> hello I just start coding in PERL. I got a script with
    reno> thoses lines that I don't understand.

    ($fname) = $cd =~ /\bfilename="([^"]*)"/i; #"; # filename can be null-str
    ($fname) = $cd =~ /\bfilename=([^\s:;]+)/i unless defined $fname;

    reno> Can someone explain me ?

I'll try.  And I bet I'll learn as much as you will in the process.

First line:

    ($fname) = $cd =~ /\bfilename="([^"]*)"/i; 

Starting from the right, /\bfilename="([^"]*)"/i is a matching
operation with regex, perhaps described in English as matching a line
case-insensitively, including the word `filename=' and then a double-
quoted string.  The double-quoted string (<something>) is remembered.

	<word-separator>filename="<something>"

The =~ operator binds the match to apply to the contents of $cd.
The results of this match are evaluated in list context and then
assigned to  $fname.  This list context means the remembered string
(<something>) is the value assigned to $fname.  

So if $cd is a line like 

     This is a filename="/var/boot/plan9/usparc.img"

then $fname is assigned /var/boot/plan9/usparc.img

Second line:

    ($fname) = $cd =~ /\bfilename=([^\s:;]+)/i unless defined $fname;

This does something very similar, except that the line match and
assignment do not occur if $fname is already defined.  That is, if the
previous line of Perl succeeded in assigning to $fname.

You know, I learn a lot by doing this!

-- 
Quentin Fennessy			AMD, Austin Texas
Secret hacker rule #11 - hackers read manuals


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

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

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