[22955] in Perl-Users-Digest
Perl-Users Digest, Issue: 5175 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jul 3 18:10:40 2003
Date: Thu, 3 Jul 2003 15:10:13 -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, 3 Jul 2003 Volume: 10 Number: 5175
Today's topics:
detecting links jsowers@csc.com
Re: detecting links (Tad McClellan)
Re: detecting links jsowers@csc.com
Re: detecting links <uri@stemsystems.com>
Re: detecting links (Tad McClellan)
Finding a solution for make routing registry (Non Banditwing)
Re: Getting the size of files from a list? (Greg Bacon)
Re: Getting the size of files from a list? (Math55)
Re: help with regular expressions (j355)
huge hash creates Illegal instruction (core dumped) (Hauke Juhls)
Re: Is there a good free/not so expensive Perl IDE for <gblydenburgh@nospam.com>
Re: problem with Tk800.023.tar.gz from CPAN (Hugo)
Problems with MakeMaker <bdonlan@bd-home-comp.no-ip.org>
renaming badly named files... <N.Hirani@hgmp.mrc.ac.uk>
Re: renaming badly named files... <tim@vegeta.ath.cx>
Re: renaming badly named files... (Tad McClellan)
Re: script for unrestricted permutation (weberh)
unlink full path to files <tony1911@hotmail.com>
Re: unlink full path to files (Tad McClellan)
Re: unlink full path to files <noreply@gunnar.cc>
Re: unlink full path to files <bigj@kamelfreund.de>
Re: unlink full path to files <noreply@gunnar.cc>
Re: using 'DB_File' versus just plain tie() ? <paul.marquess@btinternet.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Thu, 3 Jul 2003 14:16:24 -0400 (EDT)
From: jsowers@csc.com
Subject: detecting links
Message-Id: <be1rto$864$1@lore.csc.com>
Is there any simple way to determine if a reference returned via readdir
is a soft- or hardlink rather than a directory or filename.
None of my perl books seem to show any way of telling.
Thanks
------------------------------
Date: Thu, 3 Jul 2003 13:38:44 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: detecting links
Message-Id: <slrnbg8u1k.25a.tadmc@magna.augustmail.com>
jsowers@csc.com <jsowers@csc.com> wrote:
> Is there any simple way to determine if a reference returned via readdir
> is a soft- or hardlink
perldoc -f readlink
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 3 Jul 2003 15:07:55 -0400 (EDT)
From: jsowers@csc.com
Subject: Re: detecting links
Message-Id: <be1uub$9dj$1@lore.csc.com>
Thanks, but not quite the answer. readlink will return the name of the
directory/file which
the link points to. I need something equivalent to the '-d' to determine
if an item is a directory.
Basically, I want to avoid following the link when walking a directory
tree.
------------------------------
Date: Thu, 03 Jul 2003 19:14:26 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: detecting links
Message-Id: <x7y8zfzalp.fsf@mail.sysarch.com>
>>>>> "j" == jsowers <jsowers@csc.com> writes:
j> Thanks, but not quite the answer. readlink will return the name of
j> the directory/file which the link points to. I need something
j> equivalent to the '-d' to determine if an item is a directory.
j> Basically, I want to avoid following the link when walking a
j> directory tree.
perldoc -f -X
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Thu, 3 Jul 2003 16:29:11 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: detecting links
Message-Id: <slrnbg9817.2f7.tadmc@magna.augustmail.com>
jsowers@csc.com <jsowers@csc.com> wrote:
> Thanks, but not quite the answer.
Huh? It looks like the answer to me...
> readlink will return the name of the
> directory/file which
> the link points to.
Or undef if it is not a symbolic link.
> I need something equivalent to the '-d' to determine
> if an item is a directory.
That is not the same question, and you already know the answer
to that question.
> Basically, I want to avoid following the link when walking a directory
> tree.
Select those that are not symbolic and are directories (untested):
my @dirs_not_links = grep { !readlink() and -d } @directories;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Jul 2003 08:05:52 -0700
From: biomed@linuxmail.org (Non Banditwing)
Subject: Finding a solution for make routing registry
Message-Id: <107e33a5.0307030705.1169169@posting.google.com>
Hello I'm ver new in Perl. I want to get the best solution,
help me please.
I'm doing a project which use Perl. My work is to create a daemon
which do 2 jobs
1. receive call from frontends to register their route (url).
2. receive call from frontend to request backend route.
if I have many concurrent frontend how I create the high performance daemon
which can handle many concurrent frontend ?
As I think
1. this daemon must fork when any client (frontend/backend) call.
2. if it is called from backend (for register it's route) when backend finish
to transfer it's route to daemon the child must forward the route to parent
using pipe before this child will die.
3. if it is called from frontend this child only get data from it's parent process
which no need to transfer any data because routing data automatically copy
to child.
any idea ?
Thank.
------------------------------
Date: Thu, 03 Jul 2003 15:18:47 -0000
From: gbacon@hiwaay.net (Greg Bacon)
Subject: Re: Getting the size of files from a list?
Message-Id: <vg8iancknatk3c@corp.supernews.com>
In article <a2b8188a.0307030543.19cea0e7@posting.google.com>,
Math55 <magelord@t-online.de> wrote:
: how can i get the size from the 9 files in /var/log/ksymoops and how
: the size of the 8 files in /var/log? the list is noct always the same,
: it can have more or less directories. i tried it like that so far:
Here's my implementation:
#! /usr/local/bin/perl
use strict;
use warnings;
use File::Basename;
sub to_bytes {
my $size = shift;
if ($size =~ s/k$//) {
$size *= 1024;
}
elsif ($size =~ s/M$//) {
$size *= 1024 * 1024;
}
$size;
}
sub to_unit {
my $size = shift;
if ($size > 1024 * 1024) {
$size = sprintf "%.1fM", $size / (1024*1024);
}
elsif ($size > 1024) {
$size = sprintf "%.1fk", $size / 1024;
}
$size;
}
## main
my %size;
my @files = <DATA>;
for (@files) {
chomp;
my($size,$path) = split;
my $bytes = to_bytes $size;
my $dir = dirname $path;
$size{$dir} += $bytes;
}
# pass two: zap subdirs from parents' totals
for (@files) {
chomp;
my($size,$path) = split;
next unless exists $size{$path};
my $dir = dirname $path;
my $bytes = to_bytes $size;
$size{$dir} -= $bytes;
}
for (sort { $a cmp $b } keys %size) {
print "$_ - ", to_unit($size{$_}), "\n";
}
__DATA__
32k /var/log/XFree86.0.log
76k /var/log/auth.log
116k /var/log/auth.log.0
8.0k /var/log/auth.log.1.gz
228k /var/log/kdm.log
20k /var/log/kern.log
1.2M /var/log/kern.log.0
12k /var/log/kern.log.1.gz
2.8M /var/log/ksymoops
228k /var/log/ksymoops/20030628062520.ksyms
4.0k /var/log/ksymoops/20030628062520.modules
228k /var/log/ksymoops/20030629062502.ksyms
4.0k /var/log/ksymoops/20030629062502.modules
12k /var/log/ksymoops/20030630.log
228k /var/log/ksymoops/20030630062525.ksyms
4.0k /var/log/ksymoops/20030630062525.modules
12k /var/log/ksymoops/20030701.log
228k /var/log/ksymoops/20030701062504.ksyms
I make two passes. On the first, I sum the sizes, using dirname
from the File::Basename module to grab the parent directory's name.
On the second pass, I substract reported directories' sizes from
their parents' totals (e.g., /var//var/log/ksymoops in this example).
: this is what i want to have:
:
: /var/log:1720.8
: /var/log/ksymoops:3815.2
:
: is therea better and less complicated way to do that?
My results are below:
% ./try
/var/log - 1.7M
/var/log/ksymoops - 948.0k
Hope this helps,
Greg
--
The essence of government is power; and power, lodged as it must be in
human hands, will ever be liable to abuse.
-- James Madison
------------------------------
Date: 3 Jul 2003 11:07:41 -0700
From: magelord@t-online.de (Math55)
Subject: Re: Getting the size of files from a list?
Message-Id: <a2b8188a.0307031007.6363720e@posting.google.com>
Abigail <abigail@abigail.nl> wrote in message news:<slrnbg8h4s.pg4.abigail@alexandra.abigail.nl>...
> Math55 (magelord@t-online.de) wrote on MMMDXCIII September MCMXCIII in
> <URL:news:a2b8188a.0307030543.19cea0e7@posting.google.com>:
> ][ hi, lets say i have this list (its in a file):
> ][
> ][
> ][ 32k /var/log/XFree86.0.log
> ][ 76k /var/log/auth.log
> ][ 116k /var/log/auth.log.0
> ][ 8.0k /var/log/auth.log.1.gz
> ][ 228k /var/log/kdm.log
> ][ 20k /var/log/kern.log
> ][ 1.2M /var/log/kern.log.0
> ][ 12k /var/log/kern.log.1.gz
> ][ 2.8M /var/log/ksymoops
> ][ 228k /var/log/ksymoops/20030628062520.ksyms
> ][ 4.0k /var/log/ksymoops/20030628062520.modules
> ][ 228k /var/log/ksymoops/20030629062502.ksyms
> ][ 4.0k /var/log/ksymoops/20030629062502.modules
> ][ 12k /var/log/ksymoops/20030630.log
> ][ 228k /var/log/ksymoops/20030630062525.ksyms
> ][ 4.0k /var/log/ksymoops/20030630062525.modules
> ][ 12k /var/log/ksymoops/20030701.log
> ][ 228k /var/log/ksymoops/20030701062504.ksyms
>
>
> Something like (untested code):
>
> my %total;
> while (<>) {
> my ($size, $dir) = m!(\S+)\s+(\S+)/! or next;
> if ($size =~ s/k$//) {$size *= 1024}
> elsif ($size =~ s/M$//) {$size *= 1024 * 1024}
> $total {$dir} += $size;
> }
> while (my ($dir, $size) = each %total) {
> printf "%s:%.1f\n" => $dir, $size / 1024;
> }
>
>
>
> Abigail
hi, thanks you. i will try that and post back:) as soon as possible.
------------------------------
Date: 3 Jul 2003 08:16:37 -0700
From: j355ga@yahoo.com (j355)
Subject: Re: help with regular expressions
Message-Id: <b873bed6.0307030716.13fc57ad@posting.google.com>
You description is a bit vague, but you could try this for starters:
perl -i -ne 's/foo/bar/;print if !/whatever/;' myfilename.dat
jranchordas@hotmail.com (Jay) wrote in message news:<15724ad0.0307030111.5642894c@posting.google.com>...
> Hello,
>
> just getting grips with Perl and RE, but need your help.
>
> I am trying to open a file, print its contents to a textbox, but
> extract certain bits of information before outputing them to the
> textbox. LAter I want to save the contents back to the same file with
> the bits added back to the file. All this done without the user even
> realising. The bits I want to take out (and put back) are always
> located at the beginning and end of each file.
>
> This is what I have come up with so far:
>
------------------------------
Date: 3 Jul 2003 11:34:01 -0700
From: haukejuhls@web.de (Hauke Juhls)
Subject: huge hash creates Illegal instruction (core dumped)
Message-Id: <8b3fd24d.0307031034.644dd07e@posting.google.com>
Hi,
I hope anyone out there can help me... I have the following problem:
I create a huge hash of lists (~32000 keys in the hash) and the list
contain ~1000 different strings each. Unfortunately this seems to be
too large - when I watch the process increasing in memory it freezes
after occupying ~256MB of RAM - then the perl script crashes with
"Illegal instruction (core dumped)".
I am using perl version 5.005_03 on an RS6000 running AIX 4.
Anyone else had that problem before? I'm thankful for any suggestion
you make!
Thanks,
Hauke!
------------------------------
Date: Thu, 03 Jul 2003 12:36:10 -0400
From: Gary Blydenburgh <gblydenburgh@nospam.com>
Subject: Re: Is there a good free/not so expensive Perl IDE for Linux
Message-Id: <pqm8gv4e01fjri2qmp3u1o7sa16lo731v0@4ax.com>
Thank you
On Tue, 01 Jul 2003 12:05:42 +0000, Rich <scriptyrich@yahoo.co.uk>
wrote:
>Gary Blydenburgh wrote:
>
>> OK... How about any similar to Komodo.
>
>Well I'm going to rock the boat and try to give you a sensible answer (runs
>for cover!)
>
> http://www.perl.org.il/editors.html
>
>Gives a list of IDEs, though most are Win32 only. There's also:
>
> http://www.indigostar.com/perledit.html
>
>But that appears to need Qt2 to work.
>
>Also consider Eclipse with the epic plugin if you can put up with the time
>it takes to load - in that respect it's just like Komodo:
>
> http://e-p-i-c.sourceforge.net/main.html
>
>From my limited experience, none were particularly great, which is why
>vim/emacs may well be better in reality.
>
>Cheers,
------------------------------
Date: 3 Jul 2003 09:51:41 -0700
From: zurraspina@yahoo.com (Hugo)
Subject: Re: problem with Tk800.023.tar.gz from CPAN
Message-Id: <ce5e366c.0307030851.46ca80e3@posting.google.com>
Sorry, but I'm a newbie on this...
'perl -V:make' returns:
make='make'; ## Is this correct?
And now? what?
Thank you!
--Hugo
randy@theoryx5.uwinnipeg.ca (Randy Kobes) wrote in message news:<slrnbfet4k.bk2.randy@theoryx5.uwinnipeg.ca>...
> On Mon, 23 Jun 2003 10:14:31 -0400, Heng Xu <xuheng@iastate.edu> wrote:
> >I just encountered a little problem with the installation of
> >the Tk module from CPAN. After "perl Makefile.PL", I typed "make".
> >Then there came a msg saying that
> >
> >Writing Makefile for Tk
> >Makefile:95: *** missing separator. Stop.
> > /usr/bin/make -- NOT OK
>
> This type of message often means that the 'make' program
> invoked isn't the same as what Perl's Config.pm thinks it is.
> Does 'perl -V:make' report an equivalent to /usr/bin/make?
------------------------------
Date: Thu, 03 Jul 2003 17:49:02 -0400
From: "bd" <bdonlan@bd-home-comp.no-ip.org>
Subject: Problems with MakeMaker
Message-Id: <pan.2003.07.03.21.49.02.139720@bd-home-comp.no-ip.org>
I have two problems with ExtUtils::MakeMaker:
1) When I 'make clean', it deleted 'pm_to_blib', which Makefile.PL
complains about.
2) In a new 'make dist', it won't copy the .pm file into the blib/ dir
until I make clean and re-run Makefile.PL
A tarball of the offending module is at
http://bd-home-comp.no-ip.org/Hash-Cash-0.01.tar.gz
--
Freenet distribution not available
"The geeks shall inherit the earth."
-- Karl Lehenbauer
------------------------------
Date: Thu, 03 Jul 2003 21:53:05 +0100
From: Naran Hirani <N.Hirani@hgmp.mrc.ac.uk>
Subject: renaming badly named files...
Message-Id: <be2570$r1f$1@niobium.hgmp.mrc.ac.uk>
Hi All,
I am looking for a perl code fragment, or utility that will enable me to
rename badly named files and/or dir elements to such files, by replacing
the dubious character with an underscore. It would nice if such a
utility worked recursively through unix dirs and also had a mode where
by it just shows what would be renamed.
If any body knows of such a utility or supply me with a code fragment
that might do the above please could you e-mail me as well as posting here.
TIA.
Naran
------------------------------
Date: 3 Jul 2003 14:38:22 -0700
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: renaming badly named files...
Message-Id: <slrnbg98hc.v5r.tim@vegeta.ath.cx>
Naran Hirani graced us by uttering:
> I am looking for a perl code fragment, or utility that will
> enable me to rename badly named files and/or dir elements to
> such files, by replacing the dubious character with an
> underscore. It would nice if such a utility worked recursively
> through unix dirs and also had a mode where by it just shows
> what would be renamed.
>
> If any body knows of such a utility or supply me with a code
> fragment that might do the above please could you e-mail me as
> well as posting here.
You can find the rename.pl utility here:
http://borkware.com/quickies/files/rename.pl
Using this script, you can enter any expression as the first
argument and it will be executed on each filename. e.g.:
rename.pl 's/\.MP3$/mp3/;' *.MP3
In your case, try the tr/// operator:
rename.pl 'tr/bad_charset/_/;' [files to rename]
In this was, rename.pl has become one of the most flexible tools
in my ~/bin/.
HTH,
Tim Hammerquist
--
Once you can accept the universe as matter expanding into nothing
that is something, wearing stripes with plaid comes easy.
-- Albert Einstein
------------------------------
Date: Thu, 3 Jul 2003 16:46:20 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: renaming badly named files...
Message-Id: <slrnbg991b.2f7.tadmc@magna.augustmail.com>
Naran Hirani <N.Hirani@hgmp.mrc.ac.uk> wrote:
> I am looking for a perl code fragment, or utility that will enable me to
> rename badly named files
To provide code that does that, you would need to define "badly named".
What counts as "badly named"?
> and/or dir elements to such files, by replacing
> the dubious character with an underscore.
What should it do when these 2 files are present in the same directory?
foo?bar
foo_bar
if we follow your specification, data will be lost.
Fix your specification.
> It would nice if such a
> utility worked recursively through unix dirs
use File::Find;
> and also had a mode where
> by it just shows what would be renamed.
That would be easy enough.
> If any body knows of such a utility or supply me with a code fragment
> that might do the above
Since you've left many things unspecified, that means we get to
pick whatever specs we want. Being Lazy, we are likely to pick
specs that make it easier on us, rather than what Does What You Need.
Poor specs lead to poor implementations, so take some care when
composing your spec.
---------------------------
# untested
use File::Find;
find \&unwanted, '.';
sub unwanted {
return unless /\W/; # only \w chars allowed
my $new = $_;
$new =~ s/\W/_/g; # or maybe: tr/a-zA-Z0-9_/_/cs
return if -e $new; # don't stomp over existing files
rename $_, $new or die "could not move '$_' $!";
}
---------------------------
> please could you e-mail me as well as posting here.
Ask here, get the answer here (maybe).
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: 3 Jul 2003 11:56:12 -0700
From: weberh@zedat.fu-berlin.de (weberh)
Subject: Re: script for unrestricted permutation
Message-Id: <7003ec4a.0307031056.22785260@posting.google.com>
Thanks for the hint.
I have to admit, that I haven't understood bd's code yet.
I'll make a hardcopy and study it at home with a cup of tea.
tiltonj@erols.com (Jay Tilton) wrote in message
> It's essentially a base-n counter, where n is the number of permutable
> items. By changing it from a counter to a decimal-to-base-n
> converter, it can be used to obtain any arbitrary permutation without
> having to generate the entire set.
------------------------------
Date: Thu, 03 Jul 2003 15:40:43 GMT
From: Tony <tony1911@hotmail.com>
Subject: unlink full path to files
Message-Id: <%7YMa.876$JI4.10920@news-server.bigpond.net.au>
I would like to use the full pathname with the unlink
function but it doesn't seem to work that way?
Is it possible or must you always be in the directory
that the files are deleted from?
This is perl, v5.6.1 built for i386-linux
use strict;
use warnings;
These first two work,
chdir '/floppy' or die "Can't cd to /floppy: $!\n";
system("rm /floppy/@delete_files") == 0 or warn
"Problem when system rm @delete_files: $!"; # works
chdir '/floppy' or die "Can't cd to /floppy: $!\n";
unlink @delete_files or warn
"Problem when unlinking @delete_files: $!"; # works
These don't work.
chdir '/floppy' or die "Can't cd to /floppy: $!\n";
unlink "/floppy/@delete_files" or warn
"Problem when unlinking @delete_files: $!"; # error
No such file or directory at..
chdir '/floppy' or die "Can't cd to /floppy: $!\n";
unlink "\/floppy\/@delete_files" or warn
"Problem when unlinking @delete_files: $!"; # error
No such file or directory at..
------------------------------
Date: Thu, 3 Jul 2003 11:00:23 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: unlink full path to files
Message-Id: <slrnbg8kon.1q4.tadmc@magna.augustmail.com>
Tony <tony1911@hotmail.com> wrote:
>
> I would like to use the full pathname with the unlink
> function
That will be fine.
> Is it possible
Yes.
> These don't work.
>
> chdir '/floppy' or die "Can't cd to /floppy: $!\n";
> unlink "/floppy/@delete_files" or warn
Try looking at what you are giving to unlink():
print "/floppy/@delete_files";
And you might see something like:
/floppy/file1 file2 file3
That is a single scalar, unlink wants a _list_.
that should one file named '/floppy/file1 file2 file3',
ie a filename with spaces in it.
> "Problem when unlinking @delete_files: $!"; # error
> No such file or directory at..
What you _want_ unlink to see is the list of absolute paths:
unlink '/floppy/file1', /floppy/file2', ...
You could get that with (untested):
unlink map { "/floppy/$_" } @delete_files;
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Thu, 03 Jul 2003 18:08:30 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: unlink full path to files
Message-Id: <be1kd4$9kl7$1@ID-184292.news.dfncis.de>
Tony wrote:
> I would like to use the full pathname with the unlink
> function but it doesn't seem to work that way?
Yes it does. You do not need to chdir to the directory where the files
to be deleted are.
> These don't work.
>
> chdir '/floppy' or die "Can't cd to /floppy: $!\n";
> unlink "/floppy/@delete_files" or warn
---------^^^^^^^^^^^^^^^^^^^^^^^
If the array @delete_files would include the elements 'file1.txt' and
'file2.txt', that expression tries to do:
unlink '/floppy/file1.txt file2.txt'
which obviously cannot work.
You can try to just do this (chmod not necessary):
for (@delete_files) {
unlink "/floppy/$_" or warn $!;
}
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 03 Jul 2003 13:42:00 +0200
From: "Janek Schleicher" <bigj@kamelfreund.de>
Subject: Re: unlink full path to files
Message-Id: <pan.2003.07.03.11.41.58.568742@kamelfreund.de>
Tony wrote at Thu, 03 Jul 2003 15:40:43 +0000:
> I would like to use the full pathname with the unlink
> function but it doesn't seem to work that way?
> Is it possible or must you always be in the directory
> that the files are deleted from?
>
> This is perl, v5.6.1 built for i386-linux
>
> use strict;
> use warnings;
>
> These first two work,
>
> chdir '/floppy' or die "Can't cd to /floppy: $!\n";
> system("rm /floppy/@delete_files") == 0 or warn
> "Problem when system rm @delete_files: $!"; # works
I doubt it.
That will only work if @delete_files contains only 1 element.
If @delete_files = ("a", "b") for example
"rm /floppy/@delete_files" is interpolated to
"rm /floppy/a b"
what is perhaps something different of what you wanted to achieve.
> chdir '/floppy' or die "Can't cd to /floppy: $!\n";
> unlink @delete_files or warn
That try to do something lik
rm a b
(with @delete_files like above)
> "Problem when unlinking @delete_files: $!"; # works
You might better try something like
unlink map "/floppy/$_", @delete_files or die "...";
Greetings,
Janek
------------------------------
Date: Thu, 03 Jul 2003 18:22:34 +0200
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: unlink full path to files
Message-Id: <be1l7g$9l67$1@ID-184292.news.dfncis.de>
Gunnar Hjalmarsson wrote:
> You can try to just do this (chmod not necessary):
I meant of course: chdir not necessary.
>
> for (@delete_files) {
> unlink "/floppy/$_" or warn $!;
> }
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Thu, 3 Jul 2003 16:21:43 +0100
From: "Paul Marquess" <paul.marquess@btinternet.com>
Subject: Re: using 'DB_File' versus just plain tie() ?
Message-Id: <3f044a08$0$10630$ed9e5944@reading.news.pipex.net>
"dan baker" <botfood@yahoo.com> wrote in message
news:13685ef8.0307021847.281453c7@posting.google.com...
> Perusion Hostmaster <nanae@bill.perusion.com> wrote in message
news:<slrnbg6dg5.j9u.nanae@bill.heins.net>...
> >
> > AFAIK, DB_File is portable between machines and even big-endian
> > and little-endian architectures (unlike GDBM or NDBM).
> >
> > You may be running into version bifurcation -- many DB_File
> > modules still use 1.x, and a lot have moved to 2.x/3.x.
> >
> --------------------
>
> huh, I wonder how I can tell if this is the issue? All I know is that
> if I FTP the tied()ed file from the unix host to my pc, the app can't
> read it when run on my localhost...
There are two main reasons why people have difficulty moving DB_File
database files between platforms.
Firstly, if ftp was used, and the transfer was done in ASCII mode, the
database file will be completely trashed. The transfer must be done in ftp
binary mode.
The second, and most likely, is that the version of Berkeley DB used to
build DB_File was different on the each machine. The most recent version of
Berkeley DB is 4.1.25 and there have been quite a few changes made to the
database file format between version 1 and version 4. If the versions of
Berkeley DB are compatible, it is possible to copy database files between
platforms without any problem.
You can determine which versions of Berkeley DB were used to build DB_File
on your systems by running this one-liner on each platform.
perl -e "use DB_File; print qq{Berkeley DB ver $DB_File::db_ver\n}"
If the versions are identical, the database file can be used on either
platform.
Assuming the versions are different, the next thing you want to do is run
the dbinfo script that comes with DB_File against the database file you want
to copy. It will tell you what versions of Berkeley DB are capable of
building it, and therefore what versions can read it.
If you draw a blank with that, and you still want to use DB_File, the only
options have are: to rebuild DB_File on one of the platforms using the
version of Berkeley DB from the other; or, you can use the db_dump/db_load
utilities that come with Berkeley DB to dump/rebuild the database.
> I was hoping there would be a
> simple (although maybe slower) alternative that would save the info in
> a p-lain ASCII file rather than abinary b-tree or however they do it
> internally.
DB_File has a Recno mode that uses text file as backing store. The Perl
interface is via a tied array, rather than a hash though. Have a look at the
DB_File documentation for more details.
cheers
Paul
------------------------------
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 5175
***************************************