[16473] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 3885 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Aug 2 11:10:28 2000

Date: Wed, 2 Aug 2000 08:10:18 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <965229018-v9-i3885@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Wed, 2 Aug 2000     Volume: 9 Number: 3885

Today's topics:
    Re: Running other programs in background <bart.lateur@skynet.be>
        Splitting and matching, code problems <samara_biz@hotmail.com>
    Re: Splitting and matching, code problems <jmaggard@va.mediaone.net>
    Re: Splitting and matching, code problems <samara_biz@hotmail.com>
    Re: Splitting and matching, code problems <samara_biz@hotmail.com>
    Re: splitting on spaces <bdilworth@mco.edu>
    Re: splitting on spaces (Anno Siegel)
    Re: Upload File??? <samara_biz@hotmail.com>
    Re: Using symbolic references to call methods decided a <jamesht@idt.net>
    Re: Using symbolic references to call methods decided a (Andrew J. Perrin)
    Re: Whats wrong with this???? <jmaggard@va.mediaone.net>
    Re: Why does exists($hash{$key}) complain? (Anno Siegel)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 02 Aug 2000 13:29:56 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Running other programs in background
Message-Id: <sj7goskrfevt4jrb5o5sl0l4v2bo0gvtpl@4ax.com>

ericr@yankthechain.com wrote:


>> To make a long story short: this module has a "Kill" method.
>
>I tried $WinExec->Kill();, $WinExec->Kill("data\mplayer2"); and
>$WinExec->destroy();, and in all three cases the program froze on me
>and I got an "Out of memory!" error and had to cntl-alt-del the
>program...

Very creative... No, I ment that the module Win32::Process supports a
Kill method. Win32API does not. In fact, the Win32API wholeheartedly
supports *launching* programs, but provides no friendly means of killing
it again. There's only "TerminateProcess", but that's the same as
pressing ctrl-alt-del to stop it. Any loaded DLL's won't be freed.

The nicest way would be to activate the window (it may still be
minimized), and do the equivalent of pressing Alt-F4. It's a lot of
work: it involves:

 * get the hWnd of the Desktop, GetDesktopWindows
 * going through the top level windows, by examining each child window
in turn, by GetWindow(hWnd, GW_CHILD) (for the first) or GetWindow(hWnd,
GW_NEXT)
 * checking which process the window belongs to, through
GetWindowLong(GWL_HINSTANCE)
 * if it's the correct process, do the equivalent of pressing Alt-DEL,
by using SendMessage(hWdn, WM_SYSCOMMAND, SC_CLOSE, 0)

Maybe you'd better make a list of windows to close, and close them all
at the end. 

Gee, I don't feel like making this work right now. :-)

>I'm running ActiveState Perl 5.6. Out of curiousity, do you know why
>they didn't port Win32::Process to the new version of Perl?

Dunno. A lot of modules are still missing. Lack of time, I guess. What
bothers me, is that the list of ported modules hasn't seemed to grow in
over a month time.

The internals of 5.6 might be so different, that porting turns out to be
far from easy.

-- 
	Bart.


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

Date: Wed, 02 Aug 2000 09:15:47 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Splitting and matching, code problems
Message-Id: <39881F03.C580E709@hotmail.com>

Hi,

I'm storing a list of files with their filesizes in $Session object in
the following format:
<filename1>=<filesize1>|<filename2>=<filename2>|
etc..

Later in my script, I get data from a form and get a string which looks
like this: "<somefilename> (<its size> kb)
So, I want to see if this <somefilename> is in my $Session object
already. I have this code, but it doesn't seem to work. It just doesn't
seem to find a match. I've written a separate simple script to test if
the problem is in the variable interpolation, but it's not.

I'm lost....  If anyone can see what I'm doing wrong, could you give me
a hint?

Here's the code:

 foreach (split( /\|/, $Session->Contents->Item('Files') )){
       (my $temp1, my $temp2) = split(/=/, $_);

       $_ = $filename_with_size;

       if( /$temp1/ ){
            $Response->write('Matched!!!');
       } #if

 } #foreach


Thanks a lot!

Alex



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

Date: Wed, 02 Aug 2000 13:47:02 GMT
From: Jason Maggard <jmaggard@va.mediaone.net>
Subject: Re: Splitting and matching, code problems
Message-Id: <3988265F.40A5CF95@va.mediaone.net>

THE MATCHING CODE LOOKS FINE, I would have to suspect that the variables
are off.  You might have leftover charachters in your vars.  Right after
the assignment, print your variable and close it with colons or something.
Look for extra whitespaces and newlines.

print ":"$temp1":"$filename_with_size":"

Also, as I understand, is that filename with size that you are really
passing??

the way I understand it is that you have a file like

file.txt=1028

after the split:

temp1 -> file.txt
temp2 -> 1028

Is $filename_with_size -> "file.txt" or "file.txt,1028"

Hope this helps.
Hamnrye

"Alex T." wrote:

> Hi,
>
> I'm storing a list of files with their filesizes in $Session object in
> the following format:
> <filename1>=<filesize1>|<filename2>=<filename2>|
> etc..
>
> Later in my script, I get data from a form and get a string which looks
> like this: "<somefilename> (<its size> kb)
> So, I want to see if this <somefilename> is in my $Session object
> already. I have this code, but it doesn't seem to work. It just doesn't
> seem to find a match. I've written a separate simple script to test if
> the problem is in the variable interpolation, but it's not.
>
> I'm lost....  If anyone can see what I'm doing wrong, could you give me
> a hint?
>
> Here's the code:
>
>  foreach (split( /\|/, $Session->Contents->Item('Files') )){
>        (my $temp1, my $temp2) = split(/=/, $_);
>
>        $_ = $filename_with_size;

>        if( /$temp1/ ){
>             $Response->write('Matched!!!');
>        } #if
>
>  } #foreach
>
> Thanks a lot!
>
> Alex



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

Date: Wed, 02 Aug 2000 10:16:59 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Re: Splitting and matching, code problems
Message-Id: <39882D5B.4CD5FBB7@hotmail.com>

Alright. I got it.

The problem was that if in PerlScript you refer to your data in your
web-form as:
$Request->Form('file') then it returns the pointer to the data, and not the
data itself.

It should have been $Request->Form('file')->Item

Stupid mistake...


"Alex T." wrote:

> Hi,
>
> I'm storing a list of files with their filesizes in $Session object in
> the following format:
> <filename1>=<filesize1>|<filename2>=<filename2>|
> etc..
>
> Later in my script, I get data from a form and get a string which looks
> like this: "<somefilename> (<its size> kb)
> So, I want to see if this <somefilename> is in my $Session object
> already. I have this code, but it doesn't seem to work. It just doesn't
> seem to find a match. I've written a separate simple script to test if
> the problem is in the variable interpolation, but it's not.
>
> I'm lost....  If anyone can see what I'm doing wrong, could you give me
> a hint?
>
> Here's the code:
>
>  foreach (split( /\|/, $Session->Contents->Item('Files') )){
>        (my $temp1, my $temp2) = split(/=/, $_);
>
>        $_ = $filename_with_size;
>
>        if( /$temp1/ ){
>             $Response->write('Matched!!!');
>        } #if
>
>  } #foreach
>
> Thanks a lot!
>
> Alex



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

Date: Wed, 02 Aug 2000 10:05:16 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Re: Splitting and matching, code problems
Message-Id: <39882A9B.2364182@hotmail.com>

Thanks for reply!

Well, I do print the variables, but I don't see any extra spaces or
anything...


> THE MATCHING CODE LOOKS FINE, I would have to suspect that the variables
> are off.  You might have leftover charachters in your vars.  Right after
> the assignment, print your variable and close it with colons or something.
> Look for extra whitespaces and newlines.
>
> print ":"$temp1":"$filename_with_size":"
>
> Also, as I understand, is that filename with size that you are really
> passing??
>
> the way I understand it is that you have a file like
>
> file.txt=1028
>
> after the split:
>
> temp1 -> file.txt
> temp2 -> 1028

Right.

>
>
> Is $filename_with_size -> "file.txt" or "file.txt,1028"

$filename_with_size = "file.txt (10 kb)"

Could it have anything to do that I'm using $_ twice in foreach loop?

Alex



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

Date: Wed, 02 Aug 2000 09:25:43 -0400
From: Bob Dilworth <bdilworth@mco.edu>
To: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Subject: Re: splitting on spaces
Message-Id: <39882157.9E2C9E62@mco.edu>

Anno Siegel wrote:

> Dilworth  <dilworth@megsinet.net> wrote in comp.lang.perl.misc:
>
> > The s/ +//g should indeed be s/ +/ /g (i.e. space between the 2nd and 3rd
> >"/").  Fat fingers today.  Sorry about that.  I pride myself on being
> >embarassed as much and as often as possible and am glad that folks point out
> >my shortcomings. :-(
>
> [radical jeopardectomy by amputation of everything else]
>
> Please post your replies so that they follow, not precede, what you
> are replying to.

I'm new to this newsgroup and took the plunge and posted two replies yesterday to
questions.  Both have been groused about for formatting sins (as above).  I'm
also not familiar with the "jeopardectomy" metaphor and am curious as to what the
heck it refers.  Based on responses so far, this group seems very elitist and
doesn't seem to take well to errors of any sort, formatting or otherwise.  The
other groups I frequent are far more forgiving of human foibles.  I'd appreciate
it if someone would explain to me exactly why the culture of this group is so
unforgiving.

Bob Dilworth
Toledo, Ohio
bdilworth@mco.edu



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

Date: 2 Aug 2000 14:22:40 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: splitting on spaces
Message-Id: <8m9arg$ifa$1@lublin.zrz.tu-berlin.de>

Bob Dilworth  <bdilworth@mco.edu> wrote in comp.lang.perl.misc:
>Anno Siegel wrote:
>
>> Dilworth  <dilworth@megsinet.net> wrote in comp.lang.perl.misc:
>>
>> > The s/ +//g should indeed be s/ +/ /g (i.e. space between the 2nd and 3rd
>> >"/").  Fat fingers today.  Sorry about that.  I pride myself on being
>> >embarassed as much and as often as possible and am glad that folks point out
>> >my shortcomings. :-(
>>
>> [radical jeopardectomy by amputation of everything else]
>>
>> Please post your replies so that they follow, not precede, what you
>> are replying to.
>
>I'm new to this newsgroup and took the plunge and posted two replies yesterday to
>questions.  Both have been groused about for formatting sins (as above).

More grousing:  Pleas keep your line length below 72 characters or so.  And
don't Cc postings per email without clearly indicating that the same
message was also posted to the group.  Both are rules that apply all
over Usenet and are by no means specific to this group.

>also not familiar with the "jeopardectomy" metaphor and am curious as to what the
>heck it refers.

Hang around a bit.  The term "jeopardy posting" (and implicitly
"jeopardectomy") are explained about twice or three times a week.

>                 Based on responses so far, this group seems very elitist and
>doesn't seem to take well to errors of any sort, formatting or otherwise.  The
>other groups I frequent are far more forgiving of human foibles.  I'd appreciate
>it if someone would explain to me exactly why the culture of this group is so
>unforgiving.

Usenet groups tend to be as forgiving as they can afford to be.  Some
groups are under more pressure than others.

Anno


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

Date: Wed, 02 Aug 2000 09:26:48 -0400
From: "Alex T." <samara_biz@hotmail.com>
Subject: Re: Upload File???
Message-Id: <39882198.35B233E0@hotmail.com>

I have to deal with absolutely same problem right now.
The thing is when you want to use the browser's file uploading feature,
you have to specify ENCTYPE="multipart/form-data" in your web-form. In
this case, you're getting raw HTTP data back from your form, and you're
the one responsible to parse it.

If you don't use multipart/form-data then you can not upload the file.

So what I'm doing now is separating my form fields from file uploading.
I guess you can make a separate form, just like Hotmail does their for
Attachments (Now I understand why they do that! :))

Alex

Abel Almazan wrote:

> Hi,
>
> I need to upload a file and i have a perl that do that, but...
>
> i need to retrieve more information from the form (like description,
> etc..) and i don't know how to get this info.
>
> normallly i use CGI.pm and param('<name of the field>'), but i don't
> hope this work this time.
>
> Help, please
>
> Reply me to my mail address too.
>
> Thanx



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

Date: Wed, 02 Aug 2000 08:57:29 -0700
From: James Tolley <jamesht@idt.net>
Subject: Re: Using symbolic references to call methods decided at run-time.
Message-Id: <398844E9.DFC9F750@idt.net>

>   &{$guy->{$string}};
> }
> 
> How would I decide on which method of guy to call depending on the value of
> $string) ?

$guy->$string();

hth,

James


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

Date: 02 Aug 2000 09:16:16 -0500
From: aperrin@demog.berkeley.edu (Andrew J. Perrin)
Subject: Re: Using symbolic references to call methods decided at run-time.
Message-Id: <87em47bvf3.fsf@achebe.perrins>

"David T. Liu" <david.t.liu@intel.com> writes:

> package main;
> main();
> 
> sub main(){
>   $guy = new Class;
> 
>   my $string = "f2";
> 
>   &{$guy->{$string}};
> }

Do you call any other methods this way? This looks for an anonymous
code reference stored in the anonymous hash pointed to by $guy, with
the key of $string, and attempts to execute it.

> 
> How would I decide on which method of guy to call depending on the value of
> $string) ?

A method call can be a string:

$guy->$string;

should do it.

Andy Perrin


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

Date: Wed, 02 Aug 2000 13:25:54 GMT
From: Jason Maggard <jmaggard@va.mediaone.net>
Subject: Re: Whats wrong with this????
Message-Id: <3988216B.D8500FBE@va.mediaone.net>

Try using a write and a one line format.
It's much more reliable, and formats better output.

also, make the data read part of your foreach loop:
while (<FILEHANDLE>) {  #reads data one line at a time
chomp ;                        #forget the $i, we are working on "it"
(aka. $_)
($crap, $found) = split(/\|/,$_) #here we explicitly call $_
etc.........
This way you use less memory.

also, what kind of problem?? It doesn't go to the file?? Some goes some
doesn't??

psycho wrote:

> im haveing a problem with this trying to print to a file, can
> anyone help?
>
> Code Below:
>
> #!/usr/bin/perl -w
>
> $zonedir = "Base dir/cgi-bin/cgimania/banner/";
>
> print "content-type: text/html\n\n";
> $lookfor = "6343914";
>
> @put = ();
>
> open(FILE,"$zonedir/test.txt");
> @stuff = <FILE>;
> close(FILE);
>
> foreach $i (@stuff) {
> chomp($i);
> ($crap, $found) = split(/\|/,$i);
> if($crap eq "$lookfor"){
> push(@put, $i);
> }
> }
>
> $get = $put[0];
> ($crap, $found) = split(/\|/,$get);
>
> open(INF,"+<$zonedir/test.txt");
> flock(INF,2);
> seek(INF,0,0);
> foreach $i (@stuff) {
> chomp($i);
> if ($i eq $get) {
> $found = $found + 1;

#########################################

> write INF ;

#########################################

>
> print "Found !";
> }
> }
> close(INF);
>

format STDOUT=
@<<<<<<<<<<<<<<@<<<<<<<<<<<<<<<<<<
$crap                    $found
 .

>
> -----------------------------------------------------------
>
> Got questions?  Get answers over the phone at Keen.com.
> Up to 100 minutes free!
> http://www.keen.com



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

Date: 2 Aug 2000 13:06:55 -0000
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: Why does exists($hash{$key}) complain?
Message-Id: <8m96df$i9p$1@lublin.zrz.tu-berlin.de>

John J. Lee <phrxy@csv.warwick.ac.uk> wrote in comp.lang.perl.misc:

>The following:
>sub foo {
>	if (not exists($ignore{$col}) {
>		# stuff not involving %ignore goes here
>		return $something;
>	}
>	# stuff involving %ignore goes here
>	return $something_else;
>}
>
>(where $col == 6), gives me a warning (Use of uninitialised value) with -w
>in perl 5.005.  The warning points to the 'if' line.  Why should it warn
>me about this when I'm testing exists() precisely so that I can *avoid*
>using the uninitialised value?

The line numbers perl reports with errors and warnings must be taken
with a grain of salt.  The situation that triggers the warning may
occur somewhere within the if statement, not necessarily in  its
first line.

Anno


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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 V9 Issue 3885
**************************************


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