[29937] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1180 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Jan 9 03:09:40 2008

Date: Wed, 9 Jan 2008 00:09:03 -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, 9 Jan 2008     Volume: 11 Number: 1180

Today's topics:
    Re: Active State perl for windows not working. <invalid@invalid.net>
    Re: Active State perl for windows not working. <john@castleamber.com>
    Re: Active State perl for windows not working. <nospam@somewhere.com>
    Re: Active State perl for windows not working. <jurgenex@hotmail.com>
    Re: every($key, $interval) function <ben@morrow.me.uk>
    Re: every($key, $interval) function <rvtol+news@isolution.nl>
    Re: every($key, $interval) function <uri@stemsystems.com>
    Re: HELP!  File Copy, Move and Rename will not work in  <veatchla@yahoo.com>
    Re: HELP! File Copy, Move and Rename will not work in m <joe@inwap.com>
    Re: HELP! File Copy, Move and Rename will not work in m <someone@example.com>
        new CPAN modules on Wed Jan  9 2008 (Randal Schwartz)
    Re: Segmentation Fault (core dumped) on Solaris 10 <joe@inwap.com>
    Re: Using CPAN "lightweight" <ben@morrow.me.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Tue, 8 Jan 2008 21:28:01 -0700
From: "Reagan Revision" <invalid@invalid.net>
Subject: Re: Active State perl for windows not working.
Message-Id: <1199852244_24795@sp12lax.superfeed.net>


"Caduceus" <kcom@fusemail.com> wrote in message 
news:dhn7o3hannpg0ugh7okc1t5k466m4gdogb@4ax.com...
> When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
> nothing happens.  Is there something I can do for this?  TIA Steve

In order for the perl command to do anything in my AS installation, I have 
to use a dos prompt in the \perl\bin directory.

To that end, I use the following shortcut:

%windir%\system32\cmd.exe /K CD /D \perl\bin

-- 
Reagan Revision

"We are being told that a competent, trustworthy president is someone
who brandishes his religion like a neon sign, loads a gun and goes out
hunting for beautiful winged creatures, and tries to imitate a past
president who, by the way, never shot a bird or felt the need to imitate
anybody."

~~  Patti Davis Is Not Flattered by GOP Candidates' Pale Imitations of
Her Father 



----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----


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

Date: 9 Jan 2008 04:47:06 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <Xns9A1FE7C9E5D30castleamber@130.133.1.4>

"Reagan Revision" <invalid@invalid.net> wrote:

> 
> "Caduceus" <kcom@fusemail.com> wrote in message 
> news:dhn7o3hannpg0ugh7okc1t5k466m4gdogb@4ax.com...
>> When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
>> nothing happens.  Is there something I can do for this?  TIA Steve
> 
> In order for the perl command to do anything in my AS installation, I
> have to use a dos prompt in the \perl\bin directory.
> 
> To that end, I use the following shortcut:
> 
> %windir%\system32\cmd.exe /K CD /D \perl\bin

Uhm, so you develop software with admin rights (sounds like a bad idea).

Also, it *should* work from any location, has been doing so for me for 
years.

C:\Documents and Settings\John\My Documents\Amber\Sites\johnbokma.com
\scripts>perl -v                                        
                                                                                                                             
This is perl, v5.8.8 built for MSWin32-x86-multi-thread                                                                      
(with 50 registered patches, see perl -V for more detail)           

[ rest snipped ]

-- 
John

Arachnids near Coyolillo - part 1
http://johnbokma.com/mexit/2006/05/04/arachnids-coyolillo-1.html


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

Date: Tue, 8 Jan 2008 23:59:36 -0500
From: "Thrill5" <nospam@somewhere.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <56CdnfwPvKMlyRnanZ2dnUVZ_qWtnZ2d@comcast.com>

Add the "perl/bin" (whatever it is for your installation, but the default is 
"C:\perl\bin" for ActiveState installations) directory in your PATH 
environment variable.

"Caduceus" <kcom@fusemail.com> wrote in message 
news:dhn7o3hannpg0ugh7okc1t5k466m4gdogb@4ax.com...
> When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
> nothing happens.  Is there something I can do for this?  TIA Steve 




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

Date: Wed, 09 Jan 2008 05:24:35 GMT
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Active State perl for windows not working.
Message-Id: <2hm8o3pb07is3abdh97guc9hn6p2icrrjg@4ax.com>

"Reagan Revision" <invalid@invalid.net> wrote:
>
>"Caduceus" <kcom@fusemail.com> wrote in message 
>news:dhn7o3hannpg0ugh7okc1t5k466m4gdogb@4ax.com...
>> When I try to type in perl -v, perl -h,perl -w, or perl -procinv.pl
>> nothing happens.  Is there something I can do for this?  TIA Steve
>
>In order for the perl command to do anything in my AS installation, I have 
>to use a dos prompt in the \perl\bin directory.

Well, why don't you add \perl\bin (or whatever your Perl bin directory is)
to your search path? Normally an ActiveState installation will do that
automatically unless you tell it otherwise.

jue


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

Date: Wed, 9 Jan 2008 02:18:54 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: every($key, $interval) function
Message-Id: <ehnd55-724.ln1@osiris.mauzo.dyndns.org>


Quoth Ted Zlatanov <tzz@lifelogs.com>:
> I find this function very useful:
> 
> {
>  my %counters = ();
>  sub every
>  {
>   my $id = shift @_;
>   my $when = shift @_;
> 
>   return (0 == ++$counters{$id} % $when);
>  }
> }
> 
> I call it like this:
> 
> print "debug info: ..."
>  if every("debug spot", 50);
> 
> print "extra info: ..."
>  if every("extra spot", 100);
> 
> So the debug info will be printed on every 50th call to every().  It's
> small and convenient, but I have to make up a new ID every time.
> 
> I'd like to preserve the functional interface, so no OOP cheating.  How
> can I avoid the $id parameter, creating an automatically localized
> every() call each time?  I thought of __FILE__ and __LINE__ but those
> are not unique enough, since you could potentially have
> 
> if (every(50)||every(33)) {}
> 
> on a line...  I also thought of every(\&action_sub, 50) but that avoids
> the problem sideways (it doesn't create a unique key, but makes the
> action the key, which is not the same thing).

The obvious answer is to call it like

    every(my $dummy, 50)

and key your hash on refaddr \$_[0], or, better, make it a fieldhash
(Hash::Util::Fieldhash, new with 5.10). An alternative would be to write
a tiny bit of XS that grabs the return op number from the top entry in
the call stack: basically, this would key on the place in the source
where every was called.

Ben



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

Date: Wed, 9 Jan 2008 04:30:35 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: every($key, $interval) function
Message-Id: <fm1iqq.1uo.1@news.isolution.nl>

Ben Morrow schreef:
> Ted Zlatanov:

>> I find this function very useful:
>>
>> {
>>  my %counters = ();
>>  sub every
>>  {
>>   my $id = shift @_;
>>   my $when = shift @_;
>>
>>   return (0 == ++$counters{$id} % $when);
>>  }
>> }
>>
>> I call it like this:
>>
>> print "debug info: ..."
>>  if every("debug spot", 50);
>>
>> print "extra info: ..."
>>  if every("extra spot", 100);
>>
>> So the debug info will be printed on every 50th call to every().
>> It's small and convenient, but I have to make up a new ID every time.
>>
>> I'd like to preserve the functional interface, so no OOP cheating.
>> How can I avoid the $id parameter, creating an automatically
>> localized every() call each time?  I thought of __FILE__ and
>> __LINE__ but those are not unique enough, since you could
>> potentially have
>>
>> if (every(50)||every(33)) {}
>>
>> on a line...  I also thought of every(\&action_sub, 50) but that
>> avoids the problem sideways (it doesn't create a unique key, but
>> makes the action the key, which is not the same thing).
>
> The obvious answer is to call it like
>     every(my $dummy, 50)
> and key your hash on refaddr \$_[0]
> [...]

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

sub every{
  my %counters if 0;
  (++$counters{ \$_[1] } % $_[0]) or $_[1] and print $_[1], "\n";
}

for my $i (1..13) {
  every(7, my $ev0);
  every(3, my $ev1 = "A:$i");
  every(3, my $ev2 = "B:$i");
  every(5, my $ev3 = "C:$i");
}

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: Wed, 09 Jan 2008 05:08:11 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: every($key, $interval) function
Message-Id: <x7hchnio1x.fsf@mail.sysarch.com>

>>>>> "R" == Ruud  <rvtol+news@isolution.nl> writes:

  R> sub every{
  R>   my %counters if 0;

don't use that broken idiom. it will fail under 5.10 since it supports
state variables.

  R>   my ($div, @id) = @_;
  R>   return !(++$counters{ caller(), $div, @id } % $div);

just for education of others, that is the old pseudo multilevel hash
from perl4 days. it is rare to see a good use for it these days.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Architecture, Development, Training, Support, Code Review  ------
-----------  Search or Offer Perl Jobs  ----- http://jobs.perl.org  ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Tue, 08 Jan 2008 20:32:27 -0600
From: l v <veatchla@yahoo.com>
Subject: Re: HELP!  File Copy, Move and Rename will not work in my script!
Message-Id: <13o8chsr0r34qba@news.supernews.com>

kwalike57 wrote:
> Hello.
> 
> I have a perplexing question that seems like it should be very
> simple.  I have a perl script that in a nutshell, reads a directory
> and then looks for a specific file naming convention which is matched
> up by using a regExp that loads a variable $FILE.  Once it finds this
> it Connect:Directs (copies file) the file to a remote node.  After
> this is done I send an email notification that the file transfer
> completes.  My problem is that when this whole process completes, I
> want to rename the $FILE to a file.done format.  I do this with the
> rename function normally but saying rename ($FILE, $FILEDONE).  This
> is not working.  I can tell the script to print out the value of $FILE
> and $FILEDONE and both values are correctly indicated.  For example if
> $FILE is FILEa.txt then $FILEDONE would be FILEa.txt.done.
> 
> So my question is, why won't my file rename properly.  My script exits
> with an error indicating cannot rename $FILE.
> 
> In light of this I decided to try to copy $FILE and then also tried to
> move $FILE.  Neither work.  This script runs on a Windows box and so I
> tried to manually execute the copy and move commands from the command
> line and both work fine.  I can rename, copy and move the file with no
> problem.  I am using File::Copy in my script.  I have tried using the
> system command to execute the copy and moves and I have tried to
> manually type in the copy and moves as well in the script.  I have
> only tried to do this with the variable values and have not tried
> executing these commands with a qualified path to the file name.
> 
> Any ideas?  This seems like it should be the easiest part of the whole
> process and it has taken up a bunch of time trying to get this last
> element to work.
> 
> Thanks for your help!!
> 
> Karin Walike

It's been about 15 since I have done anything with CONNECT:Direct (OS2 
and a whopping 25Mhz pc) - if were are talking about the same product, 
by Computer Associates?  Come to think of it, I think our mainframe uses 
this.  I seem to recall, but not certain, that Connect:Direct initiates 
a request to send the file to the remote node and control returns to 
your script before the transfer is complete.  Therefore your local file 
may still be in use not allowing the rename.  I believe there is a 
parameter to override this behavior causing the Direct:Connect to "hang" 
until the transfer is complete.  This is simple enough to test, skip the 
Connect:Direct step.  An any case, look at the documentation.

-- 

Len


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

Date: Tue, 08 Jan 2008 20:21:27 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: HELP! File Copy, Move and Rename will not work in my script!
Message-Id: <IIudnbUlzO5a1hnanZ2dnUVZ_oWdnZ2d@comcast.com>

kwalike57 wrote:

> 	print "filedone=$FILEDONE\n";
> 	#rename ("D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\
> \RU_VIRGIN_MOBILE_1_20071130.007.gz", "D:\\Prod_D\\BOP\\Data\\SMSDATA\
> \PCSWHSLE\\CD\\VM\\RU_VIRGIN_MOBILE_1_20071130.007.gz.done");
> 	rename ($FILE, $FILEDONE);

You did not check whether rename() returned success or not.
You did not print the error codes on failure, which you'll need
to do troubleshooting.

   if (rename($FILE,$FILEDONE)) {
     print "Renamed to $FILEDONE\n";
   } elsif (move($FILE,$FILEDONE)) {
     print "Moved to $FILEDONE\n";
   } else {
     warn "Unable to rename or move '$FILE' to '$FILEDONE'; error = '$!' $^E\n";
     errorexit(9, "Unable to move $FILE '$!' $^E");
   }

Also, remember that Windows won't let you rename a file if some other
program still has the file open.

	-Joe


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

Date: Wed, 09 Jan 2008 05:04:19 GMT
From: "John W. Krahn" <someone@example.com>
Subject: Re: HELP! File Copy, Move and Rename will not work in my script!
Message-Id: <nBYgj.9010$fj2.803@edtnps82>

kwalike57 wrote:
> On Jan 8, 3:33 pm, "John W. Krahn" <some...@example.com> wrote:
>> 
>> Your second posting of the same problem and you still have not posted
>> any code.
>>
>> My crystal ball seems to think that you may have a problem with
>> directories, either incorrect names or missing completely?  Possibly on
>> line 42?

It looks like my crystal ball is batting .500, correct problem, wrong 
line number.


> Here is the code...
> 
> #!/perl/bin/perl

You should start off with the two pragmas:

use warnings;
use strict;

> #
> #NewAutoConDir.pl
> #Karin Walike
> #12.01.07
> #
> #Connect:Direct process automation for server PKSW1714
> #The script sleeps and wakes up to check and see if there is a file
> #has been loaded to the server for Connect:Direct to customer.
> #
> #
> #We currently have XX customers sending/receiving data to this node.
> #
> #Product list:  xx, xx, xx, xx, xx,
> 
> use MIME::Lite;
> use Cwd;
> use File::Copy;

You don't appear to be using either Cwd or File::Copy?

> my $date=localtime();
> 
> my $dirVM="D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\\";
> my $doneDir="D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\\DONE\
> \";
> 
> my $FILE;
> my @FILES;

These should be declared inside the loop instead of here.

> my $doneExt = ".done";
> 
> my $ConDir1="D:\\tools\\'Sterling Commerce'\\'CONNECT Direct v4.1'\
> \'Common Utilities'";
> my $ConDir2="D:\\Prod_D\\BOP\\Scripts\\temp";
> my $ConDir3="D:\\Prod_D\\BOP\\scripts\\triggerDir";
> 
> my $LOG="D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_1.txt";
> my $LOG2="D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_2.txt";
> 
> my $LOG3="D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_3.txt";
> my $LOG4="D:\\Prod_D\\BOP\\Logs\\ConDirLogVM_4.txt";
> 
> my $EXCONDIR="D:\\Prod_D\\BOP\\Scripts\\temp\\ConDirVM.cmd";

You should use the forward slash (/) instead of the backslash (\) for 
path separators.

> open (OUT,">>$LOG");

You should *always* verify the success of open().  You should probably 
use a different name for the filehandle.

> while(1) {
> 
> 
> 	# Open the directory VM
> 
> 	if( -d $dirVM ) {
> 		opendir( VMDIR, $dirVM ) || die "Cannot open directory $dirVM $!";
> 	}else{
> 		print "Directory $dirVM does not exist. Exiting...\n";
> 	exit;
> 	}
> 
> 	# Iterate through the directory VM
> 
> 	opendir(VMDIR, $dirVM) || die "Cannot open directory $dirVM $!";

Why open the directory twice.  The whole if-else block is superfluous.

> 	#open(VMDIR,"D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\VM") || die
> "Cannot open directory $dirVM $!";
> 	#open(VMDIR,'dir "D:\Prod_D\BOP\Data\SMSDATA\PCSWHSLE\VM" |') || die;
> 
> 		@FILES = readdir(VMDIR);
> 
> 	#closedir(VMDIR);
> 
> 		chomp (@FILES);

chomp() is superfluous and *may* damage valid file names.

> 		print "\n@FILES\n";
> 
> 	foreach $FILE ( @FILES ) {
> 
> 		if ($FILE !~ /^RU_VIRGIN_MOBILE_[0-9]_[0-9][0-9][0-9][0-9][0-9][0-9]
> [0-9][0-9].*\.gz$/) {
> 			#print "$FILE is not an EMBARQ product...\n";
> 			goto sleeplabel;

You don't need to use goto, you should use next and a continue block 
instead.

> 		}else{
> 
> 		chomp($FILE);

Why chomp the same variable a second time?  chomp() is superfluous and 
*may* damage valid file names.

> 		print "\nFile is $FILE\n";
> 
> 		print "\nBeginning Connect:Direct processing for VIRGIN MOBILE
> customer file...\n";
> 
> 		print OUT "\n$date $FILE\n";
> 
> 		goto sleeplabel if (!$FILE);

You don't need to use goto, you should use next and a continue block 
instead.  How did $FILE get modified so that it became '0' or ''?

> 			if (file_transfer_complete($FILE)) {

One of the classic beginner mistakes.  Your subroutine 
file_transfer_complete is using stat() on the file names but you need 
the complete path to properly stat() the file.

> 			print "\nFound file $FILE\n";
> 
> 
> 
> 
> 	open(IN, "$ConDir3\\send_triggerVM.pl");
> 	open(OUT, ">$ConDir2\\tmp_sendVM.cdp");

Why are you reusing the same filehandle name that you used for the log file?

> 	while (<IN>) {
> 		if (/ConDirFile/) {
> 		s/ConDirFile/$dirVM$FILE/;

You don't have to use the same regular expression twice.

> 		}
> 		print OUT $_;
> 		}
> 		close(OUT);
> 		close(IN);
> 
> 	print "First Connect:Direct pre-processing step passed...\n";
> 
> 	"$ConDir2\\tmp_sendVM.cdp > D:\\Prod_D\\BOP\\scripts\\temp\\file";

If you had warnings enabled you would have received a warning about a 
constant in void context here.

> sleep 10;
> 
> 	print "Second Connect:Direct pre-processing step passed...\n";
> 
> 	system  $EXCONDIR || errorexit(2, "\nConnect:Direct process failed");

Because of the relatively high precedence of the || operator the 
errorexit() sub will never be called.  If you fixed the precedence then 
errorexit() will only be called when system() succeeded.

> 	print "\nConnect:Direct processing for VIRGIN MOBILE customer file
> completed...\n";
> 
> 	print OUT "\nConnect:Direct Processed for $date $FILE\n";
> 
> 	# Send email to notify file has been C:D to mainframe
> 
> 	my $machine = "PKSW1714";
> 
> 	my $email = 'IOP-ITSupport@sprint.com';
> 
> 	my $email2 = 'CD.Rom@sprint.com';
> 
> 	my $subject = "Connect:Direct Processing VIRGIN MOBILE: $FILE has
> been sent to VIRGIN MOBILE node VSCPFTP01";
> 
> 	my $body = " Hello, \n\n $FILE has been moved from $machine to
> VSCPFTP01. \n\n Please contact $email2 with questions. \n\n Thanks, \n
> \n IOP Connect:Direct Team\n\n";
> 
> 	my $server = "10.214.13.55";

$machine, $email, $email2 and $server are constants so why are they 
inside the loop?

> 	my $msg = MIME::Lite->new(
> 		From => 'CD.Rom@sprint.com',
> 		To => 'IOP-ITSupport@sprint.com',

Why define variables for those strings and then not use them?

> 		Subject => $subject,
> 		Type => 'TEXT',
> 		Data => $body
> 	);
> 
> 	#Use SMTP to send
> 	MIME::Lite->send('smtp', $server, Timeout=>60);
> 	sleep 30;
> 	$msg->send;
> 	open(OUT, ">>$LOG"); #reopen closed LOG

If you had used a different name for the filehandle then you wouldn't 
have to do this.

> 	print "\nEmail notification of Connect:Direct transfer sent...\n";
> 
> 
> 	#sleeplabel2:
> 	print"\n\n*******Waiting for VIRGIN MOBILE file processing to
> complete*******\n\n";
> 	sleep 50;
> 
> 	# Rename the current process to done
> 
> 	chomp($FILE);

Why chomp the same variable a third time?  chomp() is superfluous and 
*may* damage valid file names.

> 	print "File is writable\n" if -w $FILE;

You are using the file name only not the complete path so -w will not 
find the file you want.

> 	$FILEDONE = $FILE . $doneExt;
> 
> 	chomp($FILEDONE);

Again, why are you chomp()ing the file name?  Do you know what chomp() does?

> 	print "filedone=$FILEDONE\n";
> 
> 	#rename ("D:\\Prod_D\\BOP\\Data\\SMSDATA\\PCSWHSLE\\CD\\VM\
> \RU_VIRGIN_MOBILE_1_20071130.007.gz", "D:\\Prod_D\\BOP\\Data\\SMSDATA\
> \PCSWHSLE\\CD\\VM\\RU_VIRGIN_MOBILE_1_20071130.007.gz.done");
> 	rename ($FILE, $FILEDONE);

You are using the file name only not the complete path so rename() will 
not find the file you want.

> 	#if (renamefiles($FILE)) {
> 			print "\nFile successfully renamed: $FILEDONE\n" || errorexit(14,
> "Could not rename $FILE");
> 	#}
> 
> 	#move ($FILE,$FILEDONE) || errorexit(9, "Unable to move $FILE");
> 
> 	#copy ($FILE,$FILEDONE) || errorexit(12, "Unable to copy $FILE to
> $FILEDONE");
> 
> 	sleeplabel:

You don't need to use goto, you should use next and a continue block 
instead.

> 	print"\n\n*******Waiting for VIRGIN MOBILE Connect:Direct file*******
> \n\n";
> 	sleep 10;
> 
> 
> #
> # Begin Subroutines
> #

Why are you defining your subroutines *inside* the loop?

> #
> # Sub file_transfer_complete
> #
> # monitor a file for size changes over a brief period
> #
> # parm1 - file name
> # parm2 - delay in seconds (optional)
> #
> sub file_transfer_complete {
> 
> my $filename = shift;
> my $waitTime = shift || 20;
> 
> my $sizefirst = -s $filename;	# initial file size
> sleep $waitTime;		# wait a while
> 
> my $sizeDelta = -s $filename;	#file size after wait

You are using the file name only not the complete path so -s will not 
find the file you want.

> if( $sizeDelta == $sizefirst ) {
> 	print "transfer complete $filename 1: $sizefirst\t2: $sizeDelta" ;
> 	return 1;
> } else {
> 	print "transfer incomplete $filename 1: $sizefirst\t2: $sizeDelta" ;
> 	return 0;
> 	}
> }
> 
> 
> 
> # Sub errorexit print error message to the log and return an error
> code
> #
> sub errorexit {
> 	my $returncode = shift;
> 	my $message = shift;
> 	open (OUT, ">>$LOG");

If you had used a different name for the filehandle then you wouldn't 
have to do this.

> 	print OUT "\n### ERROR $returncode ### $message";
> 	exit ($returncode);
> }
> 
> # Sub Rename files to .done extension
> #
> sub renamefiles {
> 
> 	my $file1 = shift;
> 
> 	my $done = ".done";

Why not use the $doneExt variable?

> 	my $file2 = $file1 . $done;
> 
> 	rename ($file1, $file2) || die "Cannot rename $file1\n";

You are using the file name only not the complete path so rename() will 
not find the file you want.

> }
> }
> }
> }
> }

To sum up, here is the code with modifications that should work better 
(*UNTESTED*):

#!/perl/bin/perl
use warnings;
use strict;
#
#NewAutoConDir.pl
#Karin Walike
#12.01.07
#
#Connect:Direct process automation for server PKSW1714
#The script sleeps and wakes up to check and see if there is a file
#has been loaded to the server for Connect:Direct to customer.
#
#
#We currently have XX customers sending/receiving data to this node.
#
#Product list:  xx, xx, xx, xx, xx,

use MIME::Lite;

my $dirVM    = 'D:/Prod_D/BOP/Data/SMSDATA/PCSWHSLE/CD/VM';
my $doneDir  = 'D:/Prod_D/BOP/Data/SMSDATA/PCSWHSLE/CD/VM/DONE';
my $ConDir2  = 'D:/Prod_D/BOP/Scripts/temp';
my $ConDir3  = 'D:/Prod_D/BOP/scripts/triggerDir';
my $LOG      = 'D:/Prod_D/BOP/Logs/ConDirLogVM_1.txt';

my $EXCONDIR = 'D:/Prod_D/BOP/Scripts/temp/ConDirVM.cmd';

my $date     = localtime;
my $doneExt  = '.done';
my $machine  = 'PKSW1714';
my $email    = 'IOP-ITSupport@sprint.com';
my $email2   = 'CD.Rom@sprint.com';
my $server   = '10.214.13.55';


open my $LOGFH, '>>', $LOG or die "Cannot open '$LOG' $!";

while ( 1 ) {
     # Open the directory VM
     # Iterate through the directory VM
     opendir my $VMDIR, $dirVM or die "Cannot open directory $dirVM $!";
     my @FILES = readdir $VMDIR;
     closedir $VMDIR;
     print "\n@FILES\n";
     for my $FILE ( @FILES ) {
         if ( $FILE !~ /^RU_VIRGIN_MOBILE_[0-9]_[0-9]{8}.*\.gz$/ ) {
             #print "$FILE is not an EMBARQ product...\n";
             next;
             }
         print "\nFile is $FILE\n";
         print "\nBeginning Connect:Direct processing for VIRGIN MOBILE 
customer file...\n";
         print $LOGFH "\n$date $FILE\n";
         next unless file_transfer_complete( "$dirVM/$FILE" );
         print "\nFound file $FILE\n";
         open my $IN,  '<', "$ConDir3/send_triggerVM.pl" or die "Cannot 
open '$ConDir3/send_triggerVM.pl' $!";
         open my $OUT, '>', "$ConDir2/tmp_sendVM.cdp"    or die "Cannot 
open '$ConDir2/tmp_sendVM.cdp' $!";
         while ( <$IN> ) {
             s/ConDirFile/$dirVM$FILE/;
             print $OUT $_;
             }
         close $OUT;
         close $IN;
         print "First Connect:Direct pre-processing step passed...\n";
         sleep 10;
         print "Second Connect:Direct pre-processing step passed...\n";
         system( $EXCONDIR ) == 0 or errorexit( 2, "\nConnect:Direct 
process failed" );
         print "\nConnect:Direct processing for VIRGIN MOBILE customer 
file completed...\n";
         print $LOGFH "\nConnect:Direct Processed for $date $FILE\n";
         # Send email to notify file has been C:D to mainframe
         my $subject = "Connect:Direct Processing VIRGIN MOBILE: $FILE 
has been sent to VIRGIN MOBILE node VSCPFTP01";
         my $body = <<BODY;
  Hello,

  $FILE has been moved from $machine to VSCPFTP01.

  Please contact $email2 with questions.

  Thanks,

  IOP Connect:Direct Team

BODY
         my $msg = MIME::Lite->new(
             From    => $email2,
             To      => $email,
             Subject => $subject,
             Type    => 'TEXT',
             Data    => $body,
             );
         #Use SMTP to send
         MIME::Lite->send( 'smtp', $server, Timeout => 60 );
         sleep 30;
         $msg->send;
         print "\nEmail notification of Connect:Direct transfer sent...\n";
         print "\n\n*******Waiting for VIRGIN MOBILE file processing to 
complete*******\n\n";
         sleep 50;
         # Rename the current process to done
         print "File is writable\n" if -w "$dirVM/$FILE";
         my $FILEDONE = $FILE . $doneExt;
         print "filedone=$FILEDONE\n";
         rename "$dirVM/$FILE", "$dirVM/$FILEDONE" or die "Cannot rename 
'$dirVM/$FILE' to '$dirVM/$FILEDONE' $!";
         print "\nFile successfully renamed: $FILEDONE\n" or errorexit( 
14, "Could not rename $FILE" );
         }
     continue {
         print "\n\n*******Waiting for VIRGIN MOBILE Connect:Direct 
file*******\n\n";
         sleep 10;
         }
     }

#
# Begin Subroutines
#

# Sub file_transfer_complete
#
# monitor a file for size changes over a brief period
#
# parm1 - file name
# parm2 - delay in seconds (optional)
#
sub file_transfer_complete {
     my $filename = shift;
     my $waitTime = shift || 20;
     my $sizefirst = -s $filename;    # initial file size
     sleep $waitTime;                 # wait a while
     my $sizeDelta = -s $filename;    #file size after wait
     if ( $sizeDelta == $sizefirst ) {
         print "transfer complete $filename 1: $sizefirst\t2: $sizeDelta";
         return 1;
         }
     else {
         print "transfer incomplete $filename 1: $sizefirst\t2: $sizeDelta";
         return 0;
         }
     }

# Sub errorexit print error message to the log and return an error code
#
sub errorexit {
     my $returncode = shift;
     my $message    = shift;
     print $LOGFH "\n### ERROR $returncode ### $message";
     exit $returncode;
     }

__END__




John
-- 
Perl isn't a toolbox, but a small machine shop where you
can special-order certain sorts of tools at low cost and
in short order.                            -- Larry Wall


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

Date: Wed, 9 Jan 2008 05:42:18 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Wed Jan  9 2008
Message-Id: <JuD3uI.19r7@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Algorithm-SVMLight-0.08
http://search.cpan.org/~kwilliams/Algorithm-SVMLight-0.08/
Perl interface to SVMLight Machine-Learning Package 
----
Apache-Dispatch-0.10
http://search.cpan.org/~phred/Apache-Dispatch-0.10/
call PerlHandlers with the ease of Registry scripts 
----
Bread-Board-0.02
http://search.cpan.org/~stevan/Bread-Board-0.02/
A solderless way to wire up you application components 
----
Bread-Board-0.03
http://search.cpan.org/~stevan/Bread-Board-0.03/
A solderless way to wire up you application components 
----
CPAN-Reporter-1.0602
http://search.cpan.org/~dagolden/CPAN-Reporter-1.0602/
Adds CPAN Testers reporting to CPAN.pm 
----
CPAN-Reporter-1.07_01
http://search.cpan.org/~dagolden/CPAN-Reporter-1.07_01/
Adds CPAN Testers reporting to CPAN.pm 
----
Cache-FastMmap-Tie-0.01_02
http://search.cpan.org/~suzuki/Cache-FastMmap-Tie-0.01_02/
Using Cache::FastMmap as hash 
----
Class-Accessor-Grouped-0.08000
http://search.cpan.org/~claco/Class-Accessor-Grouped-0.08000/
Lets you build groups of accessors 
----
Class-STAF-0.03
http://search.cpan.org/~semuelf/Class-STAF-0.03/
Simplify version for the Perl STAF API 
----
DBD-InterBase-0.48
http://search.cpan.org/~edpratomo/DBD-InterBase-0.48/
DBI driver for Firebird and InterBase RDBMS server 
----
DBIx-Perlish-0.35
http://search.cpan.org/~gruber/DBIx-Perlish-0.35/
a perlish interface to SQL databases 
----
DBIx-Placeholder-Named-0.07
http://search.cpan.org/~izut/DBIx-Placeholder-Named-0.07/
DBI with named placeholders 
----
Data-FormValidator-Constraints-CreditCard-0.01
http://search.cpan.org/~gtermars/Data-FormValidator-Constraints-CreditCard-0.01/
Data constraints, using Business::CreditCard 
----
Data-FormValidator-EmailValid-0.02
http://search.cpan.org/~gtermars/Data-FormValidator-EmailValid-0.02/
Data::FormValidator e-mail address constraint/filter 
----
Data-Visitor-0.13
http://search.cpan.org/~nuffin/Data-Visitor-0.13/
Visitor style traversal of Perl data structures 
----
DateTime-Format-Natural-0.65_01
http://search.cpan.org/~schubiger/DateTime-Format-Natural-0.65_01/
Create machine readable date/time with natural parsing logic 
----
Devel-Caller-2.03
http://search.cpan.org/~rclamp/Devel-Caller-2.03/
meatier versions of caller 
----
Devel-DTrace-0.06
http://search.cpan.org/~andya/Devel-DTrace-0.06/
Enable dtrace probes for subroutine entry, exit 
----
Devel-FindBlessedRefs-1.0.0
http://search.cpan.org/~jettero/Devel-FindBlessedRefs-1.0.0/
find all refs blessed under a package 
----
FProt-Client-0.08
http://search.cpan.org/~avar/FProt-Client-0.08/
Client interface to the fpscand(1) virus scanning daemon 
----
File-Assets-0.02
http://search.cpan.org/~rkrimen/File-Assets-0.02/
Manage .css and .js assets in a web application 
----
Finance-QuoteOptions-0.13
http://search.cpan.org/~kbocek/Finance-QuoteOptions-0.13/
Perl extension for retrieving options pricing and series information from the web. 
----
Finance-QuoteOptions-0.14
http://search.cpan.org/~kbocek/Finance-QuoteOptions-0.14/
Perl extension for retrieving options pricing and series information from the web. 
----
Font-TTF-Scripts-0.10.3
http://search.cpan.org/~mhosken/Font-TTF-Scripts-0.10.3/
Smart font script supporting modules and scripts for TTF/OTF 
----
Geo-Coordinates-UTM-XS-0.03
http://search.cpan.org/~salva/Geo-Coordinates-UTM-XS-0.03/
C/XS reimplementation of Geo::Coordinates::UTM 
----
Graphics-ColorNames-2.10_05
http://search.cpan.org/~rrwo/Graphics-ColorNames-2.10_05/
defines RGB values for common color names 
----
HTML-Template-Pro-0.68
http://search.cpan.org/~viy/HTML-Template-Pro-0.68/
Perl/XS module to use HTML Templates from CGI scripts 
----
HTML-Template-Pro-0.68.1
http://search.cpan.org/~viy/HTML-Template-Pro-0.68.1/
Perl/XS module to use HTML Templates from CGI scripts 
----
Log-Smart-0.006
http://search.cpan.org/~shibuya/Log-Smart-0.006/
Messages for smart logging to the file 
----
Log-Smart-0.007
http://search.cpan.org/~shibuya/Log-Smart-0.007/
Messages for smart logging to the file 
----
MooseX-Params-Validate-0.04
http://search.cpan.org/~stevan/MooseX-Params-Validate-0.04/
an extension of Params::Validate for using Moose's types 
----
Net-RawIP-0.22
http://search.cpan.org/~szabgab/Net-RawIP-0.22/
Perl extension for manipulate raw ip packets with interface to libpcap 
----
Net-RawIP-0.23
http://search.cpan.org/~szabgab/Net-RawIP-0.23/
Perl extension for manipulate raw ip packets with interface to libpcap 
----
Net-SFTP-Foreign-1.34
http://search.cpan.org/~salva/Net-SFTP-Foreign-1.34/
Secure File Transfer Protocol client 
----
ONTO-PERL-1.09
http://search.cpan.org/~easr/ONTO-PERL-1.09/
----
POE-Component-Client-FTP-0.14
http://search.cpan.org/~bingos/POE-Component-Client-FTP-0.14/
Implements an FTP client POE Component 
----
POE-Component-Server-SimpleHTTP-1.32
http://search.cpan.org/~bingos/POE-Component-Server-SimpleHTTP-1.32/
Perl extension to serve HTTP requests in POE. 
----
POE-Component-SmokeBox-Recent-0.03
http://search.cpan.org/~bingos/POE-Component-SmokeBox-Recent-0.03/
A POE component to retrieve recent CPAN uploads. 
----
Parse-Eyapp-1.099
http://search.cpan.org/~casiano/Parse-Eyapp-1.099/
Extensions for Parse::Yapp 
----
Rose-DBx-Garden-0.10
http://search.cpan.org/~karman/Rose-DBx-Garden-0.10/
bootstrap Rose::DB::Object and Rose::HTML::Form classes 
----
SOAP-WSDL-2.00_28
http://search.cpan.org/~mkutter/SOAP-WSDL-2.00_28/
SOAP with WSDL support 
----
Scalar-Defer-0.14
http://search.cpan.org/~audreyt/Scalar-Defer-0.14/
Lazy evaluation in Perl 
----
Scalar-Util-Clone-0.10
http://search.cpan.org/~chocolate/Scalar-Util-Clone-0.10/
recursively copy datatypes using perl's builtin functions 
----
Swarmage-0.01001
http://search.cpan.org/~dmaki/Swarmage-0.01001/
A Distributed Job Queue 
----
Swarmage-0.01002
http://search.cpan.org/~dmaki/Swarmage-0.01002/
A Distributed Job Queue 
----
Sys-Statistics-Linux-0.25_01
http://search.cpan.org/~bloonix/Sys-Statistics-Linux-0.25_01/
Front-end module to collect system statistics 
----
Test-Harness-Straps-0.30
http://search.cpan.org/~mschwern/Test-Harness-Straps-0.30/
detailed analysis of test results 
----
Text-MeCab-0.20001
http://search.cpan.org/~dmaki/Text-MeCab-0.20001/
Alternate Interface To libmecab 
----
URL-Grab-1.3
http://search.cpan.org/~opitz/URL-Grab-1.3/
Perl extension for blah blah blah 
----
Video-PlaybackMachine-0.05
http://search.cpan.org/~stephen/Video-PlaybackMachine-0.05/
Perl extension for creating a television station 
----
WordNet-QueryData-1.47
http://search.cpan.org/~jrennie/WordNet-QueryData-1.47/
direct perl interface to WordNet database 
----
X12-0.09
http://search.cpan.org/~prasad/X12-0.09/
----
kurila-1.7_0
http://search.cpan.org/~tty/kurila-1.7_0/
Perl Kurila 


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


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

Date: Tue, 08 Jan 2008 20:46:13 -0800
From: Joe Smith <joe@inwap.com>
Subject: Re: Segmentation Fault (core dumped) on Solaris 10
Message-Id: <baudnWBZkqEIzBnanZ2dnUVZ_r6rnZ2d@comcast.com>

mariakvelasco@gmail.com wrote:

> I am trying to run a perl script on a Solaris 10 machine, which is
> suppose to display a dialog box

Dialog boxes are not an integral part of perl; such things are provided
by modules.  Are you using the Tk module?

> I keep getting a Segmentation
> Fault (core dumped) error.  I don't get this error message when I run
> it on Windows or Linux.

I've seen problems like this happen if $ENV{DISPLAY} or $ENV{WINDOWID}
get corrupted.

Do you get different results when running on a dtterm, an xterm, or
ssh/rlogin from elsewhere?

	-Joe


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

Date: Wed, 9 Jan 2008 02:04:15 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Using CPAN "lightweight"
Message-Id: <vlmd55-724.ln1@osiris.mauzo.dyndns.org>


Quoth Bernie Cosell <bernie@fantasyfarm.com>:
> Is there a way to use the CPAN module *without* its creating a directory
> and doing all sorts of fancy initialization and such?  I want to set up a
> program that I'd intended to "use CPAN" and do some mucking about with
> modules and such, but when I try to run it I get barraged with dialogs and
> it stashes away config stuff and who knows what...  I'd like to run it
> "self contained", no readline, no ".cpan" directories... just run?

Have you looked at CPANPLUS? It is core as of 5.10, and it was designed
to be a more programmer-friendly replacement for CPAN.

Ben



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

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


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