[7535] in Perl-Users-Digest
Perl-Users Digest, Issue: 1162 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Oct 12 01:08:25 1997
Date: Sat, 11 Oct 97 22:00:32 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Perl-Users Digest Sat, 11 Oct 1997 Volume: 8 Number: 1162
Today's topics:
autoload module IO for SGI needed <ziege@ito.umnw.ethz.ch>
Re: Best way to comma seperate a number? (brian d foy)
Re: DATABASING IN PERL (HELP!) <polone@acc.mcrest.edu>
Re: DATABASING IN PERL (HELP!) (brian d foy)
Re: DATABASING IN PERL (HELP!) <fain@actcom.co.il>
file handle names <alvin@qualcomm.com>
file handle names <alvin@qualcomm.com>
Re: file handle names <barnetda@ghg.net>
Getting File Information Quickly franklin@nospamingideas4you.com
Re: Getting File Information Quickly <barnetda@ghg.net>
Re: Getting File Information Quickly (brian d foy)
Re: Getting File Information Quickly (Tad McClellan)
JAVASCRIPT in PERLSCRIPTS <Marion@netway.at>
Re: libwww for win32 S.O.S <polone@acc.mcrest.edu>
Re: Need help in searching a string <fain@actcom.co.il>
Newbie just starting out:perl in MS-DOS (Cdobney2)
Re: Perl DBM file sizes?!? (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Re: Perl vs. Java <polone@acc.mcrest.edu>
Replacing anything not matching with s/? <mattias.lonnqvist@-NO-SPAM-.uidesign.se>
Time? <mdoc@rollanet.org>
Re: umask and mkdir.. (Tad McClellan)
Re: umask and mkdir.. (Malcolm Hoar)
Re: umask and mkdir.. (Jeremy D. Zawodny)
Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Sun, 12 Oct 1997 01:08:54 +0200
From: Michael Ziege <ziege@ito.umnw.ethz.ch>
Subject: autoload module IO for SGI needed
Message-Id: <344007C2.2EC2@ito.umnw.ethz.ch>
Hi
I dont't know if this is the right place to ask this question but any
help would be appreciated:
I'm currently working with Perl 5.003 on a SGI running IRIX 6.2 and I
need the IO::Socket.pm module. I don't have a running C compiler on this
machine so make doesn't work. Is there a place to get the package
allready compiled for this system or does anybody know how to get it
work without a compiler?
Thanks very much for help.
Michael
------------------------------
Date: Sat, 11 Oct 1997 19:33:20 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Best way to comma seperate a number?
Message-Id: <comdog-ya02408000R1110971933200001@news.panix.com>
In article <61nscv$lg3$1@sparc.tibus.net>, tony@crux.blackstar.co.uk (Tony Bowden) wrote:
>What would be the best way to turn a number in a comma seperated version
>for printing?
>
>e.g. 1029 -> 1,029 12930233 -> 12,930,233 etc.
>
>The best I can come up with is:
[snip]
>but I'm sure there must be a better way...
Jeffrey Freidl gives two alternatives[1] to the FAQ answer - both of which
he says are significantly faster than the FAQ answer.
an unachored version:
s| (\d{1,3})
(?=
(?:\d\d\d)+
(?!\d)
)
|$1,|gx;
and an anchored version:
s| \G
((?:^-)?\d{1,3})
(?=
(?:\d\d\d)+
(?!\d)
)
|$1,|gx;
[1] see pp. 229 and 291 of
Mastering Regular Expressions
Jeffrey E.F. Freidl
ISBN 1-56592-257-3
<URL:http://www.oreilly.com>
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 11 Oct 1997 22:25:24 -0500
From: Patrick O'Lone <polone@acc.mcrest.edu>
To: fain@actcom.co.il
Subject: Re: DATABASING IN PERL (HELP!)
Message-Id: <34404323.6F950EE0@acc.mcrest.edu>
> Companyname DD/MM/YY #### DESCRIPTION
>
Observe how the line is broken by spaces. Now, to break it up you use
the SPLIT command. Here is how I would break it up:
open(FILE,"database.txt");
while(<FILE>) {
(@company,@date,@number,@desc) = split(/\s+/,$_);
}
That will put them into an array. Then you can manipulate them however.
Personally, I would use a DBM array, so that seraching for the data
items is faster because you can uses keys to find them. But, this
should work for a database file that doesn't exceed 5,000 lines or more,
with relatively fast speed.
Patrick O'Lone
polone@sanasys.com
polone@mcrest.edu
"The edge is everything..."
------------------------------
Date: Sun, 12 Oct 1997 00:29:39 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: DATABASING IN PERL (HELP!)
Message-Id: <comdog-ya02408000R1210970029390001@news.panix.com>
In article <34404323.6F950EE0@acc.mcrest.edu>, polone@acc.mcrest.edu wrote:
>> Companyname DD/MM/YY #### DESCRIPTION
>Observe how the line is broken by spaces. Now, to break it up you use
>the SPLIT command. Here is how I would break it up:
> (@company,@date,@number,@desc) = split(/\s+/,$_);
what's all this then? didn't you mean to use scalars?
#split on whitespace giving a maximum of 4 parts
($company, $date, $number, $description) = split /\s+/, $_, 4;
watch what happens with your code:
#!/usr/bin/perl
$_ = 'Company,Inc. 10/10/97 43059 RandomData';
(@company,@date,@number,@desc) = split(/\s+/,$_);
print "oh no mr. bill!\n" if $_ eq join ' ', @company;
__END__
oh no mr. bill!
@company slurps up everything!
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sun, 12 Oct 1997 06:24:10 +0200
From: || Fains || <fain@actcom.co.il>
To: polone@acc.mcrest.edu
Subject: Re: DATABASING IN PERL (HELP!)
Message-Id: <34405EF9.A143AF60@actcom.co.il>
First, thanks for responding.
My Database has only a few 100 lines.
You brought up some interesting code.
In your example the parsing of the file is mixed with the code that I would
use for searching.
also, I have never seen the @ symbol used (all of my information is coming
from the other responses that I have gotten from the News Group). But if it
works, I'll take it.
Questions:
what does the \s+ and $_ do in split(/\s+/,$_) ?
I have seen this alot and don't understand it.
Ok, so in this code we have parsed the Database file. If I wanted to search
for a particular @company is this how I would do it? (forgive my coding,
it's not exact but tell me if the logic fits)
open(FILE,"database.txt");
while(<FILE>) {
(@company,@date,@number,@desc) = split(/\s+/,$_);
if (form('searchbox') eq @company)
{
print: Company Name: @company \n
print: Date: @date \n
print: Number: @number \n
print: Desc: @desc \n
}
}
Excusing the lousy coding that I did for a moment, does what I have added
make sense?
now the coding.
Is it OK to do the search in the "while" area or should I pull my code
outside of "while" all together?
In the code I added should I use the @ symbol in-front of the variables
(@company) or should I replace the @'s with $ ($company)?
Thanks
- Nathan Fain
Patrick O'Lone wrote:
> > Companyname DD/MM/YY #### DESCRIPTION
> >
>
> Observe how the line is broken by spaces. Now, to break it up you use
> the SPLIT command. Here is how I would break it up:
>
> open(FILE,"database.txt");
> while(<FILE>) {
> (@company,@date,@number,@desc) = split(/\s+/,$_);
> }
>
> That will put them into an array. Then you can manipulate them however.
> Personally, I would use a DBM array, so that seraching for the data
> items is faster because you can uses keys to find them. But, this
> should work for a database file that doesn't exceed 5,000 lines or more,
> with relatively fast speed.
>
> Patrick O'Lone
> polone@sanasys.com
> polone@mcrest.edu
> "The edge is everything..."
------------------------------
Date: Wed, 08 Oct 1997 15:16:46 -0700
From: Alvin Tanhehco <alvin@qualcomm.com>
Subject: file handle names
Message-Id: <343C064E.25FF@qualcomm.com>
How do I go about opening and closing file handles with sequential names
like OUT1, OUT2, OUT3...? I tried OUT($num), {OUT}$num, but these don't
work.
------------------------------
Date: Wed, 08 Oct 1997 15:17:59 -0700
From: Alvin Tanhehco <alvin@qualcomm.com>
Subject: file handle names
Message-Id: <343C0697.7847@qualcomm.com>
How do I go about opening and closing file handles with sequential names
like OUT1, OUT2, OUT3...? I tried OUT($num), {OUT}$num, but these don't
work.
------------------------------
Date: Sat, 11 Oct 1997 21:34:21 -0500
From: "David A. Barnett" <barnetda@ghg.net>
Subject: Re: file handle names
Message-Id: <3440372C.3B010E04@ghg.net>
Alvin Tanhehco wrote:
> How do I go about opening and closing file handles with sequential names
> like OUT1, OUT2, OUT3...? I tried OUT($num), {OUT}$num, but these don't
> work.
How about:
for ($i = 1; $i < 10; $i++) {
$OUTFILE = OUT$i; # OUT${i} makes perl believe out is a hash,
and $i is the key
# Not sure what (OUT)$i
would do....
open($OUTFILE,">>outfile") or die "Unable to open outfile.\n";
select ($OUTFILE);
$| = 1; # Set for my test so output
is in the order I wanted.
print $OUTFILE ("Output for $OUTFILE\n");
}
This was manually typed into message, so beware typos....
You should be able to reference $OUTFILE for any instance where you would
otherwise be
able to reference OUT.
Hope this helps. :)
Dave Barnett
barnetda@ghg.net
------------------------------
Date: Sat, 11 Oct 97 20:32:57 -0400
From: franklin@nospamingideas4you.com
Subject: Getting File Information Quickly
Message-Id: <34401ac0$2$senaxyva$mr2ice@news.alltel.net>
Is there a way to read a get all the directory information. Kind of like
doing a DOS Dir to get the filename, size, etc... with out having to set a
File Handle for each file and then doing a stat.
--
-----------------------------------------------------------
Coming Soon,
"Discussion Groups" the power of the news groups packed into the manageablity of a mail list.
Virtual Computer Shopper
VCS Manager: Franklin Smith
E-Mail Address: franklin@ideas4you.com
Web Site: http://www.ideas4you.com/vcs
Ideas Unlimited Consulting
http://www.ideas4you.com
We do custom REXX and Paradox programming, Web Site Construction and Management, and Computer Hardware and Software Sales and Service.
Books Unlimited
BU Mangaer: Jim Smith
E-Mail Address: jimsmith@ideas4you.com
http://www.ideas4you.com/bu
-----------------------------------------------------------
------------------------------
Date: Sat, 11 Oct 1997 21:37:08 -0500
From: "David A. Barnett" <barnetda@ghg.net>
Subject: Re: Getting File Information Quickly
Message-Id: <344037D4.3C2A8935@ghg.net>
franklin@nospamingideas4you.com wrote:
> Is there a way to read a get all the directory information. Kind of like
> doing a DOS Dir to get the filename, size, etc... with out having to set a
> File Handle for each file and then doing a stat.
Wouldn't:
@DirectoryInformation = `ls -al /usr/bin`
work? I think so. Should put all ls info into the @DirectoryInformation, where you can use
foreach loop to go through each entry.
Hope it helps. :)
Dave Barnet
barnetda@ghg.net
------------------------------
Date: Sat, 11 Oct 1997 23:30:29 -0400
From: comdog@computerdog.com (brian d foy)
Subject: Re: Getting File Information Quickly
Message-Id: <comdog-ya02408000R1110972330290001@news.panix.com>
In article <344037D4.3C2A8935@ghg.net>, barnetda@ghg.net wrote:
>franklin@nospamingideas4you.com wrote:
[ironic address considering that i've blocked that domain from
my site because it's a spam haven...]
>> Is there a way to read a get all the directory information. Kind of like
>> doing a DOS Dir to get the filename, size, etc... with out having to set a
>> File Handle for each file and then doing a stat.
>
> Wouldn't:
>
> @DirectoryInformation = `ls -al /usr/bin`
>
>work?
that would work, but it's easy to get bitten by not using the full
path to the executable. remember that stat() doesn't need a
FILEHANDLE to work - it also takes a filename.
an alternate solution that doesn't hand off the grunt work to the
shell and doesn't depend on Unix (YMMV):
#!/usr/bin/perl -wT
use HTTP::Date;
my $directory = '/export/home/brian';
my %files;
opendir(DIR, $directory);
foreach $filename ( readdir(DIR) )
{
#test for files. salt to taste.
next unless -f $filename;
#get the info on the file. stat takes either a FILEHANDLE
#or an EXPR. see perlfunc.
my @info = stat $filename;
$files{$filename} = [ @info ];
}
closedir(DIR);
#let's sort the files by last modification time
foreach $file ( sort { $files{$a}[9] <=> $files{$b}[9] }
keys %files )
{
my $date = HTTP::Date::time2str($files{$file}[9]);
print "$date\t$file\n";
}
__END__
Thu, 04 Sep 1997 01:29:39 GMT perl_comm.12fps.movie
Thu, 09 Oct 1997 01:42:13 GMT prettyperl.pl
Thu, 09 Oct 1997 01:46:52 GMT test.pl.bak
Thu, 09 Oct 1997 02:37:47 GMT pgp_test2.pl
Thu, 09 Oct 1997 02:38:50 GMT pgp_test3.pl
Fri, 10 Oct 1997 18:40:06 GMT suggest.html
Sun, 12 Oct 1997 03:14:37 GMT test.pl
--
brian d foy <comdog@computerdog.com>
NY.pm - New York Perl M((o|u)ngers|aniacs)* <URL:http://ny.pm.org/>
CGI Meta FAQ <URL:http://computerdog.com/CGI_MetaFAQ.html>
------------------------------
Date: Sat, 11 Oct 1997 21:38:14 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: Getting File Information Quickly
Message-Id: <m6dp16.2h3.ln@localhost>
franklin@nospamingideas4you.com wrote:
: Is there a way to read a get all the directory information. Kind of like
: doing a DOS Dir to get the filename, size, etc... with out having to set a
: File Handle for each file and then doing a stat.
@fileinfo = stat 'name_of_file'; # no filehandle required, just like it
# says in the perlfunc man page...
Is that what you meant?
[
A 18 line sig on a 3 line article?
Sheesh.
]
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 11 Oct 1997 11:06:48 +0100
From: Marion <Marion@netway.at>
Subject: JAVASCRIPT in PERLSCRIPTS
Message-Id: <343F4FB8.D8D3BC24@netway.at>
--------------BD0331BA7CC5004CC50904EC
Content-Type: text/plain; charset=x-user-defined
Content-Transfer-Encoding: 7bit
Dear Perl-Gurus!
Well. I have a little problem with this next Lines.
As normal html-code works the example without any problem.
<!--
<HTML>
<HEAD>
<TITLE>Cookie -est</TITLE>
<meta http-equiv="refresh" content="0; URL=/home_so.html">
</HEAD>
<BODY BGCOLOR="#FFFFFF">
<SCRIPT LANGUAGE="Javascript">
var text="abcdefghij"
document.cookie=text
alert(text)
</SCRIPT>
</BODY>
</HTML>
//-->
But in a PERLSCRIPT it doesn't work!
<!--
print "<BODY>\n";
print "<SCRIPT LANGUAGE=\"Javascript\">\n";
print "var text=\"abcdefghij\"\n";
print "document.cookie=text\n";
print "alert(text)\n";
print "</SCRIPT>\n";
//-->
I can't set a COOKIE.
Thank you!!!!!!!!!!!!!!!!!!.
--------------BD0331BA7CC5004CC50904EC
Content-Type: text/html; charset=x-user-defined
Content-Transfer-Encoding: 8bit
<HTML>
<FONT SIZE=-1>Dear Perl-Gurus!</FONT>
<P><FONT SIZE=-1>Well. I have a little problem with this next Lines.</FONT>
<BR><FONT SIZE=-1>As normal html-code works the example without any problem.</FONT>
<P><FONT SIZE=-1><!--</FONT>
<BR><FONT SIZE=-1><HTML></FONT>
<BR><FONT SIZE=-1><HEAD></FONT>
<BR><FONT SIZE=-1> <TITLE>Cookie -est</TITLE></FONT>
<BR><FONT SIZE=-1> <meta http-equiv="refresh" content="0; URL=/home_so.html"></FONT>
<BR><FONT SIZE=-1></HEAD></FONT>
<P><FONT SIZE=-1><BODY BGCOLOR="#FFFFFF"></FONT>
<BR><FONT SIZE=-1> <SCRIPT LANGUAGE="Javascript"></FONT>
<BR><FONT SIZE=-1> var text="abcdefghij"</FONT>
<BR><FONT SIZE=-1> document.cookie=text</FONT>
<BR><FONT SIZE=-1> alert(text)</FONT>
<BR><FONT SIZE=-1> </SCRIPT></FONT>
<BR><FONT SIZE=-1></BODY></FONT>
<BR><FONT SIZE=-1></HTML></FONT>
<BR><FONT SIZE=-1>//--></FONT>
<P><FONT SIZE=-1>But in a PERLSCRIPT it doesn't work!</FONT>
<P><FONT SIZE=-1><!--</FONT>
<BR><FONT SIZE=-1> print "<BODY>\n";</FONT>
<BR><FONT SIZE=-1> print "<SCRIPT LANGUAGE=\"Javascript\">\n";</FONT>
<BR><FONT SIZE=-1> print "var text=\"abcdefghij\"\n";</FONT>
<BR><FONT SIZE=-1> print "document.cookie=text\n";</FONT>
<BR><FONT SIZE=-1> print "alert(text)\n";</FONT>
<BR><FONT SIZE=-1> print "</SCRIPT>\n";</FONT>
<BR><FONT SIZE=-1>//--></FONT>
<P><FONT SIZE=-1>I can't set a COOKIE.</FONT>
<BR>
<P><FONT SIZE=-1>Thank you!!!!!!!!!!!!!!!!!!.</FONT></HTML>
--------------BD0331BA7CC5004CC50904EC--
------------------------------
Date: Sat, 11 Oct 1997 22:02:26 -0500
From: Patrick O'Lone <polone@acc.mcrest.edu>
To: Gal Samuel <nakadina@ibm.net>
Subject: Re: libwww for win32 S.O.S
Message-Id: <34403DC2.48BA17E3@acc.mcrest.edu>
--------------8B8A6D3A302A8D81A4D719CE
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
>
The problem with the variable @INC is this...
@INC is the path of your modules. To check where those lead, run this
script from console:
foreach(@INC) {
print "$_\n";
}
That should print out your paths. The modules you install MUST be in
the path, or else they will not execute correctly or even, for that
matter, at all. When I installed perl, it was only a matter of allowing
the programs to self extract themselves. I am afraid that's all I know
about the installation.....
Patrick O'Lone
polone@sanasys.com
polone@mcrest.edu
"The edge is everything..."
--------------8B8A6D3A302A8D81A4D719CE
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
<BLOCKQUOTE TYPE=CITE><A HREF="http://www.nakadina.org/"></A> </BLOCKQUOTE>
The problem with the variable @INC is this...
<P>@INC is the path of your modules. To check where those lead, run
this script from console:
<P>foreach(@INC) {
<BR> print
"$_\n";
<BR>}
<P>That should print out your paths. The modules you install MUST
be in the path, or else they will not execute correctly or even, for that
matter, at all. When I installed perl, it was only a matter of allowing
the programs to self extract themselves. I am afraid that's all I
know about the installation.....
<P>Patrick O'Lone
<BR>polone@sanasys.com
<BR>polone@mcrest.edu
<BR>"The edge is everything..."
<BR> </HTML>
--------------8B8A6D3A302A8D81A4D719CE--
------------------------------
Date: Sun, 12 Oct 1997 05:48:29 +0200
From: || Fains || <fain@actcom.co.il>
To: brian d foy <comdog@computerdog.com>
Subject: Re: Need help in searching a string
Message-Id: <3440569D.AEFDE1BA@actcom.co.il>
OK, I know I didn't start the questions but after reading your message I now have
one (it could be because I am coming in late). I understood everything up to this
line of code:
push @foods, $1;
What does "push" do?
what do we expect to find in @Foods?
last but not least - what does the $1 do?
Thanks for helping
- Nathan fain@cs.huji.ac.il
brian d foy wrote:
> In article <61okv3$gee$1@news3.realtime.net>, masroor <masroor@bga.com> wrote:
>
> > service:: catering
> > food type: southwestern
>
> > Basically I can search for the string "service:: catering:, now once I
> > find the search string, then I need to find the string "food type:". If
> > you notice the string "food type:" is in relation to the 1st string search
> > of "service:: catering". My question How do I tell the perl program to
> > move the file pointer from the 1st string search. Normally in while loop
> > in checks one line by one line.
> >
> > Below is my program which can find the 1st string.
>
> [snip program that never could have worked with all those syntax
> errors]
>
>
> here is some pseudo-code
>
> 1. get a line from the file
> 2. is this line "service:: catering"?
> NO: go back to 1.
> YES: get the next line, which should be "food type: "
> 3. was the nest line "food type: "?
> NO: do some error handling stuff
> YES: do your thang
> 4. go back to 1.
>
> now that we have a method to accomplish this task, we can translate it
> into code:
>
> #1. get a line from the file
> while( $line = <FILE> )
> {
> #2. is this the right line?
> next unless $line =~ m/service:: catering/;
>
> #2 YES: so get the next line:
> $next_line = <FILE>;
>
> #3. was it the right line?
> next unless $next_line =~ m/food type: (.*)/;
>
> #3 YES: do your thing
> push @foods, $1;
> }
>
> good luck :)
>
> --
> brian d foy <http://computerdog.com>
> #!/usr/bin/perl
> $_=q|osyrNewkecnaYhe.mlorsePptMskurj|;s;[NY.PM]; ;g;local$\=
> qq$\n$;@pm=split//;while($NY=pop @pm){$pm.=$NY;$ny.=pop @pm}
> $pm=join'',reverse($ny,$pm);open(NY,'>&STDOUT');print NY $pm
------------------------------
Date: 12 Oct 1997 04:17:57 GMT
From: cdobney2@aol.com (Cdobney2)
Subject: Newbie just starting out:perl in MS-DOS
Message-Id: <19971012041700.AAA13902@ladder02.news.aol.com>
I am a novice programmer who is just beginning to learn perl.
I have downloaded perl5 from the internet, and also a c compiler
("miracle c") , which I was told I need also. They are both for MS-DOS, and
are unzipped. What do I do now? Do I need anything else? If not, how, then, do
I get my stupid little "hello world!" text file to execute?
I'm sorry, I know these are moron questions, but the book I am learning
from assumes that the reader is on a UNIX system, and the documentation from
the downloads may as well have been in Cantonese.
I would appreciate it if anyone who finds the time to answer this would
take it step-by-step from the C:\prompt in ms-dos. I'm not stupid, really,
just ignorant.
Thank you,
Christopher Dobney
<cdobney@willinet.net>
------------------------------
Date: Sat, 11 Oct 97 19:21:15 -0400
From: bsa@void.apk.net (Brandon S. Allbery KF8NH; to reply, change "void" to "kf8nh")
Subject: Re: Perl DBM file sizes?!?
Message-Id: <34400c1f$3$ofn$mr2ice@speaker>
In <343e9efa.116163125@news.synapse.net>, on 10/10/97 at 09,
yves@streamwave.com (Yves Dagenais) said:
+-----
| Under FreeBSD:
| - DBM file size is approx 7 Megs.
| - file extension becomes a .db
| Under Win95:
| - DBM file size is approx. 70 Megs!
| - file extension becomes a .pag & a .dir
| Under Solaris:
| - DBM file size is approx. 50 Megs!
| - file extension becomes a .pag & a.dir
| My questions is does anybody know why .pag DBMs are sooo much larger than
| the FreeBSD .db DBM format.??? Is the .db DBM format using a compress of
+--->8
Solaris is probably using ndbm; if so, it's taking advantage of a filesystem
trick: the file really isn't 50MB, because it has "holes" (unallocated disk
blocks) in it. The basic idea is to define a database block size which is a
multiple of the filesystem block size, then store data in the filesystem block
indexed by the hash code instead of having a table mapping hash codes to data
locations. This is fast but creates files that appear to be rather large, and
become rather large if you blindly cp them. (du should show the actual file
size.)
(Note that if you copy it with a utility that doesn't understand sparse files,
it'll "fill in the holes" in the copy.)
I have no idea what Win95 is using.
FreeBSD is using the BSD db library, which uses the more traditional approach
of storing disk offsets in the hash table. This makes for a smaller file but
has either slower inserts/deletes or a *lot* of wasted space when
variable-sized records are deleted and inserted randomly.
--
brandon s. allbery [Team OS/2][Linux] bsa@void.apk.net
cleveland, ohio mr/2 ice's "rfc guru" :-) KF8NH
Warpstock '97: OS/2 for the rest of us! http://www.warpstock.org
Memo to MLS: End The Burn Scam --- Doug Logan MUST GO! FORZA CREW!
------------------------------
Date: Sat, 11 Oct 1997 22:11:33 -0500
From: Patrick O'Lone <polone@acc.mcrest.edu>
Subject: Re: Perl vs. Java
Message-Id: <34403FE5.D63BDBC@acc.mcrest.edu>
>
Don't think that Java is better than Perl just yet! Consider the fact
that Java has not yet been STANDARDIZED. That is apparent in the Java
v1.0 to v1.1 upgrade in which almost everyone's older applets didn't
work without much headache of adjusting them. Perl can be an OOP
language, supporting objects, polymorphism, inheritance, multiple
inheritance, and overlays...
Patrick O'Lone
polone@sanasys.com
polone@mcrest.edu
"The edge is everything..."
------------------------------
Date: Wed, 08 Oct 1997 12:00:42 +0100
From: "Mattias Lvnnqvist" <mattias.lonnqvist@-NO-SPAM-.uidesign.se>
Subject: Replacing anything not matching with s/?
Message-Id: <343B67D9.503700F7@-NO-SPAM-.uidesign.se>
I am trying to replace anything not matching a-z, A-Z, blank/space with
nothing, eg
getting a resulting string with only these chars.
The following snippet is where I attempt to do it.
foreach $line (split(/\n/, $wholist)) {
$_=$line;
#strip out so only a-z, A-Z & blank remains
# This does not do it, since it keeps everything not
matching too...
#s/[\w]+/$1/g;
# replace 1 or more space in a row with :
s/\s+/:/g;
@words=split(/:/);
#do something with words
}
So, I guess I am looking for a not operator that can be used in the
regex. I tried s/![\w]+//g but that didnt do the trick.
I've already tried checking perlsyn & perlop, with no success.
/Mattias
--
Mattias Lonnqvist * M.Sc. * Software consultant * Remove -NO-SPAM-
from email adress to reply. * no mail-to: link here, sorry.
Unsolicited commercial email is subject to an archival fee of $400.
See <http://www.uidesign.se/~malo/mail.html> for more info.
------------------------------
Date: 12 Oct 1997 03:39:37 GMT
From: "Mdoc" <mdoc@rollanet.org>
Subject: Time?
Message-Id: <01bcd6bf$b71f2320$3c7237c0@rollanet.org.rollanet.org>
I am wondering how I would get the time from varous locations around the
world, say China? Would I do it with GMT +/-, or another way? Any help
would be appreciated!
Thanks,
Vic
mdoc@rollanet.org
------------------------------
Date: Sat, 11 Oct 1997 16:48:36 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: umask and mkdir..
Message-Id: <k7so16.pj2.ln@localhost>
Alex Krohn (alex@gossamer-threads.com) wrote:
: I'm having a real problem with mkdir.
short answer: Put a zero in front of the MODE argument to mkdir()
long answer: All the rest of this post ;-o
: What I want to do is create a
: directory (from the web) and create a file inside the directory (again
: from the web). I need to create the directory with permissions 777 (as
^^^
_we_ know that this is an octal number ^^^
: the web server runs as other) so that I can create the file inside of
: it.
So, 'other' wants to create a directory and 'other' wants to write
a file into that directory?
I don't see why you "need to" have those wide open permissions.
755 seems like it would work, unless there is some other reason that
you have not made apparent. (and, we know, that that too was an octal number)
: I'm unable to create a directory with the right permissions.
OK. I'll set aside what the really "right" permissions are and
assume you really want to go with open to the whole world.
... but I'll feel uneasy the whole time I'm doing it ;-)
: I'm not
: sure if I'm meant to use the chmod number (777) or the umask number
^^^^^^^^^^^^ ^^^^^^^^^^^^
: (which I think is meant to be 000 but i'm a little unsure). I've tried
: a wide variety of combinations but still can't get it to work.
Oh. So then you went to check what the perlfunc man page had to say
about those two functions, right? (although the mkdir() entry doesn't
say anything explicitly)
----------------------------
=item chmod LIST
Changes the permissions of a list of files. The first element of the
list must be the numerical mode, which should probably be an octal
number, and which definitely should I<not> a string of octal digits:
C<0644> is okay, C<'0644'> is not. Returns the number of files
successfully changed. See also L</oct>, if all you have is a string.
$cnt = chmod 0755, 'foo', 'bar';
chmod 0755, @executables;
$mode = '0644'; chmod $mode, 'foo'; # !!! sets mode to --w----r-T
$mode = '0644'; chmod oct($mode), 'foo'; # this is better
$mode = 0644; chmod $mode, 'foo'; # this is best
----------------------------
Then you would have said to yourself, "Hmmm. Wonder why all those
examples put a zero in front of the number?"
And you would have tried putting a zero in front of the number,
and it would have worked right then when the problem occured
rather than hours later after you waited around for an answer
from Usenet
;-)
Use the docs, Luke.
You can most likely get away with a correct call to mkdir(), probably
won't need to mess with either chmod() or umask().
mkdir 'my_web_dir', 0777 or die "could not make 'my_web_dir' $!";
to perl:
777 is base 10
0777 is base 8
: I've also tried creating the directory and then trying to chmod it
: 777, but it always comes back can't find file or directory.
Can't help with that one, 'cause I don't see any of your code.
Unless, of course, the call to mkdir() was failing first, so it really
didn't exist, in which case chmod() is doing the Right Thing.
But that could not happen because you are a careful programmer who
wants to invest an extra ten seconds of typing in order to avoid
long debugging times in the future, so you checked the return value
from mkdir() rather than just trusting that it succeeded.
Right? ;-)
: Any ideas what I'm doing wrong?
Posting and waiting a long time rather than getting the answer
in 5-10 minutes from the free documentation included with perl?
--
Tad McClellan SGML Consulting
tadmc@flash.net Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 11 Oct 1997 23:46:10 GMT
From: malch@malch.com (Malcolm Hoar)
Subject: Re: umask and mkdir..
Message-Id: <61p341$r95$1@nntp1.ba.best.com>
In article <k7so16.pj2.ln@localhost>, tadmc@flash.net (Tad McClellan) wrote:
>Alex Krohn (alex@gossamer-threads.com) wrote:
>: What I want to do is create a
>: directory (from the web) and create a file inside the directory (again
>: from the web). I need to create the directory with permissions 777 (as
> ^^^
> _we_ know that this is an octal number ^^^
>
>: the web server runs as other) so that I can create the file inside of
>: it.
>
>
>So, 'other' wants to create a directory and 'other' wants to write
>a file into that directory?
>
>I don't see why you "need to" have those wide open permissions.
>
>755 seems like it would work, unless there is some other reason that
>you have not made apparent. (and, we know, that that too was an octal number)
>
>
>: I'm unable to create a directory with the right permissions.
>
>
>OK. I'll set aside what the really "right" permissions are and
>assume you really want to go with open to the whole world.
>
>
> ... but I'll feel uneasy the whole time I'm doing it ;-)
and so you should :-(
777 is a really, really Bad Idea [TM].
Check the http server docs and find another way (unless you
really want to find a couple of Gigs of porn and/or warez
in your 777 directory) .........
See some of the CGI Security FAQ's. eg:
http://www-genome.wi.mit.edu/WWW/faqs/www-security-faq.html
http://www.csclub.uwaterloo.ca/u/mlvanbie/cgisec/
--
|~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
| Malcolm Hoar "The more I practice, the luckier I get". |
| malch@malch.com Gary Player. |
| http://www.malch.com/ Shpx gur PQN. |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
------------------------------
Date: Sat, 11 Oct 1997 22:02:42 GMT
From: jzawodn@wcnet.org (Jeremy D. Zawodny)
Subject: Re: umask and mkdir..
Message-Id: <343ff737.1135045889@woody.wcnet.org>
[original author automagically cc'd via e-mail]
On Sat, 11 Oct 1997 19:45:29 GMT, alex@gossamer-threads.com (Alex
Krohn) wrote:
>I've also tried creating the directory and then trying to chmod it
>777, but it always comes back can't find file or directory.
>
>Any ideas what I'm doing wrong?
Without seeing you code, I don't have the slighted idea.
However, this test program appears to work fine for me:
---chmd.pl---
#!/usr/bin/perl -w
use strict;
die unless $ARGV[0];
mkdir($ARGV[0], 666);
chmod 0777, $ARGV[0];
---end---
Run ./chmd.pl blah and see what the permissions on 'blah' look like.
Hope this helps somehow...
Jeremy
--
Jeremy D. Zawodny
WCNet Technical Geek & Web Stuff
<URL:http://www.wcnet.org/~jzawodn/>
"That's an example of how Perl can bring school yard cruelty to new heights."
-- Jon Orwant at the 1st Annual Perl Conference
------------------------------
Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 8 Mar 97)
Message-Id: <null>
Administrivia:
The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc. For subscription or unsubscription requests, send
the single line:
subscribe perl-users
or:
unsubscribe perl-users
to almanac@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.misc (and this Digest), send your
article to perl-users@ruby.oce.orst.edu.
To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.
To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.
The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.
The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.
For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.
------------------------------
End of Perl-Users Digest V8 Issue 1162
**************************************