[28960] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 204 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 8 00:10:29 2007

Date: Wed, 7 Mar 2007 21:09:11 -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           Wed, 7 Mar 2007     Volume: 11 Number: 204

Today's topics:
        Create zombie intentionally? <stahl.karl@gmail.com>
    Re: Create zombie intentionally? <ben@morrow.me.uk>
    Re: How can I access the variables in my script ($main: <tadmc@augustmail.com>
    Re: LWP Package issue in my script.. <tadmc@augustmail.com>
    Re: Newbie question re initialization <spamtrap@dot-app.org>
    Re: Newbie question re initialization <edMbj@aes-intl.com>
    Re: Newbie question re initialization <edMbj@aes-intl.com>
    Re: Perl script fails silently at start, can't debug <DJStunks@gmail.com>
    Re: Perl script fails silently at start, can't debug <jonhendry_usenet@mac.com>
    Re: Perl script fails silently at start, can't debug <jonhendry_usenet@mac.com>
    Re: Perl script fails silently at start, can't debug <jonhendry_usenet@mac.com>
    Re: Perl tie hash question <ecarlson@vmware.com>
        Redirect to another web page using CGI ? <viveklinux@gmail.com>
    Re: Redirect to another web page using CGI ? <spamtrap@dot-app.org>
    Re: Regexp for email addresses. <abigail@abigail.be>
    Re: Splitting a filename <bik.mido@tiscalinet.it>
    Re: Splitting a filename <stoupa@practisoft.cz>
    Re: Splitting a filename <uri@stemsystems.com>
    Re: Splitting a filename <stoupa@practisoft.cz>
        Support for dbmopen/dbmclose? <perl4hire@softouch.on.ca>
    Re: Support for dbmopen/dbmclose? <uri@stemsystems.com>
    Re: Support for dbmopen/dbmclose? <perl4hire@softouch.on.ca>
    Re: Using Substr and Regular expressions. <tadmc@augustmail.com>
    Re: What is abriviation for CHR(4) <tadmc@augustmail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 7 Mar 2007 18:55:29 -0800
From: "Ishmael" <stahl.karl@gmail.com>
Subject: Create zombie intentionally?
Message-Id: <1173322529.536536.268310@30g2000cwc.googlegroups.com>

Ok, this may sound odd, but I would like to create a zombie process
intentionally.  I've been reading the perldoc for perlipc and it seems
like an unhappy marriage between 'alarm' and 'system' should do the
trick, but I haven't been able to get it to work.  Can someone give me
a simple (!) example of how to create a zombie (using the alarm/
system  combo - or even better, using fork and exec)?  Thanks for you
help!

By the way, here's what I've been trying (unsuccessfully):

eval {
    local $SIG{ALRM} = sub {die "system call killed by alarm"};
    alarm 1;
    my $cmd = 'perl -e \'while(1) { print "bla\n"; sleep(1); }\'';
    # my $cmd = "/bin/tcsh\nwhile 1\necho \"bla\\n\"\nend\n";
    print $cmd, "\n";
    system($cmd);
    alarm 0;
};



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

Date: Thu, 8 Mar 2007 03:59:34 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Create zombie intentionally?
Message-Id: <6ae4c4-ncd.ln1@osiris.mauzo.dyndns.org>


Quoth "Ishmael" <stahl.karl@gmail.com>:
> Ok, this may sound odd, but I would like to create a zombie process
> intentionally.  I've been reading the perldoc for perlipc and it seems
> like an unhappy marriage between 'alarm' and 'system' should do the
> trick, but I haven't been able to get it to work.  Can someone give me
> a simple (!) example of how to create a zombie (using the alarm/
> system  combo - or even better, using fork and exec)?  Thanks for you
> help!

    use POSIX qw/_exit/;

    $SIG{CHLD} = 'DEFAULT';
    # just to make sure. the important thing is that is shouldn't be
    # 'IGNORE', or zombies may be automatically reaped.
    
    my $kid = fork;
    defined $kid or die "fork failed: $!";
    $kid or _exit 0;

    # now be careful with wait/waitpid

Ben

-- 
Heracles: Vulture! Here's a titbit for you / A few dried molecules of the gall
   From the liver of a friend of yours. / Excuse the arrow but I have no spoon.
(Ted Hughes,        [ Heracles shoots Vulture with arrow. Vulture bursts into ]
 'Alcestis')        [ flame, and falls out of sight. ]         ben@morrow.me.uk


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

Date: Wed, 7 Mar 2007 18:53:00 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: How can I access the variables in my script ($main::var)
Message-Id: <slrneuunjc.aje.tadmc@tadmc30.august.net>

Sean <imfeaw5672@pacbell.net> wrote:

> I need to access some of the variables in my script. 


What script?

We cannot help you with code that we cannot even see.

Have you seen the Posting Guidelines that are posted here frequently?


> These variables are 
> used by methods called in packages that might be nested.
> I have used $main::var. This does not seem to do job. 


What does "not seem to do job" mean when you say it?

That is, what did you observe that led you to conclude that it
is not doing the job?

Delivering a diagnosis without being told any of the symptoms
is futile.


> Any sugestions?


I suggest providing enough information so that we can help you.


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


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

Date: Wed, 7 Mar 2007 18:59:14 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: LWP Package issue in my script..
Message-Id: <slrneuunv2.aje.tadmc@tadmc30.august.net>

Uri Guttman <uri@stemsystems.com> wrote:
>>>>>> "s" == schimata  <schimata@gmail.com> writes:

>  s> blah..blah..
>  s> blah..
>
> that isn't valid perl code! :)


He just has a few too many dots.

    blah..blah.
    blah

There, that's better.


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


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

Date: Wed, 07 Mar 2007 21:24:26 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Newbie question re initialization
Message-Id: <m2tzww79r9.fsf@local.wv-www.com>

Ed Jay <edMbj@aes-intl.com> writes:

> Sherm Pendley scribed:
>
>>Ed Jay <edMbj@aes-intl.com> writes:
>>
>>> At the start of a script I have (without the line numbers):
>>>
>>> 17  my $username = param('usrnm');
>>> 18  @subList = param('ptList');
>>> 19  my $newUsername = $username."{";
>>> 20  my $user = $username.",";
>>>
>>> When I submit my script for testing I receive the following warnings:
>>>
>>> Use of uninitialized value in concatenation (.) or string at foo.pl line 19.
>>> Use of uninitialized value in concatenation (.) or string at foo.pl line 20.
>>>
>>> I don't understand the message, nor do I know what to do to resolve the
>>> issue. Help!
>>
>>What's not to understand? You're trying to concatenate two strings. One of
>>them is uninitialized - i.e. its value is undef. Obviously that isn't going
>>to be the "{" or "," strings, so that leaves $username.
>>
>>Why is $username undef then? Check your form - make sure that it has some-
>>thing named 'usrnm' in it. And validate your input; sooner or later someone
>>*will* leave that form element blank.
>>
> The form being submitted does indeed have a field named 'usrnm.' It's value
> is _always_ populated onSubmit via javascript.

Perl is telling you that your script did not in fact receive a value for
that input.

You can ignore crystal-clear evidence and claim what is happening here is
impossible, or you can figure out why it's happening. Your choice.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Wed, 07 Mar 2007 18:59:33 -0800
From: Ed Jay <edMbj@aes-intl.com>
Subject: Re: Newbie question re initialization
Message-Id: <v8uuu2d3l447qcd4khokj4hurgpu7qd18n@4ax.com>

Sherm Pendley scribed:

>Ed Jay <edMbj@aes-intl.com> writes:
>
>> Sherm Pendley scribed:
>>
>>>Ed Jay <edMbj@aes-intl.com> writes:
>>>
>>>> At the start of a script I have (without the line numbers):
>>>>
>>>> 17  my $username = param('usrnm');
>>>> 18  @subList = param('ptList');
>>>> 19  my $newUsername = $username."{";
>>>> 20  my $user = $username.",";
>>>>
>>>> When I submit my script for testing I receive the following warnings:
>>>>
>>>> Use of uninitialized value in concatenation (.) or string at foo.pl line 19.
>>>> Use of uninitialized value in concatenation (.) or string at foo.pl line 20.
>>>>
>>>> I don't understand the message, nor do I know what to do to resolve the
>>>> issue. Help!
>>>
>>>What's not to understand? You're trying to concatenate two strings. One of
>>>them is uninitialized - i.e. its value is undef. Obviously that isn't going
>>>to be the "{" or "," strings, so that leaves $username.
>>>
>>>Why is $username undef then? Check your form - make sure that it has some-
>>>thing named 'usrnm' in it. And validate your input; sooner or later someone
>>>*will* leave that form element blank.
>>>
>> The form being submitted does indeed have a field named 'usrnm.' It's value
>> is _always_ populated onSubmit via javascript.
>
>Perl is telling you that your script did not in fact receive a value for
>that input.

I know for fact that Perl isn't receiving a value...maybe you hit the nail
on the head as to why I'm getting the warning, though. I did not run the
preceding script and submit the form. I ran the script alone through Perl,
so it couldn't have received a value. 

The instant script is one of about 30 scripts, each of which generates a
form to submit to the next module. The only way I know to test the entire
application, i.e., all scripts/modules is to run it through my web host to
my browser. That, however, doesn't generate warnings...the scripts either
work or crash. I had a different problem with the instant script, so I ran
it through Perl installed on my machine and in addition to illuminating the
problem I had, it also generated the warnings I originally posted. I didn't
understand the meaning of the warnings, so I queried this Group. Unless I'm
wrong (again), you provided the hint that explains the warnings in your post
that I'm answering. 
>
>You can ignore crystal-clear evidence and claim what is happening here is
>impossible, or you can figure out why it's happening. Your choice.
>
If I wanted to ignore something why would I post here seeking assistance?
 
Thank you all very much. Between you, Sherm, and Paul and Uri I learned a
bunch today. Thank you all. :-)
-- 
Ed Jay (remove 'M' to respond by email)


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

Date: Wed, 07 Mar 2007 19:09:26 -0800
From: Ed Jay <edMbj@aes-intl.com>
Subject: Re: Newbie question re initialization
Message-Id: <k1vuu217vnjitkfjru22f4m8tsej845lg8@4ax.com>

Uri Guttman scribed:

>>>>>> "EJ" == Ed Jay <edMbj@aes-intl.com> writes:
>
>  >> even better, use a here doc and one print. makes it all much cleaner and
>  >> easier to edit:
>  >> 
>  >> print <<HTML ;
>  >> <form id='form1' name='form1' action="foo.pl" method="post">
>  >> <input type='hidden' name='usrnm' value=''>
>  >> </form>
>  >> HTML
>  >> 
>  >> now you can read it and see the html structure.
>
>  EJ> I didn't post the HTML stuff...I presumed (mea culpa) it would be
>  EJ> understood it was all there.
>
>i didn't say anything about missing html. i said to use a here doc to
>print the html so you can then read it more easily and edit it. reading
>and editing quoted strings with backwhacked quotes is insane.

That certainly are more interesting ways to go blind, I agree. I was so
snowed today that I didn't realize you meant a heredoc.
>
>  EJ> Again, I simply didn't show the opening...or that I skip the first
>  EJ> 12 lines of the file.
>
>then you shouldn't have shown the seek line.
>
>  >> and what if no username was matched? $c_value has no value.
>
>  EJ> There will always be a match. The links are derived from the file
>  EJ> containing all valid usernames.
>
>but if an invalid username was entered it could screw things up. also i
>didn't notice if you chomped the lines from that file which could also
>lead to a problem with matching them later. this still isn't addressing
>the fact that you seem to have an undef in $username.

As I pointed out to Sherm, I ran the script without feeding it, so indeed
there was no value passed. I now understand...
>
>  >> whitespace is free. use more of it. squished code is hard to read.
>  >> 
>  EJ> print header(-cookie => $cookie);
>  >> 
>  >> you use whitespace there around => so why not in the previous code?
>
>  EJ> Different day...
>
>consistancy in style will help you 100 days from now when you go back to
>read your code. coding is about discipline.
>
>  EJ> The cookie is properly set with the name $username.
>  >> 
>  >> but you say you are still getting a warning on that line which has
>  >> $username. so it must be empty in some way. i think see the bug. since
>  >> you have an empty username, it will match the first line of T2FILE and
>  >> so $c_value will be set to that name and the cookie is set from that. so
>  >> you are getting proper results from a series of bugs that seem to cancel
>  >> each other out. try using a username that is not in the file or the
>  >> second one in the file and see if it still works. my bet is it
>  >> fails. which means you aren't getting the username from the form
>  >> properly.
>
>  EJ> I am able to select any username by link and it works as planned.
>  >> 
>  >> and why are you using javascript just to make hidden variables? you can
>  >> do that with html much easier.
>  >> 
>  EJ> If I did it using only HTML I would only get the last username in the list. 
>
>huh??? you can generates as many hidden fields as you want in html and
>use the same param name for them all. each will be sent in the POST and
>if you are using CGI.pm they will be parsed out properly. you have a
>misconception about html and posting hidden values. remember, html was
>around and doing this way before javascript came along. i would
>recommend using pure html over unneeded javascript because then you CAN
>automate using your site for robots or testing or whatever. it is much
>harder to do that if you use javascript (and in this case it serves no
>purpose).
>
I could populate a bunch of hidden fields if I wanted to get real
complicated. The list that's being generated comprises a few hundred
'usernames,' so the use of js, IMHO, is called for as an alternative to
generating and populating beaucoup fields. This is an in-house application,
so there's no concern about js being disabled. etc. 

You have been of great assistance and I've learned a bunch from you. Thanks
much.
-- 
Ed Jay (remove 'M' to respond by email)


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

Date: 7 Mar 2007 15:20:22 -0800
From: "DJ Stunks" <DJStunks@gmail.com>
Subject: Re: Perl script fails silently at start, can't debug
Message-Id: <1173309621.909243.207930@s48g2000cws.googlegroups.com>

On Mar 7, 2:43 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
> Hi,
>
> I'm working on some perl scripts - one longish script and some
> short .pm's containing object classes (one each).
>
> This morning I was able to run the script. After lunch, it stopped
> working for no apparent reason. It just fails, silently.
>
> If I try running it in the debugger, the script terminates instantly,
> with no error messages.
>
> perl -wc reveals no problems with any of the files.
>
> For a while, after experimenting with commenting out use statements, I
> was able to get it to a point where it would fail and report that one
> of the .pm's didn't return true, but that wasn't true either - all the
> pm's included a terminal 1;.

WAG - is it missing the blank line at the end of the file after the 1?

-jp



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

Date: 7 Mar 2007 15:22:52 -0800
From: "Jon Hendry" <jonhendry_usenet@mac.com>
Subject: Re: Perl script fails silently at start, can't debug
Message-Id: <1173309772.147536.22440@q40g2000cwq.googlegroups.com>

On Mar 7, 6:20 pm, "DJ Stunks" <DJStu...@gmail.com> wrote:
> On Mar 7, 2:43 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
>
>
>
> > Hi,
>
> > I'm working on some perl scripts - one longish script and some
> > short .pm's containing object classes (one each).
>
> > This morning I was able to run the script. After lunch, it stopped
> > working for no apparent reason. It just fails, silently.
>
> > If I try running it in the debugger, the script terminates instantly,
> > with no error messages.
>
> > perl -wc reveals no problems with any of the files.
>
> > For a while, after experimenting with commenting out use statements, I
> > was able to get it to a point where it would fail and report that one
> > of the .pm's didn't return true, but that wasn't true either - all the
> > pm's included a terminal 1;.
>
> WAG - is it missing the blank line at the end of the file after the 1?
>
> -jp

Hm. Lemme check.



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

Date: 7 Mar 2007 15:39:12 -0800
From: "Jon Hendry" <jonhendry_usenet@mac.com>
Subject: Re: Perl script fails silently at start, can't debug
Message-Id: <1173310752.312169.199030@c51g2000cwc.googlegroups.com>

On Mar 7, 6:22 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
> On Mar 7, 6:20 pm, "DJ Stunks" <DJStu...@gmail.com> wrote:
>
>
>
> > On Mar 7, 2:43 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
>
> > > Hi,
>
> > > I'm working on some perl scripts - one longish script and some
> > > short .pm's containing object classes (one each).
>
> > > This morning I was able to run the script. After lunch, it stopped
> > > working for no apparent reason. It just fails, silently.
>
> > > If I try running it in the debugger, the script terminates instantly,
> > > with no error messages.
>
> > > perl -wc reveals no problems with any of the files.
>
> > > For a while, after experimenting with commenting out use statements, I
> > > was able to get it to a point where it would fail and report that one
> > > of the .pm's didn't return true, but that wasn't true either - all the
> > > pm's included a terminal 1;.
>
> > WAG - is it missing the blank line at the end of the file after the 1?
>
> > -jp
>
> Hm. Lemme check.

Aha! Something seems to have gone wonky with line endings. There were
blank lines, but they weren't being treated as such.

(I ran a diff between two versions of the script, neither of which
worked anymore, and diff complained about the lack of a newline at the
end of the files, even though there visually appeared to be.)

Thanks!

It kinda works now, except for instance \n's aren't being treated as
newlines in the output. But at least I can see that it's doing
something.



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

Date: 7 Mar 2007 15:41:18 -0800
From: "Jon Hendry" <jonhendry_usenet@mac.com>
Subject: Re: Perl script fails silently at start, can't debug
Message-Id: <1173310878.635347.315800@8g2000cwh.googlegroups.com>

On Mar 7, 6:39 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
> On Mar 7, 6:22 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
>
>
>
> > On Mar 7, 6:20 pm, "DJ Stunks" <DJStu...@gmail.com> wrote:
>
> > > On Mar 7, 2:43 pm, "Jon Hendry" <jonhendry_use...@mac.com> wrote:
>
> > > > Hi,
>
> > > > I'm working on some perl scripts - one longish script and some
> > > > short .pm's containing object classes (one each).
>
> > > > This morning I was able to run the script. After lunch, it stopped
> > > > working for no apparent reason. It just fails, silently.
>
> > > > If I try running it in the debugger, the script terminates instantly,
> > > > with no error messages.
>
> > > > perl -wc reveals no problems with any of the files.
>
> > > > For a while, after experimenting with commenting out use statements, I
> > > > was able to get it to a point where it would fail and report that one
> > > > of the .pm's didn't return true, but that wasn't true either - all the
> > > > pm's included a terminal 1;.
>
> > > WAG - is it missing the blank line at the end of the file after the 1?
>
> > > -jp
>
> > Hm. Lemme check.
>
> Aha! Something seems to have gone wonky with line endings. There were
> blank lines, but they weren't being treated as such.
>
> (I ran a diff between two versions of the script, neither of which
> worked anymore, and diff complained about the lack of a newline at the
> end of the files, even though there visually appeared to be.)
>
> Thanks!
>
> It kinda works now, except for instance \n's aren't being treated as
> newlines in the output. But at least I can see that it's doing
> something.

Just for posterity, changing the file encoding in Xcode back to
'Western (Mac OS Roman)' from 'Non-lossy ASCII' fixed the problem with
the \n's.



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

Date: 7 Mar 2007 16:59:56 -0800
From: "Eric" <ecarlson@vmware.com>
Subject: Re: Perl tie hash question
Message-Id: <1173315596.112503.118920@j27g2000cwj.googlegroups.com>

On Mar 7, 1:45 pm, "DJ Stunks" <DJStu...@gmail.com> wrote:
> On Mar 7, 1:21 pm, "Eric" <ecarl...@vmware.com> wrote:

Thanks for your reply, DJ. My responses inline:

> if you just want to be able to read your DBM file from the shell there
> are tools for this or you could write a quick perl script to do so
> (just tie it the same way, and then dump the hash).

What I want to do is create a humanly readable output file, not read
from STDOUT (if that's what you meant when you said "shell"). Are you
saying that I can/should write a separate Perl script to do this as
post processing (on the file after execution of the script has
completed), or is there a way to write into the file during the
execution of the script in a way that can be read using Dumper, etc.?

> Or, if you want a
> human readable output, I'd suggest using the Config::Simple module,
> which will let you tie your hash (for read/write) but the output would
> be an .ini style config file.

I'm looking into this. I am working in a shared environment where I
have to get the IT folks to install any CPAN modules that I need.

Eric



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

Date: 7 Mar 2007 18:09:18 -0800
From: "vivekian" <viveklinux@gmail.com>
Subject: Redirect to another web page using CGI ?
Message-Id: <1173319758.697202.97980@h3g2000cwc.googlegroups.com>

Hi,

This is a small authentication cgi perl script which makes use of
CGI.pm.

#!/usr/bin/perl

use strict;
use CGI;

my $q = new CGI;

my $username = $q -> param ('username') ;
my $password = $q -> param ('password') ;

if ($username eq "guest")
{
	if ($password eq "guest")
	{
		#Not sure what comes here
	}
}

else
{
	print $q->header( "text/plain" );
	print "Authorization Failed"
}

If the authentication succeeds would like to redirect to another page
in directory say foo.html. How can this be done ? Also is there an
authentication function which allready exists in CGI.pm ?

Thanks in advance,
vivekian.



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

Date: Wed, 07 Mar 2007 21:50:35 -0500
From: Sherm Pendley <spamtrap@dot-app.org>
Subject: Re: Redirect to another web page using CGI ?
Message-Id: <m2ps7k78jo.fsf@local.wv-www.com>

"vivekian" <viveklinux@gmail.com> writes:

> This is a small authentication cgi perl script which makes use of
> CGI.pm.

 ...

> If the authentication succeeds would like to redirect to another page
> in directory say foo.html. How can this be done ?

This is a SAQ. Look at the docs for CGI.pm. Find the term "redirect". Kick
yourself for not reading the docs, or for missing the obvious - whichever
one applies here.

> Also is there an
> authentication function which allready exists in CGI.pm ?

If you've enabled standard HTTP authentication on your web server, then
use CGI.pm's remote_user() function to get the user name.

Many folks don't use that though - for instance, they may want to design a
"login" box that appears as part of their page, instead of relying on the
browser to pop up its built-in dialog. Application-level authentication
like that can be built with the low-level services that CGI.pm provides,
but it's not part of CGI.pm itself.

sherm--

-- 
Web Hosting by West Virginians, for West Virginians: http://wv-www.net
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: 07 Mar 2007 23:14:49 GMT
From: Abigail <abigail@abigail.be>
Subject: Re: Regexp for email addresses.
Message-Id: <slrneuuhqj.r1r.abigail@alexandra.abigail.be>

Ted Zlatanov (tzz@lifelogs.com) wrote on MMMMCMXXXVI September MCMXCIII
in <URL:news:g69vehctzx3.fsf@dhcp-65-162.kendall.corp.akamai.com>:
""  On 14 Feb 2007 21:55:40 GMT Abigail <abigail@abigail.be> wrote: 
""  
""  A> use 5.9.5;   # In fact, you need the newest blead.
""  
""  
""  A> my $email_address = qr {
""  A>     (?(DEFINE)
""  A>       (?<addr_spec>       (?&local_part) \@ (?&domain))
""  ...
""  A>     (?&addr_spec)
""  A> }x;
""  
""  I have a question (to you or anyone else informed), as I don't follow
""  the latest Perl 5 changes and features: is this grammar syntax
""  experimental, or will it definitely remain in Perl 5 at this point?  I
""  don't mind the latest blead, but I don't want to commit my own code to
""  it if the feature is experimental.

Well, until 5.10 anything could change. But with 5.10 getting close,
it seems unlikely there will be significant changes to the features
I used in the regexp.



Abigail
-- 
$_ = "\x3C\x3C\x45\x4F\x54" and s/<<EOT/<<EOT/e and print;
Just another Perl Hacker
EOT


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

Date: Thu, 08 Mar 2007 00:26:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Splitting a filename
Message-Id: <40iuu2128fknpi46niq36uup667vbu691d@4ax.com>

On Wed, 07 Mar 2007 18:10:43 GMT, "Noel Sant" <noel@sant.me.uk> wrote:

>I want to split a filename into the name itself and the extension. This:

  use File::Basename;

> ($name, $extension) = split /\./, $input_file;

are you using strict, btw?

>works fine, providing there's only one dot in the filename, but if there are 
>more I just get the first two bits of name. I really want to get the last 
>bit into $extension and all the rest, including dots, into $name.

my ($name, $extension) = $input_file =~ /^(.*)\.([^.]*)\z/;
my ($name, $extension) = split /\.([^.]*)\z/, $input_file;  # abusing
                                                            # split()

>I suppose I could use an array on the left-hand side, find out how many 
>element there are and just build up $name from all the arrays bar the last, 
>but this seems long-winded. I tried using "split /\.$/, ..." but then I got 

Yes, it is long winded, but you wouldn't *have* to "find out how many
element there are":

  my @tmp = split /\./, $input_file;
  my $extension=pop @tmp;
  my $name=join '.', @tmp;


Michele
-- 
{$_=pack'B8'x25,unpack'A8'x32,$a^=sub{pop^pop}->(map substr
(($a||=join'',map--$|x$_,(unpack'w',unpack'u','G^<R<Y]*YB='
 .'KYU;*EVH[.FHF2W+#"\Z*5TI/ER<Z`S(G.DZZ9OX0Z')=~/./g)x2,$_,
256),7,249);s/[^\w,]/ /g;$ \=/^J/?$/:"\r";print,redo}#JAPH,


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

Date: Thu, 8 Mar 2007 01:19:54 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Splitting a filename
Message-Id: <esnqr0$64m$2@ns.felk.cvut.cz>

"Noel Sant" <noel@sant.me.uk> píše v diskusním příspěvku 
news:DeDHh.46060$Fm2.12157@newsfe1-gui.ntli.net...
>I want to split a filename into the name itself and the extension. This:
>
> ($name, $extension) = split /\./, $input_file;
>
> works fine, providing there's only one dot in the filename, but if there 
> are more I just get the first two bits of name. I really want to get the 
> last bit into $extension and all the rest, including dots, into $name.
>
I use my own function. Maybe stupid but 100% functional ;-)

sub parsename {
my $filename = shift;
my ($name, $ext) = ('') x2;
if($filename =~ m/\./) {$filename =~ s/^(.*)(\..*)$/$1$2/; $name = $1; $ext 
= $2; }
else {$name = $filename;}
return ($name, $ext);
}

-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)




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

Date: Wed, 07 Mar 2007 21:28:37 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Splitting a filename
Message-Id: <x71wk0a2p6.fsf@mail.sysarch.com>

>>>>> "PV" == Petr Vileta <stoupa@practisoft.cz> writes:

  PV> I use my own function. Maybe stupid but 100% functional ;-)

very stupid!

  PV> sub parsename {
  PV> my $filename = shift;
  PV> my ($name, $ext) = ('') x2;

why the initialization of both? $name is ALWAYS set to something below.

  PV> if($filename =~ m/\./) {$filename =~ s/^(.*)(\..*)$/$1$2/; $name =

are you allowing a empty file name with just a .suffix? what about a
name with a dot with no suffix. ?

  PV> $1;

why the destruction and rebuilding of $filename with s///? $filename is
never used again inside that block. you can use the m// to get the same
$1 and $2 as the s///.

  PV> $ext = $2; }

your $ext always has the . which is not typical when breaking up a
filename and extension.

why save $1 and $2 when you can just return them? 

  PV> else {$name = $filename;}

your indenting is either very bad or your usenet program ruined it.

  PV> return ($name, $ext);
  PV> }

this is almost just (untested) this one line sub:

	return $_[0] =~ /^(.*)(\..*)$/ ;

other than making sure both parts are '' if not matched. that could be
fixed easily too.

stick with the module.

uri

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


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

Date: Thu, 8 Mar 2007 05:16:53 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: Splitting a filename
Message-Id: <eso2vv$a31$1@ns.felk.cvut.cz>

"Uri Guttman" <uri@stemsystems.com> píse v diskusním príspevku 
news:x71wk0a2p6.fsf@mail.sysarch.com...
>>>>>> "PV" == Petr Vileta <stoupa@practisoft.cz> writes:
>
>  PV> I use my own function. Maybe stupid but 100% functional ;-)
>
> very stupid!
>
Thanks ;-)

>  PV> sub parsename {
>  PV> my $filename = shift;
>  PV> my ($name, $ext) = ('') x2;
>
> why the initialization of both? $name is ALWAYS set to something below.
>
>  PV> if($filename =~ m/\./) {$filename =~ s/^(.*)(\..*)$/$1$2/; $name =
>
> are you allowing a empty file name with just a .suffix?
>
Yes this return '' and '.ext'

> what about a
> name with a dot with no suffix. ?
>
This return 'name' and '.'

>  PV> $1;
>
> why the destruction and rebuilding of $filename with s///? $filename is
> never used again inside that block. you can use the m// to get the same
> $1 and $2 as the s///.
>
My example is a workong part of real funcion only. I use filename in some 
next lines.

>  PV> $ext = $2; }
>
> your $ext always has the . which is not typical when breaking up a
> filename and extension.
>
It is because I many times do some like $filename = "$name$ext" instead of
$filename = $name . '.' . $ext

> why save $1 and $2 when you can just return them?
>
As I said, I use $filename, $name and $ext for some comparison. This was be 
example only.
-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)




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

Date: Wed, 07 Mar 2007 19:50:08 -0500
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Support for dbmopen/dbmclose?
Message-Id: <T2JHh.1929$yc.816@read2.cgocable.net>

I have to do some data mangling in a DBM file but would like to do my 
testing on my development system (Win2K running ActiveState Perl 5.8.8). 
I've read that this type of database is not supported by Win32, and 
according to the ActiveState docs at ASPN:
"Functions obsoleted in perl5

     dbmclose, dbmopen
"
So, is is possible for me to work with a DBM file on my development machine?

The script that resides on the Unix server runs fine, but not when I try 
to run it here. I've tried

$DBFILE="TKL-db";
dbmopen(%DBF,$DBFILE,0600) or die "Can't open $DBFILE: $!";
and
dbmopen(%DBF,$DBFILE,undef) or die "Can't open $DBFILE: $!";
and
dbmopen(%DBF,"TKL-db",undef) or die "Can't open 'TKL-db': $!";

and get no data when I try to read records from it. The error log shows:
Uncaught exception from user code:
	Can't open TKL-db: No such file or directory at test_dbm.pl line 16.


####################### 8X cut here 8X ###################
#! /usr/bin/perl
BEGIN
{
	open (STDERR,">>$0-err.txt");
	print STDERR "\n",scalar localtime,"\n";
}
use strict;
use warnings;
use diagnostics;

my $DBFILE="TKL-db";
my %DBF;
my ($key,$value,$Counter);

$Counter=0;
dbmopen(%DBF,$DBFILE,0600) or die "Can't open $DBFILE: $!";
while (($key,$value) = each (%DBF))
{
	print "$key\n";
	$Counter++;
}
dbmclose (%DBF);
print "All done\n$Counter records.";
####################### 8X cut here 8X ###################

-- 
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
Perl | MySQL programming for all data entry forms.
"We make web sites work!"


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

Date: Wed, 07 Mar 2007 20:27:54 -0500
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: Support for dbmopen/dbmclose?
Message-Id: <x77itsa5id.fsf@mail.sysarch.com>

>>>>> "AN" == Amer Neely <perl4hire@softouch.on.ca> writes:

  AN> I have to do some data mangling in a DBM file but would like to do my
  AN> testing on my development system (Win2K running ActiveState Perl
  AN> 5.8.8). I've read that this type of database is not supported by
  AN> Win32, and according to the ActiveState docs at ASPN:
  AN> "Functions obsoleted in perl5

  AN>      dbmclose, dbmopen

those functions are deprecated for all perl versions. use tie with a
hash instead. that works on all platforms and with many different db
types (some have core modules and others on cpan).

uri

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


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

Date: Wed, 07 Mar 2007 20:52:27 -0500
From: Amer Neely <perl4hire@softouch.on.ca>
Subject: Re: Support for dbmopen/dbmclose?
Message-Id: <iZJHh.1937$yc.525@read2.cgocable.net>

Uri Guttman wrote:
>>>>>> "AN" == Amer Neely <perl4hire@softouch.on.ca> writes:
> 
>   AN> I have to do some data mangling in a DBM file but would like to do my
>   AN> testing on my development system (Win2K running ActiveState Perl
>   AN> 5.8.8). I've read that this type of database is not supported by
>   AN> Win32, and according to the ActiveState docs at ASPN:
>   AN> "Functions obsoleted in perl5
> 
>   AN>      dbmclose, dbmopen
> 
> those functions are deprecated for all perl versions. use tie with a
> hash instead. that works on all platforms and with many different db
> types (some have core modules and others on cpan).
> 
> uri
> 

OK, I'll try that. Thanks.

-- 
Amer Neely
w: www.softouch.on.ca/
b: www.softouch.on.ca/blog/
Perl | MySQL programming for all data entry forms.
"We make web sites work!"


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

Date: Wed, 7 Mar 2007 18:40:57 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Using Substr and Regular expressions.
Message-Id: <slrneuumsp.aje.tadmc@tadmc30.august.net>

Broke <nospam@tele2.fr> wrote:

> For myself I would like to recommend the simply excellent
> book or Randal L. Schwartz, & Tom Christiansen
> Published by O'REILLY.


That is the 2nd edition of the book, and kind of old.

"Learning Perl" is currently in its 4th edition.


> I simply love Perl it became my obsession !


You are not alone.


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


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

Date: Wed, 7 Mar 2007 19:04:38 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: What is abriviation for CHR(4)
Message-Id: <slrneuuo96.aje.tadmc@tadmc30.august.net>

max <max@xxx.tovle.ct> wrote:

> CHR(9) is "\t"


No it isn't, CHR(9) is an error.

   perl -e 'CHR(9)'
   Undefined subroutine &main::CHR called at -e line 1.

Case matters.


-- 
    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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 204
**************************************


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