[16346] in Perl-Users-Digest
Perl-Users Digest, Issue: 3758 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 20 14:06:20 2000
Date: Thu, 20 Jul 2000 11:05:25 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <964116325-v9-i3758@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Thu, 20 Jul 2000 Volume: 9 Number: 3758
Today's topics:
Re: "Missing coprocessor" ("Ian.")
Re: "Missing coprocessor" <gellyfish@gellyfish.com>
Re: - I Need Help <juex@deja.com>
Arrays from scalars <mike@cyborg-group.com>
Re: Arrays from scalars <care227@attglobal.net>
Re: Arrays from scalars nobull@mail.com
Re: Arrays from scalars <mike@cyborg-group.com>
Re: can i compare refs? <aqumsieh@hyperchip.com>
Re: can i compare refs? nobull@mail.com
Check string for a certain format <colin_larcombe@hotmail.com>
Re: Check string for a certain format <tony_curtis32@yahoo.com>
Re: Check string for a certain format <care227@attglobal.net>
Re: Check string for a certain format <abuse@localhost>
cperl-mode.el <sam.lay@bigfoot.com>
Re: cperl-mode.el <plord@hgmp.mrc.ac.uk>
Re: cperl-mode.el <sam.lay@bigfoot.com>
Re: cperl-mode.el <walters@cis.ohio-state.edu>
Re: cperl-mode.el <plord@hgmp.mrc.ac.uk>
dazed & confused, file append problem <.@.com>
Re: dazed & confused, file append problem <cal@iamcal.com>
Re: dazed & confused, file append problem <callgirl@la.znet.com>
Re: dazed & confused, file append problem <bill.kemp@wire2.com>
Re: Delete records in 2 weeks time nobull@mail.com
Re: Determine relative path from 2 absolute path <abuse@localhost>
Re: Determine relative path from 2 absolute path <stephen.kloder@gtri.gatech.edu>
Re: directory structure listing <dbohl@sgi.com>
Re: Explanation needed for "Security Audit and Taint Ch (Tad McClellan)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 20 Jul 2000 09:14:09 +0000 (UTC)
From: ian.freedomnet@softhome.net ("Ian.")
Subject: Re: "Missing coprocessor"
Message-Id: <20000720.0914.1018snz@softhome.net>
I> Ive just started looking into Perl. I collected a DOS version of
I> Perl 5 from ftp.demon.co.uk. Im ok with the DPMI bit but when
I> I try to run the .exe on my 386, its complaining about the lack
I> of a coprocessor. I know there are some 387 emulators around
I> somewhere but could someone please tell me the right one
I> to use with this Perl. I did try just making wemu387.386 from the
I> Perl 4 package available to it but it didnt do anything with it.
Hey! Does anyone know the answer to this? Im never going to get
started with Perl if I cant get the interpreter to work. Is
this the wrong newsgroup? The "misc" in the name sounds right
to me.
--
Bye now,
Ian.
------------------------------
Date: Thu, 20 Jul 2000 16:15:10 GMT
From: Jonathan Stowe <gellyfish@gellyfish.com>
Subject: Re: "Missing coprocessor"
Message-Id: <iAFd5.603$Px6.53763@news.dircon.co.uk>
On Thu, 20 Jul 2000 09:14:09 +0000 (UTC), "Ian." Wrote:
> I> Ive just started looking into Perl. I collected a DOS version of
> I> Perl 5 from ftp.demon.co.uk. Im ok with the DPMI bit but when
> I> I try to run the .exe on my 386, its complaining about the lack
> I> of a coprocessor. I know there are some 387 emulators around
> I> somewhere but could someone please tell me the right one
> I> to use with this Perl. I did try just making wemu387.386 from the
> I> Perl 4 package available to it but it didnt do anything with it.
>
> Hey! Does anyone know the answer to this? Im never going to get
> started with Perl if I cant get the interpreter to work. Is
> this the wrong newsgroup? The "misc" in the name sounds right
> to me.
>
Hey! You want to get killfiled over this ?
Firstly if you are on a WIn32 system you should download the version of
Perl from <http://www.activestate.com> if you really are on a DOS / Win 3.1?
system then you should get
<http://www.delorie.com/djgpp/dl/ofc/simtel/v2gnu/perl552b.zip>
And read the other requirements in the sundry documents at the same
site.
I have posted a full list of the requirements in the past but I think you
need to learn patience.
/J\
------------------------------
Date: Thu, 20 Jul 2000 08:57:49 -0700
From: "Jürgen Exner" <juex@deja.com>
Subject: Re: - I Need Help
Message-Id: <39772185@news.microsoft.com>
"Bob Kling" <bbkling@earthlink.net> wrote in message
news:39768F7D.4C0E3E5D@earthlink.net...
> I need to hire a Programmer - WORK AT HOME -Full Time
> Ideal person would be strong in Perl, with some Java, and some SQL.
> Server admin skills a big plus; Unix and some NT
This must be the 10th or 12th job advertisment I've seen recently. Has this
NG been renamed to ...perl.jobs.offered ???
Furthermore you are spamming multiple NGs with identical postings.
In other words: You are in serious violation of the nettiquette and you are
pissing off a
lot of people.
***PLONK***
jue
------------------------------
Date: Thu, 20 Jul 2000 16:56:45 +0000
From: Mike <mike@cyborg-group.com>
Subject: Arrays from scalars
Message-Id: <964108611.20947.0.nnrp-09.9e986064@news.demon.co.uk>
Does anyone know whether yocan read a scalar variable into an array. My
script runs a proedure for every record in a file (email and name) which
are comma seperated However it does not recognise the comma as a seperator
and does not seem to like either putting the scalar into an array or a
file handle. Any help appreciated.
Script follows
#! /usr/bin/perl -w
use Net::SMTP; use MIME::Entity;
$from = "xxx";
$mailinglist = "/home/data/bulk/xxx.txt";
$body = "/home/data/bulk/xxxt.txt";
open (MESSAGE, "$body");
@message=<MESSAGE>;
&bulk;
sub bulk { open (LIST, "$mailinglist"),
@recips = <LIST>;
foreach $recips (@recips) { &smtpsend; }
close (LIST); };
$recips=$recips;
sub smtpsend {
$message=@message;
$smtp = Net::SMTP->new('smtp.xxx.com',Debug=>1);
$smtp->mail ($from);
&parse;
$smtp->to ($recips[0]);
my $msg = MIME::Entity->build(
From => 'xxx', To => $recips[1], Subject => 'test message1', Data =>
["Dear\ $recips[1] t\n"]
);
$smtp->data ();
$smtp->datasend ($msg->stringify)
}}
------------------------------
Date: Thu, 20 Jul 2000 12:44:30 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Arrays from scalars
Message-Id: <39772C6E.4F810FE0@attglobal.net>
Mike wrote:
>
> Does anyone know whether yocan read a scalar variable into an array. My
> script runs a proedure for every record in a file (email and name) which
> are comma seperated However it does not recognise the comma as a seperator
> and does not seem to like either putting the scalar into an array or a
> file handle. Any help appreciated.
>
> Script follows
>
> #! /usr/bin/perl -w
> use Net::SMTP; use MIME::Entity;
>
> $from = "xxx";
> $mailinglist = "/home/data/bulk/xxx.txt";
> $body = "/home/data/bulk/xxxt.txt";
>
> open (MESSAGE, "$body");
> @message=<MESSAGE>;
>
> &bulk;
>
> sub bulk { open (LIST, "$mailinglist"),
> @recips = <LIST>;
> foreach $recips (@recips) { &smtpsend; }
> close (LIST); };
> $recips=$recips;
> sub smtpsend {
> $message=@message;
Are you sure you know what this does? Assigning an array to a scalar
in this manner returns the number of elements in the array, not the
array concatenated into a string. Try using the join() function
to build that scalar instead.
Anymore than that I can't say without spending alot more time with
this than I have right now. You are using alot of globals instead
of passing the necessary values to the subroutines, which I've found
to be a Bad Thing.
And what is the use of $recips=$recips; ? Its kinda like saying
1=1. No?
------------------------------
Date: 20 Jul 2000 17:48:44 +0100
From: nobull@mail.com
Subject: Re: Arrays from scalars
Message-Id: <u9r98oeoib.fsf@wcl-l.bham.ac.uk>
Mike <mike@cyborg-group.com> writes:
> Does anyone know whether yocan read a scalar variable into an array.
By "read" do you mean "split"? Yeah, sure, use the split() function.
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 20 Jul 2000 18:37:05 +0000
From: Mike <mike@cyborg-group.com>
Subject: Re: Arrays from scalars
Message-Id: <964114631.24587.0.nnrp-09.9e986064@news.demon.co.uk>
In article <964108611.20947.0.nnrp-09.9e986064@news.demon.co.uk>, Mike
<mike@cyborg-group.com> wrote:
By the time my post appears I worked it out by using split within the
$smtpsend sub - now works perfect
I have amended the script to correspond with the working.
> Does anyone know whether yocan read a scalar variable into an array. My
> script runs a proedure for every record in a file (email and name) which
> are comma seperated However it does not recognise the comma as a
> seperator and does not seem to like either putting the scalar into an
> array or a file handle. Any help appreciated.
>
> Script follows
>
> #! /usr/bin/perl -w
> use Net::SMTP; use MIME::Entity;
>
> $from = "xxx";
> $mailinglist = "/home/data/bulk/xxx.txt";
> $body = "/home/data/bulk/xxxt.txt";
> open (MESSAGE, "$body");
> @message=<MESSAGE>;
>
> &bulk;
>
> sub bulk { open (LIST, "$mailinglist"),
> @recips = <LIST>;
> foreach $recips (@recips) { &smtpsend; }
> close (LIST); };
> sub smtpsend {
> $message=@message;
@recips1=split(','$recips)
> $smtp = Net::SMTP->new('smtp.xxx.com',Debug=>1);
> $smtp->mail ($from);
>
> $smtp->to ($recips1[0]);
> my $msg = MIME::Entity->build(
> From => 'xxx', To => $recips[1], Subject => 'test message1', Data =>
> ["Dear\ $recips1[1] t\n"]
> );
>
> $smtp->data ();
> $smtp->datasend ($msg->stringify)
>
> }}
------------------------------
Date: Thu, 20 Jul 2000 15:40:34 GMT
From: Ala Qumsieh <aqumsieh@hyperchip.com>
Subject: Re: can i compare refs?
Message-Id: <7aem4oizd7.fsf@merlin.hyperchip.com>
clintp@geeksalad.org (Clinton A. Pierce) writes:
> [Posted and mailed]
>
> In article <8l5n3j$ncb$1@nnrp1.deja.com>,
> kdmasary@my-deja.com writes:
> > Is it possible to compare references? I know this doesn't work but I'm
^^^^^^^^^^^^^^^^^^^^^^^^
^^^^^^^^^^^^^^^^^^^^^^^^
How do you know this? Did you try it? It should work.
> > trying to do something like it:
> >
> > if ($reference1 == $reference2) {
> > do stuff;
> > }
>
> Compare them like this:
>
> if ($reference eq $reference2) {
> }
>
> Using a reference like a string won't harm it in this case. This'll
> be true if both references point to the same thing..
True, but I believe that, in numeric context, a reference returns the
memory address of the memory location it refers to. This was
specifically done to optimize comparing references:
if ($ref1 == $ref2) {
# They point to the same location
}
This should be much faster than stringifying the references and
comparing them.
--Ala
------------------------------
Date: 20 Jul 2000 17:36:50 +0100
From: nobull@mail.com
Subject: Re: can i compare refs?
Message-Id: <u9zoncep25.fsf@wcl-l.bham.ac.uk>
clintp@geeksalad.org (Clinton A. Pierce) writes:
> [Posted and mailed]
>
> In article <8l5n3j$ncb$1@nnrp1.deja.com>,
> kdmasary@my-deja.com writes:
> > Is it possible to compare references? I know this doesn't work but I'm
> > trying to do something like it:
> >
> > if ($reference1 == $reference2) {
> > do stuff;
> > }
>
> Compare them like this:
>
> if ($reference eq $reference2) {
> }
No, compare them like this:
if ($reference == $reference2) {
}
It's semantically equivalent but faster. In a numeric context a
reference returns the memory address of the referenced object. Two
references are only numerically equal if they refer to the same
object.
If two references refer to separate objects and you want to know if
these separate objects (rather than the references) are the same you
must first define what you mean by "the same".
See also he FAQ "How do I test whether two arrays or hashes are
equal?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 20 Jul 2000 15:45:55 GMT
From: "Colin Larcombe" <colin_larcombe@hotmail.com>
Subject: Check string for a certain format
Message-Id: <T8Fd5.23222$aS.176067@telenews.teleline.es>
Newbie writes
I need to check a string for the format XX9999999999. I was going to check
that the 1st char was alpha the 3rd was numeric and the length was 12.
1. How can I check that the 1st char is alpha and the 3rd is numeric ?
2. Any other suggestions for a better test gratefully received.
Thanks
Colin
------------------------------
Date: 20 Jul 2000 10:51:57 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Check string for a certain format
Message-Id: <873dl4lrz6.fsf@limey.hpcc.uh.edu>
>> On Thu, 20 Jul 2000 15:45:55 GMT,
>> "Colin Larcombe" <colin_larcombe@hotmail.com> said:
> Newbie writes I need to check a string for the format
> XX9999999999. I was going to check that the 1st char was
> alpha the 3rd was numeric and the length was 12.
perldoc perlre perldoc -f length
Extracting positions: perldoc -f substr
You could also use a regexp to match the pieces
(TIMTOWTDI).
hth
t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: Thu, 20 Jul 2000 12:08:31 -0400
From: Drew Simonis <care227@attglobal.net>
Subject: Re: Check string for a certain format
Message-Id: <397723FF.E310C9F4@attglobal.net>
Colin Larcombe wrote:
>
> I need to check a string for the format XX9999999999. I was going to check
> that the 1st char was alpha the 3rd was numeric and the length was 12.
>
> 1. How can I check that the 1st char is alpha and the 3rd is numeric ?
read perlfunc, specifically about the substr() and length() functions.
#!/usr/bin/perl -w
use strict;
my $string = 'XX999999999';
if ( substr($string, 0, 1) =~ /[a-zA-Z]/
and substr($string, 2, 1) =~ /\d/
and length($string) == 12){
print "match!"
}else{
print "oopsie"
}
> 2. Any other suggestions for a better test gratefully received.
Well, the above does what you ask, but it isn't very pretty.
However, without knowing what you want to test for, and what
you want to test against, its hard to offer alternates.
Were I you, I'd read the Perl regular expression docs and see
if I could come up with something a bit more elegant. Maybe
/^[a-zA-Z]{2}?\d{10}?$/, as in:
#!/usr/bin/perl -w
$string = 'XX9999999999';
if ($string =~ /^[a-zA-Z]{2}?\d{10}?$/){
print "match!"
}else{
print "oopsie"
}
That works on a string that starts with exactly 2 alpha chars
followed by exactly 10 numerics followed by the end of the line.
HTH
------------------------------
Date: Fri, 21 Jul 2000 00:16:52 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: Check string for a certain format
Message-Id: <8l786t$7738@imsp212.netvigator.com>
###
$st = '00XX9999999999';
if ($st =~ /^[A-Za-z].\d.{9}$/) {
print 'valid';
} else {
print 'invalid';
}
###
Hope this helps.
"Colin Larcombe" <colin_larcombe@hotmail.com> wrote
> Newbie writes
>
> I need to check a string for the format XX9999999999. I was going to check
> that the 1st char was alpha the 3rd was numeric and the length was 12.
>
> 1. How can I check that the 1st char is alpha and the 3rd is numeric ?
> 2. Any other suggestions for a better test gratefully received.
>
> Thanks
>
> Colin
>
>
------------------------------
Date: Thu, 20 Jul 2000 11:35:53 -0400
From: "Sam Lay" <sam.lay@bigfoot.com>
Subject: cperl-mode.el
Message-Id: <8l76hm$tmq$1@slb2.atl.mindspring.net>
I've recently downloaded GNU emacs 20.7 for win32.
I am running onWinnt4.0 sp5.
When I attempt to go into cperl-mode, I get the following error:
Invalid read syntax ")"
When I try to use auto-load, I get:
File mode specification error: (invalid-read-syntax ")")
This all seemed to work for GNU emacs 20.5.
Anybody seen this and/or know what the problem could be?
As for me, I'm totally elisp illiterate.
Thanks, Sam
------------------------------
Date: 20 Jul 2000 17:04:08 +0100
From: Phillip Lord <plord@hgmp.mrc.ac.uk>
Subject: Re: cperl-mode.el
Message-Id: <okg0p4iy9z.fsf@arginine.sbc.man.ac.uk>
>>>>> "Sam" == Sam Lay <sam.lay@bigfoot.com> writes:
Sam> I've recently downloaded GNU emacs 20.7 for win32. I am
Sam> running onWinnt4.0 sp5. When I attempt to go into cperl-mode,
Sam> I get the following error: Invalid read syntax ")"
Sam> When I try to use auto-load, I get: File mode specification
Sam> error: (invalid-read-syntax ")")
Sam> This all seemed to work for GNU emacs 20.5. Anybody seen this
Sam> and/or know what the problem could be? As for me, I'm totally
Sam> elisp illiterate.
It means that you have an extra ")" somewhere in cperl.el
or one of the other files that it loads. I'm not really sure why this
is the case. Its possible that there is a problem with the 20.7
distribution, but I would say that its more likely that you have added
a ")" by mistake at some stage or have a problem with a hook. I would
try switching backtracing on (Help-->Options-->Debug on error). The
output looks fairly scary and incomprehensible, but its not as bad as
it looks and it will tell you where the error is.
Alternatively unpack cperl-mode.el (or cperl-mode.elc) from
the distribution of emacs that you got and install it over the old
version see if it fixes it..
------------------------------
Date: Thu, 20 Jul 2000 12:47:11 -0400
From: "Sam Lay" <sam.lay@bigfoot.com>
Subject: Re: cperl-mode.el
Message-Id: <8l7anc$aoa$1@slb2.atl.mindspring.net>
Never mind, found a new cperl-mode.el in the current perl sources.
Pardon my noise . . .
BTW, how do you locate unbalanced parens, etc. in an elisp source?
"Sam Lay" <sam.lay@bigfoot.com> wrote in message
news:8l76hm$tmq$1@slb2.atl.mindspring.net...
> I've recently downloaded GNU emacs 20.7 for win32.
> I am running onWinnt4.0 sp5.
> When I attempt to go into cperl-mode, I get the following error:
> Invalid read syntax ")"
>
> When I try to use auto-load, I get:
> File mode specification error: (invalid-read-syntax ")")
>
> This all seemed to work for GNU emacs 20.5.
> Anybody seen this and/or know what the problem could be?
> As for me, I'm totally elisp illiterate.
>
> Thanks, Sam
>
>
------------------------------
Date: 20 Jul 2000 13:28:56 -0400
From: Colin Walters <walters@cis.ohio-state.edu>
Subject: Re: cperl-mode.el
Message-Id: <85vgy0sobr.fsf@meta.verbum.org>
"Sam Lay" <sam.lay@bigfoot.com> writes:
> BTW, how do you locate unbalanced parens, etc. in an elisp source?
Well, usually the indentation will give you a clue. You could do
'C-x h C-M-\' to re-indent the whole buffer. If you see things like
(defun foo ...) misaligned, then you know what area the missing paren
is in.
Additionally, Ilisp has a function to help you find unbalanced parens;
I've never tried it, and I'm not sure if it would work for Elisp.
------------------------------
Date: 20 Jul 2000 18:43:14 +0100
From: Phillip Lord <plord@hgmp.mrc.ac.uk>
Subject: Re: cperl-mode.el
Message-Id: <okya2whf4d.fsf@arginine.sbc.man.ac.uk>
>>>>> "Sam" == Sam Lay <sam.lay@bigfoot.com> writes:
Sam> Never mind, found a new cperl-mode.el in the current perl
Sam> sources. Pardon my noise . . .
Sam> BTW, how do you locate unbalanced parens, etc. in an elisp
Sam> source?
There are a couple of ways. show-paren.el (M-x
show-paren-mode) or one of the other paren matching modes works pretty
well. Alternatively just re-indent the entire buffer (mark the whole
buffer then M-x ident-region) and see where the indentation goes
awry. Or if you know roughly where the problem is, just hit [tab] on
the appropriate lines and look for one which moves.
Thats the way I do it anyway.
Phil
------------------------------
Date: Thu, 20 Jul 2000 16:52:39 +0100
From: "Ben" <.@.com>
Subject: dazed & confused, file append problem
Message-Id: <U6Fd5.602$Px6.53706@news.dircon.co.uk>
Hello all,
I have recently been debugging someone elses perl/cgi scripts, on someone
elses server. The scripts are well written and I am trying to make minor
ammends to them. The unix server has all file permissions in this area set
to full-access for owners (rwxrwxrwx). I am only trying to append to a text
file, and it seems that I am not allowed WHY ?
I'm not a Unix expert, so I believe this to be my problem but need advice as
to why, I've set up a dummy script which allows me to read the file and
print to a browser. (THIS WORKS OK) but when I change the script to allow me
to append to the document using >> the script falls over ? Why ?
#!/usr/bin/perl
print "Content-type: text/html\n\n";
$strfile = "../var/zen.txt";
# if you can write to file
if(-w $strfile){
print "yip";
open(LOG,>>$strfile);
@loglines = <LOG>;
close(LOG);
$n=1;
print "<BR>Document Text<BR>";
foreach $message(@loglines){
print "<LI>line $n was $message\n";
$n++;
}
} else {
&ErrorMessage;
}
# Error Sub
sub ErrorMessage {
print "<P>The server has a problem. Aborting script. \n";
exit;
}
------------------------------
Date: Thu, 20 Jul 2000 16:52:07 +0100
From: "Cal Henderson" <cal@iamcal.com>
Subject: Re: dazed & confused, file append problem
Message-Id: <heFd5.501$yE4.7814@news2-win.server.ntlworld.com>
"Ben" wrote...
[snip]
:
: I'm not a Unix expert, so I believe this to be my problem but need advice as
: to why, I've set up a dummy script which allows me to read the file and
: print to a browser. (THIS WORKS OK) but when I change the script to allow me
: to append to the document using >> the script falls over ? Why ?
:
: #!/usr/bin/perl
: print "Content-type: text/html\n\n";
: $strfile = "../var/zen.txt";
:
: # if you can write to file
: if(-w $strfile){
: print "yip";
: open(LOG,>>$strfile);
: @loglines = <LOG>;
: close(LOG);
[snip]
Aren't you assuming the current working directory?
Why not try an absolute path?
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: Thu, 20 Jul 2000 09:16:23 -0700
From: "Godzilla!" <callgirl@la.znet.com>
Subject: Re: dazed & confused, file append problem
Message-Id: <397725D7.A91A7EBE@la.znet.com>
Ben wrote:
(snippage)
> The unix server has all file permissions in this area set
> to full-access for owners (rwxrwxrwx). I am only trying
> to append to a text file, and it seems that I am not allowed...
Be sure to restrict your permissions after you are
finished beta testing. This setting you display is
not secure; it allows WWW write ability.
> I'm not a Unix expert, so I believe this to be my problem
> but need advice as to why, I've set up a dummy script which
> allows me to read the file and print to a browser. (THIS WORKS OK)
> but when I change the script to allow me to append to the document
> using >> the script falls over ? Why ?
> $strfile = "../var/zen.txt";
Have you tried using a full internal path name?
An example would be:
/ftp/var/home/alan_gingsberg/public_html/zen.txt
Logic strongly suggests you have a problem with
your script simply not being able to locate your
file to which you want to write. You will need
to check this server's FAQ or contact them to
obtain the correct internal path name.
This will make a few scream, seems this situation
is a perfect one for error checking for opening
of a file, ... || die ("fubar... etc... :$!");
Hmm... using fatals to browser might be a good idea.
Perhaps a very simple open, write, close type of
script would be better for beta testing?
open (LOG, ">>$strfile") || die ("fubar: $!");
print LOG "TEST";
close (LOG);
Use of quotes in your open sometimes helps as well.
Try changing to a full internal path name, check your
syntax, include fatals to browser and, add error checking
for your file opening. I suspect you will have fairly good
luck, at least in making discoveries about what is not quite
right. If needed, you could contact this server and ask the
right questions to attain quick resolution.
Godzilla!
--
print "file:///%43|%2f";
------------------------------
Date: Thu, 20 Jul 2000 17:31:03 +0100
From: "W Kemp" <bill.kemp@wire2.com>
Subject: Re: dazed & confused, file append problem
Message-Id: <964110825.4639.0.nnrp-13.c3ad6973@news.demon.co.uk>
<snip>
>elses server. The scripts are well written
<snip- yeah!>
>print to a browser. (THIS WORKS OK) but when I change the script to allow
me
>to append to the document using >> the script falls over ? Why ?
>
>#!/usr/bin/perl
>print "Content-type: text/html\n\n";
>$strfile = "../var/zen.txt";
>
># if you can write to file
>if(-w $strfile){
>print "yip";
>open(LOG,>>$strfile);
Pull your hair out no more:-
It should have double quotes around ">>$strfile"
They really should have put in some sort of error catching on that line.
------------------------------
Date: 20 Jul 2000 17:37:37 +0100
From: nobull@mail.com
Subject: Re: Delete records in 2 weeks time
Message-Id: <u9ya2wep0u.fsf@wcl-l.bham.ac.uk>
Taurean <jaurangNOjaSPAM@crosswinds.net.invalid> writes:
> I have a text file containing lines of records. I want to
> delete the records one by one from the file 2 weeks after
> posting. How do I do that? TIA.
See FAQ: "How do I change one line in a file/delete a line in a
file/insert a line in the middle of a file/append to the beginning
of a file?"
See FAQ: "How can I compare two dates and find the difference?"
--
\\ ( )
. _\\__[oo
.__/ \\ /\@
. l___\\
# ll l\\
###LL LL\\
------------------------------
Date: Thu, 20 Jul 2000 23:39:40 +0800
From: "multiplexor" <abuse@localhost>
Subject: Re: Determine relative path from 2 absolute path
Message-Id: <8l7616$59b8@imsp212.netvigator.com>
It's great....... in size :)
I've also tried to write the followings but I don't know if there are any
bugs. I found that converting a path into an array helps a lot.
###
$from = 'http://www.domain.com/dir1/dir2/dir3/';
$to = 'http://www.domain.com/dir1/dir2/dir4/';
# Separate domain and path
($domain_from, $path_from) = ( $from =~ m!^(http://[^/]*/)(.*)!i );
($domain_to, $path_to) = ( $to =~ m!^(http://[^/]*/)(.*)!i );
#print "$domain_from ; $path_from";
# Put domain and splited paths into array;
@from = ( $domain_from, split(/\//, $path_from) );
@to = ( $domain_to, split(/\//, $path_to) );
#print join(',', @from) . "\n" . join(',', @to) . "\n";
# Compare domain and sub dirs of @from and @to
for($i=0 ; $i<=$#from ; $i++) {
if ($from[$i] ne $to[$i]) { last; }
}
#print "i=$i ; #from=$#from ; #to=$#to\n";
# Use $i, $#from and $#to to determine the rel path
$result = '';
if ($i == 0) {
$result = $to; # Same domain
} else {
if ($i == $#from + 1 && $#from == $#to) {
$result = './'; # Same path
} else {
$result = '../' x ($#from - $i + 1) . join( '/', splice(@to, $i, $#to - $i
+ 1) );
if ( substr($result, -1, 1) ne '/' ) {
$result .= '/';
}
}
}
print $result;
###
Hope this works.
<aqutiv@my-deja.com> wrote
> In article
> "multiplexor" <abuse@localhost> wrote:
> > Thanks for pointing me to a right source. I guess the URI::WithBase
> is what
> > I need but I don't quite understand the documentation. Would you like
> to
> > give me, a newbie, a simple example?
> >
>
> I was quite curious myself how to do it, So I've come to this solution:
>
> $source_url = 'http://www.domain.com/dir1/file2.htm';
> $relative = $target_url
> = 'http://www.domain.com/dir1/dir2/dir3/file1.htm';
>
>
> $source_domain = ($source_url =~ m[^(https?://(www.)?.+?)/])[0];
> $source_path = ($source_url =~ m[^https?://.+?(/.+)$])[0];
> $target_domain = ($target_url =~ m[^(https?://(www.)?.+?)/])[0];
> $target_path = ($target_url =~ m[^https?://.+?(/.+)$])[0];
>
> for (1..2) { #This loop is made just for the example purpose
> print "source: $source_domain - $source_path\n";
> print "target: $target_domain - $target_path\n";
>
> $relative = FindReleative($source_path, $target_path) if
> ($source_domain eq $target_domain);
>
> print "Relative path: $relative\n\n";
> ($source_path, $target_path) = ($target_path, $source_path); #Swap
> pathes
> }
>
> sub FindReleative {
> my ($Spath, $Tpath) = @_;
> $InCommon = "";
> my $relative = "";
> $GoUp = 0;
>
> @CompareS = split /\//, $Spath;
> @CompareT = split /\//, $Tpath;
> shift @CompareS; shift @CompareT; #First element is always empty.
>
> if (@CompareS < @CompareT) { $ToLength = @CompareS; }
> else { $ToLength = @CompareT; $GoUp = 1; }
>
> $ToLength--;
>
> for (0..$ToLength) {
> $InCommon .= "/$CompareS[$_]" if ($CompareS[$_] eq $CompareT[$_]);
>
> }
>
> if ($GoUp) {
> $diff = @CompareS - @CompareT;
> for(1..$diff) { $relative .= ".."; $relative .= "/" if !($_ ==
> $diff) }
> }
> else {
> $relative = ".";
> }
>
> return $relative . substr ($Tpath, length($InCommon));
>
>
> }
>
> how's that? ;-)
> Not sure how efficient it is, but It works.
>
>
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
------------------------------
Date: Thu, 20 Jul 2000 11:49:13 -0400
From: Stephen Kloder <stephen.kloder@gtri.gatech.edu>
Subject: Re: Determine relative path from 2 absolute path
Message-Id: <39771F79.7BF316F@gtri.gatech.edu>
aqutiv@my-deja.com wrote:
> I was quite curious myself how to do it, So I've come to this solution:
>
>
> <code snipped for brevity purposes>
> how's that? ;-)
> Not sure how efficient it is, but It works.
>
Wow. You went all out there. Whereas I just hacked together something
short (also out of curiosity):
sub relpath {
my ($src,$dst) = @_;
my ($surl) = $src =~m#^(https?://.*?)/#;
my ($durl) = $dst =~m#^(https?://.*?)/#;
return $dst if $surl ne $durl; # absolute path
my $back = 0;
while(1) { # relative path
my @spath = $src =~m#^(https?://(.*?/)*)((.*?/){$back})#;
return '../'x$back.$1 if $dst =~ m/$spath[0](.*)/;
$back++;
}
}
I've yet to determine if it is foolproof, but it seems to work.
------------------------------
Date: Thu, 20 Jul 2000 12:26:19 -0500
From: Dale Bohl <dbohl@sgi.com>
Subject: Re: directory structure listing
Message-Id: <3977363B.CA6F2E39@sgi.com>
no spam wrote:
>
> Hi,
> I still pretty new to perl but I'm trying to generate a tree listing
> that would look something like
>
> top
> dir1
> dir2
> dir2.1
> dir3
>
> so far I havent done very well. I made an attempt using find in a shell
> script but that didn't work out well
> here is what I have so far but its not much.
>
> #!/usr/local/bin/perl
>
> use file::find;
>
> my $dir = "/somewhere"; # directory to start in
>
> sub showit
> {
> print $dir
> }
>
> find(&showit, $dir);
>
> Thanks in advance for all your help
> Greg.
Here's a shell version in case you're interested.
:
# @(#) tree v1.0a visual display of a file tree
if [ "$#" -gt 1 ]
then echo "tree: wrong arg count" >&2
echo "usage: tree [dir]" >&2
exit 2
fi
if [ "$#" -eq 1 ]
then if [ ! -d $1 ]
then echo "$0: $1 not a directory" >&2
echo "usage: tree [dir]" >&2
exit 2
fi
fi
find ${1:-.} -print | sort | sed -e "1p" -e "1d" \
-e "s|[^/]*/| /|g" \
-e "s|^ */|/|" \
-e "s|/\([^/]*\)$|\1|"
--
Thanks,
Dale
Dale Bohl
SGI Information Services
dbohl@sgi.com
(715)-726-8406
http://wwwcf.americas.sgi.com/~dbohl/
perl -e 'print "Just Another Perl Hacker.\n";'
------------------------------
Date: Thu, 20 Jul 2000 10:52:24 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Explanation needed for "Security Audit and Taint Check" on perldoc ...
Message-Id: <slrn8ne81o.10c.tadmc@maxim.metronet.com>
On 19 Jul 2000 14:03:52 GMT, ARC <tangb@pt.cyanamid.com> wrote:
> As I
>tried to run the "perldoc perldoc" command, I got the response:
>
>"Superuser must not run perldoc without security audit and taint checks."
>
> I am running on an IRIX 6.5 system. Could someone please explain to me
>what that means
It means that it is not safe to use the perldoc program as root.
>and what I need to do to get the perldoc command working.
Use the perldoc program as a user besides root.
Use *all* programs as a user besides root, unless you _have_
to be root.
Do not do routine things as root.
You should not know the root password if you do not already know that...
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 V9 Issue 3758
**************************************