[22412] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4633 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Feb 27 09:06:06 2003

Date: Thu, 27 Feb 2003 06: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           Thu, 27 Feb 2003     Volume: 10 Number: 4633

Today's topics:
    Re: Anyway to do away with ?: in the map function <tore@aursand.no>
    Re: Anyway to do away with ?: in the map function <oxmard.Rules@ab.ab>
    Re: Beginner question: Accessing anonymous data struct <brinker.h@stn-atlas.de>
    Re: Delete a single leading space from a line <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
    Re: FAQ proposal: Why can't I compare two strings using (Anno Siegel)
    Re: geting premature end of script header error (Helgi Briem)
    Re: Getting answers with perldocs (C Marshall)
    Re: getting prmature end of script headers <REMOVEsdnCAPS@comcast.net>
    Re: How to temporarily untie and then tie again <jihghong@yahoo.com.tw>
    Re: How to temporarily untie and then tie again (Anno Siegel)
        Including my perl functions in one file in another perl (Warren Ayling)
    Re: Including my perl functions in one file in another  <bernard.el-hagin@DODGE_THISlido-tech.net>
        Killing "process groups" on Win32 <allan_herriman.hates.spam@agilent.com>
        moving sub routine to module (Mike Solomon)
    Re: moving sub routine to module <noreply@gunnar.cc>
    Re: moving sub routine to module (Tad McClellan)
        Necessary modules? <edgue@web.de>
    Re: Necessary modules? (Anno Siegel)
    Re: newbie regexp question <tore@aursand.no>
        PerlCC Error on Win2k - Perl57.lib ?! (Martin Bohnert)
        Regular Expression for Email Aliases <strap@fabiand.net>
    Re: Regular Expression for Email Aliases <ian@WINDOZEdigiserv.net>
    Re: Regular Expression for Email Aliases <strap@fabiand.net>
    Re: Regular Expression for Email Aliases (Tad McClellan)
    Re: require subs and global parameters (kydongau)
    Re: Simple question about Perl Regular Expressions <tore@aursand.no>
        Writing my own scripting language. Need advice. <kellygreer1@hell.rr.com>
    Re: Writing my own scripting language. Need advice. <corno@%spam%.dds.nl>
    Re: Writing my own scripting language. Need advice. <trollking@shaw.ca>
    Re: Writing my own scripting language. Need advice. <ubl@schaffhausen.de>
    Re: Writing my own scripting language. Need advice. <saywhat@spammer.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 27 Feb 2003 13:28:58 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Anyway to do away with ?: in the map function
Message-Id: <pan.2003.02.26.22.55.25.710423@aursand.no>

On Wed, 26 Feb 2003 12:57:13 -0600, Peter Shankey wrote:
> map {
>  / values \((\w*),('[\W*|\w*]*'),([\w]*),([\w]*)/
> [...]

Just a tip;  Try to avoid using 'map' in a void context.


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: Thu, 27 Feb 2003 07:15:59 -0600
From: "Peter Shankey" <oxmard.Rules@ab.ab>
Subject: Re: Anyway to do away with ?: in the map function
Message-Id: <jeSdnUZo1vcQksOjXTWc3w@comcast.com>

I did run into some warning messages when I was trying to use map. Any
particular reason why?


"Tore Aursand" <tore@aursand.no> wrote in message
news:pan.2003.02.26.22.55.25.710423@aursand.no...
> Just a tip;  Try to avoid using 'map' in a void context.

> Tore Aursand - tore@aursand.no - http://www.aursand.no/
>




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

Date: Thu, 27 Feb 2003 10:18:37 GMT
From: Heinz Brinker <brinker.h@stn-atlas.de>
Subject: Re: Beginner question: Accessing anonymous data struct
Message-Id: <1103_1046341117@dsit03>


> It would have been nice if you had simply given it in "exactly like"
> form so that we could easily have real data to work with...

Sorry, I promise to do next time.

> >    'person' => {
> >       'P1' => {
> 
> >       'P2' => {
> Numerically increasing keys make it likely that an array
> would be better than a hash at this level...

Good point. Thank you. Ill think it over.

> > First I'd like to learn how I can find the number of persons in
> > the person hash.
> 
> Use keys() in a scalar context to find out how many entries are in a hash:
> 
>    my $num_persons = keys %{ $h{persons}{person} };

Aah, now I see what I did wrong. Its the surrounding braces 
I didnt figure out. I always tried to use the % inside the
outer hashes. Thank you for your advice.

> I don't understand the question. Is "P2" the "name" or is
> "Name of person 1" the "name" that you refer to?

"Name of person 1" is the name I was referring to.

>    my $num_persons = keys %hash;  # pretend it is a plain hash
> 
>    my $num_persons = keys %{  };  # replace the name with a block

I didnt understand this step. :-(

>    # fill in the block with a reference to the desired hash
>    my $num_persons = keys %{ $h{persons}{person} };

Thats it. Thanks alot!

Greets   Heinz 






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

Date: 27 Feb 2003 11:35:21 GMT
From: Rene van Leeuwen <r.t.j.van.leeuwenNOSPAM@THANKSplanet.nl>
Subject: Re: Delete a single leading space from a line
Message-Id: <b3kt5p$dp1$1@reader11.wxs.nl>

In article <c2d0c52.0302261325.1cd5450c@posting.google.com>, crivers wrote:
> If I have a string that contains more than one leading space,
> how can I delete only the first space and keep the remaining spaces?
> The regular expression below deletes all leading spaces:
> 
> $str =~ s/^\s//;

Your regex wipes any white-character on the first position, you should
use:
$str =~ s/^ //;



-- 
 ___              _
| _ \___ _ _  ___//
|   / -_) ' \/ -_)  
|_|_\___|_||_\___|  


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

Date: 27 Feb 2003 12:29:53 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: FAQ proposal: Why can't I compare two strings using == ?
Message-Id: <b3l0c1$nfc$2@mamenchi.zrz.TU-Berlin.DE>

Philip Lees <pjlees@ics.forthcomingevents.gr> wrote in comp.lang.perl.misc:
> On Thu, 27 Feb 2003 07:37:42 GMT, pjlees@ics.forthcomingevents.gr
> (Philip Lees) wrote:
> 
> >NOTE: If you use warnings (as you should) then Perl will alert you to
> 
> Gak! I did it again. Of course, I meant 'perl'.

I don't think "Perl" is wrong in this context.  It's a language feature.
Lowercase "perl" is only needed when you're talking about the executable
file (/usr/bin/Perl is obviously be wrong).

Anno


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

Date: Thu, 27 Feb 2003 13:05:28 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: geting premature end of script header error
Message-Id: <3e5e0bee.1732324540@news.cis.dfn.de>

On Wed, 26 Feb 2003 22:45:46 GMT, "matt"
<urzaserra@home.com> wrote:

>I just got this perl cgi program that is a web based database searcher and
>editor but i am getting the premature end of script header errors.
>
>http://www.onlinewebpromotion.com/cgi-bin/dbrowser/search.cgi
>
>I am very new to perl and cant see why this is happening.

Read perldoc -q 500 first, also known as:
   My CGI script runs from the command line but not the 
   browser.  (500 Server Error)

Debug your program from the command line before
deploying it in the CGI environment

Use a CGI module to write CGI programs.

Learn to walk before you run.

Your query is off-topic for this newsgroup which
is for the discussion of the Perl programming 
language.

Direct CGI questions to an appropriate newsgroup
such as comp.infosystems.www.authoring.cgi

Direct web server configuration problems to the
appropriate newsgroup in the comp.infosystems.www.servers.* 
hierarchy

-- 
Regards, Helgi Briem
helgi AT decode DOT is


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

Date: 27 Feb 2003 03:28:20 -0800
From: c_j_marshall@hotmail.com (C Marshall)
Subject: Re: Getting answers with perldocs
Message-Id: <cb9c7b76.0302270328.4f793d5f@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message 
> >>    perl -ne "print if /remove/ and /space/" *.pod
> > Is there any way to get this line to also print the name of the file
> > it found the match in ?
> 
> 
> Yes.
> perl -ne 'print "$ARGV: $_" if /remove/ and /space/' *.pod
> 
>

Ah - I was missing the "" - thank you.


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

Date: Thu, 27 Feb 2003 07:06:30 -0600
From: "Eric J. Roode" <REMOVEsdnCAPS@comcast.net>
Subject: Re: getting prmature end of script headers
Message-Id: <Xns932F526403DEDsdn.comcast@216.166.71.239>

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

"matt" <urzaserra@home.com> wrote in
news:k_g7a.2317$Pa.285343@news2.west.cox.net: 

> 
> "Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
> news:Xns932EE1121F382sdn.comcast@216.166.71.239...
>> Who the hell is handing this crap out?
> 
> I got it from a free cgi script website after doing a search free perl
> scripts this is the website from where i got it.
> 
> http://www.summersault.com/software/db_browser/
> 

I downloaded the DB_browser code and had a look at it.  It's not quite as 
horrible as I had first thought it would be, but it's not that good.  It 
does little or no input validation, so it opens your website to attack -- 
not good.

The best source of free CGI perl scripts on the web is nms-
cgi.sourceforge.net.  Unfortunately, they don't seem to have a database 
browser, which is apparently what you're looking for.  You might want to 
try freeperlcode.com -- they seem to have a lot of stuff -- but I didn't 
download any of it, so I can't vouch for how good or how bad it is.

I would still advise you to find a good book or two and get learning :-)
Good luck.

- -- 
Eric
print scalar reverse sort qw p ekca lre reh 
ts uJ p, $/.r, map $_.$", qw e p h tona e;

-----BEGIN xxx SIGNATURE-----
Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>

iQA/AwUBPl4NM2PeouIeTNHoEQLnWQCbBTD3M6WFFwttwWheugc1YC1AFyQAn3Xj
Rfvk45OcdSunC6UZ2fLOwWoo
=lO9O
-----END PGP SIGNATURE-----


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

Date: Wed, 26 Feb 2003 10:07:00 +0800
From: "John Lin" <jihghong@yahoo.com.tw>
Subject: Re: How to temporarily untie and then tie again
Message-Id: <b3h7g5$93i@netnews.hinet.net>

nobull wrote
> "John Lin" wrote
> > "Brian McCauley" wrote
> > > (John Lin) writes:
> > > > I want to temporarily untie [...] and then tie it back again
> > > use Tie::Restore;
> > > tie *STDOUT, 'Tie::Restore', $tied;    # Yes, it does work.
>
> > Cool!  The source code of this module is only a few lines:
> > So, just grabbing what I need, my code becomes:
> >
> > tie *STDOUT,'Tie::Restore',$tied;
> > sub Tie::Restore::TIEHANDLE { $_[1] }
>
> I would discourge this behaviour.

I understand.  Here I found there might be something new for me to learn:

> If you are writing a script this should be in namespace that's reserved
> never to appear in a CPAN module.

I know "lower case barewords" are reserved for Perl language itself.
So we are suggested to use "upper case CamelStyle words" for class names.

As for "namespace reserved never to appear in a CPAN module",
is there such a thing?  Let me guess:

"My"?  No, it would collide with those who uses MakeMaker (for example).
"_LeadingUnderscore"? Sounds good.  Is it the answer? Where documented?

> Now Tie::Restore exists it is better to use it.

I know.  If Tie::Restore is in standard distribution, I surely would.
(I work on Perl5.6 (I have to), don't know about Perl5.8)

The "one line solution" is just for lazy me to avoid the overhead of
downloading (and distributing) a non-standard CPAN module.

P.S.
Good news, your "use select instead" advice solved one of my big problems.

Thank you very much!!!

John Lin




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

Date: 27 Feb 2003 12:31:26 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to temporarily untie and then tie again
Message-Id: <b3l0eu$nfc$3@mamenchi.zrz.TU-Berlin.DE>

John Lin <jihghong@yahoo.com.tw> wrote in comp.lang.perl.misc:
> nobull wrote
> > "John Lin" wrote
> > > "Brian McCauley" wrote
> > > > (John Lin) writes:
> > > > > I want to temporarily untie [...] and then tie it back again

[discussion snipped]

Just for its entertainment value, here is an alternative method to
temporarily suspend the tie on a variable.  It only works with
tied package variables:

    our $var;
    tie $var, 'Some::Class';
    {
        local *var;  # this suspends the tie
        tie $var, 'Other::Class'; # you can tie it to something else
    }
    # now $var is again tied to Some::Class

I don't think the behavior is described anywhere, so it cannot be
seriously recommended; I found it by coincidence.

Anno



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

Date: 27 Feb 2003 05:14:35 -0800
From: warren_ayling@hotmail.com (Warren Ayling)
Subject: Including my perl functions in one file in another perl script file
Message-Id: <da669e11.0302270514.576102c9@posting.google.com>

I have been reading various Perl books and searching the Perl Google
group but with little luck.

Is there any way to include Perl functions in one file, in anther Perl
file, e.g.:

include "../utils/my_perl_utils";

I am new to Perl but have already collected and written some great
utility functions that I would like to be able to reuse in other
scripts.

Do I have to compile them into a module before I can reuse them?

Many thanks


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

Date: Thu, 27 Feb 2003 13:23:01 +0000 (UTC)
From: "Bernard El-Hagin" <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: Including my perl functions in one file in another perl script file
Message-Id: <Xns932F919C93654elhber1lidotechnet@62.89.127.66>

Warren Ayling wrote:

> I have been reading various Perl books and searching the Perl Google
> group but with little luck.
> 
> Is there any way to include Perl functions in one file, in anther Perl
> file, e.g.:
> 
> include "../utils/my_perl_utils";


perldoc -f require


-- 
Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'



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

Date: Thu, 27 Feb 2003 21:05:30 +1100
From: Allan Herriman <allan_herriman.hates.spam@agilent.com>
Subject: Killing "process groups" on Win32
Message-Id: <jnnr5v4b5t3mgobfvtb64jvjq7f841kfl2@4ax.com>

Hi,

I'm trying to kill a subprocess and all its children.

Does anyone know how I can do this?

The bad news is that I'm using Activestate perl 5.6 or 5.8 on NT or
Windows 2000, and I don't think windows has the concept of a process
group.  (Actually 2000 has "jobs" in its API, but these don't seem to
be available through Perl.  In any case, they wouldn't work on NT.)

BTW, the children could be any abitrary program, and the "parent"
subprocess is created by Win32::Process::Create.

TIA,
Allan.


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

Date: 27 Feb 2003 04:59:53 -0800
From: mike_solomon@lineone.net (Mike Solomon)
Subject: moving sub routine to module
Message-Id: <56568be5.0302270459.77306294@posting.google.com>

I have a little sub routine I use for debugging and I want to put it
into a module rather than in each script

The problem I have is that the module needs to know the debug flag I
have set in the script and the file I have opened to write the
debugging information to

I am sure there must be an easy way to do what I want but I am having
problems working out how to do it

I only want to pass the text to be printed to the subroutine

I have included an extract of my code below

It obviously does not work

Any help with this issue would be gratefully received

Thanks

--------------------------------------
#test.pl

#set pragmas
use strict;
use testmodule;	

#create new cgi
my $g_cgi = new CGI;

my $g_debug = "Y";		#set debug status
open DEBUG, ">debug/exib_detail.txt" if $g_debug eq "Y";

my $g_time = localtime;	#used with debug
&Debug($g_time);

exit;
-----------------------------------------
#testmodule.pm

package testmodule;				#declare package

use Exporter ();
@ISA = qw(Exporter);
@EXPORT = qw(Debug);

use strict;

1;

sub Debug {
	#debug routine
	my ($text) = @_;
	print DEBUG "$text\n" if $g_debug eq "Y";
} #end Debug

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

Regards


Mike Solomon


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

Date: Thu, 27 Feb 2003 14:23:50 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: moving sub routine to module
Message-Id: <b3l3qo$1nmm9o$1@ID-184292.news.dfncis.de>

Mike Solomon wrote:
> I have a little sub routine I use for debugging and I want to put it
> into a module rather than in each script
> 
> The problem I have is that the module needs to know the debug flag I
> have set in the script and the file I have opened to write the
> debugging information to

As far as I understand, the function in the module needs to know:
- the debug status
- the time
- the content of the file

So you need to pass all that.

Instead of

     &Debug($g_time);
----^
(unnecessary)

you may want to try

     Debug($g_debug, $g_time, <DEBUG>);

And in the module:

     sub Debug {
         my $g_debug = shift;
         my $g_time = shift;
         #debug routine
         ...

/ Gunnar

-- 
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl



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

Date: Thu, 27 Feb 2003 07:58:29 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: moving sub routine to module
Message-Id: <slrnb5s6c5.7rv.tadmc@magna.augustmail.com>

Mike Solomon <mike_solomon@lineone.net> wrote:

> I have a little sub routine I use for debugging and I want to put it
> into a module rather than in each script
> 
> The problem I have is that the module needs to know the debug flag I
> have set in the script and the file I have opened to write the
> debugging information to

   perldoc -q filehandle

      "How can I make a filehandle local to a subroutine?  
       How do I pass filehandles between subroutines?  
       How do I make an array of filehandles?"


> #test.pl

> my $g_debug = "Y";		#set debug status


   our $g_debug = "Y";


> open DEBUG, ">debug/exib_detail.txt" if $g_debug eq "Y";


   open our $DB, ">debug/exib_detail.txt" if $g_debug eq "Y";


> my $g_time = localtime;	#used with debug
> &Debug($g_time);


   Debug($g_time);


> #testmodule.pm
> package testmodule;				#declare package


All lower-case module names are reserved for pragmas by convention.

Use at least one upper case char in your module's name.


> sub Debug {
> 	#debug routine
> 	my ($text) = @_;
> 	print DEBUG "$text\n" if $g_debug eq "Y";
> } #end Debug


   sub Debug {
       return unless $main::g_debug eq "Y";
       my ($text) = @_;
       print $main::DB "$text\n";
   } #end Debug


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


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

Date: Thu, 27 Feb 2003 11:20:14 +0100
From: Edwin Guenthner <edgue@web.de>
Subject: Necessary modules?
Message-Id: <3E5DE65E.6070909@web.de>

Hello folks,

I am using Perl 5.8 on OS/2. This perl is only used to
run my application - so I am in total control of this perl.

My problem is: the perl consumes to much memory. I have to
use the static binary [there are misc. perl.EXEs for OS/2
and for certain reasons I have to use the perl_.exe that
is just ONE big EXE]. But as I mentioned: I want to run
my special application - nothing else. So I would like to
recompile the perl_.exe _without_ the stuff that I dont need.
Or lets say: _without_ stuff that I dont need and that can
be "remove" savely.

My question is: how can I find out which of built-in
modules are really necessary for me?
I scanned my files for their "use" lines; here is the
summary:

use base qw ( whatever );
use constant whatever
use English;
use Exporter;
use Fcntl ':flock'; # import LOCK_* constants
use File::Copy;
use Getopt::Long qw (:config no_auto_abbrev);
use IO::Handle;
use IO::Socket::INET;
use Socket;
use strict;
use Time::HiRes;
use UNIVERSAL;
use vars '$VERSION';
use warnings;

Any hints, tips, recommendations what modules I should avoid
when trying to build a new perl?

regards,
eg



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

Date: 27 Feb 2003 10:56:06 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Necessary modules?
Message-Id: <b3kqs6$jv1$1@mamenchi.zrz.TU-Berlin.DE>

Edwin Guenthner  <edgue@web.de> wrote in comp.lang.perl.misc:
> Hello folks,
> 
> I am using Perl 5.8 on OS/2. This perl is only used to
> run my application - so I am in total control of this perl.
> 
> My problem is: the perl consumes to much memory. I have to
> use the static binary [there are misc. perl.EXEs for OS/2
> and for certain reasons I have to use the perl_.exe that
> is just ONE big EXE]. But as I mentioned: I want to run
> my special application - nothing else. So I would like to
> recompile the perl_.exe _without_ the stuff that I dont need.
> Or lets say: _without_ stuff that I dont need and that can
> be "remove" savely.
> 
> My question is: how can I find out which of built-in
> modules are really necessary for me?
> I scanned my files for their "use" lines; here is the
> summary:
> 
> use base qw ( whatever );
> use constant whatever
> use English;
> use Exporter;
> use Fcntl ':flock'; # import LOCK_* constants
> use File::Copy;
> use Getopt::Long qw (:config no_auto_abbrev);
> use IO::Handle;
> use IO::Socket::INET;
> use Socket;
> use strict;
> use Time::HiRes;
> use UNIVERSAL;
> use vars '$VERSION';
> use warnings;
> 
> Any hints, tips, recommendations what modules I should avoid
> when trying to build a new perl?

Nothing concrete, but I'd like to point out that your list is
probably incomplete.  There may be (will be) modules that are
loaded indirectly (used by modules you load).

To get a more complete list, you can insert a coderef into @INC
that prints out every module that is searched for:

    BEGIN { unshift @INC, sub { warn "loading $_[ 1]\n"; return } }

With this line early in your application, run it once (perl -c ...
is sufficient) and collect STDERR.

Basically you'd have to check the resulting list for modules that
have an XS component and build Perl with (at least) these linked
in statically.

Anno


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

Date: Thu, 27 Feb 2003 13:29:00 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: newbie regexp question
Message-Id: <pan.2003.02.26.22.41.29.78683@aursand.no>

On Wed, 26 Feb 2003 19:00:46 +0000, Mike wrote:
>> It's just silly.  You will have to distribute your script somehow. You
>> can just wrap up the additional modules with the script, and make your
>> installation script also install whatever modules are required.

> it won't be distributed ... just left where it is once completed .....

And excactly _why_ can't you just leave the proposed modules there with
it?  If you're not gonna distribute the script, it's even easier too let
it use some of the CPAN goodies.


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: 27 Feb 2003 01:51:53 -0800
From: martin.bohnert.ibm@froeschl.de (Martin Bohnert)
Subject: PerlCC Error on Win2k - Perl57.lib ?!
Message-Id: <c08299c0.0302270151.2c4536a0@posting.google.com>

Hi there,

I`d be glad if someone could help me out of this one:

I`m trying to compile a script (see below) on Win2k SP3 using
ActiveState`s Perl 5.8.0.

C:\>perlcc -o mf.exe c:\mbohnert\source\perl\mf.pl
pcc94Sga.c
pcc94Sga.c(20389) : warning C4101: 'targ' : Unreferenzierte lokale
Variable --> "unreferenced local variable"
pcc94Sga.c(30817) : warning C4101: 'targ' : Unreferenzierte lokale
Variable
pcc94Sga.c(41314) : warning C4101: 'targ' : Unreferenzierte lokale
Variable
pcc94Sga.c(51731) : warning C4101: 'targ' : Unreferenzierte lokale
Variable
pcc94Sga.c(54500) : warning C4101: 'targ' : Unreferenzierte lokale
Variable
LINK : fatal error LNK1181: Eingabedatei "perl57.lib" kann nicht
geoeffnet werde
n -> "could not open perl57.lib"

%PATH% includes the path to perl/bin and perl/lib. perl57.lib doesn`t
exist, OK - but the script runs fine if interpreted. Here`s the source
code:

use File::copy;
use File::stat;
use Time::localtime;

$usage = "mf <Input path> <Output path> <Pattern>\n";

if (@ARGV != 3) {die "$usage";}

for ($ARGV[0], $ARGV[1]) { s/([^\\])$/\1\\/; }

opendir(INDIR, $ARGV[0]) || die "Couldn't open input path
$ARGV[0].\n";
opendir(OUDIR, $ARGV[1]) || die "Couldn't open output path
$ARGV[1].\n";

$te=localtime(time)->mon() + 1;
$te=~s/^(\S)$/0\1/;
$te=$te . substr(localtime(time)->year() + 1900, 2, 4);

BAR: while($file=readdir(INDIR)) {
    if($file=~m/\.fdf$/i) {
	print "Deleting file $ARGV[0]$file.\n";
	if (!unlink $ARGV[0].$file) {
	    print "Delete failed, DOS deleting.\n";
	    open(FOO, "del $ARGV[0]$file |");
	    while(<FOO>) {print "$_\n";}
	    close FOO;
	}
	next BAR;
    }
    if ($file=~m/$ARGV[2]/i) {
	print "Copying file $ARGV[0]$file to $ARGV[1]$file.$te\n";
	if (!copy $ARGV[0].$file, $ARGV[1].$file.".".$te) {
	    print "Copy failed, DOS copying.\n";
	    open(FOO, "copy $ARGV[0]$file $ARGV[1]$file.$te |");
	    while(<FOO>) {print "$_\n";}
	    close FOO;
	}
    }
} 

Any hints on getting this thing to compile ?


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

Date: Thu, 27 Feb 2003 11:50:00 +0100
From: "Daniel Fabian" <strap@fabiand.net>
Subject: Regular Expression for Email Aliases
Message-Id: <1046342304.883726@news.liwest.at>

Hi,

I guess you guys must be really tired of correcting regular expressions in
perl, but I have one I just don't understand.

I'm trying to evaluate email aliases entered by users. They should apply to
following rules:

- must not start or end with [\.\-_]
- [\.\-_] in the first part of the alias (before the @) must occur 2 times
at most
- all the other rules that apply to email adresses

I created the regex
return 2 unless ($alias =~
/([0-9A-Za-z]+[\.\-_]?[0-9A-Za-z]+){1,2}@[\-0-9A-Za-z]+\.[\-\.0-9A-Za-z]+/);

But for some reasons .df.df@test.com passes the test. And I don't quite
understand why. Also the [\.\-_] can occur as many times as the length
allows. Even though I know why that is, I don't have an idea for a regex
that fullfills this rule.

Thanks in advance,
Daniel




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

Date: Thu, 27 Feb 2003 10:59:14 GMT
From: "Ian.H [dS]" <ian@WINDOZEdigiserv.net>
Subject: Re: Regular Expression for Email Aliases
Message-Id: <fnrr5vc0if5uo4h56rn33jj6l6k3o394ej@4ax.com>
Keywords: Remove WINDOZE to reply

-----BEGIN xxx SIGNED MESSAGE-----
Hash: SHA1

In a fit of excitement on Thu, 27 Feb 2003 11:50:00 +0100, "Daniel
Fabian" <strap@fabiand.net> managed to scribble:

> I created the regex
> return 2 unless ($alias =~
> /([0-9A-Za-z]+[\.\-_]?[0-9A-Za-z]+){1,2}@[\-0-9A-Za-z]+\.[\-\.0-9A-Z
> a-z]+/);  
> 
> But for some reasons .df.df@test.com passes the test. And I don't
> quite understand why. Also the [\.\-_] can occur as many times as
> the length allows. Even though I know why that is, I don't have an
> idea for a regex that fullfills this rule.
> 
> Thanks in advance,
> Daniel


I think an anchor is required:


  /^([\w]+[._-]?[\w]+){1,2}@[\w-]+\.[\w.-]+$/


This adds the ^ (beginning) and $ (ending) anchors to your RegEx and
shorteded using \w to represent a-zA-Z0-9.

Without using the anchor, your RegEx will match anywhere _within_ the
data being matched, not necessarily starting at the first char.



Regards,

  Ian

-----BEGIN xxx SIGNATURE-----
Version: PGP 8.0

iQA/AwUBPl3vfmfqtj251CDhEQI3wwCeKCXlfNfKl4tm7CSNpw/jFayTZV0AoN/V
/127YU3K2TaUwdrGPet5gOOU
=jMf/
-----END PGP SIGNATURE-----

-- 
Ian.H  [Design & Development]
digiServ Network - Web solutions
www.digiserv.net  |  irc.digiserv.net  |  forum.digiserv.net
Scripting, Web design, development & hosting.


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

Date: Thu, 27 Feb 2003 12:31:21 +0100
From: "Daniel Fabian" <strap@fabiand.net>
Subject: Re: Regular Expression for Email Aliases
Message-Id: <1046344786.498219@news.liwest.at>

Hi Ian,

> I think an anchor is required:
>   /^([\w]+[._-]?[\w]+){1,2}@[\w-]+\.[\w.-]+$/

Thanks a lot for your help, everything works smoothly now!

> Regards,
>   Ian

Greets,
Daniel




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

Date: Thu, 27 Feb 2003 07:19:59 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regular Expression for Email Aliases
Message-Id: <slrnb5s43v.7ou.tadmc@magna.augustmail.com>

Daniel Fabian <strap@fabiand.net> wrote:

>> I think an anchor is required:
>>   /^([\w]+[._-]?[\w]+){1,2}@[\w-]+\.[\w.-]+$/
> 
> Thanks a lot for your help, everything works smoothly now!
                              ^^^^^^^^^^
                              ^^^^^^^^^^ not really


You need to change the [\w] left of @ back to [0-9A-Za-z],
else you will allow 'a_b_c_d@e.f'.

It marks single-letter addresses as illegal, eg. 'a@b.c'.

It requires a dot after the @, so this is illegal 'abc@localhost'.

It allows forbidden chars at the end, eg 'aa@b.c-', change
the last part to:

   ...[\w.-]*[0-9A-Za-z]$/



I trust that you've seen the Perl FAQ about mail addresses?


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


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

Date: 27 Feb 2003 05:11:20 -0800
From: kydongau@yahoo.com.au (kydongau)
Subject: Re: require subs and global parameters
Message-Id: <738c2d89.0302270511.2fa22185@posting.google.com>

kydongau@yahoo.com.au (kydongau) wrote in message news:<738c2d89.0302251455.67b87d4c@posting.google.com>...
> Hi,
>  
> Is it possible to require a perl file that contains sub routines as
> such:
>  
> #main script
>  
> my ($cmd);
>  

Thanks all, our ($cmd) is what I need.
ky


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

Date: Thu, 27 Feb 2003 13:28:59 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: Simple question about Perl Regular Expressions
Message-Id: <pan.2003.02.26.22.52.27.123172@aursand.no>

On Wed, 26 Feb 2003 17:28:27 +0000, Hermeto Mendes wrote:
> How would one write:
> 
> firstname lastname
> lastname, firstname
> 
> so both variants are recognised, but I have to write the name only once?

Hmm.  It seems to me that you're trying to match agains a name no matter
how you enter the name?  If so, how many variations can there be?

If you have just the two variations above, I would simple have done
something like this:

  my $given_names = '';
  my $surname     = '';

  if ( index($name, ',') > 0 ) {
      ( $surname, $given_names ) = $name =~ m/^(.*),\s*(.*)$/;
  }
  else {
      ( $given_names, $surname ) = $name =~ m/^(.*)\s+(.*)$/;
  }

Maybe not as compact, but easy to read.  And it's especially easier to
read (and understand) if you want to deal with other name variations some
time after you wrote the original script.


-- 
Tore Aursand - tore@aursand.no - http://www.aursand.no/



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

Date: Thu, 27 Feb 2003 08:08:34 GMT
From: "Kelly Greer" <kellygreer1@hell.rr.com>
Subject: Writing my own scripting language. Need advice.
Message-Id: <6Ij7a.53060$If5.2803299@twister.southeast.rr.com>

hi newsgroup,

Sorry if this off topic a little, but I thought the groups might be able to
help.

If was going to write my own scripting language what books do I need to
read, websites do I need to go to, etc...
Any classic books on 'programming language design'?

I am not new to programming (C++, C#, PHP, VB, ASP and Java experience).
As far as writing my own language, I don't know where to start.  Where could
I find the best information on parsing my new language?  Any Open Source
projects I should have a look at?

Any advice would help - Thanks,

Kelly Greer
kellygreer1@nospam.com
Change nospam to yahoo




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

Date: Thu, 27 Feb 2003 09:55:48 +0100
From: "Corno Schraverus" <corno@%spam%.dds.nl>
Subject: Re: Writing my own scripting language. Need advice.
Message-Id: <b3kjtr$t84$1@news.tudelft.nl>

Hi Kelly,

Roughly, there are 3 things that you need to do, with all more or less their
own approach;
a) work out a grammar.
b) write a parser (and a lexer) for that grammar. (you can combine steps a
and b, and define the grammar rules as you proceed).
c) process the output from the parser.

a) You can work out the grammar by defining rules in a notation called BNF
or EBNF (Extended Backus Naur Form).
b) There are multiple tools that can help you to create a lexer / parser
combination, with the grammar rules as input. Simply put, a lexer is able to
recognize words and a parser is able to recognize sentences. You could use
the famous combination of lex and yacc (or their OO sibblings; flex and
bison), or, as I did, use the more modern ANTLR (open source,
www.antlr.org).
I found that the art of parser development has a steep learning curve as it
is completely different from procedural programming, but eventually it is
definately worth the effort compared to writing the parser 'by hand'!
Although a bit rough, there's documentation at the antlr website on the
general concept of parser development and a user manual for antlr itself.
c) Once you have the parser, you start to write pieces of 'traditional' code
that are triggered when a certain pattern is matched and that do the actual
work.

So, to get back to your question, after a lot of reseach I found that I did
not need much more documentation than what I found on the antlr website.

HTH,

Corno

"Kelly Greer" <kellygreer1@hell.rr.com> wrote in message
news:6Ij7a.53060$If5.2803299@twister.southeast.rr.com...
> hi newsgroup,
>
> Sorry if this off topic a little, but I thought the groups might be able
to
> help.
>
> If was going to write my own scripting language what books do I need to
> read, websites do I need to go to, etc...
> Any classic books on 'programming language design'?
>
> I am not new to programming (C++, C#, PHP, VB, ASP and Java experience).
> As far as writing my own language, I don't know where to start.  Where
could
> I find the best information on parsing my new language?  Any Open Source
> projects I should have a look at?
>
> Any advice would help - Thanks,
>
> Kelly Greer
> kellygreer1@nospam.com
> Change nospam to yahoo
>
>




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

Date: Thu, 27 Feb 2003 09:01:11 GMT
From: Dean Kutryk <trollking@shaw.ca>
Subject: Re: Writing my own scripting language. Need advice.
Message-Id: <3E5DD3EC.3070704@shaw.ca>

Kelly Greer wrote:
> hi newsgroup,
> 
> Sorry if this off topic a little, but I thought the groups might be able to
> help.
> 
> If was going to write my own scripting language what books do I need to
> read, websites do I need to go to, etc...
> Any classic books on 'programming language design'?
> 
> I am not new to programming (C++, C#, PHP, VB, ASP and Java experience).
> As far as writing my own language, I don't know where to start.  Where could
> I find the best information on parsing my new language?  Any Open Source
> projects I should have a look at?
> 
> Any advice would help - Thanks,
> 
> Kelly Greer
> kellygreer1@nospam.com
> Change nospam to yahoo
> 
> 

Unfortunately this isn't a code question pertaining directly to Standard 
C++.







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

Date: Thu, 27 Feb 2003 10:17:54 +0100
From: Malte Ubl <ubl@schaffhausen.de>
Subject: Re: Writing my own scripting language. Need advice.
Message-Id: <b3koav$j1a$1@news.dtag.de>

Kelly Greer wrote:
> hi newsgroup,
> 
> Sorry if this off topic a little, but I thought the groups might be able to
> help.
> 
> If was going to write my own scripting language what books do I need to
> read, websites do I need to go to, etc...
> Any classic books on 'programming language design'?
> 
> I am not new to programming (C++, C#, PHP, VB, ASP and Java experience).
> As far as writing my own language, I don't know where to start.  Where could
> I find the best information on parsing my new language?  Any Open Source
> projects I should have a look at?
> 
> Any advice would help - Thanks,

Maybe Parrot could be of interest for you:
http://www.parrotcode.org/

The codebase includes a couple of small demo languages that could give 
you a good entrance into how to program your own programming language.

->malte


-- 
srand 108641088; print chr int rand 256 for qw<J A P H>



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

Date: Thu, 27 Feb 2003 20:27:04 +1000
From: "Ray" <saywhat@spammer.com>
Subject: Re: Writing my own scripting language. Need advice.
Message-Id: <b3kp59$qi2$1@lust.ihug.co.nz>


"Kelly Greer" <kellygreer1@hell.rr.com> wrote in message
news:6Ij7a.53060$If5.2803299@twister.southeast.rr.com...
> hi newsgroup,
>
> Sorry if this off topic a little, but I thought the groups might be able
to
> help.
>
> If was going to write my own scripting language what books do I need to
> read, websites do I need to go to, etc...
> Any classic books on 'programming language design'?
>
> I am not new to programming (C++, C#, PHP, VB, ASP and Java experience).
> As far as writing my own language, I don't know where to start.  Where
could
> I find the best information on parsing my new language?  Any Open Source
> projects I should have a look at?
>
> Any advice would help - Thanks,
>
> Kelly Greer
> kellygreer1@nospam.com
> Change nospam to yahoo
>

The classic book in the area of language design and implementation is the
dragon book (because there is a picture of a dragon on the cover) -
Compilers: Principles, Techniques, and Tools by Aho/Sethi/Ullman [ISBN:
0201100886]. This will teach you all the necessary techniques you need to
implement your own full fledged language (TM). It is no easy task but you
can learn by studying the implementation of other languages. Maybe Python
would be a good start?

Also this question is OT for these newsgroups, in future you might want to
access general programming questions like this in comp.programming (i've set
follow ups to this newsgroup).

Ray.






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

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


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