[7716] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1342 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Nov 19 15:27:26 1997

Date: Wed, 19 Nov 97 12:01:29 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 19 Nov 1997     Volume: 8 Number: 1342

Today's topics:
     Re: 2 quicks questions, really (Tom Harrington)
     Re: An elegant solution wanted for removing .. in path <rjc@liddell.cstr.ed.ac.uk>
     Re: An elegant solution wanted for removing .. in path (Terry Michael Fletcher - PCD ~)
     Re: An elegant solution wanted for removing .. in path <sr@pc-plus.de>
     Bug in perl on Solaris? <dot@dotat.at>
     Re: exclusive file rights (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
     Help needed: Calling another program <mlinde@atpco.com>
     Re: how do i append todays date to the end of a filenam <zenin@best.com>
     Re: How to determine absolute file path on UNIX <usenet-tag@qz.little-neck.ny.us>
     Howto debug an extension module <gmarzot@baynetworks.com>
     Is there a nice way to make MSWord print? (Luke Diamand)
     Re: Keeping command line window open in Win95 <he_is@home.chillin.so.no.spam.please>
     Re: Last element of an anonymous array (Terry Michael Fletcher - PCD ~)
     Re: Last element of an anonymous array <markm@nortel.ca>
     Re: Last element of an anonymous array <markm@nortel.ca>
     Re: Looking for flat database modules... (robert)
     Re: mkdir not mking my dir (Honza Pazdziora)
     Re: mkdir not mking my dir (Scott DiNitto)
     Need advise on XS (Tom Grydeland)
     perl 5.4.4 install trub on io_sock.t <zephyr@wesell.com>
     Perl5.004_04 install problems nstewart@dy4.com
     Re: PerlScript under WinNT (Brian Jepson)
     Regexp that's bugging me <rjk@fprsdev3.fmr.com>
     SHARE UUNET T1-SETUP ALREADY PAID <dvigil@ccweb.net>
     Re: Solaris & Irix Satan (Arthur Hagen)
     Re: Sorting datas in hash of arrays <markm@nortel.ca>
     Theory behind perl <sampav@cc.gatech.edu>
     type glob error in FileHandle.pm (Joseph Scott Stuart)
     Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: 19 Nov 1997 17:36:39 GMT
From: tph@longhorn.uucp (Tom Harrington)
Subject: Re: 2 quicks questions, really
Message-Id: <64v837$bgc1@eccws1.dearborn.ford.com>

Alan (ahecker@interport.net) wrote:

: 1st question revolves around a sample config file, which contains the
: following lines:

: 1:\BThis is a test
: 2:\BThe time is:\T

<snip>
: Now, I've been having a hell of a time trying to get this to work out.
: First, I tried:

: ($loop, $b, $text, $t) = (\d)\:\\(\w)(.*)\\(*);

: and variations thereof. Most of the time, I get many "undefined
: variable" messages. But, as many of you already know, I should just hire
: out someone to do regexes for me at this point.

The backslashes in the text make this one kinda challenging.
Keep in mind that "\B" will be seen as an escaped "B", but an
escaped "B" has no special meaning, it's just a "B".  The following 
seems to work for the two lines above:

($loop, $b, $text, $t) = /^(\d)\:(\w)(.*)(T?)$/;

 ...although this assumes that "\T" is the only escaped character you'll
ever get at the end of the line.  Anything else after the "\" will
break it.  It's hard to generalize this because if you do something
like this:

($loop, $b, $text, $t) = /^(\d)\:(\w)(.*)(\w?)$/;

you'll _always_ get the last letter in $t, whether or not it's a "\T".

If it's _always_ going to be a "\B", you could go one step simpler
and use:

($loop, $b, $text, $t) = /^(\d)\:(B)(.*)(T?)$/;


--
Tom Harrington --------- tph@rmii.com -------- http://rainbow.rmii.com/~tph
     "Freedom of choice is what you got!  Freedom from choice is what
                             you want!" -Devo
Cookie's Revenge: ftp://ftp.rmi.net/pub2/tph/cookie/cookies-revenge.sit.hqx


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

Date: 19 Nov 1997 12:14:21 +0000
From: Richard Caley <rjc@liddell.cstr.ed.ac.uk>
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <eyhu3d9t71e.fsf@liddell.cstr.ed.ac.uk>

In article <j46s46.lo.ln@localhost>, Tad McClellan (tm) writes:

Richard Caley (rjc@liddell.cstr.ed.ac.uk) wrote:

rjc> Er, am I missing something? ...

tm> I think so.

tm> It won't work if the 'blah/..' does not happen to fall between
tm> 'usr' and 'local' (ie. It works for only the one case given, not
tm> for the general case)

Indeed, but I have no way of knowing how general a case was to be
coverred and was trying to find out.

-- 
rjc@cstr.ed.ac.uk			_O_
					 |<



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

Date: 19 Nov 1997 18:01:27 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <64v9ho$cm4$1@news.fm.intel.com>

Eli the Bearded (usenet-tag@qz.little-neck.ny.us) so eloquently and verbosely pontificated:
> 
> To normalize a path -- ignoring quirks such as symbolic links -- requires
> a bit more thought.

excellent point.

>         tr:/:/:s;	# remove /// patterns
> 	s: /\./ :/:xg;	# remove /./ patterns
> 	1 while ( s: / (?!\.\.) [^/]+ / \.\. / :/:x ); # remove /foo/../
> 	s, \A / (?: (?: \. | \.\. ) / )+ ,/,x;	# remove leading junk
> 
> But -- I stress -- this Does the Wrong Thing(tm) when the path contains
> a symbolic link, or in a number of more obscure cases.

well, to be sure it doesn't mislead by screwing up symbolic links,
maybe add this to the beginning?

$testsym = "";
for ( m#(/[^/]*)#g ) {
        $testsym .= $_;
        die "$testsym is a symlink\n" if -l $testsym;
}

-- 
#!/usr/local/bin/perl -w- tfletche@pcocd2.intel.com
sleep 1;$"=(time-$^T)<<1;$SIG{ALRM}=sub{print};${q$_$}=join"",
map{chr(hex)}split/(..)/,"4a75737420";alarm$";<>;s y(\0\w){4}.
?yreverse q brehtonabyex;alarm$";<>;for(;length>4;chop){}tr&to
an&empti&;alarm$";<>;s@$_@reverse',ret'.q csaw c@e;alarm$";<>;



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

Date: Wed, 19 Nov 1997 19:50:20 +0100
From: Stephen Riehm <sr@pc-plus.de>
Subject: Re: An elegant solution wanted for removing .. in path
Message-Id: <347334EC.2781@pc-plus.de>

I've been watching this thread with interest, and have come to the
conclusion that the sollution has more or less been provided.

BUT....

there's a difference between visually cleaning up a path (stripping . ..
and //'s) and "manipulating" a path.

Once a path has been visually cleaned up, I find it very usefull to
split the path into a list, and you can then do neat things on
the components of the path.

An implementation of mkdir -p could look something like this:

$path =~ s,/\./,/,g; # remove /./'s, leaving a leading ./ in tact
# note that splitting an absolute path sets the first element in the
# list to null, so joining it again, provides a / at the front of the
# path - no information is lost!
@path = split( /\/+/, $path );
foreach( $i = 0; $i <= $#path; $i++ )
{
    $test = join( "/", @path[0..$i] );
    mkdir $test		unless -d $test;
}

you can also do other neat things like searching multiple paths for
common parts, or checking I-node numbers to ensure that two directories
really are related, or you can look directly in ../include by applying
a simple pop and push (or splice).

I'll leave it to the readers to sort out the "../ over a symbolic link"
problem though :-)

Maybe someone can make use of this stuff (I know I have :-)

Steve
//   __________________________ ._ o  ________________________________
\\\\ Stephen Riehm             /  //\.        Stephen.Riehm@pc-plus.de
//// pc-plus                  '  \>> |         Phone: +49 89 45566 148
  \\ 81675 Munich, Germany        \\ `           Fax: +49 89 45566 113


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

Date: 19 Nov 1997 11:25:00 GMT
From: Tony Finch <dot@dotat.at>
Subject: Bug in perl on Solaris?
Message-Id: <64uiac$ebe@info.noc.demon.net>

I stumbled over a rather unpleasant problem when developing a program
that splits a mailbox into messages and forks a process for each one.
The code below works as expected on perl 5.004_04 compiled with gcc
2.7.2.1 on FreeBSD 2.2.2 (i.e. it prints each message surrounded by
the -start- and -end- lines once), but on sparc Solaris 2.5.1 with
perl 5.004_04 compiled with gcc 2.5.6, it appears to read the input
multiple times. It has been suggested that because the children close
their file handles when they exit, the file pointer gets reset to the
point when the fork occurred, but I would have expected that something
like this shouldn't affect the parent.

This code demonstrates the bug.

$line = <>;
for (;;) {
    exit unless (defined $line);
    undef @lines;
    do {
	push @lines, $line;
	$line = <>;
    } while (defined $line and $line !~ /^From /);
    print "---start---\n", @lines, "----end----\n";
    sleep 1;
    $pid = fork;
    defined $pid or die "ERROR: couldn't fork: $!\n";
    exit if $pid == 0; # child
}

When the program is passed this input on the Sun it loops
indefinitely.

----8<----
>From dot@dotat.at Tue Nov 18 14:41:23 1997
From: Tony Finch <dot@dotat.at>
To: Tony Finch <dot@dotat.at>
Subject: test

test

>From dot@dotat.at Tue Nov 18 14:42:45 1997
From: Tony Finch <dot@dotat.at>
To: Tony Finch <dot@dotat.at>
Subject: test

test

>From dot@dotat.at Tue Nov 18 14:44:14 1997
From: Tony Finch <dot@dotat.at>
To: Tony Finch <dot@dotat.at>
Subject: test

test

----8<----

Tony.


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

Date: Wed, 19 Nov 97 14:26:07 -0500
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: exclusive file rights
Message-Id: <34733ee0$8$ofn$mr2ice@speaker>

In <8c7ma44xz7.fsf@gadget.cscaper.com>, on 11/19/97 at 10:03 AM,
   Randal Schwartz <merlyn@stonehenge.com> said:
+-----
> (re: removing text about advisory file locking from perlfunc.pod/flock)
| The statement is CORRECT as it stands.
| What would make you think otherwise?
+--->8

You did miss the beginning of the thread.  flock() is advisory on Unix, but
is(?) mandatory on Win32. (Which I would chalk up as "another reason to prefer
Unix for such work", but that's another story.  Besides, who am I to throw
stones?  ---EMX's flock() is a stub, so Perl currently does no file locking at
all on OS/2.  Sigh.)

-- 
brandon s. allbery           [Team OS/2][Linux][JAPH]        bsa@void.apk.net
cleveland, ohio              mr/2 ice's "rfc guru" :-)                  KF8NH
"Never piss off a bard, for they are not at all subtle and your name scans to
 `Greensleeves'."  ---unknown, quoted by Janet D. Miles in alt.callahans



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

Date: Wed, 19 Nov 1997 14:00:34 -0500
From: Marcos Lindekugel <mlinde@atpco.com>
Subject: Help needed: Calling another program
Message-Id: <34733752.81E0B961@atpco.com>

Hi, I'm new to Perl (and programming in general) and am trying to write
a program that will take input from a form, analyze it and, depending on

the results, call one of several cgi programs (it also must forward the
information entered in the form to the next cgi program, as if the
second program were called directly from the form). It seems to work
when I run it from the command line, but when I run it from the form I
get an "Internal Error" message. I think the problem is in the way I'm
using the exec command:

    $programName = "/app/apache/cgi-bin/".$databaseName;
    exec $programName;

But I guess it might be in the form itself (in which case I apologize
because I guess this is the wrong place to ask), but I can't figure out
why it works when I run it on the machine but not from the web page. The

reason I don't think the problem is in the form is because if I take the

exec command out of the program, it does execute from the form.
Unfortunately I don't know much about Unix, Perl, forms or programming
in general ... the problem probably is obvious to everyone but me, but
I'd appreciate any help.
Thanks.
Marcos Lindekugel
mlinde@atpco.com





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

Date: 19 Nov 1997 11:14:51 GMT
From: Zenin <zenin@best.com>
Subject: Re: how do i append todays date to the end of a filename?
Message-Id: <879938245.271355@thrush.omix.com>

Andrew Ellerton <andrewe@technologyXchange.com> wrote:
	>snip<
: Portable Shmortable. The man just wanted to get the date and append it
: to a string for goodness sake.  Who said anything about making sure it
: works on every damn UNIX system or non-UNIX system...

	Hehe, you haven't been programming long, have you?

	Keep that mind-set and you probably won't be either. :-)

-- 
-Zenin
 zenin@best.com


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

Date: 19 Nov 1997 18:39:36 GMT
From: Eli the Bearded <usenet-tag@qz.little-neck.ny.us>
Subject: Re: How to determine absolute file path on UNIX
Message-Id: <eli$9711191422@qz.little-neck.ny.us>

Alfred von Campe <alfred@hw.stratus.com> wrote:
> Eli the Bearded (usenet-tag@qz.little-neck.ny.us) wrote:
> |>Consider cwd is "/" and $srcipt is "..////bin/qux". You end up with
> |>"/..//bin/qux". Change those two lines to:
> |>      $script =~ s|/[.][.]?/|/|g;
> |>      $script =~ tr|/|/|s;
> I don't quite see how this works.  The first line replaces any
> "/./" or "/../" patterns with just "/".  But that's not the
> right thing to do, is it?  In the case of "/../", you need to
> also remove the directory just before the "/../", don't you?

Order is important. With the now-edited out while loop, I had
already removed any directory-dotdot pairs, the only remaining
ones are at the begining of the path.

> And I didn't understand what the second line did at all, until
> I looked up tr in my Camel book to figure out what the "s" does.

"s"queezes duplicates of the named characters. Should be marginally
faster than the equivilent s/// command. (And less prone to the
error you had in your substitute that replaced pairs of slashes
with single slashes.)

> Wait, I think I just figured it out.  The "/../" is being
> replaced with "/" only after all other "[^/]+/../" patterns
> have been eliminated, right?  I see...

Yes, exactly. It might be nice to put an anchor in there to
make it easier for a reader to understand, but it should not be
needed.

Elijah
------
hey! you quoted with "|>" -- that will skew your OCR!


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

Date: 19 Nov 1997 10:10:27 -0500
From: Joe Marzot <gmarzot@baynetworks.com>
Subject: Howto debug an extension module
Message-Id: <pdg1osgbrw.fsf@baynetworks.com>


Does anyone have any cool ideas on how to debug a dynamically loaded
extension module? Is it enought to have symbols compiled into the
extension module or must perl have them as well. I hope I don't have to
compile statically to debug.

What I really want to do is say 'make debug' and have 'make test' run in
the debugger.

write now I am resorted to good (and tedious) old fprintf. please help.

Thanks for any ideas. -GSM

-- 
 G. S. Marzot <gmarzot@baynetworks.com>   Network Management Development
 Bay Networks Inc.                        (508)670-8888 x63990
--


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

Date: 19 Nov 1997 19:35:16 GMT
From: Diamand@btinternet.com (Luke Diamand)
Subject: Is there a nice way to make MSWord print?
Message-Id: <64vf1k$j4k@argon.btinternet.com>

I'd like to persuade Microsoft Word to print out a 
document for me (from a perl script, of course) - and
make it print to a specific file.

I've got as far as using OLE to fire up word, open 
the document and print to the default printer, but
the last part defeats me.

Any ideas?

Luke Diamand




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

Date: Wed, 19 Nov 1997 13:01:40 -0500
From: "Mark" <he_is@home.chillin.so.no.spam.please>
Subject: Re: Keeping command line window open in Win95
Message-Id: <64v9i6$hs5$1@news.rdu.bellsouth.net>

Why not run your script from the dos prompt??

1) Run DOS
2) Run script

Simple enough?

Harry Rowe wrote in message <64uu90$s04@nntp1.erinet.com>...
>Sorry if this is a FAQ. Brand new to Perl. Just installed
>win32 build 313.
>
>How the heck do you keep the window open after a Perl script
>runs? I know enough to put a loop in to hold it for a working
>program. I'm talking about my script not running at all due to
>syntax errors.  I can't see what they are because the window
>stays open for "half-a-heart-beat".
>
>I'm a racing director for a Nascar 2 series and don't relish
>having to cut-n-paste up to 100 ASCII results files together
>when Perl will do it in one step.
>
>Regards,
>
>Harry
>
>




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

Date: 18 Nov 1997 17:47:34 GMT
From: tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~)
Subject: Re: Last element of an anonymous array
Message-Id: <64skbm$38o$1@news.fm.intel.com>

Norman Gaywood (norm@turing.une.edu.au) so eloquently and verbosely pontificated:
> 
> How do I find the last element of an anonymous array in the following
> context. At least, I think I'm asking that question!

[code with typo-syntax errors deleted]

> That seems to work OK.  But, suppose I don't want the first element of
> each line. I want to do an array slice and write the map part as:
> 
>            map { TR( $_ ) } (map { td( $_ ) } @data)[1..$#??]
> 
> But what goes where the ?? is? 

you've got some syntax errors in there (that i dont want to pick on), but
the dereferencing you're looking for is:

@{ $data[$i] }[ 1 .. $#{ $data[$i] } ]   # or, working backwards
@{ $data[$i] }[ -$#{ $data[$i] } .. -1 ]

where $i is the index into your list of lists.

then your statement would look like this:

map { TR($_) } map { td($_) } @{ $data[$i] }[ 1 .. $#{ $data[$i] } ];

but be aware that your lists need more than two elements.
  (the range produces 1,0 for a 1 element list, and 1,1 for a 2 elem.)

hope that helps.

-- 
#!/usr/local/bin/perl -w- tfletche@pcocd2.intel.com
sleep 1;$"=(time-$^T)<<1;$SIG{ALRM}=sub{print};${q$_$}=join"",
map{chr(hex)}split/(..)/,"4a75737420";alarm$";<>;s y(\0\w){4}.
?yreverse q brehtonabyex;alarm$";<>;for(;length>4;chop){}tr&to
an&empti&;alarm$";<>;s@$_@reverse',ret'.q csaw c@e;alarm$";<>;


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

Date: 19 Nov 1997 14:14:26 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Last element of an anonymous array
Message-Id: <lq1hg98ofvx.fsf@bmers2e5.nortel.ca>

tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~) writes:
> Norman Gaywood (norm@turing.une.edu.au) so eloquently and verbosely pontificated:
> > How do I find the last element of an anonymous array in the following
> > context. At least, I think I'm asking that question!
> > That seems to work OK.  But, suppose I don't want the first element of
> > each line. I want to do an array slice and write the map part as:
> > 
> >            map { TR( $_ ) } (map { td( $_ ) } @data)[1..$#??]
> > 
> > But what goes where the ?? is? 
> you've got some syntax errors in there (that i dont want to pick on), but
> the dereferencing you're looking for is:
>    map { TR($_) } map { td($_) } @{ $data[$i] }[ 1 .. $#{ $data[$i] } ];
> but be aware that your lists need more than two elements.
>   (the range produces 1,0 for a 1 element list, and 1,1 for a 2 elem.)

Hmmm... i don't think that's what he wanted to do :-)

In perl you can do things like:

   $hour = (localtime)[2];

The question as to whether you can say:

   @all_but_first = (localtime)[1..];

I can only say... i wish :-) In fact i tried it before in hope or something...
but it seems the ".." operator is simply that. It's not special when "in array
element number context" :-) The only way i know of how to do it now is:

   @all = localtime();
   @all_but_first = @all[1..$#all];

Sorry... :-) But you can apply that to to your map { TR } etc...

mark

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


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

Date: 19 Nov 1997 14:13:22 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Last element of an anonymous array
Message-Id: <lq1iutoofxp.fsf@bmers2e5.nortel.ca>

tfletche@pcocd2.intel.com (Terry Michael Fletcher - PCD ~) writes:
> Norman Gaywood (norm@turing.une.edu.au) so eloquently and verbosely pontificated:
> > How do I find the last element of an anonymous array in the following
> > context. At least, I think I'm asking that question!
> > That seems to work OK.  But, suppose I don't want the first element of
> > each line. I want to do an array slice and write the map part as:
> > 
> >            map { TR( $_ ) } (map { td( $_ ) } @data)[1..$#??]
> > 
> > But what goes where the ?? is? 
> you've got some syntax errors in there (that i dont want to pick on), but
> the dereferencing you're looking for is:
>    map { TR($_) } map { td($_) } @{ $data[$i] }[ 1 .. $#{ $data[$i] } ];
> but be aware that your lists need more than two elements.
>   (the range produces 1,0 for a 1 element list, and 1,1 for a 2 elem.)

Hmmm... i don't think that's what he wanted to do :-)

In perl you can do things like:

   $hour = (localtime)[2];

The question as to whether you can say:

   @all_but_first = (localtime)[1..];

I can only say... i wish :-) In fact i tried it before in hope or something...
but it seems the ".." operator is simply that. It's not special when "in array
element number context" :-) The only way i know of how to do it now is:

   @all = localtime();
   @all_but_first = @all[1..$#all];

Sorry... :-) But you can apply that to to your map { TR } etc...

mark

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


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

Date: 19 Nov 1997 12:28:52 +0100
From: robert@il.fontys.nl (robert)
Subject: Re: Looking for flat database modules...
Message-Id: <64uihk$ivo@bsd1.hqehv-internal.ilse.net>

as646@FreeNet.Carleton.CA (John Robson):
 >I'm looking for a FLAT database module that would hopefully do at least the
 >following :
 >- Open, close a flat file.
 >- Query the database with SQL-like commands.
 >- Add, modify, delete records with file-locking.
 >And it should be simple to use!
 >Any suggestions, pointers, leads, info?  Thanks!

You might want to take a look at Sprite (CPAN/modules/by-module/Sprite/),
which can perform SQL-queries (though just a subset of SQL commands) on
text-delimited databases.

                                                                   robert


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

Date: Wed, 19 Nov 1997 18:27:06 GMT
From: adelton@fi.muni.cz (Honza Pazdziora)
Subject: Re: mkdir not mking my dir
Message-Id: <adelton.879964026@aisa.fi.muni.cz>

Leon Andrews <leon@staff.netchannel.co.uk> writes:

> if I do
> 
> $thedir = "/export/home/nc/NC/html/talk/boards/$directory";
> mkdir $thedir, oct("775");
			    or die $!;
			       ???
might help.

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


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

Date: Wed, 19 Nov 1997 18:51:48 GMT
From: sdinitto@kronos.com (Scott DiNitto)
Subject: Re: mkdir not mking my dir
Message-Id: <347334fc.79976660@news>

On Wed, 19 Nov 1997 18:32:39 +0000, Leon Andrews
<leon@staff.netchannel.co.uk> wrote:

>
>--------------59518EA66CA2AD140A784934
>Content-Type: text/plain; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
>If I do...
>
>$thedir = "/export/home/nc/NC/html/talk/boards/dir_name";
>mkdir $thedir, oct("775");
>
>then the dir is successfully created.
>
>if I do
>
>$thedir = "/export/home/nc/NC/html/talk/boards/$directory";
>mkdir $thedir, oct("775");

I am no expert. But until one comes along, try 

$thedir = "/export/home/nc/NC/html/talk/boards/".$directory;

or

$thedir = "/export/home/nc/NC/html/talk/boards/${directory}";

SD

>
>where $directory is exactly "dir_name", nothing happens.
>
>we're all stumped here - any ideas?
>
>--
>..................
>Leon Andrews
>NetChannel UK Ltd.
>
>
>
>--------------59518EA66CA2AD140A784934
>Content-Type: text/html; charset=us-ascii
>Content-Transfer-Encoding: 7bit
>
><HTML>
>If I do...
>
><P>$thedir = "/export/home/nc/NC/html/talk/boards/dir_name";
><BR>mkdir $thedir, oct("775");
>
><P>then the dir is successfully created.
>
><P>if I do
>
><P>$thedir = "/export/home/nc/NC/html/talk/boards/$directory";
><BR>mkdir $thedir, oct("775");
>
><P>where $directory is exactly "dir_name", nothing happens.
>
><P>we're all stumped here - any ideas?
><PRE>--&nbsp;
>..................
>Leon Andrews
>NetChannel UK Ltd.</PRE>
>&nbsp;</HTML>
>
>--------------59518EA66CA2AD140A784934--
>



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

Date: 19 Nov 1997 18:57:25 GMT
From: Tom.Grydeland@phys.uit.no (Tom Grydeland)
Subject: Need advise on XS
Message-Id: <slrn676dkk.s4e.Tom.Grydeland@mitra.phys.uit.no>


I am trying to write a Perl interface to PGPlib, a C library for
performing PGP-compatible encryption/decryption without actually using
pgp the program.

I am underway, armed with the xs and guts manpages, and I've got some of
the stuff to work, but I'm troubled with massive memory leaks, and I'd
like some advise from the experts.

The library is well structured;  each function has input arguments and
output arguments, allocates the memory it needs and returns a code
saying all went well (0).

In my first attempt, I ended up writing XSs like

SV *
armor(arg)
        SV *      arg

        PREINIT:
        u_char *  inbuf;
        char *    outbuf;
        u_long    len;
        int       res, used, outbuflen;

        CODE:
        inbuf = (u_char *)SvPV(arg, len);
        res   = armor_buffer(inbuf, len, &used, &outbuf, &outbuflen);
        ST(0) = sv_newmortal();

        if (res == 0) {
                sv_setpvn(ST(0), outbuf, outbuflen);
                free(outbuf);
        }

and this worked.  However, a little bird whispered in my ear:
"You really want to write that glue in Perl instead", and so I scrapped
that, and tried something more comfortable, like

int
armor_buffer(buf, buf_len, used, a_buf, a_len)
        u_char *        buf
        int             buf_len
        int             &used  = NO_INIT
        char *          &a_buf = NO_INIT
        int             &a_len = NO_INIT
        OUTPUT:
        used
        a_buf
        a_len

with a matching Perl subroutine

sub armor {
    my $buf = shift;

    my($u,$r,$l);

    if (armor_buffer($b, length($b), $u, $r, $l) == 0) {
        return $r;
    } else {
        return;
    }
}

And this also worked, except now I have a memory leak from a_buf which
isn't freed.  I've tried using a CLEANUP: section with free(a_buf);
this fails, since Perl (or xsubpp) has its own ideas about what a_buf
is and how to use it.  Hints, anyone?

On a different (but related) string;  I have another function which I
have to wrap in some more glue, since I need some scratch variables
between different calls made in preparation of the wanted call.  These
preparatory calls is "housekeeping" I want to hide from the Perl
interface.  In this case, I have more control over the different
pointers, and I imagine I manage to free all the memory allocated by the
library.  Still it leaks!

The XS looks like this:

SV *
conventional_key_encrypt(filename, pwd, compress)
        char *          filename
        u_char *        pwd
        int             compress
        PREINIT:
        int             res;
        u_char          digest[16];
        u_char *        tmp;
        int             outbuflen;
        u_char *        outbuf;
        PGPliteral_t    literal;

        CODE:
        res = create_literal(filename, &literal);
        if (res != 0)
            croak("create_literal returned %d", res);

        res = literal2buf(&literal, &tmp);
        if (res != 0)
            croak("literal2buf returned %d", res);

        MD5(pwd, strlen(pwd), digest);

        res = conventional_key_encrypt(tmp,
                packet_length(tmp),
                digest,
                compress,
                &outbuflen,
                &outbuf);

        if (res != 0)
            croak("conventional_key_encrypt returned %d", res);

        ST(0) = sv_newmortal();
        sv_setpvn(ST(0), outbuf, outbuflen);

        CLEANUP:
        free_literal(&literal);
        free(tmp);
        free(outbuf);



If anyone spots the error, I'd be grateful.


A more general question/comment:  It appears a bit wasteful to have the
library allocate the memory, just to see Perl copying it the next
moment.  Is there a better way to create Perl scalars from allocated
buffers (which I know the length of)?

-- 
//Tom Grydeland <Tom.Grydeland@phys.uit.no>


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

Date: 19 Nov 97 16:16:14 GMT
From: <zephyr@wesell.com>
Subject: perl 5.4.4 install trub on io_sock.t
Message-Id: <01bcf491$feb45e40$0200a8c0@xperts>

trying to install on linux. bumped into 'localhost' undefined in io_sock.t
during make test.

how do i get around it. its not an option for me to bring in local host (i
dont own the box). its cute the way io_sock.t says you can hang here but
gives no hints on what to do next.

is the test crucial? how to bypass and get on with life.

tks.
john z.
zephyr@wesell.com.NoJunkPad



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

Date: 19 Nov 1997 18:54:12 GMT
From: nstewart@dy4.com
Subject: Perl5.004_04 install problems
Message-Id: <64vckk$ijb@newshost.dy4.com>

I get the following error when installing Perl 5.004_04 on a HPUX 9.05 machine, any suggestions??


	`sh  cflags libperl.a miniperlmain.o`  miniperlmain.c
*** Error code 1



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

Date: 19 Nov 1997 18:39:09 GMT
From: bjepson@ids.net (Brian Jepson)
Subject: Re: PerlScript under WinNT
Message-Id: <slrn676ch2.6e7.bjepson@gelvis.ids.net>

In article <347e48aa.81540679@woody.wcnet.org>, Jeremy D. Zawodny wrote:
>[original author automagically cc'd via e-mail]
>
>On Tue, 18 Nov 1997 11:11:49 -0700, Neil McKellar
><mckellar@cs.ualberta.ca> wrote:
>
[...]
>
>>I have installed Perl for Win32 on a Pentium WinNT 4.0 box (no problems
>>there).  I have *tried* to install PerlScript (PerlSE) from ActiveState
>>on the same box with significantly less success.
>
>You're not alone. Many folks have had trouble getting PerlScript to
>work properly. Recent builds (>309) appear to be a bit more stable in
>this respect.
>
>>Currently, the box in question has the appropriate OSRs, running IIS3.0,
>>and FrontPage97.  I had IE3.0 but it kept displaying the PerlScript
>>*code* rather than running it.  I thought it was kludged and so I
>>installed IE4.0 (just the browser).  It doesn't display the code
>>anymore, but it still doesn't execute it.
>
>Woah!
>
>If you believe that the *browser* is supposed to run your code, you
>have a fundamental misunderstanding of how CGI scripts work!
>
[...]

Actually, PerlScript *can* run in the browser. It's an ActiveX Scripting
component, and as such, can run in any ActiveX scripting container, such
as an Active Server Page or Internet Explorer. 

Since client-side PerlScript needs all of Perl installed, it's not
safe to assume you can deploy web pages on the Internet that require 
client-side PerlScript. OTOH, client-side PerlScript is a nice option
for GUI development with Perl on Win32. It's okay to use if you know 
that every desktop will support it, but every desktop needs Perl and
PerlScript installed.

>
>>I'm assuming (based on past experience) that I need to tweak something
>>in the Registry to get PerlScript to be recognized by the system. 
>
>The installation routines to most of that for you.
>

It might be possible to get PerlScript going under IE 4.0 with:

  regsrv32 perlse.dll
  
It may be that some things changed the way components are registered under
IE 4.0 versus IE 3.0. I downgraded to 3.02 to try out client-side Perl, since
I could not get PerlScript to work with 4.0. I'll be looking into this
further shortly.
 
[...] 

>
>
>>The general lack of docs is getting me down.  If you know of a helpful
>>website for trouble shooting, or if you can offer assistance, please
>>e-mail or post here. I'll be watching this subject heading.
>
[...]

I'm going to be doing a lot myself with PerlScript in the coming months.
I'll be sure to keep an eye on this thread or similar ones, as well.

Cheers,

-- 
Brian Jepson * (bjepson@ids.net) * http://users.ids.net/~bjepson


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

Date: Wed, 19 Nov 1997 13:04:05 -0500
From: Rick Meldrum <rjk@fprsdev3.fmr.com>
Subject: Regexp that's bugging me
Message-Id: <34732A15.DE6@fprsdev3.fmr.com>

Hi;

I am attempting to change one of the parameters in a command string:

$command = 'myprog -a arga -b bbb -c argc'

I need to change the string after -b to "argb", I don't know how
many args are there - or if the -b is even there - and I don't
know the current value of the -b parameter. This works great...

$command =~ s:(^.*-b)\s*\S+\s+(.+$):$1 $new_argb $2:;

 ...until the  -b bbb  is the last arg...   Any suggestions?

Rick

  \   O(\          _____________________________________________
   \ __\\\        ( Rick Meldrum          Unix guy, Hiker,     ()
    \   \\\       ( rjk@fprsdev3.fmr.com  Brewer, Photographer.()
     \  _\()      (____________________________________________()
      \_\|  /\     
       \_| /  \   
        \ /    \


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

Date: Wed, 19 Nov 1997 04:31:30 -0800
From: Dan Vigil <dvigil@ccweb.net>
Subject: SHARE UUNET T1-SETUP ALREADY PAID
Message-Id: <3472DC22.C9E28D16@ccweb.net>

We are a new company located in Beverly Hills, CA and are looking for
someone to
share some of the cost of  a T1 we're using from UUNET--we would allow
you to co-locate servers in our facility and allow you access to the
facility for a negotiable monthly fee--we are just trying to reduce our
monthly fees.

Please reply via email or telephone:

Dan Vigil
CCWeb Networks
310-550-0802



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

Date: 19 Nov 1997 12:03:05 GMT
From: art@kether.broomstick.com (Arthur Hagen)
Subject: Re: Solaris & Irix Satan
Message-Id: <64ukhp$a7q$1@bone.globalone.no>


In article <879934503.1593@dejanews.com>, surabaia@hotmail.com writes:
> In article <64hg91$4os$1@bone.globalone.no> art@kether.broomstick.com
> 
> >You must have a very old version of S.A.T.A.N.  Get a newer one from
> >wietse's site ftp.win.tue.nl  The error is because the script expects
> >perl 4, and you have perl 5 on the systems.
> 
> Just downloaded Satan 1.1.1 from Wietse's site. Running against
> Perl 5.004_02 and Netscape 3.0 the problem IS still there.
> I even tried to remove all "mailto:" from the source, to no avail:
> the problem just shows up in another place. Is there any hope that
> downgrading to Perl 5.003 could fix the problem?
> 

Just add a \ before the @'s in the email addresses in the scripts, and
you should be fine.  S.A.T.A.N. runs fine with 5.004_04 here.
And I can't understand why you get this problem at all, because there's
NO "satan@fish.com" in the latest version - it's "satan\@fish.com"
all the places I can see.
No, downgrading to 5.003 won't help.

Or you could try something like this (untested):

find . -name "*.pl" -print | sed 's/\.pl//' | awk '\
{print "cp "$1".pl "$1".pl.O"} \
{print "sed <"$1".pl.O >"$1".pl s/satan@fish/satan\\\@fish/g"} \
' | sh

Regards,
--
*Art


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

Date: 19 Nov 1997 13:50:45 -0500
From: Mark Mielke <markm@nortel.ca>
Subject: Re: Sorting datas in hash of arrays
Message-Id: <lq1lnykogze.fsf@bmers2e5.nortel.ca>

"J.-F. Pelletier" <gigabyte@generation.net> writes:
> I have a hash of arrays. The keys are terms (strings) I'm looking for in
> other strings with REs (in a different file) and the values are arrays
> containing datas I'm looking for in an other file. I want to sort the
> hash of arrays so the longuest strings (keys) will be match first before
> the shortest ones. For example, if I have the expressions "long
> expression" and "this is a very long expression" as keys in my hash, I
> want to  look for the longuest key ("this is a very long expression")
> before I test for the short one ("long expression"). I know that hashes
> sort datas in a random order; is there any way to sort them in a
> decreasing length order?

Assuming i understand the question:

--- CUT HERE ---
%cool = ("a"    => "fifth",
         "b"    => "sixth",
         "ab"   => "third",
         "ba"   => "fourth",
         "abc"  => "first",
         "cba"  => "second");

my $key;
foreach $key (sort { length($b) <=> length($a) || $a cmp $b } keys %cool) {
    printf "%5s = %s\n", $key, $cool{$key};
}
--- CUT HERE ---

And i guess... just stick something else in the loop... the relevant code
is the "sort { length($b) <=> length($a) || $a cmp $b } keys %cool".

hope this helps,
mark

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


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

Date: Wed, 19 Nov 1997 13:19:23 -0500
From: Sameer Kamruddin Merchant <sampav@cc.gatech.edu>
Subject: Theory behind perl
Message-Id: <34732DAB.34C9@cc.gatech.edu>

Hi,
I'm looking for some information about perl as a programming languages -
things like what were the design goals, what features and policies (like
binding and typing policies etc.) were added to the language to support
these design goals, what are the drawbacks of perl as a programming
language etc. I understand perl has had a long history over which it has
evolved to what it is now. If there is some documentation about how perl
has evolved and what influenced various modifications/ additions in perl
as it evolved, that would be great. Pointers on white papers/technical
reports about the language would help a lot.
I'd highly appreciate any help in this regard.
thanx.
Sam.


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

Date: 19 Nov 1997 18:07:54 GMT
From: nospam@ll.mit.edu (Joseph Scott Stuart)
Subject: type glob error in FileHandle.pm
Message-Id: <NOSPAM.97Nov19130754@pickering.ll.mit.edu>


Please help me understand why the following program produces the
output it does.  Is this a bug that would be fixed if I upgraded to a
newer perl or am I doing something wrong?

rock(16)% uname -a
IRIX64 rock 6.4 02121744 IP27
rock(17)% perl -v
This is perl, version 5.003 with EMBED
        built under irix at Jan 23 1997 16:55:47
        + suidperl security patch
rock(18)% memtest.pl
fh is a reference to FileHandle at memtest.pl line 12.
end of program at memtest.pl line 19.
Not a GLOB reference at /usr/freeware/lib/perl5/FileHandle.pm line 256 (#1)

    (F) Perl was trying to evaluate a reference to a "type glob" (that is,
    a symbol table entry that looks like *foo), but found a reference to
    something else instead.  You can use the ref() function to find out
    what kind of ref it really was.  See perlref.
    

Here is the code:

#!/usr/local/bin/perl

use diagnostics;
use FileHandle;
use strict;

my $fh;

$fh = new FileHandle(">t");

if (ref($fh)){
    warn "fh is a reference to ", ref($fh);
} else {
    warn "fh is not a reference";
}

$fh->close();

warn "end of program";

Line 256 of the FileHandle.pm is the destructor method for FileHandle:

sub DESTROY {
    my ($fh) = @_;
    close($fh);                       # line 256
}


-- 
Scott Stuart
stuart at ll mit edu



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

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

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