[21855] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4059 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Nov 2 14:06:19 2002

Date: Sat, 2 Nov 2002 11:05:10 -0800 (PST)
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, 2 Nov 2002     Volume: 10 Number: 4059

Today's topics:
    Re: [Q] about AUTOLOAD <bill_knight2@yahoo.com>
        [Q]How to print contents of nested HASH in Perl? <benew666@hotmail.com>
    Re: [Q]How to print contents of nested HASH in Perl? <me@dwall.fastmail.fm>
    Re: Embedding Perl >with< the ptkdb debugger (Phlip)
    Re: File truncating script <krahnj@acm.org>
    Re: fill array with equal elements <garry@ifr.zvolve.net>
        help parsing large text file <hamptonk@spamlessgalaxie.com>
    Re: help parsing large text file <krahnj@acm.org>
    Re: Limit output of examine (x) and return (r) in debug (Peter Scott)
    Re: Path problem diplaying an image <alecler@sympatico.ca>
    Re: Path problem diplaying an image <alecler@sympatico.ca>
    Re: Perl -e "print qq!    Tips and Tricks   !" (zzapper)
        Permission Error? <samuel.shoes.maranto@shoes.townisp.com>
    Re: Permission Error? <dglage_SPAMMERSWILLBEFLAMEDAT@gmx.de>
        Portability issue with open() & rename() <news-perl-01@lklundin.dk>
    Re: Portability issue with open() & rename() <rereidy@indra.com>
    Re: Portability issue with open() & rename() <news-perl-01@lklundin.dk>
    Re: Portability issue with open() & rename() <uri@stemsystems.com>
    Re: Portability issue with open() & rename() <rereidy@indra.com>
        scripture regex (HealYourChurchWebsite)
    Re: scripture regex <pinyaj@rpi.edu>
        utf-8 in Matt's Form Mail <webmasterone@kidwatch-uk.net>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 2 Nov 2002 16:38:11 +0000 (UTC)
From: bill <bill_knight2@yahoo.com>
Subject: Re: [Q] about AUTOLOAD
Message-Id: <aq0v1j$5n7$1@reader1.panix.com>


In <3DC33FD3.EF1A9330@earthlink.net> Benjamin Goldberg <goldbb2@earthlink.net> writes:

>bill wrote:
>> 
>> I've been playing with the NEXT pseudo-class, and in particular, with
>> its AUTOLOAD method.  One puzzling thing about NEXT::AUTOLOAD is that,
>> at least when it is called by another class' AUTOLOAD method, the
>> variable NEXT::AUTOLOAD is not set.  How come?  Is this a bug, or is
>> this the correct behavior?

>When Package::AUTOLOAD(...) is automatically called by perl itself, then
>perl will set the $Package::AUTOLOAD variable.  When your AUTOLOAD
>subroutine calls NEXT::AUTOLOAD(...), you don't have to set
>$NEXT::AUTOLOAD, because the subroutine NEXT::AUTOLOAD(...) "knows" that
>it's not really being called by perl, but instead is being explicitly
>called by some other AUTOLOAD subroutine, and therefor looks at the
>string in ${ caller() . "::AUTOLOAD" }.

>In short, you don't have to do that because it's smart enough to figure
>out the methodname without it.

Here's what &NEXT::AUTOLOAD does with $NEXT::AUTOLOAD:

  sub AUTOLOAD
  {
	  my ($self) = @_;
	  my $caller = (caller(1))[3]; 
	  my $wanted = $NEXT::AUTOLOAD || 'NEXT::AUTOLOAD';
	  undef $NEXT::AUTOLOAD;
	  my ($caller_class, $caller_method) = $caller =~ m{(.*)::(.*)}g;
	  my ($wanted_class, $wanted_method) = $wanted =~ m{(.*)::(.*)}g;
	  # ... etc., etc.
		  return unless $wanted_class =~ /^NEXT:.*:ACTUAL/;
		  (local $Carp::CarpLevel)++;
		  croak qq(Can't locate object method "$wanted_method" ),
			qq(via package "$caller_class");
	  # ... etc., etc.
  }

So, when $NEXT::AUTOLOAD is not set, &NEXT::AUTOLOAD simply sets it to
the string "NEXT::AUTOLOAD".  This means that &NEXT::AUTOLOAD doesn't
know whether the Package::AUTOLOAD called &NEXT::AUTOLOAD or
&NEXT::ACTUAL::AUTOLOAD.  $wanted_class is set to "NEXT" regardles.
This is why calling &NEXT::ACTUAL::AUTOLOAD from Package::AUTOLOAD
fails to deliver the promised error message for undefined methods.

It looks to me like the only way to get around this bug in NEXT is to
explicitly set $NEXT::AUTOLOAD before calling &NEXT::ACTUAL::AUTOLOAD.

E.g.:
  package Foo;
  sub new { bless {}, 'Foo' }
  sub AUTOLOAD {
    use NEXT;
    $NEXT::AUTOLOAD = 'NEXT::ACTUAL::AUTOLOAD';
    (shift)->NEXT::ACTUAL::AUTOLOAD(@_);
  }

But this is only a partial work around, because, although this
AUTOLOAD won't fail silently, it produces a confusing error message:

  $f = Foo->new();
  $f->bar();  # -->  Can't locate object method "AUTOLOAD" via package "Foo" at next.pl line 17

bill


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

Date: Sat, 02 Nov 2002 08:37:30 GMT
From: "Stoone" <benew666@hotmail.com>
Subject: [Q]How to print contents of nested HASH in Perl?
Message-Id: <e9Mw9.21040$04.298196@news.bora.net>

Hi,

I am trying to print the nested hash tables under Perl.
For example, when there are hash tables like this,

$hash{key1}=valule1;
$hash{key2}{keya}=value2;
$hash{key2}{keyb}=value3;
$hash{key2}{keyc}=value4;
$hash{key2}{keyd}{A}=value5;
 ......
 .....

Someone please tell me how to print the key/value in the hash tables such as
above?

In the simple hash tables, I can do like this,

foreach $i (keys %hash} {
print "hash{$i}=$hash{$i}\n";
}

but, since the above hash is nested, this simple codes does not work.

Thanks in advance.






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

Date: Sat, 02 Nov 2002 15:48:19 GMT
From: "David K. Wall" <me@dwall.fastmail.fm>
Subject: Re: [Q]How to print contents of nested HASH in Perl?
Message-Id: <Xns92BA6DEC18E33dkwwashere@204.127.202.16>

[Followups directed to comp.lang.perl.misc]

"Stoone" <benew666@hotmail.com> wrote:
> I am trying to print the nested hash tables under Perl.
> For example, when there are hash tables like this,
> 
> $hash{key1}=valule1;
> $hash{key2}{keya}=value2;
> $hash{key2}{keyb}=value3;
> $hash{key2}{keyc}=value4;
> $hash{key2}{keyd}{A}=value5;
> ......
> .....
> 
> Someone please tell me how to print the key/value in the hash tables
> such as above?
> 
> In the simple hash tables, I can do like this,
> 
> foreach $i (keys %hash} {
> print "hash{$i}=$hash{$i}\n";
> }
> 
> but, since the above hash is nested, this simple codes does not work.

There are numerous examples of this sort of thing in perldsc ("Perl Data 
Structures Cookbook").  If you have trouble with the examples, then you 
may need to read up on references.  In that case, see perlref and 
perlreftut (Perl references and a tutorial on references).

-- 
David Wall - me@dwall.fastmail.fm
"Oook."


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

Date: 2 Nov 2002 08:41:49 -0800
From: phlip_cpp@yahoo.com (Phlip)
Subject: Re: Embedding Perl >with< the ptkdb debugger
Message-Id: <63604d2.0211020841.1350ef2f@posting.google.com>

Phlip wrote:

> >     char *embedding[] = { "", "-d:ptkdb", "-e1" };

> Now this gives "Can't load module Tk::Event, dynamic loading not available 
> in this perl."

From top to bottom, here's how to run an embedded script inside your
own app, publish a method into it, and debug that method with ptkdb.

Start with the FAQ:

http://www.dwam.net/docs/perl/faq/Windows/ActivePerl-Winfaq10.html

Now -e is a red herring (I got it from another FAQ).

That FAQ recommends the C++ PerlHost object, which generates 103
syntax errors. But we can still learn from it:

 * generate DynaLoader.c, by 
  - downloading ActivePerl's source, 
  - compiling it for win32
  - copy out the files DynaLoader.c dlutils.c
  - throw everything else away

 * generate your own XS method using the existing hyperactive
documentation

 * put them all together:

#   include <string>
#   include <EXTERN.h>
#   include <perl.h>
#   include "XSUB.h"


    static PerlInterpreter * my_perl;

    // DynaLoader stuff.
    //
    char *staticlinkmodules[] = {
        "DynaLoader",
        NULL,
    };
    
    // More DynaLoader stuff.
    //
    extern "C" XS(boot_DynaLoader);


    static
XS(XS_Module_guiMotionMan)
{
    dXSARGS;
    if (items != 3)
	Perl_croak(aTHX_ "Usage: guiMotionMan(src, srcLang, tgtLang)");
    {
	char const *	src = (char *)SvPV(ST(0),PL_na);	
	char const *	srcLang = (char *)SvPV(ST(1),PL_na);
	char const *	tgtLang = (char *)SvPV(ST(2),PL_na);
	char const *	RETVAL;
	dXSTARG;

    using std::string;
    string MotionMan(char const * src, char const * srcLang, char
const * tgtLang);

    string tgt (MotionMan(src, srcLang, tgtLang));

		RETVAL = tgt.c_str();

	sv_setpv(TARG, RETVAL); XSprePUSH; PUSHTARG;
    }
    XSRETURN(1);
}


    static void
xs_init(PerlInterpreter * my_perl)
{
    char *file = __FILE__;
    dXSUB_SYS;
    newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file);
    newXS("guiMotionMan", XS_Module_guiMotionMan, __FILE__);
}

    
    void
embedPerl()
{

    my_perl = perl_alloc();

        static char *
    embedding[] = { 
        "", 
        "-Ic:\\phlip\\zeus\\utils",
//      "-d:ptkdb", // decomment to debug
        "./test.pl"
        };
    
    perl_construct( my_perl );
    int const argc (sizeof embedding / sizeof embedding[0]);
    perl_parse(my_perl, xs_init, argc, embedding, NULL);
    perl_run(my_perl);    
    perl_destruct(my_perl);   
    perl_free(my_perl);

}

The trick was to not use -e, to pass the target script directly into
the embedding arguments, but to initialize DynaLoader inside xs_init
>before< perl gets to the arguments.

-- 
Phlip
  http://www.greencheese.org/HatTrick


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

Date: Sat, 02 Nov 2002 11:12:33 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: File truncating script
Message-Id: <3DC3B308.B09272EF@acm.org>

Bob wrote:
> 
> I wrote a script that trims a file to a certain size by chopping off
> lines from the beginning of the file.  This is specifically for log files.
> 
> I need it because our apache logs are growing huge, and we have
> webtrends installed.  The powers that be want to keep roughly 2 months
> of stats always in the logs, so this was one way I thought of to
> accomodate this.  I thought also of using logrotate ( Im on a redhat 7.1
> box), but rotating out an entire log file loses the 2 month minimum.
> 
> The script works, but it seems a bit slow when processing large files.
> Im not sure this can be improved too much, but if someone could tell me
>   in what way I can optimize the code or give a general critique that
> would be great.


I'd probably do it like this:

#!/usr/bin/perl -w
use strict;
use Fcntl ':seek';

my $usage = <<USAGE;
Useage: $0 filename size B|K|M
M = megabytes, K = kilobytes, B = bytes

USAGE

die $usage unless @ARGV == 3;

use constant K => 1_024;
use constant M => K * K;
my %units = ( B => [ 1, ''  ],
              K => [ K, 'K' ],
              M => [ M, 'M' ],
            );

my ( $file, $entered_size, $unit ) = @ARGV;
die $usage unless $size =~ /^\d+$/ and $unit =~ /^[BKM]$/;

my $bytes = -s $file;
( my $size = $entered_size ) *= $units{$unit}[0];
die "$file is already less than $entered_size $units{$unit}[1]bytes
($bytes bytes)\n\n"
    unless $bytes > $size;

open FILE, "+< $file" or die "Cannot open $file: $!";
seek FILE, $bytes - $size, SEEK_SET;
<FILE>;   # discard partial line
my $trim = do { local $/; <FILE> };
seek FILE, 0, SEEK_SET;
print FILE $trim;
truncate FILE, length $trim;
close FILE;

__END__



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 02 Nov 2002 14:43:25 GMT
From: Garry Williams <garry@ifr.zvolve.net>
Subject: Re: fill array with equal elements
Message-Id: <slrnas7orl.arf.garry@zfw.zvolve.net>

On Fri, 1 Nov 2002 13:58:30 +0100, peter pilsl <pilsl_use@goldfisch.at> wrote:
> Paul van Eldijk wrote:
>> 
>> my @array = ($value) x 10000;
>> 
> 
> I was sure that there is an easy solution but I didnt dream of such an easy 
> and obvious one ..
> 
> Its about twice as fast as all the other solutions and I think there is no 
> faster one.

Does 

  my @array;
  $#array = 9999;
  @array = ($value) x 10000;

speed it up?  

-- 
Garry Williams


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

Date: Sat, 02 Nov 2002 06:53:58 GMT
From: "Hampton Keathley" <hamptonk@spamlessgalaxie.com>
Subject: help parsing large text file
Message-Id: <aEKw9.56730$wG.162608@rwcrnsc51.ops.asp.att.net>

Greetings,

My expertise with perl is limited to regular expression search and replace
stuff and I've run into a project that I can't figure out.

I need to parse some large files and put them into a format that will go
into a database. Not every line has complete information. Some of the
information is missing. I need to throw away the descriptions and leave
behind the good info and put "none" in the missing spots so the fields will
line up properly and import into the database.

The file has lines that look like this:

country=US:state=TX:city=Dallas:areacode=214:lat=42.5044:long=-71.1964:timez
one=CST:etc...
country=GB:state=EN:city=London:lat=51.50:long=151.22

I want
US:TX:Dallas:214:42.5044:-71.1964:CST
GB:EN:London:none:51.50:151.22
etc.

I'm thinking I need to do a subroutine on each line, split it on the colons
and then match up data with variables like $country, $state, etc. Then
assign "none" to missing variables and write the whole line back out?

$line =~ s/(.*?)/&replace($1)/e;
    sub replace {
        my($wholeline)=@_;
            my @pieces = split(":", $wholeline);
            for each $pieces (@pieces) #is this right?
            {
            don't know what to do here?
            }
                return "$country:$state:$city:$areacode:$lat:$long";
                }

And that may be too inefficient for a huge file. Is there a better way?

thanks,


Hampton




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

Date: Sat, 02 Nov 2002 13:14:35 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: help parsing large text file
Message-Id: <3DC3CFA5.2DCB1341@acm.org>

Hampton Keathley wrote:
> 
> My expertise with perl is limited to regular expression search and replace
> stuff and I've run into a project that I can't figure out.
> 
> I need to parse some large files and put them into a format that will go
> into a database. Not every line has complete information. Some of the
> information is missing. I need to throw away the descriptions and leave
> behind the good info and put "none" in the missing spots so the fields will
> line up properly and import into the database.
> 
> The file has lines that look like this:
> 
> country=US:state=TX:city=Dallas:areacode=214:lat=42.5044:long=-71.1964:timez
> one=CST:etc...
> country=GB:state=EN:city=London:lat=51.50:long=151.22
> 
> I want
> US:TX:Dallas:214:42.5044:-71.1964:CST
> GB:EN:London:none:51.50:151.22
> etc.
> 
> I'm thinking I need to do a subroutine on each line, split it on the colons
> and then match up data with variables like $country, $state, etc. Then
> assign "none" to missing variables and write the whole line back out?
> 
> $line =~ s/(.*?)/&replace($1)/e;
>     sub replace {
>         my($wholeline)=@_;
>             my @pieces = split(":", $wholeline);
>             for each $pieces (@pieces) #is this right?
>             {
>             don't know what to do here?
>             }
>                 return "$country:$state:$city:$areacode:$lat:$long";
>                 }
> 
> And that may be too inefficient for a huge file. Is there a better way?


Something like this should work.

my @fields = qw/country state city areacode lat long timezone/;
my %data;

while ( <FILE> ) {
    chomp;
    @data{@fields} = ('none') x @fields;

    %data = ( %data, split /[:=]/ );

    print join( ':', @data{@fields} ), "\n";
    }



John
-- 
use Perl;
program
fulfillment


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

Date: Sat, 02 Nov 2002 14:00:19 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: Limit output of examine (x) and return (r) in debugger.
Message-Id: <TTQw9.657764$Ag2.25032567@news2.calgary.shaw.ca>

In article <apu5cr$tqf$1@plover.com>,
 mjd@plover.com (Mark Jason Dominus) writes:
>In article <s0p1suknk1di5bra5o49upar5pejlr7tcb@4ax.com>,
>Teh (t'p) <teh@mindless.com> wrote:
>>Sadly I'm using an older version.
>
>
>But you can obtain the perl5db.pl from 5.8.0 and use it instead of the
>one you were using, without having to change the version of Perl you
>are using.

And also update dumpvar.pl at the same time, which has at least one
new function in that's called from the new perl5db.pl (not for any of the
things the poster was asking about, though).

-- 
Peter Scott
http://www.perldebugged.com


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

Date: Sat, 02 Nov 2002 13:09:17 -0500
From: Andre <alecler@sympatico.ca>
Subject: Re: Path problem diplaying an image
Message-Id: <alecler-3AF473.13091702112002@news1.qc.sympatico.ca>

In article <3dc33f28@newsgate.imsbiz.com>, "Corin" <corin@cadaway.co.uk> 
wrote:

> This is a very simple problem which is really bugging me.
> I have written a script to upload an image file ($final_filename) from my
> hard disc to the server .
> If I upload it to my root directory then I can display the image using :
> 
> print("<img src=\"$final_filename\">");
> 
> but if I specify the upload path to be in another directory I cannot display
> the image, the new path being :
> 
> print("<img
> src=\http://www.mydomain.com/public_html/photo_uploads/$final_filename\>");
> or
> print("<img
> src=\"/home/mydomain/public_html/photo_uploads/$final_filename\">");
> 
> I know the image file ($final_filename) is in the photo_uploads directory
> coz I can see it and it isn't corrupt.

[This reply e-mailed to you because off-topic for c.l.p.misc.]

Try:

   print qq(<img src="/photo_uploads/$final_filename">);

The webserver should automatically expand the first "/" to the actual path 
of your HTML root directory.

Hope this helps, sorry if it doesn't.
Andr


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

Date: Sat, 02 Nov 2002 13:10:51 -0500
From: Andre <alecler@sympatico.ca>
Subject: Re: Path problem diplaying an image
Message-Id: <alecler-D27373.13105102112002@news1.qc.sympatico.ca>

In article <alecler-3AF473.13091702112002@news1.qc.sympatico.ca>, Andre 
<alecler@sympatico.ca> wrote:

> [...]Try:[...]

Darn! I intended to e-mail this, posted it by mistake.

Andre


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

Date: 2 Nov 2002 03:50:53 -0800
From: david@tvis.co.uk (zzapper)
Subject: Re: Perl -e "print qq!    Tips and Tricks   !"
Message-Id: <f677762.0211020350.63c2a7ea@posting.google.com>

Benjamin Goldberg <goldbb2@earthlink.net> wrote in message news:<3DC2F1CC.3988B114@earthlink.net>...
> zzapper wrote:

$_=",.,,,.,,.,,.,,,,..,,,,,,,,.,,,,,,,,,,,,,.,,,,,,,,,.,,,,,,,..,..,,.,,,,,
   ,,,,";s/\s//gs;tr/,./05/;@a=split(//);$_=<DATA>;tr/~`'"^/0-4/;map{$o
   .=$a[$i]+$_;$i++}split(//);@a=$o=~m!...!g;map{print chr}@a;
__DATA__
~'^``'``~```~"'~^'``~```````~^`~```^~"'~"~`~```^`~"~"'`~^~^'~^^`~'`~```^~`~

Bejamin I found this "stinker" JAPH

It's not a perl -e, but does it fit your "anything resembling
plaintext is insuffienctly obscure"
criteria


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

Date: Sat, 2 Nov 2002 11:12:42 -0500
From: "Newman" <samuel.shoes.maranto@shoes.townisp.com>
Subject: Permission Error?
Message-Id: <us7ubl1k1ll21c@corp.supernews.com>

I'm using a semi-free web server (Tripod by Lycos) and trying to run a free
CGI/Perl script.  The script (cgiComments) allows users to comment on a
weblog.  I am receiving the following error when trying to execute the
script:

Insecure dependency in open while running with -T switch at cgicomments.cgi
line 84.

The offending line (84):

open (COMMENTS, ">>$comment_directory$blog_id") or die ("Can't write to file
$blog_id");

The offending variable, I beleive, is:

my($comment_directory) = '/';

I suspect that the script is unable to open a file in the comment directory,
perhaps because I have not properly set the value of "comment_directory"?
The FAQ documentation for my web hosting service has this to say:

" What is the root directory for my scripts? -- The root directory for your
scripts is your cgi-bin itself; if you need to fill in the root directory,
it is simply "/".  "

So that's what I set "comment_directory" to.  Can anyone spot the issue?

Thanks





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

Date: Sat, 2 Nov 2002 19:32:43 +0100
From: Daniel Glage <dglage_SPAMMERSWILLBEFLAMEDAT@gmx.de>
Subject: Re: Permission Error?
Message-Id: <Xns92B9C4F2A590CNowstopsanobleheartG@62.153.159.134>

Being severely ignorant of "cgicomments.cgi"'s purpose, I'd suspect that 
using somthing like

my $filename = $comment_directory . $blog_id;
open(COMMENTS, ">>$filename") or die("Can't write to $filename: $!");
# instead of
> open (COMMENTS, ">>$comment_directory$blog_id") or die ("Can't write
> to file $blog_id");

might prove helpful - 'die' should then log the filename AND reason to your 
http-errors log. :)

If you suspect the fileNAME opened causing a problem, why not

die("My filename is: $filename");

before your "open" call?


Good luck :)


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

Date: Sat, 02 Nov 2002 15:16:04 +0100
From: "Lars Kr. Lundin" <news-perl-01@lklundin.dk>
Subject: Portability issue with open() & rename()
Message-Id: <pan.2002.11.02.15.16.04.620746.18252@lklundin.dk>

Hello,

(This is my first posting to this group).

The following command produces the same result under
IRIX, Solaris and Linux but a different result under CygWin:

perl -le 'open(OUT,">a");open(OUT,">b");print "$^O $] ", rename("a","b")'

irix 5.00502 1
solaris 5.00503 1
linux 5.006001 1

cygwin 5.006001 0

Apart from the fact that one would probably not want to
involve an open file in a rename() I find it disturbing that
the code is not portable.

Can anyone here point me to other portability issues with perl
especially with regard to differences between Linux & CygWin ?

Thank you,
-Lars Lundin.
-- 
GEDCOMP: An extensive and free database for genealogists with
interest in Denmark: http://www.lklundin.dk/gedcomp/


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

Date: Sat, 02 Nov 2002 07:40:18 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Portability issue with open() & rename()
Message-Id: <3DC3E3D2.499E988C@indra.com>

"Lars Kr. Lundin" wrote:
> 
> Hello,
> 
> (This is my first posting to this group).
> 
> The following command produces the same result under
> IRIX, Solaris and Linux but a different result under CygWin:
> 
> perl -le 'open(OUT,">a");open(OUT,">b");print "$^O $] ", rename("a","b")'
> 
> irix 5.00502 1
> solaris 5.00503 1
> linux 5.006001 1
> 
> cygwin 5.006001 0
> 
> Apart from the fact that one would probably not want to
> involve an open file in a rename() I find it disturbing that
> the code is not portable.
> 
> Can anyone here point me to other portability issues with perl
> especially with regard to differences between Linux & CygWin ?
> 
> Thank you,
> -Lars Lundin.
> --
> GEDCOMP: An extensive and free database for genealogists with
> interest in Denmark: http://www.lklundin.dk/gedcomp/
So, what is the "different" result?
-- 
Ron Reidy
Oracle DBA


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

Date: Sat, 02 Nov 2002 15:57:13 +0100
From: "Lars Kr. Lundin" <news-perl-01@lklundin.dk>
Subject: Re: Portability issue with open() & rename()
Message-Id: <pan.2002.11.02.15.57.13.420841.18252@lklundin.dk>

Sat, 02 Nov 2002 15:40:18 +0100 skrev Ron Reidy:

> So, what is the "different" result?

That the rename fails under CygWin producing a '0'
in the standard output as shown in the first posting.

-Lars Lundin.
-- 
GEDCOMP: An extensive and free database for genealogists with
interest in Denmark: http://www.lklundin.dk/gedcomp/


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

Date: Sat, 02 Nov 2002 18:00:31 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Portability issue with open() & rename()
Message-Id: <x7k7jvj1hd.fsf@mail.sysarch.com>

>>>>> "LKL" == Lars Kr Lundin <news-perl-01@lklundin.dk> writes:

  LKL> Sat, 02 Nov 2002 15:40:18 +0100 skrev Ron Reidy:
  >> So, what is the "different" result?

  LKL> That the rename fails under CygWin producing a '0'
  LKL> in the standard output as shown in the first posting.

this has nothing to do with perl. it is an OS difference. winblows
doesn't allow files to be moved, renamed or deleted if they are open.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
----- Stem and Perl Development, Systems Architecture, Design and Coding ----
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: Sat, 02 Nov 2002 11:44:34 -0700
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Portability issue with open() & rename()
Message-Id: <3DC41D12.CCA44970@indra.com>

"Lars Kr. Lundin" wrote:
> 
> Sat, 02 Nov 2002 15:40:18 +0100 skrev Ron Reidy:
> 
> > So, what is the "different" result?
> 
> That the rename fails under CygWin producing a '0'
> in the standard output as shown in the first posting.
> 
> -Lars Lundin.
> --
> GEDCOMP: An extensive and free database for genealogists with
> interest in Denmark: http://www.lklundin.dk/gedcomp/
In that case, 'perldoc -q rename'.
-- 
Ron Reidy
Oracle DBA


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

Date: 1 Nov 2002 22:02:15 -0800
From: healthychurchwebsite@yahoo.com (HealYourChurchWebsite)
Subject: scripture regex
Message-Id: <7750146a.0211012202.2c5ac075@posting.google.com>

I'm tring to write a program that will identify Scripture references
and then tag them up. Here's where I'm at:

my $volumes = "I+|1st|2nd|3rd|First|Second|Third|1|2|3";
my $books = "Genesis|Exodus|Leviticus|Numbers|Deuteronomy|Joshua|Judges|Ruth|Samuel|Kings|Chronicles|Ezra|Nehemiah|Esther|Job|Psalm|Proverbs|Ecclesiastes|Song
of Solomon|Isaiah|Jeremiah|Lamentations|Ezekiel|Daniel|Hosea|Joel|Amos|Obadiah|Jonah|Micah|Nahum|Habakkuk|Zephaniah|Haggai|Zechariah|Malachi|Matthew|Mark|Luke|John|Acts|Romans|Corinthians|Galatians|Ephesians|Philippians|Colossians|Thessalonians|Timothy|Titus|Philemon|Hebrews|James|Peter|Jude|Revelation";

while(<DATA>) {
    my $passage;
    s/(?:($volumes)\s*)*(?:($books)|\G,)\s+(\d+:\d+(?:[-&]\d+)?)/
	$passage = ($1 ? "$1 ":"").($2 ? $2:"").($3 ? " $3":"") if defined
$2;
	"<scripRef passage=\"$passage\">$passage<\/scripRef>"/gce;
    print $_;
}
	
__DATA__
Romans 10:9-10, 1 Corinthians 13:1-8
III John 1:2-4, 2:1&2
III John 1:2-4, 2:1&2; 2nd Peter 2:1

# ----------------------

But I'm stuck on (\d+:\d+(?:[-&]\d+)?) ... it doesn't seem to include
2:1&2 with 1:2-4 ... e.g:

III John 1:2-4, 2:1&2

I've tried a couple of ?: and \G solutions, to no avail.

HELP?!


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

Date: Sat, 2 Nov 2002 09:40:19 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: HealYourChurchWebsite <healthychurchwebsite@yahoo.com>
Subject: Re: scripture regex
Message-Id: <Pine.A41.3.96.1021102093043.61744A-100000@vcmr-104.server.rpi.edu>

[posted & mailed]

On 1 Nov 2002, HealYourChurchWebsite wrote:

>while(<DATA>) {
>    my $passage;
>    s/(?:($volumes)\s*)*(?:($books)|\G,)\s+(\d+:\d+(?:[-&]\d+)?)/
>	$passage = ($1 ? "$1 ":"").($2 ? $2:"").($3 ? " $3":"") if defined
>$2;
>	"<scripRef passage=\"$passage\">$passage<\/scripRef>"/gce;
>    print $_;
>}

It looks like you're allowing

  I John 1:2-4 II, 1:6-8

which is kinda weird-looking.  Perhaps if you come up with a concrete
definition of what your scripture lines look like (or at least give more
examples) I can help you better.

>But I'm stuck on (\d+:\d+(?:[-&]\d+)?) ... it doesn't seem to include
>2:1&2 with 1:2-4 ... e.g:
>
>III John 1:2-4, 2:1&2

Here is how I would write the regex, but I might be dealing with a
different data set than you.

  my $verses = qr{ \d+ : \d+ (?: [-&] \d+) }x;

  m{
    ( (?: $volumes (?: \s+ $volumes )* )? )  # any number of vols.
    \s+
    ( $books )                               # the book
    \s+
    ( $verses (?: \s* , \s* $verses)* )      # all requested verses
  }x

-- 
Jeff "japhy" Pinyan      RPI Acacia Brother #734      2002 Acacia Senior Dean
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: Sat, 2 Nov 2002 16:43:50 -0000
From: "TrickieDickie" <webmasterone@kidwatch-uk.net>
Subject: utf-8 in Matt's Form Mail
Message-Id: <bkTw9.6305$VM5.274175@newsfep2-win.server.ntli.net>

Greetings,
Can anyone please advise me how to modify
Matts FormMail script so that the text inputted in the form
is the text delivered to the mail client.  I regret I know
nothing about Perl at all and my research does not seem
to give me a usable answer.

My HTML includes - in part, the following code:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<html lang=en>
<HEAD>
<TITLE></TITLE>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</HEAD>

<body>

<FORM ACTION="http://www.kidwatch-uk.net/cgi-bin/FormMail.pl" METHOD="POST"
accept-charset="utf-8">
<INPUT TYPE="HIDDEN" NAME="recipient" value="webmasterone@kidwatch-uk.net">
<INPUT TYPE="HIDDEN" NAME="redirect"
VALUE="http://www.kidwatch-uk.net/Messages/ThankyouMessage.htm"
target="main">
<INPUT TYPE="HIDDEN" NAME="subject" VALUE="MESSAGE INTERNATIONAL">
<INPUT TYPE="HIDDEN" NAME="required"
VALUE="Surname,FirstName,MESSAGE,email">
<INPUT TYPE="HIDDEN" NAME="env_report" VALUE="REMOTE_HOST,REMOTE_ADDR">

<textarea name="MESSAGE" rows=5 cols=72></textarea>
etc

The trouble is - if a message in arabic, for instance, is entered thus:

ع?د.ا SرSد
ا"عا". أ? Sتf"'., ف?^ Sتحد'ث ب"غة S^?Sf^د.

I get this back in the e-mail:

MESSAGE: ~¹T? ~¯T?~§ T ~±T ~¯
~§T?z~¹~§T?zT? ~£T? T ~ªT'T?zT'T?,
TT?T? T ~ª~­~¯T'~« ~¨T?z~º~© T T?T? T
T'T?~¯.

which, when put back into a unicode html page does not render as
Arabic text.  I just cannot find anywhere in matts script to
change the parameters of the @CODEPAGE returned or a charset
parameter.

Help Pls

--
Regards
Dick Rosser
webmasterone@kidwatch-uk.net
http://www.kidwatch-uk.net






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

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


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