[22960] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 5180 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 4 14:06:33 2003

Date: Fri, 4 Jul 2003 11:05:06 -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           Fri, 4 Jul 2003     Volume: 10 Number: 5180

Today's topics:
    Re: A little regex help? (JamesW)
    Re: Confused with array and references (Tad McClellan)
    Re: Confused with array and references <nobull@mail.com>
    Re: Delete trailing garbage chars from a set of files? (Tad McClellan)
    Re: Delete trailing garbage chars from a set of files? (Tad McClellan)
    Re: Displaying a picture until program has completely l <ThomasKratz@REMOVEwebCAPS.de>
    Re: Displaying a picture until program has completely l <krahnj@acm.org>
    Re: Getting the size of files from a list? (Tad McClellan)
    Re: huge hash creates Illegal instruction (core dumped) <shirsch@adelphia.net>
        Pre-forking SOAP servers (James Lavery)
        Problems with perlcc <dennis.hueckelheim@issdh.com>
        Regexp constructed from command line arguments. <this.is.invalid@yahoo.com>
    Re: Regexp constructed from command line arguments. <nobull@mail.com>
    Re: STDIO problem <jkeen@concentric.net>
    Re: using 'DB_File' versus just plain tie() ? <paul.marquess@btinternet.com>
    Re: using 'DB_File' versus just plain tie() ? (dan baker)
    Re: using pipe & perl's ARGV filehandle ? (Tad McClellan)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: 4 Jul 2003 11:00:33 -0700
From: gingaloon@hotmail.com (JamesW)
Subject: Re: A little regex help?
Message-Id: <27d2bd1f.0307041000.32b8b450@posting.google.com>

$line='print ("foo")';

$line=~s/^(print        #anchor to beginning of string
          .*            #match any text
           \))           #match closing parenthesis (need to escape
character)
         /$1\n/x;       #having wrapped match in () can use memory
variable
                        #and append newline.
  
print $line;   #print ("foo")\n

Ivan, not sure of the 'flavour' of your regex machine so will need to
look up how to use backreferences.  Probably \1.  The x modifier at
the end is just so I can comment the code for explanations.

s/^(print.*\))/$1\n/;

hth
j



"Ivan Marsh" <annoyed@you.now> wrote in message news:<pan.2003.07.03.17.08.01.784844@you.now>...
> Hey Folks,
> 
> This isn't actually a perl question but since you folks ar the regex
> experts I thought you might be able to help.
> 
> I want to do a search and replace in my text editor (that supports regex)
> for any line that begins with print( and ends with "); and replace the
> ending "); with \n"); where the line doesn't alredy end in \n");
> 
> ex:
> 
> print("foo");
> 
> becomes:
> 
> print("foo\n");
> 
> Thanks.


------------------------------

Date: Fri, 4 Jul 2003 10:15:09 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Confused with array and references
Message-Id: <slrnbgb6ft.4l9.tadmc@magna.augustmail.com>

Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> Kasp wrote:


> Subject: Confused with array and references


Let me point out that that isn't really the source of your confusion.

"Confused with array and list" would be more accurate.


>> use strict;
>> use warnings;
> 
> 
> Good. :-)


And all the congregation said "Amen!".


>> my $x = (5,6,7);


> (5, 6, 7) is a list, not an array. See the FAQ for the difference.


Right. This is the particular FAQ referred to:

   What is the difference between a list and an array?


> You are interpreting a list
> in scalar context, 


That cannot be, since the FAQ answer says:

   there's no such thing as a list in scalar context.


> the result of which is the last element of the list
                             ^^^^^^^^^^^^^^^^^^^^^^^^

But there _is no_ list.


> being assigned to $x.


So that should have been:

   You are interpreting the comma operator in a scalar context,
   the result of which is the value of the last expression evaluated.

:-)


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: 04 Jul 2003 17:52:20 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Confused with array and references
Message-Id: <u9isqi5j5n.fsf@wcl-l.bham.ac.uk>

tadmc@augustmail.com (Tad McClellan) writes:

> Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> > Kasp wrote:
> 
> >> my $x = (5,6,7);

> > (5, 6, 7) is a list, not an array. See the FAQ for the difference.

> That cannot be, since the FAQ answer says:
> 
>    there's no such thing as a list in scalar context.

That is correct.  For this reason I use the term "lexical list" to
refer to the sequence of caracters "5,6,7" in Perl source code.

After all consider:

sub foo ($@) {};
foo(5,6,7);

Here "5,6,7" is the (lexical) argument list of foo.  However 5 is in a
scalar context and 6,7 is actually a list!
 

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: Fri, 4 Jul 2003 10:25:41 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <slrnbgb73l.4l9.tadmc@magna.augustmail.com>

Patrick Flaherty <Patrick_member@newsguy.com> wrote:

> perl -p0777 -i.bu -e 's/\x1a+$//g' use.lis
> 
> What happens when I copy over a whole bunch of *.lis, many of which might have
> this problem?


>   This doesn't work (not surprising):
> 
> @list = glob("*.lis");
> foreach $name (@list) {
> s/\x1a+$//g $name;
> }


But this works (surprisingly!):

   # untested
   local $^I = '.bu';             # enable inplace editing
   local @ARGV = glob '*.lis';    # load up the filenames
   while ( <> ) {
      s/\x1a+$//g;
      print;
   }


In-place editing works on whatever is in @ARGV. It does not care
how the stuff got into @ARGV, it will just be expecting that they
are all names of files to edit.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 4 Jul 2003 10:33:59 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Delete trailing garbage chars from a set of files?
Message-Id: <slrnbgb7j7.4l9.tadmc@magna.augustmail.com>

Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net> wrote:
> Patrick Flaherty wrote:


>> When I copy a text file from VMS to Windows 
                                    ^^^^^^^^^^
                                    ^^^^^^^^^^

>   perl -p0777 -i.bu -e 's/\x1a+$//g' *.lis


I thought Windows didn't expand globs in its "shell"?

And that it likes double quotes?

(I dunno really, but that's what I remember hearing...)

There can only be one end-of-string, so the "g" option is not needed.


So that might need to be:

   perl -p0777 -i.bu -e "BEGIN{ @ARGV=<*.lis> } s/\x1a+$//"


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 4 Jul 2003 19:00:02 +0200
From: "Thomas Kratz" <ThomasKratz@REMOVEwebCAPS.de>
Subject: Re: Displaying a picture until program has completely loaded?
Message-Id: <3f05b28f.0@juno.wiesbaden.netsurf.de>

DQoiTWF0aDU1IiA8bWFnZWxvcmRAdC1vbmxpbmUuZGU+IHdyb3RlIGluIG5ld3M6YTJiODE4OGEu
MDMwNzA0MDY1OS4xYmU5YjYwYkBwb3N0aW5nLmdvb2dsZS5jb20uLi4NCg0KW3NraXBwZWQgY29k
ZV0gDQo+IGJ1dCBob3cgbG9uZz8gaG93IGRvIGkga25vdyBteSBwcm9ncmFtIGlzIHJlYWR5IHRv
IHN0YXJ0PyANCg0KV2hhdCBkbyB5b3UgbWVhbiBieSAibG9hZGVkIiBpbiB0aGUgc3ViamVjdD8N
Cg0KV2hlbiBleGFjdGx5IGRvIHlvdSBleHBlY3QgeW91ciAic3dpcmxpbmcgbGluZSIgdG8gYmUg
ZGlzcGxheWVkPw0KDQpQbGVhc2Uga2VlcCBpbiBtaW5kOg0KDQpBcyBsb25nIGFzIHRoZXJlIGlz
IG9ubHkgb25lIHByb2Nlc3MgYW5kIG9uZSB0aHJlYWQsIHRoZSBvbmx5IHRoaW5nIHRoYXQgeW91
ciBwcm9ncmFtIGRvZXMgd2hpbGUgc3dpcmxpbmcgdGhlIGxpbmUgaXMgc3dpcmxpbmcgdGhlIGxp
bmUuDQoNCj4gDQo+IFRIQU5LIFlPVSEhOikNCg0KTm90IG11Y2ggdG8gdGhhbmsgZm9yIHlldC4g
UGxlYXNlIGNsYXJpZnkgdGhlIHF1ZXN0aW9uLg0KDQpUaG9tYXM=



------------------------------

Date: Fri, 04 Jul 2003 17:50:58 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Displaying a picture until program has completely loaded?
Message-Id: <3F05BE81.9FCE14E6@acm.org>

Math55 wrote:
> 
> hi, i want to display the little swirling line. thats the code:
> 
> $zaehler;
> my $i;
> while($i<25){
>         print ".";
>         print("|");
>         $zaehler=0.0;
> 
>         while($zaehler<100000.0){
>                 $zaehler++;
>         }
>         print("\b");
> 
>         print("/");
>         $zaehler=0.0;
> 
>         while($zaehler<100000.0){
>                 $zaehler++;
>         }
>         print("\b");
> 
>         print("-"); $zaehler=0.0;
>         while($zaehler<100000.0){
>                 $zaehler++;
>         }
>         print("\b");
> 
>         print("\\");
>         $zaehler=0.0;
>         while($zaehler<100000.0){
> 
>                 $zaehler++;
>         }
>         print("\b");
> 
>         $i++;
> }
> 
> but how long? how do i know my program is ready to start?

You need to turn on autoflush for STDOUT.

$| = 1;

my @swirl = qw( | / - \ );

for ( 1 .. 25 ) {
    print '.';
    for ( @swirl ) {
        print "$_\b";
        sleep 2;
        }
    }



John
-- 
use Perl;
program
fulfillment


------------------------------

Date: Fri, 4 Jul 2003 10:36:53 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Getting the size of files from a list?
Message-Id: <slrnbgb7ol.4l9.tadmc@magna.augustmail.com>

Math55 <magelord@t-online.de> wrote:
> gbacon@hiwaay.net (Greg Bacon) wrote in message news:<vg8iancknatk3c@corp.supernews.com>...

[ snip 100 lines of quoted code ]

[ snip 3 lines of new text ]


Please do not do that.

   http://web.presby.edu/~nnqadmin/nnq/nquote.html

Thank you.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

Date: Fri, 04 Jul 2003 15:05:28 GMT
From: "Steven N. Hirsch" <shirsch@adelphia.net>
Subject: Re: huge hash creates Illegal instruction (core dumped)
Message-Id: <YIgNa.26977$Jw6.10183476@news1.news.adelphia.net>

This is a multi-part message in MIME format.
--------------010102020306000501030406
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

Hauke Juhls wrote:
> 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!

Read the section in AIX Developers Guide which refers to "Large Program 
Support".  Basically, AIX divides user process space into 256 MB 
segments.  Unless you take special measures at link time, your 
executable is inherently limited to 256MB stack + data.

You can either relink the Perl binary using the '-bmaxdata:0xn0000000' 
switch (replacing 'n' with the number of 256MB segments to be permitted, 
where 1 <= n <= 8) or modify the binary by direct patching.

Attached is a little script I use to muck directly with the binary.

<obligatory_warning>

Messing directly with a critical binary file is inherently dangerous, 
and may require root access to the system.  Make a backup copy and work 
carefully.  If things break, you get to keep all the pieces!!

</obligatory_warning>

Steve

--------------010102020306000501030406
Content-Type: text/plain;
 name="maxdata"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="maxdata"

#! /bin/ksh

# This script modifies 32-bit XCOFF variable o_maxdata (+4C).
# Non-zero o_maxdata uses the AIX "Large Address Space Model."
# See "AIX: General Programming Concepts, Writing and Debugging Pgms."

# exactly two parameters?
if [[ $# = 0 ]] 
then
  print 'usage: "maxdata filename [ 0-8 ]"' ; 
  print '\tThe second parameter (if present) specifies units of 256M.' ;
  print '\tIf omitted, the current value of maxdata is displayed.' ;
  print '\te.g.:  "maxdata /bin/xldb  4" sets /bin/xldb maxdata to 1G.' ;
  exit ;
fi

# first parm a 32-bit xcoff?
file $1 | grep -q 'executable (RISC System/6000) or object module' ;
if [[ $? -ne 0 ]] 
then 
  print "$1 isn't a readable 32-bit XCOFF file." ;
  exit ;
fi

if [[ $# = 1 ]]; then
  # Just display current setting.

  amount=`od -HAn -N4 -j76 $1 | head -1 | sed -e 's/^[	 ]*//g'`
  case $amount in
    0* ) print "$1 is not using a large address model"; exit ;;
    1* ) int=256 ;;
    2* ) int=512 ;;
    3* ) int=768 ;;
    4* ) int=1024 ;;
    5* ) int=1269 ;;
    6* ) int=1525 ;;
    7* ) int=1781 ;;
    8* ) int=2048 ;;
  esac
  print "$1 currently has maxdata setting of ${int}M"

elif [[ $# = 2 ]]; then
  # Set a value

  # ... and writable?
  if [[ ! -w $1 ]] 
  then
    print "$1 isn't a writable and executable file." ;
    exit ;
  fi

  # second parm equals 0,1,2,...,8 ?
  case ${2:-4} in 
  [0-8] ) typeset -i8  d=${2:-4}*16  ;
          typeset -i10 m=${2:-4}*256 ;;
      * ) print 'The second parameter has to be an integer [0-8].' ;
          exit 1 ;; 
  esac

  # Do it:
  print -n "$1 o_maxdata before: " ; od -HAx -N4 -j76 $1 | head -1 ;

  eval "print -n '\\0'${d#*#}'\\0\\0\\0' | 
      dd of=$1 bs=4 count=1 seek=19 conv=notrunc 2>/dev/null" ;

  print -n "$1 o_maxdata after:  " ; od -HAx -N4 -j76 $1 | head -1 ;

  print "Maxdata in $1 now set to ${m}M." ; 
fi

--------------010102020306000501030406--



------------------------------

Date: 4 Jul 2003 09:42:40 -0700
From: james@microsec.co.uk (James Lavery)
Subject: Pre-forking SOAP servers
Message-Id: <b966b3b3.0307040842.6046d68@posting.google.com>

Hi all,

Rob Riepel, in http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-8&selm=mvyitg0vhui.fsf%40Zathras.Stanford.EDU&rnum=2

indicates how to implement a forking SOAP server...

What I need to do is implement a pre-forking server - i.e. one which
forks of, say, 4 processes all listening on the same port.

I've already got this working for our own (in-house) tcp/ip non-SOAP
server processes (i.e. several listening on a port, and the first
picks up a request and processes it while the others continue to
listen), but we need to extend this so that they can handle SOAP
requests also/instead.

Any pointers would be greatly appreciated!

Thanks,

James


------------------------------

Date: Fri, 4 Jul 2003 17:20:57 +0200
From: "Dennis Hueckelheim" <dennis.hueckelheim@issdh.com>
Subject: Problems with perlcc
Message-Id: <be462g$12n7n$1@ID-139877.news.dfncis.de>

Hello everybody,

I want to compile a Perl-Script with perlcc. I tried the simple form:

perlcc myscript.pl

But I got much errors:

pccY3V42.c:18482: initializer element is not constant
pccY3V42.c:18482: (near initialization for `xrv_list[10].xrv_rv')

If I comment this lines:

----- snipp -----
use Unicode::String qw(utf8);
use Fcntl qw(:DEFAULT :flock);
----- snipp -----

all works fine. Can someone tell what my problem is?

Greetz, TIA


Dennis




------------------------------

Date: Fri, 04 Jul 2003 18:25:10 +0300
From: ddtl <this.is.invalid@yahoo.com>
Subject: Regexp constructed from command line arguments.
Message-Id: <q07bgv8c3baphp727t4jbtslo96e087e5c@4ax.com>

Hello everybody,

I wrote a perl script, which is supposed to rename music files : you 
pass it a directory name to use, regexp to search for
(let's call it searchexp) and a replacement regexp (let's call it
repexp). 

It reads filenames from the directory, processes filenames by
replacing searchexp by repexp, and renames the files. 

What i don't understand, is why sometimes you pass a searchexp that
matches filename, but a script won't replace it with repexp.

Here is a relevant problematic code snippet ($opts{'s'} holds
searchexp, and $opts{'r'} - repexp. $i and $n are variables
incremented 
by the loop):

1) @entry = fileparse($dir_list[$i], @extensions);

2) # if extension is not .mp3, .ogg or similar - no need to process
3) if ($entry[2] eq "") {next;}

4) $name_before[$n] = "$entry[1]" . "$entry[0]" . "$entry[2]";	
5) $entry[0] =~ s/\Q$opts{'s'}\E/\Q$opts{'r'}\E/g;
6) $name_after[$n] = "$entry[1]" . "$entry[0]" . "$entry[2]";

7) $n++;

For example, if i have one file named '00.mp3' in a directory,
searchexp is "[\d]{2}" and repexp is "a" (without surrounding
brackets, 
of course) - after execution of a line
5, $entry[0] is still "00", as before (i checked (using debugger) that
$opts{'s'} and $opts{'r'} really had a values of "[\d]{2}" and "a", 
respectively, and that value of "$entry[0]" didn't change after
execution
of a line 5).

What is wrong here? What is still stranger, is that sometimes script
does works as it should (for example, if filename is "_0_0.mp3", 
searchexp "_" and repexp "a").

ddtl.


------------------------------

Date: 04 Jul 2003 17:46:09 +0100
From: Brian McCauley <nobull@mail.com>
Subject: Re: Regexp constructed from command line arguments.
Message-Id: <u9n0fu5jfy.fsf@wcl-l.bham.ac.uk>

ddtl <this.is.invalid@yahoo.com> writes:

> Hello everybody,
> 
> I wrote a perl script, which is supposed to rename music files : you 
> pass it a directory name to use, regexp to search for
> (let's call it searchexp) and a replacement regexp (let's call it
> repexp). 

No, let's not do that.  The concept "replacement repexp"  is a bogus one.

I suspect you mean replacement string.

Actually your confusion between strings and regexps seems multi-faceted.

> It reads filenames from the directory, processes filenames by
> replacing searchexp by repexp, and renames the files. 
>
> What i don't understand, is why sometimes you pass a searchexp that
> matches filename, but a script won't replace it with repexp.
> 
> Here is a relevant problematic code snippet ($opts{'s'} holds
> searchexp, and $opts{'r'} - repexp. $i and $n are variables
> incremented 
> by the loop):

> s/\Q$opts{'s'}\E/\Q$opts{'r'}\E/g;

You are subjecting $opts{s} to quotemeta() you are therefore not
treating the contents of $opts{s} as a regexp to match but rather as a
plain string to match.

You are also subjecting $opts{r} to quotemeta().  This makes no sense
at all - if $opts{r} contained any \W characters they would actually
appear backslashed in the output.

You probably meant:

 s/$opts{s}/$opts{r}/g;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


------------------------------

Date: 04 Jul 2003 15:08:24 GMT
From: "James E Keenan" <jkeen@concentric.net>
Subject: Re: STDIO problem
Message-Id: <be4598$k2k@dispatch.concentric.net>


"Jan" <jan_buys@hotmail.com> wrote in message
news:11971c2c.0307040546.700d307b@posting.google.com...
> I'm trying to do some STD I/O on a cmd console from within a script
> called by another script.  I narrowed down the problem to the smallest
> full scripts I could.  test.pl is the main script, calling test2.pl in
> which the problems with the IO exist.
>
> Code of the 2 scripts :
>
> #!c:\perl\bin\perl.exe # Activeperl 5.6.1 - win32 build 633

I've been using ActivePerl for 3 years and have never known the shebang line
to work on Windows.  Do you know otherwise?  If I'm correct, then cqperl.exe
below is never being executed.  In any event, we'd probably need to see
cqperl.exe to help you out.

> # script : test.pl
>
> print `cqperl -w test2.pl`;
>
> #!c:\program files\Rational\clearquest\cqperl.exe
> # Cqperl, derived from Activeperl 5.6.0, win32
> # script : test2.pl
>
> $| = 1 ;
> print "Hello there\n" ;
> chomp($answer = <STDIN>);
> print "$answer to you too...\n";




------------------------------

Date: Fri, 4 Jul 2003 17:24:26 +0100
From: "Paul Marquess" <paul.marquess@btinternet.com>
Subject: Re: using 'DB_File' versus just plain tie() ?
Message-Id: <3f05aa3c$0$10622$ed9e5944@reading.news.pipex.net>

"Michele Dondi" <bik.mido@tiscalinet.it> wrote in message
news:po0bgv8acqjkrukgcuo9sdbsf9dno8e3vc@4ax.com...
> On 2 Jul 2003 19:47:48 -0700, botfood@yahoo.com (dan baker) wrote:
>
> >> 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... I was hoping there would be a
>
> Despite what you've been told, in my *experience* DB_File databases
> are definitely not portable across platforms. Not that I'm a big
> expert either, so I asked here, and I got the following answer:
>
> SH>The DB library uses platform specifics in the database. Things like
> SH>the endianness of the machine, and the size of ints. That means a
> SH>database created on one machine isn't necessarily readable on
> SH>another.
> [...]
> SH>One reason *DBM isn't made cross platform is that the performance
> SH>trade off (no longer being able to directly copy data from the file
> SH>to memory) isn't considered worth the benefit. After all you can
> SH>just read the data and write it out in a transport format (text for
> SH>example) and create a *DBM database in on the target machine. Well
> SH>I think anyway, not being the designer/author I'm just guessing.
>
> To which another valuable contributor to this ng added:
>
> BL>That's right. You can blame C, which is used to compile the
> BL>database engine for that. C tends to use pretty abstract names for
> BL>its data types, like int(), which physically are stored in the for
> BL>the machine most efficient way, but with no garantees at all about
> BL>portability. So all bets on endianness, or number of bits per
> BL>integer, are off.
> BL>
> BL>It is often possible to compile a database engine to use a portable
> BL>file format, but with a bad impact on efficiency. Speed could
> BL>easily halve.
>
> [Both quotations have been slightly edited for clarity]

There are two distinct issues here.

The first is the structure of the database itself.  As long as compatible
versions of Berkeley DB are used on all platforms, the database files can be
read/written to on all of them. The database format has been designed to be
portable and cope with big/little endian, word size etc .

The application data that is stored in the database is another matter - and
that is outside the control of DB_File. It is certainly possible to store
data on one architecture that will be read as a different value on another
architecture.

That said, by default DB_File will store ALL data as strings. So even if you
do something like this

    $hash{10} = 42 ;

the data written to the database will consist of the key: ASCII 61, ASCII 60
and the value: ASCII 64, ASCII 62. That WILL be portable across ASCII
architectures. So unless you explicitly store architecture specific data in
the database, you shouldn't have any problems with portability.

I'm going to add a note about all of this to the DB_File documentation.

Paul





------------------------------

Date: 4 Jul 2003 10:13:23 -0700
From: botfood@yahoo.com (dan baker)
Subject: Re: using 'DB_File' versus just plain tie() ?
Message-Id: <13685ef8.0307040913.4d84a5a9@posting.google.com>

"Paul Marquess" <paul.marquess@btinternet.com> wrote in message 

> 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}"
> 
----------------

good info... they are indeed different. 
so, I am faced with either making an intermeadiate "dumptoascii", and
then another to reload... or consider using a non-db_file solution. 
shucks.

thanks for help,

d


------------------------------

Date: Fri, 4 Jul 2003 11:25:48 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: using pipe & perl's ARGV filehandle ?
Message-Id: <slrnbgbakc.4l9.tadmc@magna.augustmail.com>

stu7 <stuseven@hotmail.com> wrote:

> Uri and Tad seemed frustrated when I asked about...


Because your question was incoherent.

Neither of us could make sense of what you are talking about.

Still can't.


>> perl first.pl | perl second.pl   something, something  ARGV fh ?


How piping works has *absolutely nothing* to do with what
programming language is used, so talking about languagage-specific
features such as Perl's ARGV are a red-herring that is not
related to piping.

With:

   perl first.pl | python second.py

piping behaves exactly the same (as described in my earlier followup).


>    I didn't specify what first.pl or second.pl contain, BE-cause,
>  according to what I was told, 


"told" how/where?

By a book or website? Which one?

By "some guy"? (in which case we cannot comment on what was said,
                since we did not hear it, and you seem unable to
                recite it sensibly.)


> PERL's built-in function...
>  ... the ARGV filehandle... 


A "function" and a "filehandle" are also very different concepts.

Confusing them will confuse you, and us.


>  will automatically contain the
>  content and/or arguments 


So which is it?

The "contents of a file" and "arguments" are *different* things,
you seem unaware of how they are different.

Clearing up your confusion of terms will go a long way towards
clearing up the ambiguities in what you are asking us.
   

> from the first script in this kind of
>  piping situation... in other words, those scripts could contain 
>  anything.


Then you were told a load of, ... stuff.

Since piping is only concerned with standard input and standard
output, the 1st program _must_ make output on stdout and the
2nd program _must_ read on stdin, or nothing will be communicated.

Once again, it makes no difference at all what programming language
is being used.


>    I was told, with no exception, this kind of script-to-script
>  data is automatically available via the built-in ARGV function, 


There is no ARGV function.

There is an ARGV filehandle.

There is an $ARGV scalar.

There is an @ARGV array.

There is a <> operator.

They are each different things. We need to know which one you are
talking about in order to understand what you are talking about.


>  sort-of like a  @_  


So then, you are talking about what is contained in Perl's @ARGV array?

It normally contains the command line arguments.


>     Can anybody show me an example of this working ?


You have not yet described your "this" well enough to know what
it is that you are asking, hence Uri's (unfulfilled) request for
you to backup and tell us "what is the real problem".

Forget what you were told.

Tell us what you want to accomplish and we will tell you how
to accomplish it whether it requires the use of some thingie
with "ARGV" in its name or not.


>     For the sake of discussion, first.pl could be:
>  
>            $a = 4 ; $b = 5 ; $c = ($a + $b) ;
> 
>   ...in second.pl, I would want to print $c... or even $a and $b...


That is not about the "contents" of a file, as you said earlier.

That is not about "arguments", as you said earlier, either.

That is about the values of "variables".

If you keep misleading us, we'll never get to the end of the trail...


It is impossible for one process to access the "variables"
in another process. IPC doesn't work that way.

If what you *want* to do is communicate from first.pl to second.pl,
you will need to devise some other way. 

One way might be via input/output (perhaps with a pipe).

Another way might be via command-line arguments.


>    Sorry... I'm clueless as to how it might work... 


And we were, and still are, clueless as to what "it" it is that you mean.

This is almost for sure an "XY problem".

Tell us what type of info you need to get from first.pl to second.pl,
and we can suggest ways of accomplishing that.


>    It doesn't make sense to me already, please don't remind me :)


Missing out on fundamentals will do that to you.

Your misuse of terms suggests to me that you don't have a clear
understanding of "who does what" in the running of a computer.
Please excuse me if I'm mistaken.

InterProcess Communication (IPC) depends a great deal on the
OS and shell, and only a little on which programming language
you are using.


"piping" has nothing to do with Perl.

"piping" is a feature of your OS/shell.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


------------------------------

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 5180
***************************************


home help back first fref pref prev next nref lref last post