[11278] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4878 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 12 05:07:37 1999

Date: Fri, 12 Feb 99 02:00:20 -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           Fri, 12 Feb 1999     Volume: 8 Number: 4878

Today's topics:
    Re: Announce: Perl Function Repository (was Re: Calcula (Larry Rosler)
    Re: change column of nmbers to 2 dim array (Bart Lateur)
    Re: Comments in Perl code (Ronald J Kimball)
    Re: Content-type: application/pdf breaks in MS IE3.02 (Ronald J Kimball)
    Re: creating lock file (Ronald J Kimball)
    Re: Date problem <bmb@ginger.libs.uga.edu>
        Disregard previous message. (John G)
    Re: Easy Q for a Perl Pro (Ronald J Kimball)
    Re: Easy Q for a Perl Pro (Larry Rosler)
    Re: Fast Text Search <ebohlman@netcom.com>
    Re: fun with strings... (Ronald J Kimball)
    Re: fun with strings... (Ronald J Kimball)
    Re: fun with strings... <uri@home.sysarch.com>
    Re: fun with strings... (Bart Lateur)
    Re: Help editing script chall5@hotmail.com
    Re: How do I delete a hash element ?? (Ronald J Kimball)
    Re: How do I delete a hash element ?? (Larry Rosler)
    Re: How do I delete a hash element ?? <uri@home.sysarch.com>
        How do you get SSI to work? <seongbae@students.uiuc.edu>
        How to create a directory using perl on linux? perl_beginner@my-dejanews.com
    Re: How to create a directory using perl on linux? (Sam Holden)
        ldap & web500.pl pkey@sghms.ac.uk
        Negative lookahead problem <antti.boman***NOSP@M***helsinki.fi>
    Re: PFR: UTC_to_Epoch <rra@stanford.edu>
    Re: PFR: UTC_to_Epoch <PROCURA_BV@CompuServe.com>
    Re: Problem with file creation (Ronald J Kimball)
        syntax error I can't find? (John G)
    Re: syntax error I can't find? (Larry Rosler)
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Thu, 11 Feb 1999 22:33:58 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Announce: Perl Function Repository (was Re: Calculate yesterdays           date)
Message-Id: <MPG.112d6b24da32e057989a27@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <yl3e4c7h3l.fsf@windlord.stanford.edu> on 11 Feb 1999 
13:42:06 -0800, Russ Allbery <rra@stanford.edu> says...
 ... 
> Great with me.  Here's a new version incorporating some suggestions from
> Larry Rosler and with a clear copyright statement.
> 
> sub yesterday {
>     my $now  = defined $_[0] ? $_[0] : time;
>     my $then = time - 60 * 60 * 24;

That line should read:

      my $then = $now - 60 * 60 * 24;

>     my $ndst = (localtime $now)[8] > 0;
>     my $tdst = (localtime $then)[8] > 0;
>     $then - ($tdst - $ndst) * 60 * 60;
> }

 ...

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 12 Feb 1999 08:45:57 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: change column of nmbers to 2 dim array
Message-Id: <36c6e29a.2496890@news.skynet.be>

Abigail wrote:

>Who says map changing the elements of the list it iterates over has
>something to do with using it in void context?
>
>In fact, map is an operation heavily used in functional languages. 
>Functional languages have a tendency to be side effect free as well.

So using map in order to have side effects is bad form? Changing the
elements of a list is a side effect too.

"map in a void context" is virtually synonymous to map with side
effects. Tell me, what use would the next code be, except to waste
cycles?

	map { $_.$_ } LIST;


"map" is a looping construct. But to stay absolutely clean, you may not
depend on it being executed in sequence. So the next is bad form too:

	my $i = 0;
	%map = map { $_ => $i++ } @ary;

because the phrase "$i++" has a side effect, and you may not depend on
map applying the block to each array element *in turn*. That may always
be the case now, but it's not part of the function specification. A
highly parallel machine might give a few array elements to several
processors to apply the BLOCK to, (in principle, map allows that), in
which case the previous code will break. 

It is bad form to depend on unspecified implementation details.


>!! Besides, what do you find so attractive in:
>!! 
>!! 	map BLOCK LIST;
>!! 
>!! over:
>!! 
>!! 	foreach (LIST) BLOCK
>

>Order in which things appear. What I do is often more important then
>on what I perform things.

How about:

	do { BLOCK } foreach (LIST);


>What's so attractive about foreach (LIST) {BLOCK} ?

Because that's an explicit loop. You *may* depend both on execution
sequence and side effects, including changing the original items.

	Bart.


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

Date: Fri, 12 Feb 1999 01:02:45 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Comments in Perl code
Message-Id: <1dn36fs.noo1jqtj9jygN@bay1-307.quincy.ziplink.net>

Abigail <abigail@fnx.com> wrote:

[wrapped due to line length limits]

> perl -wle\$_=\<\<EOT\;y/\\\\n/\ /\;print\;
>      -eJust -eanother -ePerl -eHacker -eEOT

What shell should this one be run under?

In sh and tcsh, I get:

Just
a other
Perl
Hacker


But remove two backslashes and it works:

perl -wle\$_=\<\<EOT\;y/\\n/\ /\;print\; -eJust -eanother -ePerl -eHacker -eEOT

Just another Perl Hacker

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
    perl -e'for(sort keys%main::){print if $$_ eq 1}
        ' -s  -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/  [rjk@linguist.dartmouth.edu]


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

Date: Fri, 12 Feb 1999 01:02:46 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Content-type: application/pdf breaks in MS IE3.02
Message-Id: <1dn36rx.1mn3k8gh97zysN@bay1-307.quincy.ziplink.net>

<Steve_Shriver@scp14.bcbsnc.com> wrote:

> Greetings, I wrote a program to securely provide access to PDF files on our
> intranet. Basically, the user (a manager) deposits a token into a web page
> that returns a PDF file of a resume. The cgi works wonderfully with NN4.0 but
> intermittantly or not at all in IE3.02 (the corporate standard).
> 
> Any clues as to why this code wouldn't work with IE?

Note that CGI scripts run on the server, not in the browser.  Thus, if
your script works "on" NN but not IE, it is because of what the browser
does with the script's *output*.

By the way, what the heck do you mean by "it doesn't work"??

>       print "Content-type: application/pdf\n";
>       print "Content-length: $bytes\n\n";

Perhaps the instances of IE are not properly configured to handle PDF
files?  Beats me.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Fri, 12 Feb 1999 01:02:47 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: creating lock file
Message-Id: <1dn370w.8s4no91u34ksjN@bay1-307.quincy.ziplink.net>

Stephen J. Tremblett <sjt@cs.mun.ca> wrote:

>     do {
>         sleep 1;
>         $timeout--;
>     next if (-e $lockfile);
>         sysopen LF, $lockfile, O_CREAT|O_WRONLY|O_EXCL || print "no open\n";

Precedence.

This is equivalent to:

sysopen LF, $lockfile, (O_CREAT|O_WRONLY|O_EXCL || print "no open\n");

Put parens around the function arguments, or change || to the lower
precedence or.


>     } while (!defined(LF) && $timeout);

LF is a bareword.  This is equivalent to:

defined('LF')

which is, of course, always true.


Instead of testing the filehandle, you should be testing the result of
sysopen().  Perhaps something like:

while ($timeout) {
  sleep 1;
  $timeout--;
  if (sysopen LF, $lockfile, O_CREAT|O_WRONLY|O_EXCL) {
    last;
  } else {
    print "no open\n";
  }
}
if ($timeout == 0) {
  die "lock failed\n";
}
# ...rest of program...


> Is 'defined(LF)' the correct way to test a filehandle?

Remember, examine the result of the operation on the filehandle, not the
filehandle itself.

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
    perl -e'for(sort keys%main::){print if $$_ eq 1}
        ' -s  -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/  [rjk@linguist.dartmouth.edu]


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

Date: Fri, 12 Feb 1999 01:58:55 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Date problem
Message-Id: <Pine.A41.4.02.9902120157550.13400-100000@ginger.libs.uga.edu>

On Thu, 11 Feb 1999, Larry Rosler wrote:
> So the Julian date scale used by astronomers and the Unix epoch are 
> inexorably drifting apart, and I know of no available code to correct 
> the problem.  (It would have to be table-driven, because the leap 
> seconds are added occasionally, with no algorithm other than that they 
> occur only on six-month boundaries.) 

But, hey, by the time it matters, we'll all be retired, right?

-Brad



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

Date: Thu, 11 Feb 1999 21:32:18 GMT
From: cybpunk@geocities.com (John G)
Subject: Disregard previous message.
Message-Id: <36c44c2b.15611565@news.ma.ultranet.com>

Sorry, I was being dumb.  I've been doing to much coding in other
languages.  I found out my little prob.
-John


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

Date: Fri, 12 Feb 1999 01:02:49 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Easy Q for a Perl Pro
Message-Id: <1dn37j0.1ynl10f1ii0k7wN@bay1-307.quincy.ziplink.net>

Dustin Christopher Preuitt <preuitt@ix.cs.uoregon.edu> wrote:

> I want to take a line of text and translate everything in parenthesis to
> uppercase and everything else to lower case.

I would do it in two steps:

$line = lc $line;
$line =~ s/(\([^\)]*\))/\U$1/g;


Or two steps, but on one line:

($line = lc $line) =~ s/(\([^\)]*\))/\U$1/g;


Note that this assumes parentheses will not be nested.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
          perl -le 'print "Just another \u$^X hacker"'


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

Date: Thu, 11 Feb 1999 23:01:47 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Easy Q for a Perl Pro
Message-Id: <MPG.112d71b6a6545d25989a29@nntp.hpl.hp.com>

In article <1dn37j0.1ynl10f1ii0k7wN@bay1-307.quincy.ziplink.net> on Fri, 
12 Feb 1999 01:02:49 -0500, Ronald J Kimball 
<rjk@linguist.dartmouth.edu> says...
 ...
> $line = lc $line;
> $line =~ s/(\([^\)]*\))/\U$1/g;
                  ^
Just to avoid misleading anyone, that backslash is superfluous.  
Parentheses are not special inside character classes.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Fri, 12 Feb 1999 07:28:20 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Fast Text Search
Message-Id: <ebohlmanF71638.1H5@netcom.com>

Zack <zack44@altavista.net> wrote:

: What's the fastest way to search through a delimited text database. 
:Line by line and checking the individual fields after a split is fine up
:to about 5,000 records or so, but I really need to use bigger databases
:(up to 50-100,000 records) and a DBI da tabase is not an option. 

Why isn't a DBI-compatible relational database engine an option?  It's 
almost certainly the best solution for this size database.

: Better to store the data in some sort of binary format?

Doubtful.

: What about indexing?  Is it possible? Feasable?

Depends on how constrained the searches are.  If the searches always look 
for literal matches on a particular field, it's both possible and 
feasible.  If they look for regexp matches that can occur anywhere within 
a record, you're SOL, even if you *do* use an RDB engine.


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

Date: Fri, 12 Feb 1999 01:02:51 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: fun with strings...
Message-Id: <1dn3813.trmurd11u1utgN@bay1-307.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> How about this variation?
> 
>        Bart1  => sub { $_ = $x; s/\\(.)/$replace{$1} || "\\$1"/egs },
> 
> Now each escape sequence is specified only in the hash.  One can write
> the hash automatically from a single list of escape characters, putting
> your 'eval' cleverness to work outside the main processing loop:
> 
>     my %replace = map { $_ => eval qq["\\$_"] } qw( n t );
> 
>   a) the substitution may be extended to other escape sequences
>   and
>   b) redundancy is avoided completely.

Very nicely done!  But...

What if the escape sequences need to be expanded to include \777 and
\xFF, where 777 and FF are arbitrary octal and hexadecimal numbers?
I think mine is the simplest solution in that case.

Actually, Bart1 might not be too bad, since you could use ranges in
initializing the hash.

I wouldn't recommend any of the other methods, though.  :-)

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
perl -e'$_="\012534`!./4(%2`\cp%2,`(!#+%2j";s/./"\"\\c$&\""/gees;print'


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

Date: Fri, 12 Feb 1999 01:02:50 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: fun with strings...
Message-Id: <1dn37up.9nl8ccjjm05pN@bay1-307.quincy.ziplink.net>

Uri Guttman <uri@ibnets.com> wrote:

> my point is that you solve a problem according the known data set. my
> solution did that as do the rest. if the data set can expand then you
> can expand any of the solutions, some easier than others. and some run
> faster than others. that is what makes perl and software engineering,
> choices.

But that's not an argument to make your solution useful for *only* the
known data set.

If you code from the beginning with the expectation that you will need
to extend your solution, then it will be much easier to do so later on.

-- 
chipmunk (Ronald J Kimball) <rjk@linguist.dartmouth.edu>
perl -e 'print map chop, sort split shift, reverse shift
' 'j_' 'e._jP;_jr/_je=_jk{_jn*_j &_j :_j @_jr}_ja)_js$_j
~_jh]_jt,_jo+_jJ"_jr>_ju#_jt%_jl?_ja^_jc`_jh-_je|' -rjk-


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

Date: 12 Feb 1999 02:02:08 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: fun with strings...
Message-Id: <x7vhh8nlzj.fsf@home.sysarch.com>

>>>>> "RJK" == Ronald J Kimball <rjk@linguist.dartmouth.edu> writes:

  RJK> Uri Guttman <uri@ibnets.com> wrote:
  >> my point is that you solve a problem according the known data set. my
  >> solution did that as do the rest. if the data set can expand then you
  >> can expand any of the solutions, some easier than others. and some run
  >> faster than others. that is what makes perl and software engineering,
  >> choices.

  RJK> But that's not an argument to make your solution useful for
  RJK> *only* the known data set.

sometimes the dataset is fixed and immutable at spec time. again that
seems to be the case the original poster had. he had \n and \t in text
and wanted them converted. there must have been some odd reason for
those strings to be there and it was a fixed dataset.

  RJK> If you code from the beginning with the expectation that you will
  RJK> need to extend your solution, then it will be much easier to do
  RJK> so later on.

true. i do that in most cases. i am not saying my solution is very
flexible (but it isn't that inflexible either). i was just solving the
problem with that fixed dataset and with speed in mind. i made that
tradeoff decision as a way of showing other solutions. in the real world
i might do it one of the other ways.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 12 Feb 1999 08:45:59 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: fun with strings...
Message-Id: <36c7e603.3369978@news.skynet.be>

Uri Guttman wrote:

>  BL> 	%replace = ( n => "\n", t => "\t", "\\" => "\\");
>  BL> 	s/\\([nt\\])/$replace{$1}/g;
>
>  BL> 	You can represent a newline as '\n'
>
>and yours can't handle the above either. no one can since it is english
>context sensitive.

Say what? Maybe you misunderstood me. Code.

	$_ = "You can represent a newline as '\\n'\n";  
	#including a newline
	$\ = "\n";
	print "Original: ",$_;

	my %decode = ( n => "\n", t => "\t", "\\" => "\\");
	my %encode = map { $decode{$_} => "\\$_" } keys %decode;
	my $encclass = join('', map { "\Q$_" } keys %encode);
	s/([$encclass])/$encode{$1}/og;
	print "Encoded: ",$_;

	my $decclass = join('', map { "\Q$_" } keys %decode);
	s/\\([$decclass])/$decode{$1}/og;
	print "Decoded: ",$_;
__END__
Original: You can represent a newline as '\n'

Encoded: You can represent a newline as '\\n'\n
Decoded: You can represent a newline as '\n'


Using your repeated substitutions, you can encode the string (replace
the bare backslashes first), but decoding it again is impossible.

	Bart.


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

Date: Fri, 12 Feb 1999 08:28:30 GMT
From: chall5@hotmail.com
Subject: Re: Help editing script
Message-Id: <7a0on8$km1$1@nnrp1.dejanews.com>

Yes he did write separate parts of the script and I tried wrapping up the
search part in to search.pl but it didn't work !

This may be to do with the fact that I am using the 1.1 version of the
database which includes sort functionality and the search bit of code was
written for the ver 1.0 version of the database which does not include sort
functionality.

No $33 just yet...


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Fri, 12 Feb 1999 01:02:52 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: How do I delete a hash element ??
Message-Id: <1dn38ex.f1z4m5ncwsg9N@bay1-307.quincy.ziplink.net>

Larry Rosler <lr@hpl.hp.com> wrote:

> > Did you search for 'delete' in the man page?
> 
> The technical term for your response is 'begging the question'.
> 

Actually, I think the term is 'rhetorical question'.  I'm not sure what
it has to do with begging the question, which is the fallacy of circular
reasoning.

-- 
#!/usr/bin/sh -- chipmunk (aka Ronald J Kimball)
    perl -e'for(sort keys%main::){print if $$_ eq 1}
        ' -s  -- -' Just' -' another ' -'Perl ' -'hacker
' http://www.ziplink.net/~rjk/  [rjk@linguist.dartmouth.edu]


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

Date: Thu, 11 Feb 1999 22:53:29 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: How do I delete a hash element ??
Message-Id: <MPG.112d6fbf8b87b3eb989a28@nntp.hpl.hp.com>

In article <1dn38ex.f1z4m5ncwsg9N@bay1-307.quincy.ziplink.net> on Fri, 
12 Feb 1999 01:02:52 -0500, Ronald J Kimball 
<rjk@linguist.dartmouth.edu> says...
> Larry Rosler <lr@hpl.hp.com> wrote:
> 
> > > Did you search for 'delete' in the man page?
> > 
> > The technical term for your response is 'begging the question'.
> 
> Actually, I think the term is 'rhetorical question'.  I'm not sure what
> it has to do with begging the question, which is the fallacy of circular
> reasoning.

I _meant_ it to refer to circular reasoning.  A search for 'delete' will 
work iff you know that the desired function is 'delete' so that a search 
for 'delete' will work.

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 12 Feb 1999 02:06:16 -0500
From: Uri Guttman <uri@home.sysarch.com>
Subject: Re: How do I delete a hash element ??
Message-Id: <x7soccnlsn.fsf@home.sysarch.com>

>>>>> "LR" == Larry Rosler <lr@hpl.hp.com> writes:

  LR> In article <1dn38ex.f1z4m5ncwsg9N@bay1-307.quincy.ziplink.net> on Fri, 
  LR> 12 Feb 1999 01:02:52 -0500, Ronald J Kimball 
  LR> <rjk@linguist.dartmouth.edu> says...
  >> Larry Rosler <lr@hpl.hp.com> wrote:
  >> 
  >> > > Did you search for 'delete' in the man page?
  >> > 
  >> > The technical term for your response is 'begging the question'.
  >> 
  >> Actually, I think the term is 'rhetorical question'.  I'm not sure what
  >> it has to do with begging the question, which is the fallacy of circular
  >> reasoning.

  LR> I _meant_ it to refer to circular reasoning.  A search for
  LR> 'delete' will work iff you know that the desired function is
  LR> 'delete' so that a search for 'delete' will work.

not exactly. you could search for delete knowing it is a good term for
the description of the operation and hoping it will be in the
appropriate text. the fact that it is the same name is irrelevent. the
poster asked about deleting and was told to search for delete which is a
reasonable rtfm type response.

uri

-- 
Uri Guttman  -----------------  SYStems ARCHitecture and Software Engineering
Perl Hacker for Hire  ----------------------  Perl, Internet, UNIX Consulting
uri@sysarch.com  ------------------------------------  http://www.sysarch.com
The Best Search Engine on the Net -------------  http://www.northernlight.com


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

Date: Fri, 12 Feb 1999 01:02:17 -0600
From: seong joon bae <seongbae@students.uiuc.edu>
Subject: How do you get SSI to work?
Message-Id: <Pine.SOL.3.96.990212005908.11620A-100000@ux10.cso.uiuc.edu>


Hello,
I'm trying to get SSI to work.
I looked at documents for SSI but couldn't find out how to use it.
They said you have to do
AddType text/x-server-parsed-html .shtml
and stuff...
but when I type Addtype, it says "Command not found"
So I'm guessing that you need to download some file and install it on the
computer.
I also tried "Options ExecCGI" and stuff...but it also says "command not
found".
Can anyone explain how i can get the SSI to work?
Thank you very much.

seong



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

Date: Fri, 12 Feb 1999 07:12:54 GMT
From: perl_beginner@my-dejanews.com
Subject: How to create a directory using perl on linux?
Message-Id: <7a0k9h$gd5$1@nnrp1.dejanews.com>

    What is the best way to create a directory using perl effectively/securely
in Linux. I intended to use it as a cgi script. Thanks!





-perl_beginner-

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: 12 Feb 1999 07:23:37 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: How to create a directory using perl on linux?
Message-Id: <slrn7c7lnp.77f.sholden@pgrad.cs.usyd.edu.au>

perl_beginner@my-dejanews.com <perl_beginner@my-dejanews.com> wrote:
>    What is the best way to create a directory using perl effectively/securely
>in Linux. I intended to use it as a cgi script. Thanks!

Why don't you have a guess and see if the coudmentation agrees with you.

-- 
Sam

Remember that the P in Perl stands for Practical.  The P in Python
doesn't seem to stand for anything.
	--Randal Schwartz in <8cemsabtef.fsf@gadget.cscaper.com>


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

Date: Fri, 12 Feb 1999 09:25:56 GMT
From: pkey@sghms.ac.uk
Subject: ldap & web500.pl
Message-Id: <36c3f2e1.1350730@news.dl.ac.uk>

Hi

I am trying to configure web500.pl as an interface to an ldap
database.

I'm having a problem authenticating - I can log in 
and get the message 'Welcome' but when I try and 'add' data 
I get:

NOTE: Please LOGIN before you change password and other 
information.

I thought I had logged in...any pointers as to where I'm 
going wrong?

Are there any websites about web500.pl & ldap?

Cheers

Paul


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

Date: Fri, 12 Feb 1999 09:29:19 GMT
From: "Antti Boman" <antti.boman***NOSP@M***helsinki.fi>
Subject: Negative lookahead problem
Message-Id: <PvSw2.42$fA5.191@read1.inet.fi>

Hi,

I'll try to explain:

$tmp1="Check http://something.com/ out.";
$tmp2="Check <a href="http://something.com/">this</a> out.";

How can substitute the URL in $tmp1 to <a href="http://something.com/">, but
still, with the same piece of code, not affect $tmp2?

This doesn't naturally work:
s{(?! href="?)(http://something.com/)}{<a href="\1">};

I found (from perlre doc) a solution, but I cannot get how I can use it with
the one above. What if I don't know the length of the string that's not
supposed to be there.

Any ideas or further questions appreciated.

-a




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

Date: 11 Feb 1999 22:26:04 -0800
From: Russ Allbery <rra@stanford.edu>
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <ylyam46sub.fsf@windlord.stanford.edu>

In comp.lang.perl.moderated, Larry Rosler <lr@hpl.hp.com> writes:

> As ground rules, I suggest that all functions be '-w' and 'use strict;'
> compliant.  Lines should fit without folding; tabs should be avoided.
> Documentation is 'good', but test code might not be necessary, to keep
> the volume down.

I'd also recommend that people make some clear statement about copyright
or licensing.  I personally will probably put anything I write for the PFR
explicitly into the public domain, since I think worrying about licenses
with excerpts of code that small is pointless.  But another reasonable
approach may be classic:

# This program is free software; you can redistribute it and/or modify it
# under the same terms as Perl itself.

or some variation of BSD, GPL, or what have you.  But in any event, I'd
encourage contributors to make it clear one way or the other; without a
clear copyright statement, a lot of people won't be able to use the code.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Fri, 12 Feb 1999 09:34:12 +0100
From: "H.Merijn Brand" <PROCURA_BV@CompuServe.com>
Subject: Re: PFR: UTC_to_Epoch
Message-Id: <36C3E784.9B2AC0A4@CompuServe.com>

Is the PFR for pur perl only or will XS do too?

I've done Larry's UTC function this in an xs module using native mktime ()
function like:

-------------------------------------- Cut ---------------------------------
#ifdef __cplusplus
extern "C" {
#endif
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#ifdef __cplusplus
}
#endif

MODULE = MkTime        PACKAGE = main

long
mktime (sec, min, hr, day, mon, yr)
        int     sec
        int     min
        int     hr
        int     day
        int     mon
        int     yr
    PROTOTYPE: $$$$$$
    CODE:
        struct tm       ltm;

        ltm.tm_sec      = sec;
        ltm.tm_min      = min;
        ltm.tm_hour     = hr;
        ltm.tm_mday     = day;
        ltm.tm_mon      = mon;
        ltm.tm_year     = yr;
        ltm.tm_wday     = 0;
        ltm.tm_yday     = 0;
        ltm.tm_isdst    = 0;

        RETVAL = mktime (&ltm);
    OUTPUT:
        RETVAL
------------------------------ Cut --------------------------------

Larry Rosler wrote:
> As ground rules, I suggest that all functions be '-w' and 'use strict;'

Agree!

> compliant.  Lines should fit without folding; tabs should be avoided.
> Documentation is 'good', but test code might not be necessary, to keep
> the volume down.

If this a 'one-to-one' interface to existing unix functions, unix man
pages should do :)

> As you can see, the setup and argument checking for this function are
> trivial but space-consuming.  The guts of the algorithm is also
> 'trivial', but quite inscrutable (to me).  Comments, suggestions, and
> brickbats are welcome, of course!

I've done none whatsoever in above example, couse (HP) doc's said that
illegal values will be used to calculate legal values:

	32 Jan 1999 = 1 Feb 1999	(Fun isn't it)

> > Have the appropriate amount of fun.
> 
> You bet!  Thanks for setting this up.  Links to the Repository need to
> be created from http://www.perl.com/ and other appropriate places, of
> course.

Do not forget TPI, I've noticed a huge increase in interrest in thas site


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

Date: Fri, 12 Feb 1999 01:02:53 -0500
From: rjk@linguist.dartmouth.edu (Ronald J Kimball)
Subject: Re: Problem with file creation
Message-Id: <1dn393a.d6qv2t1hvy2ynN@bay1-307.quincy.ziplink.net>

Patrick Fong <patfong@yoyo.cc.monash.edu.au> wrote:

> When I go onto the next page of my form and press Submit... An error
> occurs saying that the file does not exist. So I think that it is probably
> that the file was not created in the first place.

If you get an error saying that the file does not exist, it's more
likely that the CGI script is not in the right place, so the server
can't find it at the URL the browser is asking for.

-- 
 _ / '  _      /         - aka -          rjk@linguist.dartmouth.edu
( /)//)//)(//)/(     Ronald J Kimball      chipmunk@m-net.arbornet.org
    /                                  http://www.ziplink.net/~rjk/
        "It's funny 'cause it's true ... and vice versa."


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

Date: Thu, 11 Feb 1999 21:13:13 GMT
From: cybpunk@geocities.com (John G)
Subject: syntax error I can't find?
Message-Id: <36c346a3.14194921@news.ma.ultranet.com>

Hello all,
I am having a problem with a cgi script I am writing for my website,
that I can't figure out.  I get a syntax error on line 26 near "else
if".  Here is the relevant code snippet:  (I am adding line numbers
for clarification)


## Question 1
23:if (($in{a1pattern1} == "splash") && ($in{a1pattern2} == "none")) {
24:	++$total;
25:	$anwsers[0] = 0;
26:} else if ((($in{a1pattern1} == "splash") && ($in{a1pattern2} !=
"none")) || ($in{a1pattern2} == "splash")) {
27:	$total += .5;
28:	$anwsers[0] = .5;
29:} else {
30:	$anwsers[0] = 1;
31:}

Any help someone could give would be much appreciated.
TIA
-John


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

Date: Fri, 12 Feb 1999 01:11:25 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: syntax error I can't find?
Message-Id: <MPG.112d90117dc9a32c989a2a@nntp.hpl.hp.com>

[Posted and a courtesy copy mailed.]

In article <36c346a3.14194921@news.ma.ultranet.com> on Thu, 11 Feb 1999 
21:13:13 GMT, John G <cybpunk@geocities.com> says...
 ...> 
> 23:if (($in{a1pattern1} == "splash") && ($in{a1pattern2} == "none")) {
> 24:	++$total;
> 25:	$anwsers[0] = 0;
> 26:} else if ((($in{a1pattern1} == "splash") && ($in{a1pattern2} !=
> "none")) || ($in{a1pattern2} == "splash")) {
> 27:	$total += .5;
> 28:	$anwsers[0] = .5;
> 29:} else {
> 30:	$anwsers[0] = 1;
> 31:}

Your retraction (which should have been posted in response to this one, 
so it wouldn't start a new thread) presumably refers to your 
realization that in Perl 'else if' is spelled with a few fewer 
characters.  But did you also realize that in Perl, strings are compared 
using 'eq', not '=='?  And in English, 'anwsers' is spelled 'answers' 
(but it doesn't matter much in Perl if you're consistent)?

Cheers,

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 12 Dec 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Dec 98)
Message-Id: <null>


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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

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