[10771] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4373 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Dec 7 13:07:17 1998

Date: Mon, 7 Dec 98 10:01:36 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 7 Dec 1998     Volume: 8 Number: 4373

Today's topics:
        Perl/ Win32:  Displaying a msgbox/dialog box on a remot <kpifer@ti.com>
        rename <MatharuN@Logica.com>
    Re: rename (Sam Holden)
    Re: Simple chomp question <preble@ipass.net>
    Re: Simple chomp question <aqumsieh@matrox.com>
    Re: Simple chomp question (Sam Holden)
    Re: Simple chomp question (Larry Rosler)
    Re: Simple Help Needed: How do you get rid of return ca <aqumsieh@matrox.com>
    Re: split questions <aqumsieh@matrox.com>
    Re: system() problems on Win32 && infozip <proub@shadow.net>
    Re: test for a directory (Larry Rosler)
    Re: test for a directory (Sam Holden)
    Re: test for a directory (Tad McClellan)
        using UNIX-commands with Perl <remo.goetschi@bigfoot.com>
    Re: using UNIX-commands with Perl <Tony.Curtis+usenet@vcpc.univie.ac.at>
    Re: using UNIX-commands with Perl (Tad McClellan)
        Special: Digest Administrivia (Last modified: 12 Mar 98 (Perl-Users-Digest Admin)

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

Date: Mon, 07 Dec 1998 11:32:51 -0600
From: "Kurt I. Pifer" <kpifer@ti.com>
Subject: Perl/ Win32:  Displaying a msgbox/dialog box on a remote display?
Message-Id: <366C1142.875CA0E@ti.com>

Howdy!

I have met with very limited success finding an answer to this by reading the
documentation for Perl modules I've found.

Perl for Win32, I want to display a msgbox/dialog box on a remote PC, of the
flavor that InitiateSystemShutdown does, given the computer name \\something or
an IP address.

Does anyone know where I can find, or if there is, a module that has this
functionality and if there i any documentation on how to use it.

Thanks,
Kurt Pifer


--
We are not now that strength which in old days
Moved earth and heaven, that which we are, we are,
One equal temper of heroic hearts,
Made weak by time and fate, but strong in will
To strive, to seek, to find, and not to yield. --Tennyson, Ulysses
kpifer@ti.com  <*>




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

Date: Mon, 7 Dec 1998 16:48:27 -0000
From: "Navtej S Matharu" <MatharuN@Logica.com>
Subject: rename
Message-Id: <74h0st$7ev@romeo.logica.co.uk>

Can anyone tell me why this piece of code isn't working??

#Global variables detailing directories of where messages are stored and
moved to.

$A_Repository = "C:\\GatewayA\\Repository";
$A_Temp = "C:\\GatewayA\\Temp";
$A_In = "C:\\GatewayA\\In";
$A_Out = "C:\\GatewayA\\Out";
$A_Trash = "C:\\GatewayA\\Trash";
$B_Out = "C:\\GatewayB\\Out";
$B_Ack = "C:\\GatewayB\\Ack";
$B_In = "C:\\GatewayB\\In";
$B_Trash = "C:\\GatewayB\\Trash";

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


sub Initialise($Source, $Destination)

{

opendir(*SOURCE, $Source);
chdir($Source);
opendir(*DESTINATION, $Destination);
print("The contents of the $Source directory\n on Gateway A is as follows:
\n");

@Files = readdir(*SOURCE);

foreach (@Files)

{

        print ("$_\n");
        unless(open(TRYOPEN, $_))

        {

                print("Failed to open $_\n");

        }

        close(TRYOPEN);

}

#closedir(SOURCE);
#closedir(DESTINATION);
}


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

sub Move(\$Source, \$Destination)

{

unless (rename ("$_", "$Destination\\$_"))

{

        print("Failed to rename file $_\n");

}
}

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






##################################################
#               MAIN                             #
##################################################

&Initialise($Source = $A_Repository, $Destination = $A_Temp);
&Move($Destination = $A_Temp);






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

Date: 7 Dec 1998 17:03:42 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: rename
Message-Id: <slrn76o2je.5n0.sholden@pgrad.cs.usyd.edu.au>

On Mon, 7 Dec 1998 16:48:27 -0000, Navtej S Matharu <MatharuN@Logica.com> wrote:
>Can anyone tell me why this piece of code isn't working??

How doesn't it work...
does it turn the house lights off, does it burn the toast, does it reboot the
computer, does it give an eror message ???

>
>#Global variables detailing directories of where messages are stored and
>moved to.
>
>$A_Repository = "C:\\GatewayA\\Repository";
>$A_Temp = "C:\\GatewayA\\Temp";
>$A_In = "C:\\GatewayA\\In";
>$A_Out = "C:\\GatewayA\\Out";
>$A_Trash = "C:\\GatewayA\\Trash";
>$B_Out = "C:\\GatewayB\\Out";
>$B_Ack = "C:\\GatewayB\\Ack";
>$B_In = "C:\\GatewayB\\In";
>$B_Trash = "C:\\GatewayB\\Trash";
>
>##################################################
>
>
>sub Initialise($Source, $Destination)
>
>{
>
>opendir(*SOURCE, $Source);
>chdir($Source);
>opendir(*DESTINATION, $Destination);

Since you are having problems surely checking to see if these worked would
be wise ...

<insert line> || die "couldn't (open|ch)dir: $!";

>sub Move(\$Source, \$Destination)

Just what is that meant to be anyway????

>
>{
>
>unless (rename ("$_", "$Destination\\$_"))

What do you think $_ here... or do you like doing random things with
rename()???

Also "$_" should just be $_ since the "s just add confusion.

>&Initialise($Source = $A_Repository, $Destination = $A_Temp);
>&Move($Destination = $A_Temp);

perl doesn't have named argumenats like that... Maybe you should go and read
some of the documentation that came with perl....

The above should be (I suspect I could be wrong of course):
&Initialise($A_Repository, $A_Temp);
&Move(????,$A_Temp);

-- 
Sam

You are bordering on ridiculous if you think you need to support your
premises.  Such an argument is an infinite regression.
 	--George Reese in <wv0O1.1521$Ge.4809664@ptah.visi.com>


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

Date: Mon, 7 Dec 1998 11:45:43 -0500
From: "E. Preble" <preble@ipass.net>
Subject: Re: Simple chomp question
Message-Id: <5DTa2.912$kx1.1156@news.ipass.net>

>: When dumping to the email, I load the array into a string, then
>: print it:
>: $string = "@array";


>You need to take a look at the perldata (man page | HTML page |
POD) to
>see what happens when you interpolate an array variable into a
string.
>It *will* give you those extra spaces unless you take special
steps to
>prevent it.

Thanks for the instruction location tip.

For those interested:

$string = "@array";

creates a list of the variables in @array with spaces in between
them, but not before the first array variable. This obviously
makes sense because if @array = (1,2,3,4);, then $string="@array";
would yield $string="1 2 3 4".

E. Preble



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

Date: Mon, 7 Dec 1998 11:00:38 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Simple chomp question
Message-Id: <x3y1zmckkug.fsf@tigre.matrox.com>


"E. Preble" <preble@ipass.net> writes:

> 
> I have a text file that get's read into an array:
> 
> This is the text file:
> 12345
> 67890
> 13579
> 
> Chomp does this:

chomp() lops off the "\n" character at the end of the string (if it
exists). So it won't solve your problem.

> Email comes out ok as:
> 12345
> 67890
> 13579
> Backup still not ok as:
> 12345 67890 13579
> 
> I don't want the program to insert that darn space in the backup
> file!

Calm down .. this is only a program :)

> When dumping to the email, I load the array into a string, then
> print it:
> $string = "@array";
> print MAIL "$string";  # this is OK

I doubt that this is indeed what you did for your MAIL. This should
have the spaces in there.

> 
> When dumping to the file I do the same thing
> $string = "@array";
> print BAK "$array";  #this is NOT OK

            ^^^^^^^^
should be $string??

> Any ideas?

When you try to interpolate arrays inside double-quoted strings, Perl
automatically inserts the $LIST_SEPARATOR ($") between each element. By
default the list separator is a space.

do the following:

{
	$" = '';
	$string = "@array";
}
print BAK $string;

This should solve your problem.
Note: Don't chomp().



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

Date: 7 Dec 1998 17:16:52 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: Simple chomp question
Message-Id: <slrn76o3c4.5n0.sholden@pgrad.cs.usyd.edu.au>

On Mon, 7 Dec 1998 11:00:38 -0500 , Ala Qumsieh <aqumsieh@matrox.com> wrote:
>
>do the following:
>
>{
>	$" = '';
>	$string = "@array";
>}
>print BAK $string;

Or save yourself some typing and do :

print BAK @array;

At least put the local in front if the $" or strange things will begin to
happen later on in the program.

-- 
Sam

It has been discovered that C++ provides a remarkable facility for
concealing the trival details of a program--such as where its bugs are.
	--David Keppel


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

Date: Mon, 7 Dec 1998 09:13:31 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Simple chomp question
Message-Id: <MPG.10d5ac97220ec4f1989947@nntp.hpl.hp.com>

In article <5DTa2.912$kx1.1156@news.ipass.net> on Mon, 7 Dec 1998 
11:45:43 -0500, E. Preble <preble@ipass.net> says...
 ...
> $string = "@array";
> 
> creates a list of the variables in @array with spaces in between
> them...

Actually, with the contents of $" between them, which is ' ' by default.

>From 'perlvar':

$LIST_SEPARATOR
$"

     This is like ``$,'' except that it applies to array values 
interpolated into a double-quoted string (or similar interpreted 
string). Default is a space. (Mnemonic: obvious, I think.) 

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Mon, 7 Dec 1998 11:06:40 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: Simple Help Needed: How do you get rid of return carriges?
Message-Id: <x3yzp90j600.fsf@tigre.matrox.com>


David Van den Brande <brandeda@se.bel.alcatel.be> writes:

[snip chop() explanation]

> So Call allways chop after reading a number from the standard input file.
> $originaldist = <STDIN>;
> chop ($originaldist);

You should use chomp() instead. It is safer. Be sure to read some
documentation on chomp() as its return value is different from
chop()'s. 
Basically it removes \n characters only if they exist at the end of
the string. (ACtually it removes the value of $/ if it exists at the
end of the string, but that's a \n by default).

> 
> KR,
> David
> 
> Ala Qumsieh wrote:
> 
> > [posted and mailed]
> >
> > hcatre@aw.sgi.com (hector catre) writes:
> >
> > >
> > > Hey everyone,
> > >         I'm trying to get rid of return carriages in the value of a defined
> > > string. ....<CUT>...
> >
> >
> 
> --

Hmmm.. you quoted one of my replies .. although you chopped off my
reply and left the original question .. I wonder why!!



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

Date: Mon, 7 Dec 1998 10:47:54 -0500 
From: Ala Qumsieh <aqumsieh@matrox.com>
Subject: Re: split questions
Message-Id: <x3y4sr8klfo.fsf@tigre.matrox.com>


Gunnar Lindholm <dat96gln@student3.lu.se> writes:

> 
> Hello.
> I wish to split a string $line into some interesting parts,
> the parts that I wish to save can be described by 
> the regular expression RE1
> shoud this then be done by
> 
> @useful=split(/[^(RE1)]/,$line)
> 
> or is there another way?

That is not the correct way to use split(). Read some documentation on
it and you'll figure it out in no time.

> Gunnar.
> 
> By the way:
> Is there a language like  perl+pascal ?

Ha?

> I like perl, but I would like to have some elements from pascal...

Hmm.. I haven't programmed in Pascal for a few years now .. but I am
curious as to what Pascal has to offer that Perl doesn't! Could you
elaborate please on that?



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

Date: 07 Dec 1998 08:19:12 -0600
From: Paul Roub <proub@shadow.net>
Subject: Re: system() problems on Win32 && infozip
Message-Id: <uvhjohw67.fsf@shadow.net>

Bryan Hart <bryan@eai.com> writes:

> I'm just wondering if anyone here has any expience running infozip via a
> system() under Win32 (5.00502) perl.
> 
> I've tried every combination of full paths, relative paths, using/not
> using drive letters, forward slashes, back slashes, etc I can think of.
> 
> In each case, running the command via a command prompt works, running
> from system() exits with code 65280 (Invalid Argument).
> 

Also running 5.00502 here, under WinNT 4.0.  The following:

	use strict;

	my   @sysargs = ("zip.exe");

	push @sysargs, @ARGV;

	my   $result = system( @sysargs );

	print "result: $result\n";

running as:

	perl -w pz.pl *.txt

gives:

	  adding: 3.txt (stored 0%)
	  adding: 1.txt (stored 0%)
	  adding: 2.txt (stored 0%)
	result: 0

so no problem here.  Could you give an example of the code you're using?

-paul


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

Date: Mon, 7 Dec 1998 08:23:12 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: test for a directory
Message-Id: <MPG.10d5a0cd97f70ec5989946@nntp.hpl.hp.com>

[Posted to comp.lang.perl.misc and copy mailed.]

In article <79mg47.fel.ln@metronet.com> on Mon, 7 Dec 1998 07:47:19 -
0600, Tad McClellan <tadmc@metronet.com> says...
> Nick Franken (franken@cistron.nl) wrote:
> 
> : How do I test if a subdir with any name exists?
> 
> # UNTESTED
> opendir(DIR, '/firstdir') || die "could not open '/firstdir'  $!";
> @dirs = grep -d, readdir(DIR);

Gosh, same problem of current-directory twice in one morning!

  @dirs = grep -d "/firstdir/$_", readdir(DIR);

> closedir(DIR);
> 
> print "subdirs exist\n" if @dirs;

As he only wants a boolean result, it might be better to avoid capturing 
the list of subdirs, just the number (and tossing the pseudo-directories 
'.' and '..' in any case):

  $dirs = grep !/^\.\.?$/ && -d "/firstdir/$_", readdir(DIR);

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: 7 Dec 1998 16:44:03 GMT
From: sholden@pgrad.cs.usyd.edu.au (Sam Holden)
Subject: Re: test for a directory
Message-Id: <slrn76o1ej.5hi.sholden@pgrad.cs.usyd.edu.au>

On Mon, 7 Dec 1998 08:33:48 -0600, Tad McClellan <tadmc@metronet.com> wrote:
>Tad McClellan (tadmc@metronet.com) wrote:
>: Nick Franken (franken@cistron.nl) wrote:
>
>: : How do I test if a subdir with any name exists?
>
>: @dirs = grep -d, readdir(DIR);
>
>
>   Or, if you want to exclude the '.' and '..' directories:
>
>      @dirs = grep $_ !~ /^\.{1,2}$/ && -d, readdir(DIR);

Until someone goes :

mkdir ".\n",0755;
mkdir "..\n",0755;


-- 
Sam

Simple rule: include files should never include include files.
	--Rob Pike


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

Date: Mon, 7 Dec 1998 08:33:48 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: test for a directory
Message-Id: <c0pg47.2ol.ln@metronet.com>

Tad McClellan (tadmc@metronet.com) wrote:
: Nick Franken (franken@cistron.nl) wrote:

: : How do I test if a subdir with any name exists?

: @dirs = grep -d, readdir(DIR);


   Or, if you want to exclude the '.' and '..' directories:

      @dirs = grep $_ !~ /^\.{1,2}$/ && -d, readdir(DIR);

--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 07 Dec 1998 16:53:41 +0100
From: Remo Goetschi <remo.goetschi@bigfoot.com>
Subject: using UNIX-commands with Perl
Message-Id: <366BFA05.41473E78@bigfoot.com>

I want to send automatically an E-Mail from a perl-programm with the
UNIX-Command mail. How can I do this?
normally You can use the mail command as following:

mail recipient@domain.ch <return>
This is the Text
still text
 .

The point sends the message.
how can I automize this by a perlscript?

thanks in advance

-- 
In an open world without walls and fences, who needs windows and gates?


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

Date: 07 Dec 1998 17:22:36 +0100
From: Tony Curtis <Tony.Curtis+usenet@vcpc.univie.ac.at>
Subject: Re: using UNIX-commands with Perl
Message-Id: <83zp8zx6pf.fsf@vcpc.univie.ac.at>

Re: using UNIX-commands with Perl, Remo
<remo.goetschi@bigfoot.com> said:

Remo> I want to send automatically an E-Mail from a
Remo> perl-programm with the UNIX-Command mail. How
Remo> can I do this?  normally You can use the mail
Remo> command as following:

Remo> mail recipient@domain.ch

This is for CGI I take it?  Whatever.  Don't pass
(possibly uploaded) arguments, e.g. recipient,
through a shell.

Remo> The point sends the message.  how can I
Remo> automize this by a perlscript?

    perldoc Mail::Send
    perldoc MIME::Tools

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien,  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Mon, 7 Dec 1998 12:00:46 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: using UNIX-commands with Perl
Message-Id: <e45h47.elm.ln@metronet.com>

Remo Goetschi (remo.goetschi@bigfoot.com) wrote:
: I want to send automatically an E-Mail from a perl-programm with the
: UNIX-Command mail. How can I do this?
: normally You can use the mail command as following:

: mail recipient@domain.ch <return>
: This is the Text
: still text
: .

: The point sends the message.
: how can I automize this by a perlscript?


#UNTESTED
open(MAIL, '| mail recipient@domain.ch') || die "could not fork  $!";

print MAIL<<ENDMAIL;
This is the Text
still text
ENDMAIL

close(MAIL) || die "error closing mail  $!";


See also the Perl FAQ, part 8:

   "Why doesn't open() return an error when a pipe open fails?"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: 12 Jul 98 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Special: Digest Administrivia (Last modified: 12 Mar 98)
Message-Id: <null>


Administrivia:

Special notice: in a few days, the new group comp.lang.perl.moderated
should be formed. I would rather not support two different groups, and I
know of no other plans to create a digested moderated group. This leaves
me with two options: 1) keep on with this group 2) change to the
moderated one.

If you have opinions on this, send them to
perl-users-request@ruby.oce.orst.edu. 


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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 4373
**************************************

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