[21819] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4023 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 24 11:05:49 2002

Date: Thu, 24 Oct 2002 08:05:14 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 24 Oct 2002     Volume: 10 Number: 4023

Today's topics:
    Re: Adding a word to a list if it is not already in the <jurgenex@hotmail.com>
    Re: Advice Please <postmaster@localhost.localdomain>
    Re: ARGV question (Tad McClellan)
    Re: calling an external script within a script? (Helgi Briem)
    Re: calling an external script within a script? <jurgenex@hotmail.com>
    Re: CGI::Minimal does not work with enctype="multipart/ <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
    Re: deleting a file... kill ???   Thanks... <bart.lateur@pandora.be>
        File access in CGI <cschoute@liacs.nl>
    Re: File access in CGI <jurgenex@hotmail.com>
        Matching a null in [ -~\t]? (Tim Hogard)
    Re: opendir/readdir can't handle french characters: Wha (Jean Gagnon)
    Re: perl bug? "eq" less restrictive then  "=="? <mjcarman@mchsi.com>
        regular expression (R.Noory)
    Re: regular expression (Tad McClellan)
    Re: regular expression (Tad McClellan)
    Re: regular expression <kurzhalsflasche@netscape.net>
    Re: regular expression <pinyaj@rpi.edu>
    Re: regular expression <rev_1318@hotmail.com>
    Re: regular expression <josef.moellers@fujitsu-siemens.com>
    Re: regular expression <depesz@depesz.pl>
    Re: regular expression <pinyaj@rpi.edu>
    Re: regular expression <usenet@dwall.fastmail.fm>
        Sending a Mail to MajorDomo (Aryan)
        Trying to make a GUI. <spikey-wan@bigfoot.com>
    Re: Trying to make a GUI. <rereidy@indra.com>
    Re: waitpid not returning pid? news@roaima.freeserve.co.uk
    Re: waitpid not returning pid? dkoleary@attbi.com
    Re: waitpid not returning pid? dkoleary@attbi.com
        Yet Another Perl Wrinkle!!! <heather710101@yahoo.com>
    Re: Yet Another Perl Wrinkle!!! <pinyaj@rpi.edu>
    Re: Yet Another Perl Wrinkle!!! <tassilo.parseval@post.rwth-aachen.de>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 24 Oct 2002 14:50:19 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Adding a word to a list if it is not already in there
Message-Id: <LMTt9.5831$iV1.3008@nwrddc02.gnilink.net>

Yils Kraabe wrote:
> I want to add a (list of) words to a list, if this word in not already
> in there. I did something very C-like, with a flag:
[...]
> However it looks pretty ugly to me. Maybe is there a "shell"-like
> solution using sort and something similar to uniq, or something else,
> that could improve this laborious code.

Depends.
If you don't care about the order (and in most applications you you don't,
i.e. you are talking about a set, not a list) then just use a hash.
If the order of the entries is significant, then use grep. Iff the list
returned by grep is not empty then the entry exists already in the list.

jue




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

Date: Thu, 24 Oct 2002 15:00:53 +0100
From: "bengee" <postmaster@localhost.localdomain>
Subject: Re: Advice Please
Message-Id: <ap8uem$noj$1@news0.ifb.net>

<news@roaima.freeserve.co.uk> wrote in message
news:qnq8pa.voh.ln@moldev.cmagroup.co.uk...
> merlin <merlin@itwizards.sic> wrote:
> >     I know nothing about Perl.
>
> You also don't seem to know about cross-posting. If you're going to
send
> the same post to two (or more) newsgroups then please post it ONCE
to
> both of them at the same time. That way you don't get multiple
threads to
> follow, and we don't get to waste our time repeating stuff
independently
> in the two newsgroups.

Where's the cross-posting?

bengee




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

Date: Thu, 24 Oct 2002 07:52:25 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: ARGV question
Message-Id: <slrnarfr89.2v6.tadmc@magna.augustmail.com>


[ ARGV is a _filehandle_, your question is about the @ARGV _array_. ]


Maxx <mace74@hotmail.com> wrote:

> Is it possible to write a Perl script that accepts parameters that are not
> in fact files? 


Yes.

That is, in fact, the default:

   perl -e 'print $ARGV[0], $ARGV[1], "\n"' string1 string2


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


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

Date: Thu, 24 Oct 2002 13:27:38 GMT
From: helgi@decode.is (Helgi Briem)
Subject: Re: calling an external script within a script?
Message-Id: <3db7f4f2.728074085@news.cis.dfn.de>

On Thu, 24 Oct 2002 14:58:10 +0200, peter pilsl
<pilsl_use@goldfisch.at> wrote:

>Helgi Briem wrote:
>> No. Not directly, although you can pipe to a file, then read

>thats wrong.
>of course you can directly read the output of any tool without need to 
>write to a file first !! (This is the meaning of piping)
>
>open(FH,"mytool |") or die;
>while (<FH>) {print $_};

But that is not using the system function which is
what the question was about.

< SNIP loads of off-topic jabber teaching a grandmother to 
suck eggs >
-- 
Regards, Helgi Briem
helgi AT decode DOT is

                           A: Top posting
                           Q: What is the most irritating thing on Usenet?
                                           - "Gordon" on apihna


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

Date: Thu, 24 Oct 2002 14:52:50 GMT
From: "Jurgen Exner" <jurgenex@hotmail.com>
Subject: Re: calling an external script within a script?
Message-Id: <6PTt9.5832$iV1.151@nwrddc02.gnilink.net>

aragorn wrote:
> I am calling the "system" function within a cgi script to call
> an external script. The function works fine, executes the external
> script
> and returns back to the calling script.
> The problem i have is that i cann't return a value from the external
> script
> to the parent.
> Is there a way to do this with "system" or should i use some other
> command.

Why don't you check the documentation for "system"?
Excerpt:
           [...] This is
            *not* what you want to use to capture the output from a command,
            for that you should use merely backticks or `qx//', as described
            in the section on "`STRING`" in the perlop manpage. [...]

jue




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

Date: Thu, 24 Oct 2002 15:53:00 +0200
From: Koos Pol <koos_pol@NO.nl.JUNK.compuware.MAIL.com>
Subject: Re: CGI::Minimal does not work with enctype="multipart/form-data"?
Message-Id: <newscache$cwnh4h$8zi$1@news.emea.compuware.com>

Alex wrote (Thursday 24 October 2002 14:37):

> Well, I did do that. Not that I got any response,

Hmm... he has probably a good reason for it. Not long ago I had regular 
discussions with Benjamin. And his reponses were *always* prompt.

-- 
KP



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

Date: Thu, 24 Oct 2002 14:33:22 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: deleting a file... kill ???   Thanks...
Message-Id: <qt0gru871usb2t6vrmj060f3t0aggrorhk@4ax.com>

Helgi Briem wrote:

>My point is this.  When programming, you name variables
>according to their function, not according to their
>underlying hardware/language implementation. 

Well, when you create functions, you name it after what it does. So the
C people decided to call this function "unlink", because they thought
that this is what it does. And Perl, providing not much more than a
wrapper around this function, took over the name, because it basically
does the same thing.

I don't really think "unlink" is the proper name, though. It deletes a
directory entry, not necessarily the underlying file. "Unlink" suggests
to me that all it does is sever the connection between directory entry
and contents, and both keep existing, no longer related to one another.
That's not what happens.
-- 
	Bart.


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

Date: Thu, 24 Oct 2002 15:17:06 +0200
From: Christian C Schouten <cschoute@liacs.nl>
Subject: File access in CGI
Message-Id: <Pine.LNX.4.05.10210241504280.15729-100000@krypton.wi.leidenuniv.nl>

Hi,

Sorry to ask again, but I'm still having problems accessing a file from a
CGI interface form. In short, what I need to do is to have a user fill in
a form on a publicly accessible web site. This form script will then open
a file on the web server for reading/writing. My problem is that
everything seems to be fine, but the script just won't open the file.
My script is located at http://www.liacs.nl/~cschoute/let/survey_ICT.cgi
(source visible as survey_ICT.txt). A minimal version is available as
short.cgi / short.txt.

One problem could be that my regular home dir is /home/cschoute/ (not web
accessible) with a web dir of /home/cschoute/public_html/. So, would an
absolute path in the script include the public_html or not? [Rather:
http://www.liacs.nl/home/cschoute/let/survey_ICT.cgi is actually
/home/cschoute/public_html/let/survey_ICT.cgi]. If I include the
public_html in the path, it will work from the command line, but the web
can't find it neither with nor without the public_html bit.

Also, the file is set as my uid and gid on mode 777. Should I change the
uid/gid/mode? (I am not root on neither the home dir server, nor the
actual web server)

I hope I'm giving enough information...

BR,

Chris

--
#define me "Christian C. Schouten <cschoute@liacs.nl>"



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

Date: Thu, 24 Oct 2002 15:00:37 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: File access in CGI
Message-Id: <pWTt9.5833$iV1.1333@nwrddc02.gnilink.net>

Christian C Schouten wrote:
> Sorry to ask again, but I'm still having problems accessing a file
> from a CGI interface form. In short, what I need to do is to have a
[ling explanation snipped]

This doesn't seem to be a Perl issue. Does your script work when run from
the command line?

If yes then in all likelyhood you have a CGI or HTTP or HTML or ... problem.
You will get much better advice in a NG that actually deals with those areas

jue




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

Date: Thu, 24 Oct 2002 13:30:57 +0000 (UTC)
From: thogard@abnormal.com (Tim Hogard)
Subject: Matching a null in [ -~\t]?
Message-Id: <ap8smh$15it$1@knotty.abnormal.com>

I've got a bit of code that should work much like the unix strings(1)
command but only prints strings that have a null or newline at the end.
Or at least thats the theory.  

The problem is the regex matches ' [NULL]' where NULL is ascii character
code 0.  That 's  "20 5B 00 5D" in the hexeditor.
Can someone please explain why the null is ending up in $1?
perl -v says: This is perl, v5.6.0 built for i386-linux.

    #!/usr/bin/perl
    #works like strings -t x -n $cnt file file...
     
    $addr=0;
    $cnt=4;
    while(<>) {
	    $x=length($_);
	    while($_=~ /([ -~\t]{$cnt,})[\0\n]/g) {
		printf("%7lx $1\n",$addr+pos($_)-length($1)-1);
	    }
	    $addr+=$x;
    } continue {
	    $addr=0 if eof;
    }

-tim
http://web.abnormal.com


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

Date: 24 Oct 2002 06:35:32 -0700
From: jeannot@gmavt.net (Jean Gagnon)
Subject: Re: opendir/readdir can't handle french characters: What am I missing?
Message-Id: <981d6b93.0210240535.4b93bde1@posting.google.com>

"Christian Caron" <nospam@nospam.org> wrote in message news:<ap43mu$3g88@nrn2.NRCan.gc.ca>...
> I think there is a "use locale" thing to permit accented characters (but I'm
> not sure if it's only for regular expressions...).
> 
> Christian

Guys, keep please keep looking since this is not quite enough to put a
newbie on the right track... Thanks again.


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

Date: Thu, 24 Oct 2002 08:26:41 -0500
From: Michael Carman <mjcarman@mchsi.com>
Subject: Re: perl bug? "eq" less restrictive then  "=="?
Message-Id: <ap8sff$6ps2@onews.collins.rockwell.com>

On 10/24/02 4:56 AM, HEISERER DANIEL wrote:
> 
> I found that the numerical comparison "==" shows
> a difference when the lexical comparsion "eq" doesn't.
> Or am I wrong with the interpreation of "==" and "eq"?
> 
> In my eyes if "eq" gives true then also "==" has to result in true
> but not the other way.

What are the values? You would get that behavior if you compared undef
and something that nummifies to 0. (undef is treated as '' in string
contexts and 0 in numerical contexts.)

> The strange thing is that I discover things such as 
> 1!=1
> So I broke down the code to another loop
>         if ($a eq $b && $a!=$b){
>                 print "strange: $a eq $b && $a!=$b";
>         }
> strange: 1 eq 1 && 1!=1

Hmm... I can't think of any values that would produce that.

> I also retried the whole thing within a simple perlscript by setting
> $a and $b  but it did not show up again.

Try adding some defined() checks and maybe change your debug message to

    printf("strange: %s eq %s && %f != %f\n", $a, $b, $a, $b);

so that you aren't stringifying the values in the numeric part.

-mjc



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

Date: 24 Oct 2002 06:25:16 -0700
From: rnoory@videotron.ca (R.Noory)
Subject: regular expression
Message-Id: <8fec9af1.0210240525.4ec6c72b@posting.google.com>

Hello, 

My input is 
enliven
denizen
enlive
abalienate

output
(en)liv(en)
deniz(en)
(en)live
abalienate

What I want is to write a single RE that captures (en) at the begining
and the end of a word or both and live (en) alone when it is in the
middle like abalienate.

Thanks


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

Date: Thu, 24 Oct 2002 07:36:31 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regular expression
Message-Id: <slrnarfqaf.2v6.tadmc@magna.augustmail.com>

Mary Wong <mary_wong1232002@yahoo.com> wrote:


> Can anyone tell me what's wrong in this program?


You do not open() the FH filehandle.


> Everytime when i run it. I got nothing.


This "works" for me:

---------------------------
#!/usr/bin/perl
use warnings;
use strict;

while($_=<DATA>)
{
     #print words begin and end with b's
     print "1 $_" if/^b.+b$/;

     #print words contain 4 or more d
     print "2 $_" if/.*d{4,}.*/;

     #print words 3 or more letters long without vowels
     print "3 $_" if/[^aeiou]{3,}/;
}


__DATA__
bbb
bbbb
abcdefgdhijddd
qwdfgh
qaeioud
vfghj
---------------------------

output:

1 bbb
3 bbb
1 bbbb
3 bbbb
3 abcdefgdhijddd
3 qwdfgh
3 vfghj


The 2nd pattern does not match any of the strings.


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


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

Date: Thu, 24 Oct 2002 07:32:39 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: regular expression
Message-Id: <slrnarfq37.2v6.tadmc@magna.augustmail.com>

Josef Möllers <josef.moellers@fujitsu-siemens.com> wrote:
> Mary Wong wrote:

>> Everytime when i run it. I got nothing.
>> 
>> while($_=<FH>)
>> {
>>      #print words begin and end with b's
>>      print $_ if/^b.+b$/;


> Use chomp() to remove that and your program will work.


That is not the problem, the patterns will match with or
without a newline at the end.


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


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

Date: Thu, 24 Oct 2002 15:47:13 +0200
From: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: regular expression
Message-Id: <3DB7F9E1.70308@netscape.net>

R.Noory wrote:
> Hello, 
> 
> My input is 
> enliven
> denizen
> enlive
> abalienate
> 
> output
> (en)liv(en)
> deniz(en)
> (en)live
> abalienate
> 
> What I want is to write a single RE that captures (en) at the begining
> and the end of a word or both and live (en) alone when it is in the
> middle like abalienate.
> 
> Thanks


s /(^en)|(en$)/($1$2)/g;

HTH,
Dominik



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

Date: Thu, 24 Oct 2002 10:19:11 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Dominik Seelow <kurzhalsflasche@netscape.net>
Subject: Re: regular expression
Message-Id: <Pine.A41.3.96.1021024101603.27420B-100000@cortez.sss.rpi.edu>

[posted & mailed]

On Thu, 24 Oct 2002, Dominik Seelow wrote:

>> What I want is to write a single RE that captures (en) at the begining
>> and the end of a word or both and live (en) alone when it is in the
>> middle like abalienate.
>
>s /(^en)|(en$)/($1$2)/g;

That can be simplified to

  s/(^en|en$)/($1)/g;

Although it's regexically better to do it as two regexes:

  s/^en/(en)/;
  s/en$/(en)/;

-- 
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: Thu, 24 Oct 2002 16:19:47 +0200
From: Paul van Eldijk <rev_1318@hotmail.com>
Subject: Re: regular expression
Message-Id: <ap8vhu$4vn$1@odysseus.uci.kun.nl>

On Thu, 24 Oct 2002 15:47:13 +0200, Dominik Seelow wrote:

> R.Noory wrote:
>> Hello,
>> 
>> My input is
>> enliven
>> denizen
>> enlive
>> abalienate
>> 
>> output
>> (en)liv(en)
>> deniz(en)
>> (en)live
>> abalienate
>> 
>> What I want is to write a single RE that captures (en) at the begining
>> and the end of a word or both and live (en) alone when it is in the
>> middle like abalienate.
>> 
>> Thanks
> 
> 
> s /(^en)|(en$)/($1$2)/g;
> 
> HTH,
> Dominik
 
Actually, the '$2' should be left out:

s/(^en|en$)/($1)/g should do the trick nicely...

Gr,
Paul

---

PPPPPP 
P     P
P     P
PPPPPP 
P      
P      
Paul van Eldijk
=======================================
RTFM: No just an acronym, it's the LAW!


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

Date: Thu, 24 Oct 2002 16:25:02 +0200
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: regular expression
Message-Id: <3DB802BE.9A4A1020@fujitsu-siemens.com>

Tad McClellan wrote:
> =

> Josef M=F6llers <josef.moellers@fujitsu-siemens.com> wrote:
> > Mary Wong wrote:
> =

> >> Everytime when i run it. I got nothing.
> >>
> >> while($_=3D<FH>)
> >> {
> >>      #print words begin and end with b's
> >>      print $_ if/^b.+b$/;
> =

> > Use chomp() to remove that and your program will work.
> =

> That is not the problem, the patterns will match with or
> without a newline at the end.

Yep, you're right. I had stumbled acroos the missing chomp a few times,
so I thought this was the reason and only tested the corrected version.

Perhaps Mary called her program "test" and ran it on a *ix box?

Josef
-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Thu, 24 Oct 2002 15:56:42 +0200
From: hubert depesz lubaczewski <depesz@depesz.pl>
Subject: Re: regular expression
Message-Id: <slrn.pl.arfv0q.paa.depesz@depeszws.depesz.pl>

R.Noory wyrzeĽbił(a):
> My input is 
> output
> What I want is to write a single RE that captures (en) at the begining

$ cat x
enliven
denizen
enlive
abalienate

$ cat x | perl -pe 's/(^en|en$)/($1)/g'
(en)liv(en)
deniz(en)
(en)live
abalienate

$

depesz

-- 
hubert depesz lubaczewski                          http://www.depesz.pl/
------------------------------------------------------------------------
Mój Boże, spraw abym milczał, dopóki się nie upewnię,  że  naprawdę  mam
co¶ do powiedzenia.                                      (c) 1998 depesz



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

Date: Thu, 24 Oct 2002 10:29:14 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: regular expression
Message-Id: <Pine.A41.3.96.1021024102830.27420D-100000@cortez.sss.rpi.edu>

On Thu, 24 Oct 2002, Paul van Eldijk wrote:

>> s /(^en)|(en$)/($1$2)/g;
>
>s/(^en|en$)/($1)/g should do the trick nicely...

If you don't mind typing less characters ;) you can do

  s/^en|en$/(en)/g;

No need to use capturing parens in this case.

-- 
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: Thu, 24 Oct 2002 14:56:44 -0000
From: "David K. Wall" <usenet@dwall.fastmail.fm>
Subject: Re: regular expression
Message-Id: <Xns92B16F57E1195dkwwashere@216.168.3.30>

Jeff 'japhy' Pinyan <pinyaj@rpi.edu> wrote on 24 Oct 2002:

> On 23 Oct 2002, Mary Wong wrote:
> 
>>     #print words contain 4 or more d
>>     print $_ if/.*d{4,}.*/;
> 
> That only matches a word with 4 or more CONSECUTIVE d's.  The .*'s are
> extraneous where you have them.
> 
>   print if /d.*d.*d.*d/;
> 
> will match on words like "diddled".

I like 

    /(d[^d]*){4,}/

better.  Correct me if I'm wrong, but I think it will do less backtracking.  
/d.*d.*d.*d/ is easier to read, though.

-- 
David K. Wall - usenet@dwall.fastmail.fm
"Oook."


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

Date: 24 Oct 2002 07:04:19 -0700
From: aryan_us1975@yahoo.com (Aryan)
Subject: Sending a Mail to MajorDomo
Message-Id: <6e1902a1.0210240604.5c0a97e@posting.google.com>

sub subscribeTheUser{

    my($list,$subscriber) = @_;
    
    my($sendmail) = "/opt/NCRsm/bin/sendmail";
    my($postmaster) = "$whoami";
    
    open (MSG, "|$sendmail -f$postmaster -t ") ||
        die "Problem running sendmail";



print MSG <<"--end--";
To: ag210061\@yahoo.com
From: ag210061\@yahoo.com
Subject:

#  This prerecorded message has been sent you because
#  then Majordomo List Server Application knows you 
#  as the owner of the list:
#  
#  $list
#
#  The subscribers listed at the end of this message
#  have been removed because they were found to be invalid.
#  the Majordomo list: $list
#
#  The following are the results of the commands sent
#  to Majordomo.
#
#
--end--

    print MSG "subscribe $list $subscriber\n";
   close(MSG);

} 

I am using MajorDomo application to send the mail.I am trying to send
the mail to MajorDomo Application , but my this program is not sending
the mail to MajorDomo. I am sure , if some one has worked on MajorDomo
or MajorCool , he should be able to help me. If Any of you have any
Idea please guide..

Thanks.


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

Date: Thu, 24 Oct 2002 14:49:35 +0100
From: "Richard S Beckett" <spikey-wan@bigfoot.com>
Subject: Trying to make a GUI.
Message-Id: <ap8tqq$mb0$1@newshost.mot.com>

Hello.

I'm trying to add a GUI to my script, but am finding it very difficult.

I have tried guido, and the gui loft, but I find the documentation isn't
enough to get me started.

So, I pulled out the perl cookbook. On page 540 there's a simple script that
should open a dialog box with 2 buttons, but for the life of me I can't make
it work.

I need some really basic help, if you wouldn't mind.

I'm using active state on win32.

Here's the script, and errors...

use strict;
use warnings;
use TK;
use TK::DialogBox;
my $main = "";
my $dialog = $main->DialogBox( -title => "Register this program.",
       -buttons => [ "Register", "Cancel" ] );
my $button = $dialog->Show();
if ($button eq "Register"){print "Registered!\n"}
elsif ($button eq "Cancel") {print "Cancelled!\n"}

Can't call method "DialogBox" without a package or object reference at
register.pl line 6.

Thanks.

R.




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

Date: Thu, 24 Oct 2002 08:56:44 -0600
From: Ron Reidy <rereidy@indra.com>
Subject: Re: Trying to make a GUI.
Message-Id: <3DB80A2C.3A0C54AC@indra.com>

See below.

Richard S Beckett wrote:
> 
> Hello.
> 
> I'm trying to add a GUI to my script, but am finding it very difficult.
> 
> I have tried guido, and the gui loft, but I find the documentation isn't
> enough to get me started.
> 
> So, I pulled out the perl cookbook. On page 540 there's a simple script that
> should open a dialog box with 2 buttons, but for the life of me I can't make
> it work.
> 
> I need some really basic help, if you wouldn't mind.
> 
> I'm using active state on win32.
> 
> Here's the script, and errors...
> 
> use strict;
> use warnings;
> use TK;
> use TK::DialogBox;
> my $main = "";  # ERROR!
my $main = MainWindow->new();
> my $dialog = $main->DialogBox( -title => "Register this program.",
>        -buttons => [ "Register", "Cancel" ] );
> my $button = $dialog->Show();
> if ($button eq "Register"){print "Registered!\n"}
> elsif ($button eq "Cancel") {print "Cancelled!\n"}
> 
> Can't call method "DialogBox" without a package or object reference at
> register.pl line 6.
> 
> Thanks.
> 
> R.

-- 
Ron Reidy
Oracle DBA


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

Date: Thu, 24 Oct 2002 14:21:26 +0100
From: news@roaima.freeserve.co.uk
Subject: Re: waitpid not returning pid?
Message-Id: <m4s8pa.3si.ln@moldev.cmagroup.co.uk>

dkoleary@attbi.com wrote:
> I'm writing a script which
> will eventually scp multiple oracle archive logs simultaneously to a
> DR site.  [...] I have to
> track specific pids so I can remove the original file if the scp was
> successful or put the archive log back on the list if it didn't.

Can't you just check the exit status of scp and delete the archive log
while still within the child if the scp works?

    system ("scp \"$archive\" remote_host:") == 0 and unlink $archive

Shock, horror, you could then even use a /bin/sh script to do this pretty
much trivially, and you wouldn't need to worry about the complexities
of forking and reaping children:

	LOGFILES=
	for LOGFILE in *
	do
	    ( scp $LOGFILE $REMOTE_HOST:$LOGFILE && rm -f $LOGFILE ) &
	    ALLFILES="$ALLFILES $LOGFILE"
	done
	wait
	for LOGFILE in $ALLFILES
	do
	    test -f "$LOGFILE" || echo "Archived $LOGFILE"
	done

Just a thought,
Chris
-- 
@s=split(//,"Je,\nhn ersloak rcet thuarP");$k=$l=@s;for(;$k;$k--){$i=($i+1)%$l
until$s[$i];$c=$s[$i];print$c;undef$s[$i];$i=($i+(ord$c))%$l}


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

Date: Thu, 24 Oct 2002 13:58:00 GMT
From: dkoleary@attbi.com
Subject: Re: waitpid not returning pid?
Message-Id: <H%St9.2488$wF6.982854@news.randori.com>

news@roaima.freeserve.co.uk wrote:

> Can't you just check the exit status of scp and delete the archive log
> while still within the child if the scp works?

>     system ("scp \"$archive\" remote_host:") == 0 and unlink $archive

You have a good point there.  I was using the reaper function because
I thought I would have to either delete the file OR update a new_files
hash based on success/failure of the scp.  If the reaper function removes
the hash entry regardless of success/failure, the logic that reads the 
directory will simply put it back on the hash... Hmmm.  That has 
promise.  Thanks for the tip.

> Shock, horror, you could then even use a /bin/sh script to do this pretty
> much trivially, and you wouldn't need to worry about the complexities
> of forking and reaping children:

You're right that a ksh script to do the basics is trivial.  I went with 
perl to satisfy the other requirements - logging and throttling the 
number of concurrent scps.  Granted, all three reqs (scp, logging, 
process throttling)  could be done with a ksh script as well; however, 
I'll usually fall back to perl when a script reaches a subjective 
"complexity" level.  

Thanks for the response.

Doug

-------
Senior UNIX Admin
Independent consultant
dkoleary@attbi.com
resume:  http://home.attbi.com/~dkoleary/resume.html


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

Date: Thu, 24 Oct 2002 14:06:14 GMT
From: dkoleary@attbi.com
Subject: Re: waitpid not returning pid?
Message-Id: <p7Tt9.2490$wF6.982854@news.randori.com>

ctcgag@hotmail.com wrote:

> The obvious problem is that the expression 'waitpid(-1, &WNOHANG)  > 0'
> evaluates to true, and then true (i.e. 1) is stuffed into $stiff.

Obvious to you, perhaps.  I spent several hours hunting those damned
parenthesis.  Gotta love precedence.  That was it, thanks for the help.

> But I'd also worry about what happens if reaper gets interrupted by
> itself.  Should you be waiting on all zombies, or just the one zombie
> that presumably triggered reaper?

I've seen a number of warnings in this newsgroup re signal handlers 
while perusing google searches and the responses to this post.  It
doesn't seem like it's doing a whole lot to me; however, it's big enough
to set off some alarms in more experienced programmers, so I need to 
consider that a bit more.  

At the moment, the script is chugging away.  There's a couple of 
improvements for ver 2, however.

Thanks again for the help.

Doug

--------
Senior UNIX Admin
Independent consultant
dkoleary@attbi.com
resume:  http://home.attbi.com/~dkoleary/resume.html


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

Date: Thu, 24 Oct 2002 13:30:09 +0000 (UTC)
From: Da Witch <heather710101@yahoo.com>
Subject: Yet Another Perl Wrinkle!!!
Message-Id: <ap8sl1$k90$1@reader1.panix.com>



Yet another Perl "wrinkle" (I don't dare to call it "bug") cost me 1+
hours' worth of pointless print-statement-based debugging.  This code
illustrates the wrinkle:

  # wrinkle.pl
  sub foo {}
  
  my $x = foo(); print "[$x]\n";
  my @x = foo(); print "[@x]\n";
  my $y = Bar->bar(); print "[$y]\n";
  my @y = Bar->bar(); print "[@y]\n";
  my $z = Bar->baz(); print "[$z]\n";
  my @z = Bar->baz(); print "[@z]\n";
  
  package Bar;
  sub bar {()}
  sub baz {}
  __END__

  % perl wrinkle.pl
  []
  []
  []
  []
  []
  [Bar]

OK, so if the sub is completely empty *and* if it is being called in
an array context *and* it is being called as a class method, then it
returns the class name, otherwise it returns nothing (undef?).

To make matters worse, in this behavior disappears in the debugger:

  % perl -d wrinkle.pl
  Default die handler restored.
  
  Loading DB routines from perl5db.pl version 1.07
  Editor support available.
  
  Enter h or `h h' for help, or `man perldebug' for more help.
  
  main::(wrinkle.pl:4):      my $x = foo(); print "[$x]\n";
    DB<1> c
  []
  []
  []
  []
  []
  []
  Debugged program terminated.  Use q to quit or R to restart,
    use O inhibit_exit to avoid stopping after program termination,
    h q, h R or h O to get additional info.
    DB<1>


Bug or feature?

h



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

Date: Thu, 24 Oct 2002 10:23:23 -0400
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Da Witch <heather710101@yahoo.com>
Subject: Re: Yet Another Perl Wrinkle!!!
Message-Id: <Pine.A41.3.96.1021024101957.27420C-100000@cortez.sss.rpi.edu>

[posted & mailed]

On Thu, 24 Oct 2002, Da Witch wrote:

>  # wrinkle.pl
>  sub foo {}
>  
>  my $x = foo(); print "[$x]\n";
>  my @x = foo(); print "[@x]\n";
>  my $y = Bar->bar(); print "[$y]\n";
>  my @y = Bar->bar(); print "[@y]\n";
>  my $z = Bar->baz(); print "[$z]\n";
>  my @z = Bar->baz(); print "[@z]\n";
>  
>  package Bar;
>  sub bar {()}
>  sub baz {}

>OK, so if the sub is completely empty *and* if it is being called in
>an array context *and* it is being called as a class method, then it
>returns the class name, otherwise it returns nothing (undef?).

An empty subroutine returns @_ in list context.  Why, I don't know.  See
the following code:

  sub foo { }
  sub Bar::bar { }

  print foo(), "\n";
  print foo(1,2), "\n";
  print Bar->bar(), "\n";
  print Bar->bar(3,4), "\n";
  __END__
  
  12
  Bar
  Bar34

That's just what it does....

-- 
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: 24 Oct 2002 14:27:43 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: Yet Another Perl Wrinkle!!!
Message-Id: <ap900v$62l$1@nets3.rz.RWTH-Aachen.DE>

Also sprach Da Witch:

> Yet another Perl "wrinkle" (I don't dare to call it "bug") cost me 1+
> hours' worth of pointless print-statement-based debugging.  This code
> illustrates the wrinkle:
> 
>   # wrinkle.pl
>   sub foo {}
>   
>   my $x = foo(); print "[$x]\n";
>   my @x = foo(); print "[@x]\n";
>   my $y = Bar->bar(); print "[$y]\n";
>   my @y = Bar->bar(); print "[@y]\n";
>   my $z = Bar->baz(); print "[$z]\n";
>   my @z = Bar->baz(); print "[@z]\n";
>   
>   package Bar;
>   sub bar {()}
>   sub baz {}
>   __END__
> 
>   % perl wrinkle.pl
>   []
>   []
>   []
>   []
>   []
>   [Bar]
> 
> OK, so if the sub is completely empty *and* if it is being called in
> an array context *and* it is being called as a class method, then it
> returns the class name, otherwise it returns nothing (undef?).

This has something to do with the fact that Perl passes variables into a
subroutine via an internal stack. The return values are pushed on the
very same stack. If you have an empty subroutine, the stack is not
touched so whatever you pass in is passed out. Not inuitive perhaps, but
not a bug either.

Not that

    sub bar {()}

does specify an explicit return value, namely the empty list. In this
case, the values that are passed in are removed from the stack.

> To make matters worse, in this behavior disappears in the debugger:
> 
>   % perl -d wrinkle.pl
>   Default die handler restored.
>   
>   Loading DB routines from perl5db.pl version 1.07
>   Editor support available.
>   
>   Enter h or `h h' for help, or `man perldebug' for more help.
>   
>   main::(wrinkle.pl:4):      my $x = foo(); print "[$x]\n";
>     DB<1> c
>   []
>   []
>   []
>   []
>   []
>   []
>   Debugged program terminated.  Use q to quit or R to restart,
>     use O inhibit_exit to avoid stopping after program termination,
>     h q, h R or h O to get additional info.
>     DB<1>
> 
> 
> Bug or feature?

I am not sure about the debugger thing, though. In my understanding, a
program run through the debugger should behave exactly as in an ordinary
run. I am not so familiar with Perl's debugger so I can't say much about
that.

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

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


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