[19799] in Perl-Users-Digest
Perl-Users Digest, Issue: 1994 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Oct 24 00:10:34 2001
Date: Tue, 23 Oct 2001 21:10:15 -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: <1003896615-v10-i1994@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 23 Oct 2001 Volume: 10 Number: 1994
Today's topics:
Regular expression stumps me ... (Marlon Jackson)
Re: Regular expression stumps me ... <mikesl@wrq.com>
Re: Regular expression stumps me ... <lmaddox@us.ibm.com>
Remove Duplicate <blnukem@hotmail.com>
Re: Remove Duplicate <Jon.Ericson@jpl.nasa.gov>
Re: Remove Duplicate <tony_curtis32@yahoo.com>
Re: SDBM_File size limit? <goldbb2@earthlink.net>
Re: Skipping following lines if the same <iltzu@sci.invalid>
Style: error/exception handling? <dlc-usenet@halibut.com>
Re: Style: error/exception handling? <persicom@acedsl.com>
Re: Style: error/exception handling? (Garry Williams)
Re: text/html message <dave@dave.org.uk>
Re: text/html message <tintin@snowy.calculus>
Re: ualarm() emulation on win32 <goldbb2@earthlink.net>
Re: What the **** is WRONG with this!? <me@REMOVETHIStoao.net>
Re: What the **** is WRONG with this!? <me@REMOVETHIStoao.net>
Re: What the **** is WRONG with this!? <me@REMOVETHIStoao.net>
Re: What the **** is WRONG with this!? <tony_curtis32@yahoo.com>
Re: What the **** is WRONG with this!? (Jason Kohles)
Re: What the **** is WRONG with this!? <me@REMOVETHIStoao.net>
Re: What the **** is WRONG with this!? <me@REMOVETHIStoao.net>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 23 Oct 2001 16:44:23 -0700
From: marlon_jackson@yahoo.com (Marlon Jackson)
Subject: Regular expression stumps me ...
Message-Id: <a1899594.0110231544.6e9af95d@posting.google.com>
I can't figure out what this line does:
$build_dir =~ s|^.*/$source_root/||o;
It seems like it's doing a substitution with an "o" modifier. But I
don't know what the pipe chars do here. Aren't those usually used as
ORs?
Thanks, Marlon
------------------------------
Date: Wed, 24 Oct 2001 00:01:54 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: Re: Regular expression stumps me ...
Message-Id: <m3bsixewi5.fsf@thneed.na.wrq.com>
marlon_jackson@yahoo.com (Marlon Jackson) writes:
>I can't figure out what this line does:
>
> $build_dir =~ s|^.*/$source_root/||o;
>
>It seems like it's doing a substitution with an "o" modifier. But I
>don't know what the pipe chars do here. Aren't those usually used as
>ORs?
>
>Thanks, Marlon
The substitute operator accepts other characters (besides / ) to
delimit the match-regexp and the replacement-regexp. This is handy
when (as in the above instance) you're trying to match a string
containing "/" characters.
The above is equivalent to
$build_dir =~ s/^.*\/$source_root\///o;
Where the / is again the delimiter, and the actual / chars we're
trying to match must be preceeded with backslashes.
I'm pretty sure this is in the FAQ somewhere, and I'm sure one of the
more experienced Perl folks is anxious to tell you where to look.
-Mike
------------------------------
Date: 23 Oct 2001 19:01:12 -0500
From: Ren Maddox <lmaddox@us.ibm.com>
Subject: Re: Regular expression stumps me ...
Message-Id: <m34ropykhj.fsf@dhcp9-161.support.tivoli.com>
On 23 Oct 2001, marlon_jackson@yahoo.com wrote:
> I can't figure out what this line does:
>
> $build_dir =~ s|^.*/$source_root/||o;
>
> It seems like it's doing a substitution with an "o" modifier. But I
> don't know what the pipe chars do here. Aren't those usually used as
> ORs?
See the "Quote and Quote-like Operators" section of perlop(1) for a
full explanation, but basically, you can use any delimiters you want
in place of the slashes. So "s|||" is the same as "s///".
Note that "|" is not a particularly good choice as it has special
meaning within a regex, as you've noted. I find "#", or even just
paired braces ("s{}{}"), to be more useful. (One caveat with using
"#" is that you cannot put a space before it like you can with any
other delimiter.)
--
Ren Maddox
lmaddox@us.ibm.com
------------------------------
Date: Tue, 23 Oct 2001 23:47:04 GMT
From: "Blnukem" <blnukem@hotmail.com>
Subject: Remove Duplicate
Message-Id: <YjnB7.51660$wS2.6836994@news02.optonline.net>
Hi group
Without using any modules what would be the easiest way to remove duplicate
item out of flat file and assign the new value as the most current value.
Example say a user of John wants to change his address value it would remove
the first and use the new value for john in the flat file?
name|address
name|address
name|address
------------------------------
Date: 23 Oct 2001 17:46:40 +0000
From: Jon Ericson <Jon.Ericson@jpl.nasa.gov>
Subject: Re: Remove Duplicate
Message-Id: <86itd6gsfz.fsf@jon_ericson.jpl.nasa.gov>
"Blnukem" <blnukem@hotmail.com> writes:
> Without using any modules what would be the easiest way to remove
^^^^^^^^^^^^^^^^^^^^^^^^^
> duplicate item out of flat file and assign the new value as the most
> current value. Example say a user of John wants to change his
> address value it would remove the first and use the new value for
> john in the flat file?
>
> name|address
> name|address
> name|address
I was all ready to answer, but after re-reading, I guess I can't help
you.
Jon
--
"Consider carefully what you hear," he continued. "With the measure
you use, it will be measured to you--and even more. Whoever has
will be given more; whoever does not have, even what he has will be
taken from him." -- Mark 4:24-25 (NIV)
------------------------------
Date: Tue, 23 Oct 2001 21:28:18 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Remove Duplicate
Message-Id: <87y9m1kbzx.fsf@limey.hpcc.uh.edu>
>> On Tue, 23 Oct 2001 23:47:04 GMT,
>> "Blnukem" <blnukem@hotmail.com> said:
> Hi group Without using any modules what would be the
Uh oh, homework item!??
> easiest way to remove duplicate item out of flat file
> and assign the new value as the most current value.
> Example say a user of John wants to change his address
> value it would remove the first and use the new value
> for john in the flat file?
perldoc -q duplicate
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: Tue, 23 Oct 2001 21:36:16 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: SDBM_File size limit?
Message-Id: <3BD61B10.2B01CAA2@earthlink.net>
Bing Du wrote:
>
> Running the Perl script attached below returns the following error:
>
> "sdbm store returned -1, errno 22, key "memo" at ./z.cgi line xxx."
>
> Basically, the scripts tries to store a hash with only one key 'memo'
> into a SDBM database and then retrieve it right away. But it failed
> when writing. Seems there is not any problem if the text written is
> not very long.
>
> Does SDBM have any size limit on each field?
It's possible... Here's a smaller script which reproduces the problem:
#!/usr/local/bin/perl -w
use strict;
use SDBM_File;
use Fcntl qw(O_RDWR O_CREAT);
MAIN; {
tie my(%specific), "SDBM_File", "z", O_RDWR|O_CREAT, 0644
or die "Unable to create SDBM file 'z': $!";
for( 1000 .. 10000 ) {
print $_,"\n";
$specific{memo} = "x" x $_;
}
}
__END__
This produces the output:
1000
1001
1002
1003
1004
1005
sdbm store returned -1, errno 22, key "memo" at x.pl line 11.
--
Klein bottle for rent - inquire within.
------------------------------
Date: 23 Oct 2001 23:27:00 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: Skipping following lines if the same
Message-Id: <1003879056.19322@itz.pp.sci.fi>
In article <3BD4BD4F.97302A15@earthlink.net>, Benjamin Goldberg wrote:
>
>[untested]:
>my %seen;
>while(<IN>) {
> next if exists $seen{$_} && $seen{$_} == $. - 1;
> print;
> $seen{$_} = $.;
>}
I think the OP said he's "got this array", not a file. Your answer can
of course be adapted, but why not try the version in perlfaq4?
$prev = "not equal to $in[0]";
@out = grep($_ ne $prev && ($prev = $_, 1), @in);
Actually, looking more closely, it seems to me we're solving different
problems. An even closer look suggest that your solution at least is
not quite what the OP had in mind, since his example shows three
consecutive identical lines/entries collapsed into one -- the
description is too vague to tell if mine behaves like he wants or not.
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Wed, 24 Oct 2001 01:54:12 -0000
From: Dave Carmean <dlc-usenet@halibut.com>
Subject: Style: error/exception handling?
Message-Id: <ttc7q4p56cen84@corp.supernews.com>
X-Pseudo-Keywords:
relative-perl-newbie-although-I've-hacked-some-short-CGIs-and-scripts,
non-programmer-unix-admin,
don't-have-time-to-learn-a-different-language-for-this-project,
probably-don't-have-time-to-turn-it-into-an-object-oriented-script,
yes-I-know-RFC-2181-supercedes-these-criteria,
please-don't-laugh-at-my-code :o)
Greetings, gurus:
I'm struggling with a basic stylistic question, I guess, of
how to report and handle errors within functions I'm writing,
especially when trying to stick to the Perl idom "$result =
function($args) or die". For example, here's a function which
can fail in two "normal" ways:
sub isvalid_rfc_1035_label ($) {
if ( length ( my $label = shift ) > 63 ) {
return # but would like to know why....
} elsif ( $label !~ /^[a-z][a-z0-9-]*[a-z0-9]+$/i ) {
return # Same "but" here
} else { return $label }
}
Now, this function might be used by itself to check short
hostnames, but it's also called from another function named
isvalid_rfc_1035_fqdn(), which itself might fail for reasons
other than the above.
I guess either of these failures, in the scope of the function itself,
is what the docs call a "nonabortive" failure, and so a bare
return is probably "proper". But I'd like to be able to tell
the user /why/ the domain name formatting was invalid.
I see at least five choices:
1: Take the BOFH route and not report in such detail,
2: Use a global "nonabortive failure message" thingy like
*NA_Failure and have the calling code deal with it if
the function returns a null, but die/croak right in the
function if the error is "really bad". (Glob is because
I can see uses for a string, an array, or even a hash
where the equivalent of ERRNO is the key and the value
is a severity level.)
3: Don't bother with the bare return on error: just throw
an exception on just about every error and count on
having to call it in an eval {} for all but very simple
hacks. But then this requires me to do a match on $@ to
see if it's one I know how to handle; I worry about
scaleability of this.
4: Always return a list, with the first element being an
error code. Kind of breaks the "function or die" paradigm,
and kind of makes prototyping useless since they don't
behave like built-ins any longer.
5: Find some kind of module that allows me to throw "typed"
exceptions. (Which I think I understand, but remember, I'm
not really a programmer; I'm also trying to minimize use
of non-perl-dist modules.)
I seem to be stuck on this question, not wanting to proceed
until I'm satisfied I have a "scaleable" error handling style
that will work for both simple scripts and for modules, whether
running either command-line or as a CGI. (Maybe I've got an
unreasonable "reuseability" expectation without the skill level
to fulfil it.)
I've done a fair bit of RTFM and STFW on this, but haven't been
able to synthesize an answer for myself from all I've found. Any
recommendations greatly appreciated.
------------------------------
Date: Tue, 23 Oct 2001 22:35:59 -0400
From: "Matthew O. Persico" <persicom@acedsl.com>
Subject: Re: Style: error/exception handling?
Message-Id: <3BD6290F.50806@acedsl.com>
Dave Carmean wrote:
> X-Pseudo-Keywords:
> relative-perl-newbie-although-I've-hacked-some-short-CGIs-and-scripts,
> non-programmer-unix-admin,
> don't-have-time-to-learn-a-different-language-for-this-project,
> probably-don't-have-time-to-turn-it-into-an-object-oriented-script,
> yes-I-know-RFC-2181-supercedes-these-criteria,
> please-don't-laugh-at-my-code :o)
Funny.
> Greetings, gurus:
>
> I'm struggling with a basic stylistic question, I guess, of
> how to report and handle errors within functions I'm writing,
> especially when trying to stick to the Perl idom "$result =
> function($args) or die". For example, here's a function which
> can fail in two "normal" ways:
>
> sub isvalid_rfc_1035_label ($) {
> if ( length ( my $label = shift ) > 63 ) {
> return # but would like to know why....
> } elsif ( $label !~ /^[a-z][a-z0-9-]*[a-z0-9]+$/i ) {
> return # Same "but" here
> } else { return $label }
> }
>
> Now, this function might be used by itself to check short
> hostnames, but it's also called from another function named
> isvalid_rfc_1035_fqdn(), which itself might fail for reasons
> other than the above.
>
> I guess either of these failures, in the scope of the function itself,
> is what the docs call a "nonabortive" failure, and so a bare
> return is probably "proper". But I'd like to be able to tell
> the user /why/ the domain name formatting was invalid.
>
> I see at least five choices:
>
> 1: Take the BOFH route and not report in such detail,
BZZZZT. You'll pull your hair out when debugging without such detail.
>
> 2: Use a global "nonabortive failure message" thingy like
> *NA_Failure and have the calling code deal with it if
> the function returns a null, but die/croak right in the
> function if the error is "really bad". (Glob is because
> I can see uses for a string, an array, or even a hash
> where the equivalent of ERRNO is the key and the value
> is a severity level.)
DING. Used with success in DBI modules, but only as a last resort.
Individual connection or prepared query object have their own $err and
$errstr variables. The global $DBI::err and $DBI:errstr are used
primarily when an object fails to be created.
>
> 3: Don't bother with the bare return on error: just throw
> an exception on just about every error and count on
> having to call it in an eval {} for all but very simple
> hacks. But then this requires me to do a match on $@ to
> see if it's one I know how to handle; I worry about
> scaleability of this.
DING. Welcome to Java. No, seriously, you have to handle the errors no
matter what you do; traditionally, if a function returns false, you have
to do sonething OR if it returns a non-zero, it might be an error code
that has to be examined. Don't let the $@ semantics trick you into
thinking you're doing any more work by using it.
In order to help you, each function should have a limited number of
errors it can throw as part of its defined interface. If you start
coding and you find there are too many errors to deal with, then your
function does too much. Break it up into sub-funcs, call the sub-funcs
from the original funcs and handle the errors within. Consider stacking
the errors. When you get an error, push a new more general one on a
stack someplace and throw the general one. Keep doing this. At the
topmost level, print the stack of errors and die. Kind of like 'croak'
from Carp.pm.
>
> 4: Always return a list, with the first element being an
> error code. Kind of breaks the "function or die" paradigm,
> and kind of makes prototyping useless since they don't
> behave like built-ins any longer.
>
BZZZT. For the reasons you mention plus its sheer ugliness.
> 5: Find some kind of module that allows me to throw "typed"
> exceptions. (Which I think I understand, but remember, I'm
> not really a programmer; I'm also trying to minimize use
> of non-perl-dist modules.)
>
http://search.cpan.org/search?mode=module&query=exception
http://search.cpan.org/search?mode=module&query=catch
Why minimize use of non-dist modules? CPAN is your friend.
--
Matthew O. Persico
http://www.acecape.com/dsl
AceDSL:The best ADSL in Verizon area
------------------------------
Date: Wed, 24 Oct 2001 03:09:00 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: Style: error/exception handling?
Message-Id: <slrn9tcc6b.pp7.garry@zfw.zvolve.net>
On Wed, 24 Oct 2001 01:54:12 -0000, Dave Carmean
<dlc-usenet@halibut.com> wrote:
> I'm struggling with a basic stylistic question, I guess, of
> how to report and handle errors within functions I'm writing,
> especially when trying to stick to the Perl idom "$result =
> function($args) or die". For example, here's a function which
> can fail in two "normal" ways:
>
> sub isvalid_rfc_1035_label ($) {
> if ( length ( my $label = shift ) > 63 ) {
> return # but would like to know why....
> } elsif ( $label !~ /^[a-z][a-z0-9-]*[a-z0-9]+$/i ) {
> return # Same "but" here
> } else { return $label }
> }
>
> Now, this function might be used by itself to check short
> hostnames, but it's also called from another function named
> isvalid_rfc_1035_fqdn(), which itself might fail for reasons
> other than the above.
>
> I guess either of these failures, in the scope of the function itself,
> is what the docs call a "nonabortive" failure, and so a bare
> return is probably "proper". But I'd like to be able to tell
> the user /why/ the domain name formatting was invalid.
>
> I see at least five choices:
[ snip ]
> 5: Find some kind of module that allows me to throw "typed"
> exceptions. (Which I think I understand, but remember, I'm
> not really a programmer; I'm also trying to minimize use
> of non-perl-dist modules.)
If you want this alternative, you can make your own module. Just
throw an object:
#!/usr/bin/perl
use warnings;
use strict;
package My_error;
sub new {
my ($class, $msg) = @_;
bless \$msg, $class;
}
sub perr {
print "failure: ${$_[0]}\n";
}
package main;
sub isvalid_rfc_1035_label ($) {
if ( length ( my $label = shift ) > 63 ) {
die My_error->new("too long");
}
elsif ( $label !~ /^[a-z][a-z0-9-]*[a-z0-9]+$/i ) {
die My_error->new("bad stuff");
}
else {
return $label;
}
}
my $label;
eval { isvalid_rfc_1035_label("2-invalid") };
if ( $@ && ref $@ ) {
$@->perr;
}
elsif ( $@ ) {
die $@;
}
print "$label is valid\n";
__END__
--
Garry Williams
------------------------------
Date: Tue, 23 Oct 2001 23:17:28 +0100
From: Dave Cross <dave@dave.org.uk>
Subject: Re: text/html message
Message-Id: <3BD5EC78.515E87E7@dave.org.uk>
Michael wrote:
>
> with MIMI:Lite, how do I write up a multi-part message
> which is readable for both text-only and html-ready
> email software, so the right format can pop up by itself?
use MIME::Lite;
my $msg = MIME::Lite->new(To => 'you@your.host.com',
Subject => 'Multipart mail',
Type => 'multipart/alternate');
$msg->attach(Type => 'text/plain',
Data => $plain_text_version_of_msg);
$msg->attach(Type => 'text/html',
Data => $html_version_of_message);
$msg->send;
hth,
Dave...
--
Don't dream it... be it
------------------------------
Date: Wed, 24 Oct 2001 08:16:58 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: text/html message
Message-Id: <E0mB7.4$XS7.112751@news.interact.net.au>
"Michael" <min_c_lee@yahoo.com> wrote in message
news:2olB7.2384$Le.60376@sea-read.news.verio.net...
> with MIMI:Lite, how do I write up a multi-part message
> which is readable for both text-only and html-ready
> email software, so the right format can pop up by itself?
Check the mime_postcard example script that comes with MIME::Lite or use the
MIME::Lite:HTML module.
------------------------------
Date: Tue, 23 Oct 2001 22:02:19 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: ualarm() emulation on win32
Message-Id: <3BD6212B.FDD2DD40@earthlink.net>
Steffen Müller wrote:
>
> Hi,
>
> for a project I'm currently working on, I need something similar to
> ualarm() (from Time::HiRes). ualarm() works fine on Unix, but
> unfortunately, it isn't portable to win32 which it needs to be for the
> application.
>
> Can anybody give me a clue about how to implement or emulate such a
> function?
I don't think it's possible. Win32 doesn't have signals. Perl sorta
emulates them for SIGINT and SIGCHLD, but that's as far as it gets.
I would suggest you get cygwin, which *should* allow you to work with
programs which need signals [such as alarm]. I think.
--
Klein bottle for rent - inquire within.
------------------------------
Date: Wed, 24 Oct 2001 02:16:47 GMT
From: "Graham W. Boyes" <me@REMOVETHIStoao.net>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <Xns9143C4443E0BE15497002270367234@24.2.10.79>
Jason Kohles, you are hereby charged with writing the following:
> But you aren't talking to an ftp server, you are talking to a shell,
> otherwise it would have worked.
Ahhhhh...I have much to learn about Linux :)
Graham W. Boyes
--
Health warning: diet soft drinks, Equal sweetener and NutraSweet contain the
artificial sweetener Aspartame WHICH CAN CAUSE CANCER, DIABETES, OBESITY,
EYE DISEASE, PARKINSON'S AND MORE. Read more here: http://www.dorway.com/
------------------------------
Date: Wed, 24 Oct 2001 02:23:10 GMT
From: "Graham W. Boyes" <me@REMOVETHIStoao.net>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <Xns9143C5599744815497002270367234@24.2.10.79>
Jason Kohles, you are hereby charged with writing the following:
> 'mkd' is a dos command, you may have an alias that maps 'mkd' to
> 'mkdir', but those aliases are not accessible when you use system(). I
> think you meant 'mkdir'.
Okay, I have this line:
mkdir "/home/rawvancouver.org/data/forum/test", 777;
It works, but the directory is CHMODed to 411. I tried
mkdir "/home/rawvancouver.org/data/forum/test", 0777; (tip from someone
else)
and it CHMODed it to 775.
Ideas?
Graham W. Boyes
PS=The dos command is "md", not "mkd" :)
--
Health warning: diet soft drinks, Equal sweetener and NutraSweet contain the
artificial sweetener Aspartame WHICH CAN CAUSE CANCER, DIABETES, OBESITY,
EYE DISEASE, PARKINSON'S AND MORE. Read more here: http://www.dorway.com/
------------------------------
Date: Wed, 24 Oct 2001 02:28:58 GMT
From: "Graham W. Boyes" <me@REMOVETHIStoao.net>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <Xns9143C6558B03F15497002270367234@24.2.10.79>
Graham W. Boyes, you are hereby charged with writing the following:
> mkdir "/home/rawvancouver.org/data/forum/test", 0777; (tip from someone
> else)
> and it CHMODed it to 775.
For clarification, I want the directory chmoded so everyone can read, write
and execute stuff in it.
Graham W. Boyes
--
Health warning: diet soft drinks, Equal sweetener and NutraSweet contain the
artificial sweetener Aspartame WHICH CAN CAUSE CANCER, DIABETES, OBESITY,
EYE DISEASE, PARKINSON'S AND MORE. Read more here: http://www.dorway.com/
------------------------------
Date: Tue, 23 Oct 2001 21:32:09 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <87pu7dkbti.fsf@limey.hpcc.uh.edu>
>> On Wed, 24 Oct 2001 02:23:10 GMT,
>> "Graham W. Boyes" <me@REMOVETHIStoao.net> said:
> Okay, I have this line: mkdir
> "/home/rawvancouver.org/data/forum/test", 777;
> It works, but the directory is CHMODed to 411. I tried
> mkdir "/home/rawvancouver.org/data/forum/test", 0777;
Yes, the mode is an octal numeral.
> (tip from someone else) and it CHMODed it to 775.
> Ideas?
perldoc -f umask
hth
t
--
Oh! I've said too much. Smithers, use the amnesia ray.
------------------------------
Date: 24 Oct 2001 02:59:23 GMT
From: usenet@jasonkohles.com (Jason Kohles)
Subject: Re: What the **** is WRONG with this!?
Message-Id: <slrn9tcbgj.3ep.usenet@poseidon.mediabang.com>
On Wed, 24 Oct 2001 02:23:10 GMT, Graham W. Boyes wrote:
>Jason Kohles, you are hereby charged with writing the following:
>
>> 'mkd' is a dos command, you may have an alias that maps 'mkd' to
>> 'mkdir', but those aliases are not accessible when you use system(). I
>> think you meant 'mkdir'.
>
>Okay, I have this line:
>mkdir "/home/rawvancouver.org/data/forum/test", 777;
>
>It works, but the directory is CHMODed to 411. I tried
>mkdir "/home/rawvancouver.org/data/forum/test", 0777; (tip from someone
>else)
>and it CHMODed it to 775.
>
The argument is a permissions mask, and is modified by the umask of the
process that runs it. You could check any beginning unix book to find
out about umask, but basically you need to either make sure your umask
matches what you want the permissions to be, or just change them
afterwards:
umask 0000;
mkdir '/path/to/dir', 0777;
or:
mkdir '/path/to/dir', 0000;
chmod 0777, '/path/to/dir';
'perldoc -f umask' also has a fairly good description of how permissions
interact with umask.
>PS=The dos command is "md", not "mkd" :)
Oh well, I work for Red Hat, I don't use dos if I can possibly avoid it =)
--
Jason S Kohles
email@jasonkohles.com http://www.jasonkohles.com/
------------------------------
Date: Wed, 24 Oct 2001 03:27:47 GMT
From: "Graham W. Boyes" <me@REMOVETHIStoao.net>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <Xns9143D04E2A3C215497002270367234@24.2.10.79>
Jason Kohles, you are hereby charged with writing the following:
> umask 0000;
> mkdir '/path/to/dir', 0777;
ALL RIGHT!! It works! Do I need to change the umask back to like it was
before (whatever that is) after I do the above?
Graham W. Boyes
--
Health warning: diet soft drinks, Equal sweetener and NutraSweet contain the
artificial sweetener Aspartame WHICH CAN CAUSE CANCER, DIABETES, OBESITY,
EYE DISEASE, PARKINSON'S AND MORE. Read more here: http://www.dorway.com/
------------------------------
Date: Wed, 24 Oct 2001 03:40:43 GMT
From: "Graham W. Boyes" <me@REMOVETHIStoao.net>
Subject: Re: What the **** is WRONG with this!?
Message-Id: <Xns9143D27FBA15615497002270367234@24.2.10.79>
Graham W. Boyes, you are hereby charged with writing the following:
>> umask 0000;
> Do I need to change the umask back to like it
> was before (whatever that is) after I do the above?
Never mind, figured out that the umask was originally 2 so will set it back
to that. THANKS SO MUCH!!! Aren't newsgroups great? If you need a
computer hardware question or networking question answered, feel free to
visit 24hoursupport.helpdesk.
Graham W. Boyes
--
Health warning: diet soft drinks, Equal sweetener and NutraSweet contain the
artificial sweetener Aspartame WHICH CAN CAUSE CANCER, DIABETES, OBESITY,
EYE DISEASE, PARKINSON'S AND MORE. Read more here: http://www.dorway.com/
------------------------------
Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 6 Apr 01)
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.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 V10 Issue 1994
***************************************