[23342] in Perl-Users-Digest
Perl-Users Digest, Issue: 5562 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Sep 25 14:10:43 2003
Date: Thu, 25 Sep 2003 11: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)
Perl-Users Digest Thu, 25 Sep 2003 Volume: 10 Number: 5562
Today's topics:
Re: Mapping characters in a string (Alfred von Campe)
Re: Mapping characters in a string (Alfred von Campe)
Re: Mapping characters in a string (Alfred von Campe)
Re: packages <x12code-del@del-yahoo.com>
Passing a directory into $ARGV[0] from a shell script <none@none.com>
Re: Passing a directory into $ARGV[0] from a shell scri <ddunham@redwood.taos.com>
Re: Passing a directory into $ARGV[0] from a shell scri <postmaster@castleamber.com.invalid>
Re: Passing a directory into $ARGV[0] from a shell scri <none@none.com>
Re: Passing a directory into $ARGV[0] from a shell scri <ddunham@redwood.taos.com>
Re: Pattern Matching .... <jurgenex@hotmail.com>
perl "password safe"-like program -- pws.pl (Robert Jacobson)
Re: perl "password safe"-like program -- pws.pl (Anno Siegel)
Perl Par built exe, sometimes it runs, sometimes it doe (Jesse Schoch)
Re: RegExp: Matching (Anno Siegel)
Silly question...move up a directory... <none@none.com>
Re: Silly question...move up a directory... <no.name@eidosnet.co.uk>
Re: Silly question...move up a directory... <none@none.com>
Re: Silly question...move up a directory... <nospam@bigpond.com>
Re: Silly question...move up a directory... <daniel.rawson.take!this!out!@asml.nl>
Re: Silly question...move up a directory... <no.name@eidosnet.co.uk>
Re: Silly question...move up a directory... <none@none.com>
Re: Silly question...move up a directory... <none@none.com>
Re: wtf is the deal? <usenet@dwall.fastmail.fm>
Re: <bwalton@rochester.rr.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 25 Sep 2003 06:39:43 -0700
From: alfred@110.net (Alfred von Campe)
Subject: Re: Mapping characters in a string
Message-Id: <4d599f95.0309250539.6a9b1fa8@posting.google.com>
Uri Guttman <uri@stemsystems.com> wrote:
> slice to the (double) rescue!!
>
> <untested>
>
> my $encoded_md5 = join( '', (split //, $md5_map)[ split //, $md5_digest ] ) ;
Close. I get lots of errors like this:
Argument "^[" isn't numeric in list slice at ./encode.pl line 16.
And then I get a 16 byte string where all the characters are equal to
the first character in the mapping string (position 0), which makes
sense. Including a map to ord as shown in the next post solved the
problem.
Alfred
------------------------------
Date: 25 Sep 2003 06:42:38 -0700
From: alfred@110.net (Alfred von Campe)
Subject: Re: Mapping characters in a string
Message-Id: <4d599f95.0309250542.66b0abaf@posting.google.com>
Abigail <abigail@abigail.nl> wrote:
> Untested:
>
> use bytes; # Just in case.
>
> $digest = "........"; # 16 bytes.
> $chars = "........"; # 256 chars.
>
> my $str = join "" => (split // => $chars) [map {ord} split // => $digest];
Brilliant! This works just as is. BTW, the "use bytes;" is not needed.
Many thanks,
Alfred
------------------------------
Date: 25 Sep 2003 06:44:09 -0700
From: alfred@110.net (Alfred von Campe)
Subject: Re: Mapping characters in a string
Message-Id: <4d599f95.0309250544.13c54fda@posting.google.com>
"John W. Krahn" <krahnj@acm.org> wrote:
> Did you try Digest::MD5::md5_hex() or Digest::MD5::md5_base64() for a
> printable version?
Yes, but that doesn't solve my problem. I need to map it to a
specific sequence of characters to implement an existing algorithm.
Alfred
------------------------------
Date: Thu, 25 Sep 2003 09:17:37 -0500
From: David McDivitt <x12code-del@del-yahoo.com>
Subject: Re: packages
Message-Id: <pjt5nv8qikqt7dvue2fu3i5ua732qnbvdv@4ax.com>
>Subject: Re: packages
>Date: Thu, 25 Sep 2003 06:20:44 GMT
>
>David McDivitt <david-del@del-nonspiritual.com> wrote:
>
>: I am having difficulty understanding packages. I made a package, and
>: figured out how to make variables visible to modules using it without
>: qualifying with the package name, but exposing package subroutines the
>: same way is a bit confusing.
>
>It shouldn't be. For purposes of poking around in the symbol table, the
>only difference between a variable and a subroutine is the funny sigil
>in front of the name.
>
>If you show how you're exporting variables from one namespace to
>another, you can see how the same technique can export a subroutine.
I have it commented out where I tried to include a function name. All but
one function was removed for brevity. Thanks
package DGM;
use warnings;
use strict;
use CGI qw(:standard);
# use vars qw($MicrosoftTimeDiff %passed problem);
use vars qw($MicrosoftTimeDiff %passed);
$MicrosoftTimeDiff = \2209161600;
%passed;
my ($fontsize, $buttonsize, $buttonprop, $tdprop);
1;
sub problem {
print '<br>',shift(),"\n",'</body></html>';
exit;
}
------------------------------
Date: Thu, 25 Sep 2003 16:12:15 GMT
From: "John" <none@none.com>
Subject: Passing a directory into $ARGV[0] from a shell script
Message-Id: <ztEcb.122817$bo1.36547@news-server.bigpond.net.au>
Hi,
One other Q for tonite. I just realised a little nuisance...
My shell script does some things and when it finds a particular file it
calls a perl script [from within the shell script] like this:
change.pl . myfile.txt << 2 command line parameters, a directory [DOT] and
a filename
I wanted . to reflect the working directory of the file that that needs to
be edited. Since my shell script has already descended into the file's
directory then there is no need to pass any other directory to the perl
script. Hence, I wanted to use . [DOT] as I don't really want to change the
directories at this point.
But my perl script dies due to the following line in its contents:
chdir '$ARGV[0]' || die "Cannot chdir to: $!\n";
On the other hand, if I want to run the perl script on its own, I need to be
able to give it some sort of a directory - hence the $ARGV[0].
If I remove the DIE option both scripts run together as expected. Am I doing
something wrong? Why is the perl script unable to chdir '.'?
Thank you.
------------------------------
Date: Thu, 25 Sep 2003 16:27:21 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Passing a directory into $ARGV[0] from a shell script
Message-Id: <JHEcb.3003$I81.1231@newssvr29.news.prodigy.com>
John <none@none.com> wrote:
> Hi,
> My shell script does some things and when it finds a particular file it
> calls a perl script [from within the shell script] like this:
> change.pl . myfile.txt << 2 command line parameters, a directory [DOT] and
> a filename
Windows or other OS?
> I wanted . to reflect the working directory of the file that that needs to
> be edited. Since my shell script has already descended into the file's
> directory then there is no need to pass any other directory to the perl
> script. Hence, I wanted to use . [DOT] as I don't really want to change the
> directories at this point.
> But my perl script dies due to the following line in its contents:
> chdir '$ARGV[0]' || die "Cannot chdir to: $!\n";
1) '$ARGV[0]' is single quotes and will not be interpolated.
2) Did you check the value of ARGV[0] as sane before chdiring?
3) I see no point in your post where you show the output of that line,
including the valued of $!. The message would likely help understand
why the chdir is failing.
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Thu, 25 Sep 2003 18:49:37 +0200
From: John Bokma <postmaster@castleamber.com.invalid>
Subject: Re: Passing a directory into $ARGV[0] from a shell script
Message-Id: <1064508704.877870@halkan.kabelfoon.nl>
John wrote:
> But my perl script dies due to the following line in its contents:
> chdir '$ARGV[0]' || die "Cannot chdir to: $!\n";
^^^^^^^^^^
You chdir to '$ARGV[0]' and I am sure you don't have a dir with that
name. Better:
my $dir = shift; # get first arg
die "no dir" unless defined $dir;
chdir($dir) or die "Can not chdir to '$dir': $!\n";
Always put as much info in the die as possible, especially the
parameters you passed to the thingy that failed.
--
Kind regards, virtual home: http://johnbokma.com/ ICQ: 218175426
web site hints: http://johnbokma.com/websitedesign/
John I count my toes ~ one to ten ~ I meditate ~ and feel the Zen
------------------------------
Date: Thu, 25 Sep 2003 17:12:08 GMT
From: "John" <none@none.com>
Subject: Re: Passing a directory into $ARGV[0] from a shell script
Message-Id: <IlFcb.122829$bo1.15130@news-server.bigpond.net.au>
"Darren Dunham" <ddunham@redwood.taos.com> wrote in message
news:JHEcb.3003$I81.1231@newssvr29.news.prodigy.com...
> John <none@none.com> wrote:
> > Hi,
>
>
> > My shell script does some things and when it finds a particular file it
> > calls a perl script [from within the shell script] like this:
> > change.pl . myfile.txt << 2 command line parameters, a directory [DOT]
and
> > a filename
>
> Windows or other OS?
>
> > I wanted . to reflect the working directory of the file that that needs
to
> > be edited. Since my shell script has already descended into the file's
> > directory then there is no need to pass any other directory to the perl
> > script. Hence, I wanted to use . [DOT] as I don't really want to change
the
> > directories at this point.
>
> > But my perl script dies due to the following line in its contents:
> > chdir '$ARGV[0]' || die "Cannot chdir to: $!\n";
>
> 1) '$ARGV[0]' is single quotes and will not be interpolated.
> 2) Did you check the value of ARGV[0] as sane before chdiring?
> 3) I see no point in your post where you show the output of that line,
> including the valued of $!. The message would likely help understand
> why the chdir is failing.
>
> --
> Darren Dunham ddunham@taos.com
> Unix System Administrator Taos - The SysAdmin Company
> Got some Dr Pepper? San Francisco, CA bay area
> < This line left intentionally blank to confuse you. >
Darren,
OS = Solaris
1) Of course. This gives me no error, the script runs and does 85% of the
work. :)
Where it's failing is that it still cannot change the permissions of the
directory that the edited file is in UNLESS I remove the DIE extension.
I'll have a look at it tomorrow - a printout may help.
2) Value seems OK as passed from the shell script. ie.: $ARGV[0] holds .
[DOT]
3) Hmmm...I guess so :(
Thanks
J
------------------------------
Date: Thu, 25 Sep 2003 18:02:37 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: Passing a directory into $ARGV[0] from a shell script
Message-Id: <15Gcb.9321$IH2.7446@newssvr25.news.prodigy.com>
I'm a bit confused, so let me review your response here..
John <none@none.com> wrote:
> "Darren Dunham" <ddunham@redwood.taos.com> wrote in message
> news:JHEcb.3003$I81.1231@newssvr29.news.prodigy.com...
>> John <none@none.com> wrote:
>> > But my perl script dies due to the following line in its contents:
>> > chdir '$ARGV[0]' || die "Cannot chdir to: $!\n";
>>
>> 1) '$ARGV[0]' is single quotes and will not be interpolated.
> 1) Of course. This gives me no error, the script runs and does 85% of the
> work. :)
What does that mean, and what does that have to do with the fact that
you almost certainly want $ARGV[0] instead of '$ARGV[0]'.
> Where it's failing is that it still cannot change the permissions of the
> directory that the edited file is in UNLESS I remove the DIE extension.
> I'll have a look at it tomorrow - a printout may help.
Change permissions? That has nothing to do with the code you've shown.
the '$ARGV[0]' is *wrong*. Remove the single quotes. It is unnecessary
to quote a single scalar variable, and in your case it's causing you
problems.
chdir $ARGV[0] ....
--
Darren Dunham ddunham@taos.com
Unix System Administrator Taos - The SysAdmin Company
Got some Dr Pepper? San Francisco, CA bay area
< This line left intentionally blank to confuse you. >
------------------------------
Date: Thu, 25 Sep 2003 14:36:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Pattern Matching ....
Message-Id: <54Dcb.11514$ZR1.5160@nwrddc01.gnilink.net>
MJS wrote:
> How can the following pattern be matched and replaced by something
> similar to it.
Ok, so far so good
> After the pattern has been replaced, the replacing
> pattern is repeating itself for certain number of times.
Don't understand that part at all. Are you saying that the matched text
should be replaced by x copies of the new text?
Or are you saying the new text occures several times in the original file.
But then would should be done to it, should it be ignored or deleted or
replaced or ...?
Or do you mean something completely different?
>
> "The puzzle is :
>
> go to your left=> continue
>
> go to your right <= [ 20: 909]
> continue[7:0] "
>
>
> move.
>
> This is how exactly how the text is written(including the spaces).
>
> I can't figure out how to do it. Please help.
>
> I tried something like this and didn't work:
>
> ===========================================================
> # tie @array to filename using Tie::File
> tie my @array, 'Tie::File', 'result.txt' or die "Cannot open
> result.txt:$!";
>
> while(<reading the text file>){
Is your file handle really called 'reading the text file'? I would have
assumed this would yield a syntax error?
And while I've never used Tie::File myself it is my understanding that
Tie::File already ties the file's content to the array. Why are you reading
the content of the file again in the while loop (if that is what you are
trying to do; you are not showing your real code, so at best this is a
guess). I think this is just superfluous and I don't know if it will
interfere with Tie::File.
> for($firstindex; $firstindex >= 0; $firstindex--){
You never declare or define $firstindex. You are using strictures and
warnings, aren't you? They should have told you that this line won't work.
And you are not using $firstindex anywhere in your code anyway. If you want
a loop to repeat e.g. 50 times then just say so:
for (0..49) {
> $n++;
What is this $n doing here? You never ever use $n anywhere else in your
code.
> for ( 0 .. $#array ) {
It appears you are only interested in the content of the array, why do you
need the index? A simple
for (@array) {
should be easier to manage.
> my $string ="the above mentioned pattern"
> if ( $array[ $_ ] =~ /string/ ) {
Then this line becomes
if (/$string/) {...
> my $new_string= some similar pattern.
This doesn't even compile, syntax error.
Maybe you meant
my $new_string= 'some similar pattern.';
> splice @array, $_ +1, 0, /the_string/;
> last;
What the heck are these two lines supposed to do?
At the beginning you said you want to replace a pattern with some text.
Well, then just do so:
s/$string/$new_string/;
From your description I can't tell if maybe you need the "g" modifier, too.
In any case, that should replace the
jue
------------------------------
Date: 25 Sep 2003 09:06:36 -0700
From: q2m3eft02@sneakemail.com (Robert Jacobson)
Subject: perl "password safe"-like program -- pws.pl
Message-Id: <8f82078d.0309250806.5f44bd97@posting.google.com>
Hi,
On a Windows platform, I typically use the program "Password Safe" to
keep all my passwords. But, as it only works on Windows, I was
looking for a cross-platform solution.
I wrote a program (below) that has the basic functionality of the
program -- it stores your passwords in a database, encrypting both the
keys (except the KEYCHECK key) and the values with blowfish. I guess
someone could brute-force the password by encrypting the string
"JUSTCHECKING" with blowfish, trying a bunch of different passphrases.
How long would that take, assuming, say, an 16 characters passphrase?
Also, the passphrase to encrypt/decrypt is obviously stored in memory.
I don't think there's a way around this -- but how easy would it be
to get it out of memory? AFAIK, the Windows version also stores the
password in memory.
I'm pretty new at perl, so I had hoped someone here could tell me
whether my program really was as secure as I thought. The script is
below. Hold no punches (polite punches appreciated :-D ), tell me how
it is. What works, what doesn't work... whatever.
---BEGIN script---
#!/usr/bin/perl
#------------------------------------------------------------------------
# pws.pl
#"password safe"-like program in perl
# released under the BSD license
# Copyright (c) 2003, Robert Jacobson
# All rights reserved.
#------------------------------------------------------------------------
use Crypt::CBC;
use Term::ReadKey;
$SIG{INT} = clean_up;
sub clean_up {
print "Caught SIGINT, cleaning up...\n";
dbmclose(%PWS) or die "could not close database: $!";
ReadMode 0;
exit;
}
# I have no idea how to use "tie", so I'm stuck with dbm...
dbmopen(%PWS,"pws",0600) or die "Could not open database: $!";
# hash key by title, record contains
# login, pass, notes(??)
$JOIN = " "; # That's a tab, not a space
#Check for correct password
if ($PWS{KEYCHECK} eq "") {
# New database
$keymatch = 0;
while ($keymatch == 0) {
$key = "";
while (length($key) < 8) {
print "Enter new database key: ";
ReadMode 2;
chomp($key = ReadLine);
ReadMode 0;
print "\n";
if (length($key) < 8) {print "Too short\n";}
}
print "Confirm database key: ";
ReadMode 2;
chomp($key2 = ReadLine);
ReadMode 0;
print "\n";
if ("$key" ne "$key2") {
print "Keys don't match, try again\n";
} else {
$keymatch = 1;
}
}
print "Creating database...";
# Create a entry just for checking right key
$plaintext = "JUSTCHECKING";
$cipher = Crypt::CBC->new( {'key' => "$key",
'cipher' => 'Blowfish'} );
$ciphertext = $cipher->encrypt($plaintext);
$PWS{KEYCHECK} = "$ciphertext";
print "\n";
} else {
# Existing database
print "Enter key to database: ";
ReadMode 2;
chomp($key = ReadLine);
ReadMode 0;
print "\n";
# Check for right key
$cipher = Crypt::CBC->new( {'key' => "$key",
'cipher' => 'Blowfish'} );
$plaintext = $cipher->decrypt($PWS{KEYCHECK});
if ($plaintext eq "JUSTCHECKING") {
#print "That's right\n";
} else {
print "incorrect key\n";
dbmclose(%PWS);
exit;
}
}
while (1) {
print "Options:\n";
print "\t1. New Entry\n";
print "\t2. Read Entry\n";
print "\t3. Delete Entry\n";
print "\t4. Exit\n";
print "\nWhich? ";
chomp ($choice = <STDIN>);
if ($choice == 1) {&new_entry};
if ($choice == 2) {&read_entry};
if ($choice == 3) {&delete_entry};
if ($choice == 4) {
dbmclose(%PWS);
exit;
}
}
sub new_entry {
print "Enter title: ";
chomp($title = <STDIN>);
print "Enter login: ";
chomp($login = <STDIN>);
$match = 0;
while ($match == 0) {
$pass1 = "";
print "Enter pass: ";
ReadMode 2;
chomp($pass1 = ReadLine);
ReadMode 0;
print "\n";
print "confirm pass: ";
ReadMode 2;
chomp($pass2 = ReadLine);
ReadMode 0;
print "\n";
#confirm they match
if ("$pass1" ne "$pass2") {
print "They don't match,try again!\n";
} else {
$match = 1;
}
}
&encrypt_string;
#Even the hash key (title) is encrypted
$encrypted_title = $cipher->encrypt("$title");
$PWS { $encrypted_title } = "$ciphertext";
}
sub read_entry {
$showall = 0;
print "Enter title (blank for all entries without passwords): ";
chomp($title = <STDIN>);
if ($title eq "") {
$showall = 1;
} else {
$encrypted_title = $cipher->encrypt("$title");
}
print "\n";
print "Title login\tpass\n";
print "----- -----\t----\n";
for $encrypted_titles (sort keys %PWS) {
#print "key is $encrypted_titles\n";
next if $encrypted_titles eq KEYCHECK;
unless ($showall) {
#print "skipping\n";
next if "$encrypted_titles" ne "$encrypted_title";
}
$plain_title = $cipher->decrypt("$encrypted_titles");
$plaintext = $cipher->decrypt("$PWS{$encrypted_titles}");
if ($showall) {
# Dont show the password
$plaintext =~ s/\t.*/\tHIDDEN/;
}
printf("%-21s%s\n",$plain_title,$plaintext);
}
print "\n";
}
sub delete_entry {
print "Enter title to delete: ";
chomp($title = <STDIN>);
$encrypted_title = $cipher->encrypt("$title");
delete($PWS { $encrypted_title });
}
sub encrypt_string {
# Blowfish encrypt the information
$string_to_encrypt = "$login" . "$JOIN" . "$pass1";
$ciphertext = $cipher->encrypt("$string_to_encrypt");
return 1;
}
------------------------------
Date: 25 Sep 2003 17:17:28 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: perl "password safe"-like program -- pws.pl
Message-Id: <bkv7v8$q2q$1@mamenchi.zrz.TU-Berlin.DE>
Robert Jacobson <q2m3eft02@sneakemail.com> wrote in comp.lang.perl.misc:
> Hi,
>
> On a Windows platform, I typically use the program "Password Safe" to
> keep all my passwords. But, as it only works on Windows, I was
> looking for a cross-platform solution.
>
> I wrote a program (below) that has the basic functionality of the
> program -- it stores your passwords in a database, encrypting both the
> keys (except the KEYCHECK key) and the values with blowfish. I guess
> someone could brute-force the password by encrypting the string
> "JUSTCHECKING" with blowfish, trying a bunch of different passphrases.
> How long would that take, assuming, say, an 16 characters passphrase?
>
> Also, the passphrase to encrypt/decrypt is obviously stored in memory.
> I don't think there's a way around this -- but how easy would it be
> to get it out of memory? AFAIK, the Windows version also stores the
> password in memory.
Sorry to be so blunt, but when you have to ask these questions on Usenet,
you are not enough of a security expert to publish security-related
software. The copyright and license comments in the code below makes me
think you intend to distribute the program in some way.
> I'm pretty new at perl,
Another reason not to distribute sensitive software.
> so I had hoped someone here could tell me
> whether my program really was as secure as I thought. The script is
> below. Hold no punches (polite punches appreciated :-D ), tell me how
> it is. What works, what doesn't work... whatever.
It is your program, and you will have to account for it. Even if someone
here certified your program as flawless, (no-one sane will), what would
you have gained?
Use the program for yourself for a while. Try to crack it. Make it weaker
until you *can* crack it. Read about computer security, if your interest
goes that way. After a some of this you may develop a sense for the
quality of your program.
[code snipped]
Anno
------------------------------
Date: 25 Sep 2003 10:32:12 -0700
From: greenail@yahoo.com (Jesse Schoch)
Subject: Perl Par built exe, sometimes it runs, sometimes it doesn't
Message-Id: <9de9fcb4.0309250932.64841bfc@posting.google.com>
I have a client that i wrote and built into a .exe with pp. I have
tested it on Win2k, WinXP, Win98, WinME, but for some reason on WinNT
4.0 SP3 and SP6a it sometimes runs, and sometimes does not.
The perl58.dll I uses is from the tiny perl distribution, I have tried
the active state dll with no change in behavior, it doesn't even throw
an error when it decides not to run, it takes about 3 tries, and then
it will run fine, no problem, but if i re-run it will crap out with no
error whatsoever.
Any Ideas on how I might troubleshoot this?
Any possible fixes?
-greenail
------------------------------
Date: 25 Sep 2003 13:14:16 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: RegExp: Matching
Message-Id: <bkupn8$fp4$3@mamenchi.zrz.TU-Berlin.DE>
[posted and mailedsnd.no]
Tore Aursand <tore@aursand.no> wrote in comp.lang.perl.misc:
> On Tue, 23 Sep 2003 10:35:40 +0000, Anno Siegel wrote:
> > Indeed. In Perl, this would be a typical case where a single-regex
> > match is possible, but a combination with other techniques simplifies
> > things.
>
> AFAIK, there's no way I can accomplish what I'm trying to do without doing
> all this matching in _one_ regular expression.
>
> Your regexp works _perfect_ in Perl, but doesn't seem to do the same in
> Apache. Hard to debug in Apache, really, and I don't get any errors or
> warnings when running a test on the configuration file.
Here is another one that doesn't use the lookaround features of
Perl regexes:
m{^(/[^_/][^/]*)*/?$}
It may need some tweaking for marginal cases (double slashes are
probably not treated right), but apache should understand it.
Anno
------------------------------
Date: Thu, 25 Sep 2003 13:06:54 GMT
From: "John" <none@none.com>
Subject: Silly question...move up a directory...
Message-Id: <OLBcb.122662$bo1.37088@news-server.bigpond.net.au>
Sorry, but how does one move up a directory ?
I'm in a directory from which I called a script. Part of the script
functionality is checking the permissions of the directory I am in. I may
need to change the directory permissions depending on what they are. Hence,
I need to be able to move up [and possibly down] one level of the directory
tree.
chdir? Something like cd .. would be nice
Thank you.
------------------------------
Date: Thu, 25 Sep 2003 13:29:52 +0000 (UTC)
From: "D Borland" <no.name@eidosnet.co.uk>
Subject: Re: Silly question...move up a directory...
Message-Id: <bkuqkg$357$1@titan.btinternet.com>
> Sorry, but how does one move up a directory ?
>
> I'm in a directory from which I called a script. Part of the script
> functionality is checking the permissions of the directory I am in. I may
> need to change the directory permissions depending on what they are.
Hence,
> I need to be able to move up [and possibly down] one level of the
directory
> tree.
>
> chdir? Something like cd .. would be nice
You got it chdir
chdir '/home/john/scripts/' or die "Can't cd to /home/john/scripts/: $!\n";
Dagmar
---
This e-mail has been virus scanned and is certified virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/03
------------------------------
Date: Thu, 25 Sep 2003 13:48:59 GMT
From: "John" <none@none.com>
Subject: Re: Silly question...move up a directory...
Message-Id: <fnCcb.122715$bo1.60188@news-server.bigpond.net.au>
"D Borland" <no.name@eidosnet.co.uk> wrote in message
news:bkuqkg$357$1@titan.btinternet.com...
> > Sorry, but how does one move up a directory ?
> >
> > I'm in a directory from which I called a script. Part of the script
> > functionality is checking the permissions of the directory I am in. I
may
> > need to change the directory permissions depending on what they are.
> Hence,
> > I need to be able to move up [and possibly down] one level of the
> directory
> > tree.
> >
> > chdir? Something like cd .. would be nice
>
> You got it chdir
>
> chdir '/home/john/scripts/' or die "Can't cd to /home/john/scripts/:
$!\n";
>
>
> Dagmar
>
>
> ---
> This e-mail has been virus scanned and is certified virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/03
>
>
Dagmar,
Thanks. But if the script does not automatially know which directory it's
in, would I need to pass the full path to it first, then sed it to drop the
last directory and then use chdir on the remaining part from sed? Seems
awfully complicated for such a simple task... :(
Using your example, if the script does not know it's in home/john/scripts/
but I need to move up to home/john, then would I need to use the full path +
sed combo outlined in my first paragraph?
------------------------------
Date: Thu, 25 Sep 2003 23:52:28 +1000
From: Gregory Toomey <nospam@bigpond.com>
Subject: Re: Silly question...move up a directory...
Message-Id: <2332943.eqgHJgPXf2@gregs-web-hosting-and-pickle-farming>
It was a dark and stormy night, and John managed to scribble:
> Sorry, but how does one move up a directory ?
>
> I'm in a directory from which I called a script. Part of the script
> functionality is checking the permissions of the directory I am in. I may
> need to change the directory permissions depending on what they are.
> Hence, I need to be able to move up [and possibly down] one level of the
> directory tree.
>
> chdir? Something like cd .. would be nice
>
> Thank you.
chdir '..';
gtoomey
------------------------------
Date: Thu, 25 Sep 2003 10:16:38 -0400
From: Dan Rawson <daniel.rawson.take!this!out!@asml.nl>
Subject: Re: Silly question...move up a directory...
Message-Id: <bkutc7$6575n$1@ID-122008.news.uni-berlin.de>
John wrote:
> "D Borland" <no.name@eidosnet.co.uk> wrote in message
> news:bkuqkg$357$1@titan.btinternet.com...
>
>>>Sorry, but how does one move up a directory ?
>>>
>>>I'm in a directory from which I called a script. Part of the script
>>>functionality is checking the permissions of the directory I am in. I
>
> may
>
>>>need to change the directory permissions depending on what they are.
>>
>>Hence,
>>
>>>I need to be able to move up [and possibly down] one level of the
>>
>>directory
>>
>>>tree.
>>>
>>>chdir? Something like cd .. would be nice
>>
>>You got it chdir
>>
>>chdir '/home/john/scripts/' or die "Can't cd to /home/john/scripts/:
>
> $!\n";
>
>>
>>Dagmar
>>
>>
>>---
>>This e-mail has been virus scanned and is certified virus Free.
>>Checked by AVG anti-virus system (http://www.grisoft.com).
>>Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/03
>>
>>
>
>
> Dagmar,
> Thanks. But if the script does not automatially know which directory it's
> in, would I need to pass the full path to it first, then sed it to drop the
> last directory and then use chdir on the remaining part from sed? Seems
> awfully complicated for such a simple task... :(
>
> Using your example, if the script does not know it's in home/john/scripts/
> but I need to move up to home/john, then would I need to use the full path +
> sed combo outlined in my first paragraph?
>
>
>
John -
===============
use Cwd;
my $currdir = getcwd();
chdir '..';
....
chdir $currdir;
===============
perldoc Cwd
Dan
------------------------------
Date: Thu, 25 Sep 2003 14:25:09 +0000 (UTC)
From: "D Borland" <no.name@eidosnet.co.uk>
Subject: Re: Silly question...move up a directory...
Message-Id: <bkuts5$7oo$1@titan.btinternet.com>
> Dagmar,
> Thanks. But if the script does not automatially know which directory it's
> in, would I need to pass the full path to it first, then sed it to drop
the
> last directory and then use chdir on the remaining part from sed? Seems
> awfully complicated for such a simple task... :(
>
> Using your example, if the script does not know it's in home/john/scripts/
> but I need to move up to home/john, then would I need to use the full path
+
> sed combo outlined in my first paragraph?
Truthfull depends on exactly what your requirements are, i'm fairly new to
perl myself so my suggestion would probably be to move up a directory you
could just do
chdir '..' or die "$!\n";
to move through the directory you could always use 'opendir' and 'readdir'
to find new directories to explore - see perlfunc man for these functions.
But like i said i'm fairly new to perl and i haven't really thought about it
too much as i'm at work at the moment, but i'm sure there will be something
on CPAN or already in perl in to this better.
Dagmar
---
This e-mail has been virus scanned and is certified virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/03
------------------------------
Date: Thu, 25 Sep 2003 15:32:29 GMT
From: "John" <none@none.com>
Subject: Re: Silly question...move up a directory...
Message-Id: <hUDcb.122802$bo1.42250@news-server.bigpond.net.au>
"D Borland" <no.name@eidosnet.co.uk> wrote in message
news:bkuts5$7oo$1@titan.btinternet.com...
> > Dagmar,
> > Thanks. But if the script does not automatially know which directory
it's
> > in, would I need to pass the full path to it first, then sed it to drop
> the
> > last directory and then use chdir on the remaining part from sed? Seems
> > awfully complicated for such a simple task... :(
> >
> > Using your example, if the script does not know it's in
home/john/scripts/
> > but I need to move up to home/john, then would I need to use the full
path
> +
> > sed combo outlined in my first paragraph?
>
>
> Truthfull depends on exactly what your requirements are, i'm fairly new to
> perl myself so my suggestion would probably be to move up a directory you
> could just do
>
> chdir '..' or die "$!\n";
>
> to move through the directory you could always use 'opendir' and 'readdir'
> to find new directories to explore - see perlfunc man for these functions.
>
> But like i said i'm fairly new to perl and i haven't really thought about
it
> too much as i'm at work at the moment, but i'm sure there will be
something
> on CPAN or already in perl in to this better.
>
> Dagmar
>
>
> ---
> This e-mail has been virus scanned and is certified virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.521 / Virus Database: 319 - Release Date: 9/23/03
>
>
Thanks very much guys! I knew it had to be simple...
------------------------------
Date: Thu, 25 Sep 2003 16:26:31 GMT
From: "John" <none@none.com>
Subject: Re: Silly question...move up a directory...
Message-Id: <XGEcb.122820$bo1.18540@news-server.bigpond.net.au>
"Gregory Toomey" <nospam@bigpond.com> wrote in message
news:2332943.eqgHJgPXf2@gregs-web-hosting-and-pickle-farming...
> It was a dark and stormy night, and John managed to scribble:
>
> > Sorry, but how does one move up a directory ?
> >
> > I'm in a directory from which I called a script. Part of the script
> > functionality is checking the permissions of the directory I am in. I
may
> > need to change the directory permissions depending on what they are.
> > Hence, I need to be able to move up [and possibly down] one level of the
> > directory tree.
> >
> > chdir? Something like cd .. would be nice
> >
> > Thank you.
>
> chdir '..';
>
> gtoomey
Thanks Greg.
------------------------------
Date: Thu, 25 Sep 2003 16:03:51 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: wtf is the deal?
Message-Id: <Xns94017AA6E249dkwwashere@216.168.3.30>
D Borland <no.name@eidosnet.co.uk> wrote:
>> If you travelled to Britain, would you insist on driving on the
>> right-hand side of the road? After all, it's just a convention,
>> and those silly Brits will surely see the light after you show
>> them how to drive properly. What would actually happen, though,
>> is that everyone would honk at you and you would cause a wreck.
>>
>> Stop driving on the wrong side of the road.
>>
>
> Silly brits... hah!
I checked with a British acquaintance (hence the delay in replying),
and have learned that some British people are offended by the term
"Brits". For that I apologize; no offense to British people was
meant, and I will avoid the term in the future unless I deliberately
mean to offend someone.
>
> i take it your your a yankee twat?
>
> Americans - The most hated race in the world!
>
> Yous blow kids up you sick bast%rds - No-one every other country
> with a nuclear warhead has it pointed at yous.
However, you are still a foulmouthed twit for not recognizing the
intended sarcasm. If you had actually read my post instead of just
taking offense you would have seen that I was making the point that,
just as driving on the right-hand side of the road is wrong in
Britain, so is top-posting in groups where the convention is the
older custom of "bottom-posting" and interleaving responses among the
quoted text.
Perhaps I've been trolled. That's ok. I wanted to make it completely
clear to *other*, non-twit British people whom I may have
inadvertently offended that no offense was meant.
Into the killfile you go, for a while at least. By the time the
killfile entry expires I hope you will have either gone away or
learned to behave.
--
David Wall
------------------------------
Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re:
Message-Id: <3F18A600.3040306@rochester.rr.com>
Ron wrote:
> Tried this code get a server 500 error.
>
> Anyone know what's wrong with it?
>
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {
(---^
> dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
...
> Ron
...
--
Bob Walton
------------------------------
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 5562
***************************************