RE: Warning that I am receiving. but not making any sense

2008-11-26 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Rob Dixon [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, November 25, 2008 5:04 PM
 To: Perl Beginners
 Cc: Wagner, David --- Senior Programmer Analyst --- WGO
 Subject: Re: Warning that I am receiving. but not making any sense
 
 Wagner, David --- Senior Programmer Analyst --- WGO wrote:
 
  if ( ! $MyDataSw ) {
 
  It is the if statement in both cases. I changed the 
 sprintf, but the error
  comes back to the if in both cases.
 
  Thoughts?
 
 Then either the perl engine is messed up beyond hope, or the 
 scalar variable
 $MyDataSw is more than a simple scalar 'my' variable.
 
 How is $MyDataSw defined? I'm guessing it's tied.
No. It is a simple my $MyDataSw = 0 with the block that it is
being used in. That is for both cases of the variable and the warning
message that is coming up.

Wags ;)
 
 Rob
 
 
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Warning that I am receiving. but not making any sense

2008-11-25 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I get the following printed out on my terminal:

pl517c.pl:   Gen Rpt/Email St: 08:38:48
Attempt to free unreferenced scalar: SV 0x2063c74, Perl interpreter: 0x22424c at
 C:\CurrWrka\00COMM~3\pl517c.pl line 1259.
Attempt to free unreferenced scalar: SV 0x206984c, Perl interpreter: 0x22424c at
 C:\CurrWrka\00COMM~3\pl517c.pl line 1309.

The code is:

if ( ! $MyDataSw ) {
 $MyPrtBuf .= sprintf   *** No Ids were found!! ***\n;
  }

The processing completes, but I don't understand what is happening with 
the error. Running with strict and warnings, nothing appears as a warning, etc. 
I am running on xp sp 2, AS 5.8.8 build 824.

The code is exactly the same in both places where the warning comes up.

Thoughts? I searched the net and found a number of references, but 
nothing as mundane as this. I have a large number of scripts and what I am 
doing here is not much different than in others, yet I am getting this warning.

 If you have any questions and/or problems, please let me know.
 Thanks.
 
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449  FAX
http://fedex.com/us 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Warning that I am receiving. but not making any sense

2008-11-25 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Rob Dixon [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, November 25, 2008 11:46 AM
 To: Perl Beginners
 Cc: Wagner, David --- Senior Programmer Analyst --- WGO
 Subject: Re: Warning that I am receiving. but not making any sense
 
 Wagner, David --- Senior Programmer Analyst --- WGO wrote:
  I get the following printed out on my terminal:
  
  pl517c.pl:   Gen Rpt/Email St: 08:38:48
  Attempt to free unreferenced scalar: SV 0x2063c74, Perl 
 interpreter: 0x22424c at
   C:\CurrWrka\00COMM~3\pl517c.pl line 1259.
  Attempt to free unreferenced scalar: SV 0x206984c, Perl 
 interpreter: 0x22424c at
   C:\CurrWrka\00COMM~3\pl517c.pl line 1309.
  
  The code is:
  
  if ( ! $MyDataSw ) {
It is the if statement in both cases. I changed the sprintf ,
but the error comes back to the if in both cases.
Thoughts?
Wags ;)

   $MyPrtBuf .= sprintf   *** No Ids were found!! ***\n;
}
  
  The processing completes, but I don't understand what 
 is happening with the error. Running with strict and 
 warnings, nothing appears as a warning, etc. I am running on 
 xp sp 2, AS 5.8.8 build 824.
  
  The code is exactly the same in both places where the 
 warning comes up.
  
  Thoughts? I searched the net and found a number of 
 references, but nothing as mundane as this. I have a large 
 number of scripts and what I am doing here is not much 
 different than in others, yet I am getting this warning.
  
   If you have any questions and/or problems, please 
 let me know.
   Thanks.
 
 Which line is 1259 and 1309? The if or the assignment?
 
 The error is an internal perl problem, and implies a bug in 
 the XS code of one
 of the modules you're using. I can't tell why you got it here 
 that but thre's a
 chance that it may help to discard the call to sprintf(), 
 which does nothing
 useful here. So:
 
   unless ($MyDataSw) {
 $MyPrtBuf .=   *** No Ids were found!! ***\n;
   }
 
 HTH,
 
 Rob
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Attempting to use SFTP between Windows and Linux box

2008-11-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I have a couple of processes that run one on a production box and 
another on a test box. The production box script checks that a particular file 
is never more than 40 minutes old while on the test box, this checks that the 
actual polling processes ( in this case three pollers ) also are never more 
that 40 mminutes old. Each poller does it's work and then the last action it 
does is open a file as output and closes.

This has worked very over the last few years, but now with the movement 
to Linux, they want secure checking and uncertain what I am doing wrong ( or 
even right for that matter ). I am running under XP SP 2, AS 5.8.8(build 824). 
I am attempting login via SFTP to pull up the file so I can check it's stats.

What I get in my output log is:
IT2ua815132X: Reading configuration data C:/Documents and 
Settings/drw6386/.ssh/config
IT2ua815132X: Reading configuration data /etc/ssh_config
IT2ua815132X: Connecting to dhprltest.hro.freight.fedex.com, port 22.
IT2ua815132X: Remote version string: SSH-1.99-OpenSSH_3.6.1p2
IT2ua815132X: Remote protocol version 1.99, remote software version 
OpenSSH_3.6.1p2
Math::BigInt: couldn't load specified math lib(s),fallback to 
Math::BigInt::FastCalc at C:/Perl/site/lib/Crypt/DH.pm line 6
IT2ua815132X: Net::SSH::Perl Version 1.30, protocol version 2.0.
IT2ua815132X: No compat match: OpenSSH_3.6.1p2.

I have checked both locations ( PC and Linux ) and neither of those 
configuration files exist. Obviously I am trying to do this in batch/monitoring 
mode ( no interaction ).

Any insights or thoughts on how one approach this would be greatly 
appreciated?

Note: This is a working poller for FTP and not something new. Only 
trying to get secure processing is new.

 If you have any questions and/or problems, please let me know.
 Thanks.
 
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449  FAX
http://fedex.com/us 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Cron environment for execution of Perl script

2008-11-09 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas. Owens [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, November 08, 2008 10:14 AM
 To: Wagner, David --- Senior Programmer Analyst --- WGO
 Cc: Perl Beginners
 Subject: Re: Cron environment for execution of Perl script
 
 On Thu, Nov 6, 2008 at 16:42, Wagner, David --- Senior Programmer
 Analyst --- WGO [EMAIL PROTECTED] wrote:
 I need an environment variable from my .profile on 
 Solaris and having troubles getting at it. I have a Perl 
 script which executes fine outside of cron and now am trying 
 to do via cron. I wanted to stay away from a shell script and 
 was wondering what is the easiest way to get my .profile 
 loaded, so the Perl script can access the needed variable.
 
 I have tried with errors the following:
 
 25 12 * * 4 . $HOME/.profile ; /d/src/pl600.pl dp51
 
 and
 
 25 12 * * 4 . $HOME/.profile  /d/src/pl600.pl dp51
 
 I get the error:
 sh: -o: bad option(s)
 
 I believe it should not be that hard to do, but I 
 only have really enough knowledge to dangerous and know when 
 to ask for help.
 
 Thoughts, examples, site(s) where can pickup info to 
 assist in this???
 
  If you have any questions and/or problems, please 
 let me know.
  Thanks.
 snip
 
 I normally resort to a shell script calling my Perl script, but there
 lots of options:
 
 1. coding the script such that it doesn't need an environment (e.g.
 full paths on executables called)
 2. setting the necessary environment variables in %ENV manually
 3. parsing your .profile and setting the environment variables in %ENV
 
 All three have potential drawbacks:
 
 1. this is not always possible
 2. this is not always possible and if there needs to be a change you
 need to modify every file you done this in
 3. this is the best of the options, but it is not always enough and
 can be hard to do right
 
 In the end, the safest thing to do is only call shell scripts from
 your scheduler.  In fact, I often create one shell script that takes
 as an argument the name of another executable file to run.  This gives
 me common entry point for all scheduled jobs so I can do logging and
 any other work that is common to all jobs (such as setting the
 environment).
 
 -- 
Understood, but now I need two items to update: shell and Perl.
I have one variable I need and I don't need anything else, but by having
that one variable I can switch between Windows, Solars and Linux with
what I am doing without having to make changes to the script. Since
Windows uses the extention to determine what program to execute and the
location for the perl executable is pretty constant between Linux and
Unix, this makes things pretty easy to handle. I have my own poller(s)
which handle getting data from IBM(MVS), Solaris and Windows and they
have been running with no problems for a little over five years, but I
needed a cron job to make things a little bit easier and was having all
kinds of problems.

I do appreciate the feedback and will take a look at what is
happening.

Thanks much.

Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449  FAX
http://fedex.com/us 


 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Cron environment for execution of Perl script

2008-11-09 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Telemachus [mailto:[EMAIL PROTECTED] 
 Sent: Saturday, November 08, 2008 6:13 AM
 To: beginners@perl.org
 Subject: Re: Cron environment for execution of Perl script
 
 On Thu Nov 06 2008 @  3:42, Wagner, David --- Senior 
 Programmer Analyst --- WGO wrote:
  I need an environment variable from my .profile on 
 Solaris and having troubles getting at it. I have a Perl 
 script which executes fine outside of cron and now am trying 
 to do via cron. I wanted to stay away from a shell script and 
 was wondering what is the easiest way to get my .profile 
 loaded, so the Perl script can access the needed variable.
 
 Rather than try to source your entire profile, why not simply set the
 necessary environment variables in the Perl script itself, 
 using the %ENV
 hash?
I am in the same boat and after some research, came up with the
following:
30 4 * * 0,2-5 . ./.cronwrapper  /usr/bin/perl /d/src/pl600.pl
dp11
where .cronwrapper has the definitions of params needed and
exports.

 In a number of searches, most warned against doing the .profile for
security and other reasons. By placing the .cronwrapper in your home
directory, you can control and I have it running under boh Solaris and
Linux Redhat.

 If you have any questions and/or problems, please let me know.
 Thanks.
 
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449  FAX
http://fedex.com/us 

 
 See this post perhaps for some other tips (it's Solaris 
 specific, which may
 help): http://www.perlmonks.org/?node_id=624540 
 
 T
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Cron environment for execution of Perl script

2008-11-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I need an environment variable from my .profile on Solaris and having 
troubles getting at it. I have a Perl script which executes fine outside of 
cron and now am trying to do via cron. I wanted to stay away from a shell 
script and was wondering what is the easiest way to get my .profile loaded, so 
the Perl script can access the needed variable.

I have tried with errors the following:

25 12 * * 4 . $HOME/.profile ; /d/src/pl600.pl dp51 

and

25 12 * * 4 . $HOME/.profile  /d/src/pl600.pl dp51

I get the error: 
sh: -o: bad option(s)

I believe it should not be that hard to do, but I only have really 
enough knowledge to dangerous and know when to ask for help.

Thoughts, examples, site(s) where can pickup info to assist in this???

 If you have any questions and/or problems, please let me know.
 Thanks.
 
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449  FAX
http://fedex.com/us 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Changing from FTP to Secure copy

2008-10-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I am in the middle of moving from Solaris to Linux environment. On the 
current Solaris box, I use Net::FTP for all the work that needs to be done. On 
Linux, the ftp is not available, due to security concerns. The Linux 
environment had Perl at 5.8.0 and so I got the okay to bring down AS Linux for 
5.8.8. That is has been loaded and I have loaded a few other modules that I use 
in the Solaris area. I was lookng at installing Net::SFTP, but it is failing as 
follows:

Failed during this command:
 ILYAZ/modules/Math-Pari-2.010800.tar.gz  : writemakefile NO 
'/opt/ActivePerl-5.8/bin/perl-static Makefile.PL INSTALLDIRS=site' returned 
status 2304
 TURNSTEP/Net-SSH-Perl-1.32.tar.gz: make_test NO one dependency not 
OK (Math::Pari)
 DBROBINS/Net-SFTP-0.10.tar.gz: make_test NO

Did as quick look on web and found some related info on 2304. So tried 
installing the Math::Pari, but won't complete and fails with the status 2304.

If one needs to do the secure copy from machines, what is the best path 
to pursue( at this point, there are no libssh2 libraries that I can find, but 
probably could get them)? Prefer a Perl solution verses wrapping other 
commands, but I am following the lead of my backup who has more knowledge in 
this area ( and may not be alot, but does have more).

Any thoughts or ideas on how to advance, would be greatly appreciated.

 Thanks.
 
Wags ;)
David R. Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449  FAX
http://fedex.com/us 



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: store first key of a hash to scalar

2008-09-10 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: Noah [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 10, 2008 13:10
 To: Perl Beginners
 Subject: store first key of a hash to scalar
 
 Hi there,
 
 What is the easiest way to store the first key of a hash to a scalar 
 variable?
 
Perl handles the arrangement of the keys so it is efficient for
Perl. What are you after? What was the data you brought in or .   I
know there are modules that will keep the data as it came in, but need
more info to be able to assist.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 
 Cheers,
 
 Noah
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: store first key of a hash to scalar

2008-09-10 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: Noah [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 10, 2008 13:23
 To: John W. Krahn
 Cc: Perl Beginners
 Subject: Re: store first key of a hash to scalar
 
 okay that basically answers my question.  I will have to 
 figure out to 
 define a key that is the root key.

You can have various key combinations: $hash-{key1}{key2}.
where key1 could be the root portion and key2 a subset,
etc

Just remember you need to be able to get your head around what
you do. You can even have arrays associated with the hash data, so it
can be very complex, but make sure that you know what you are after or
be able to ask the questions that will give you a good understanding of
what you need.
 
  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 
 
 John W. Krahn wrote:
  Noah wrote:
  Hi there,
  
  Hello,
  
  What is the easiest way to store the first key of a hash 
 to a scalar 
  variable?
  
  A hash doesn't have a first key.  Which key do you really want?
  
  
  John
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: matching lines in array - other ways to code

2008-09-10 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Noah [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 10, 2008 16:28
 To: Perl Beginners
 Subject: matching lines in array - other ways to code
 
 Hi there,
 
 could somebody please suggest some other ways to simplify the reading 
 and perhaps make the following process quicker?
 
 
 print CHANGE what 1\n unless ( grep (/what\s1/, @lines ) );
 print CHANGE what 2\n unless ( grep (/what\s2/, @lines ) );
 print CHANGE what 3\n unless ( grep (/what\s3/, @lines ) );
 print CHANGE what 4\n unless ( grep (/what\s4/, @lines ) );
 print CHANGE what 5\n unless ( grep (/what\s5/, @lines ) );
 print CHANGE what 6\n unless ( grep (/what\s6/, @lines ) );
 print CHANGE what 7\n unless ( grep (/what\s7/, @lines ) );
 
print CHANGE what $1\n unless ( grep (/what\s([1-7])/, @lines
) );

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 

 Cheers,
 
 Noah
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: comparing text files, in a way

2008-09-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: frazzmata [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 08, 2008 10:13
 To: beginners@perl.org
 Subject: comparing text files, in a way
 
 I am writing a program where I want to be able to locate information
 regarding a person in one file, if they appear in another.
 
 For instance:
 
 I have a file that just has student IDs (for students that are new)
 
I would load the the larger one into a hash using the id as the
key and then read the one with ID's only, marking on the hash which one
had hits. Then by how you did the marking, you could print out and have
control over the sorting, print format etc.  Obviously need some error
checking so if on the id only file, but not on your master, you would
need to report on that. 

A hash, check the id on second file in hash, mark for each used.
Then you can use the hash for all your printouts.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


 It has a long list of Student IDs like this:
 
  100955
 104024
 564765
 123456
 765437
 123321
 323999
 444555
 
 Then there is another file that has information such as this:
 
 100955   BLow-Gomez, Joseph   M MEX.AMER.  QHUTC012
 101121   NOBODY, GARY E.  M CAUC   COCO0502
 101985   sOMEBODY, RICHARDM CAUC   COCO0404
 102989   GUY, JON G.  M BLACK  COCO0505
 103257   DUDE, MICHAEL D. M CAUC   TENN3306
 104024   CHICK, JENNY A.  M BLACK  QHUTJ005
 104272   GIRL, JOSIE R.   M MEX.AMER.  TENN3201
 104586   BOY, TERRELL L.  M BLACK  QHUTG013
 104802   SOMEFELLA, JAMES D.  M BLACK  QHUTA001
 105011   PERSON, JAMES J. M CAUC   COCO1909
 106455   HUMAN, STEPHEN J.M CAUC   YUMAD012
 106461   HOMOSAPIEN, RODNEY   M BLACK  QHUTB014
 106953   ERECTUS, JAVIER  M MEX.NAT.   COCO0701
 107461   THIRTYTWOTEETH, TIMOTHY  M CAUC   TENS0904
 108594   TACOBELL, ARNOLD G.  M MEX.AMER.  TENN2303
 
 (all tab delimited)
 
 For each id in the first file, I want to match it in the second file
 and then print all the info contained in the second file into a third
 file that contains only the people that were in both.
 
  This is essentially what I have so far...
 This only gets me up to a certain point. It doesn't do the
 comparison.
 
 $ifile = roster.txt;
 $ofile = output.txt;
 
 
 
 open(IFILE, $ifile);
 open(OFILE, +$ofile);
 
 #store the file in an array.
 
 my @guys;
 
 while ($line = IFILE) {
   if ($line =~ /^\d\d\d\d\d+/) {
 
   $things = substr $line,0,51;
   push @guys,$things;
   }
   }
   foreach $line (@guys) {
   if ($line =~ /^0/) {
   ($trash,$rest) = split(/^0/,$line);
   print OFILE $rest\n;
   }else{
   print OFILE $line\n;
   }
 
   }
 
 
 
 
 close IFILE;
 close OFILE;
 
 $tfile = testing.txt;
 
 
 open(IFILE, $ofile);
 open(TFILE, +$tfile);
 
 while (IFILE) {
   chomp;
   my ($adc, $record) = split(/\t+/,$_);
   push @{$table{$adc}}, $record;
 }
 
 foreach $adc (sort keys %table) {
 
   print TFILE $adc ;
   my @records = @{$table{$adc}};
 print join ', ', sort @records;
 
   print TFILE \n;
 }
 
 close IFILE;
 close TFILE;
 
 $cfile = changes.txt;
 $output = output.txt;
 
 open(TFILE, $tfile);
 open(TFILE, $cfile);
 open(OFILE, +$output);
 
 
 I am open to a complete rewrite of course, since the above code only
 gets me the file to compare to (the one with the info in it) it does
 not do the comparison (obviously)
 Please help
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: matching ' in regx

2008-08-26 Thread Wagner, David --- Senior Programmer Analyst --- WGO
From: Dan Baker [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, August 26, 2008 17:00
To: beginners@perl.org
Subject: matching ' in regx

I have a thing driving me NUTS trying to detect a ' in a variable 
with regex, and either strip it out or at least detect and error out. 
for instance, this just does NOT work.

$UploadedImage = 'badname\'s.jpg' ;

if ( $UploadedImage =~ m/'/ ) {
 Warning_Status( $cCgiStatusFile ,
 Cannot upload file with \' in the filename , .
 you MUST rename the file before upload!.
 \nPlease use the browser \Back\ button, and .
 try again after changing filename.\n );
 exit ;
}

How do I match the ' ?
thanks,

d

Unsure what is happening. I copied the statements, replaced
warning with print and it came back with the statement that incorrect
name. Removed the \', ran again, and nothing printed out.

Now I just did as a simple script, but what you are executing
here and what you are doing in your environment, there has to be a
difference.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Problems w/ MVS::JESFTP.pm

2008-07-30 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Running the following script:

my $MyJES = MVS::JESFTP-open($MyHost, $MyLogonId, $MyPw) or die;
printf open to MVS completed w/o error\n;
if ( ! defined $MyJES-submit($MyJob) ) {; #$job is the absolute name of
a valid jcl file
printf Problem with submission of job\n$MyJob\n;
die problem with submit:
 }
printf Job submitted successfully.\n;

my $MyMsg = $MyJES-message; # this will retrieve the submit message
where you can find the job number
printf Message retrieved  successfully.\n$MyMsg\n;
my $MyJobNumber = substr($MyMsg,index($MyMsg,JOB),8); # this could be
changed by a RE but ... it works
my $MyTimeOut = 60;
printf headed into wait for results.\n$MyJobNumber\n;
my $aref;
#jobname is the name of your JOB card. Timeout is 60 by default

$aref = $MyJES-wait_for_results($MyJobName, $MyTimeOut);

printf received results.\n$MyJobNumber\n;
printf Outputs:\n%s\n,
join(qq[\n], @{$aref});

$MyJES-get_results($aref); #you can use
$jes-get($jobNumber,DIRECTORY/$jobNumber.out);
 

It runs and completes on the IBM, but when it tries to get at
the data to reload back down on the PC, I get the following error:

Unable to close datastream at C:\CurrWrka\00COMM~1\pl800.pl line 43

which is coming from Net::FTP when it is attempting to close the
datastream as stated,

I am running XP SP 2, Perl AS 5.8.8, JESFTP is 1.1 Latest
version.

Anyone used the module or anyone execute jcl on MVS and pull the
output back to a PC.

Any insight would be greatly appreciated.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Reg. Directory listing program

2008-06-04 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Gunwant Singh [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, June 04, 2008 10:02
 To: beginners@perl.org
 Subject: Reg. Directory listing program
 
 Hi,
 
 I am new to this mailing list and I am very new to PERL. So, 
 please bear
 with me for my questions.
 I wrote a code that lists files in a directory with the 
 permissions. I am
 coding for MS-Windows.
 Here is my code:
 
 *1 use strict;
 2 use warnings;
 3 use File::stat();
 4
 5 opendir (DH, subcode) or die $!;
 6 foreach my $file(readdir DH)
 7 {
 8 my $perm=stat($file)-mode;

you need something like:
my $filestat = stat($file);
my $perm=$filestat-mode;
 but this will not work correctly unless you are already positioned on
the right directory location. So either you can do a chdir to the folder
you are doing or a concatenate of subcode . $file to get the file
status correctly.

Wags ;)

 9 print $file\t$perm\n;
 10 }
 11 closedir (DH);
 
 *I am getting the listing of file just fine if I dont add 
 line 8. But as
 soon as I try to display the permissions, I get this:
 
 *Can't call method mode without a package or object reference at
 C:\Documents a
 nd Settings\Myself\Desktop\code\dir-op.pl line 8.
 
 *What am I doing wrong!
 
 Thanks.
 
 -- 
 Gunwant Singh
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Reg. Directory listing program

2008-06-04 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Wagner, David --- Senior Programmer Analyst --- WGO 
 [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, June 04, 2008 11:08
 To: Gunwant Singh; beginners@perl.org
 Subject: RE: Reg. Directory listing program
 
  -Original Message-
  From: Gunwant Singh [mailto:[EMAIL PROTECTED] 
  Sent: Wednesday, June 04, 2008 10:02
  To: beginners@perl.org
  Subject: Reg. Directory listing program
  
  Hi,
  
  I am new to this mailing list and I am very new to PERL. So, 
  please bear
  with me for my questions.
  I wrote a code that lists files in a directory with the 
  permissions. I am
  coding for MS-Windows.
  Here is my code:
  
  *1 use strict;
  2 use warnings;
  3 use File::stat();
  4
  5 opendir (DH, subcode) or die $!;
  6 foreach my $file(readdir DH)
  7 {
  8 my $perm=stat($file)-mode;
 
   you need something like:
 my $filestat = stat($file);
 my $perm=$filestat-mode;
I was looking at Programming Perl and if you want to make sense
of the mode, then should 'and' with 0 and print out using %04o (
octal output ), so something like:
my $perm=$filestat-mode  0;

  but this will not work correctly unless you are already positioned on
 the right directory location. So either you can do a chdir to 
 the folder
 you are doing or a concatenate of subcode . $file to get the file
 status correctly.
 
 Wags ;)
 
  9 print $file\t$perm\n;

Then change print to
printf $file %04o\n, $perm;

Wags ;)

  10 }
  11 closedir (DH);
  
  *I am getting the listing of file just fine if I dont add 
  line 8. But as
  soon as I try to display the permissions, I get this:
  
  *Can't call method mode without a package or object reference at
  C:\Documents a
  nd Settings\Myself\Desktop\code\dir-op.pl line 8.
  
  *What am I doing wrong!
  
  Thanks.
  
  -- 
  Gunwant Singh
  
 
 **
 This message contains information that is confidential and 
 proprietary to FedEx Freight or its affiliates.  It is 
 intended only for the recipient named and for the express  
 purpose(s) described therein.  Any other use is prohibited.
 **
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: hash

2008-05-22 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Bobby [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, May 22, 2008 12:33
 To: Rob Dixon; beginners@perl.org
 Cc: Bobby
 Subject: Re: hash
 
 Rob,
 
 Yes the pids are unique. 
 
 I've tried the comparison below but didn't worked, so what do 
 you think is wrong with it?
 
 if ($pidsizes{$pid}{US} = $pidsizes{$pid}{EU}){
 print $pidsizes{US}{$us};
 
= should be == otherwise you are doing an assignment and test.
Are you using use strict and warnings? If you were, you would have
received a heads up that something was wrong.

Should always use, though you can turn off for spots in the
code, it should be a regular practice and cuts down on a lot of time and
effort.

Wags ;)

 Rob Dixon [EMAIL PROTECTED] wrote: Bobby wrote:
  
  I have a flat file that contains a pid, us_size and 
 euro_size. I want to
  create read in the file and create one hash for the us_size 
 (%US) and the
  other for the euro_size (%EURO). Then i want to do a print 
 statement if the
  pid value in the us_size hash is equal to pid value in the euro_size
  hash...maybe IF ($US{$pid} = $EURO{$pid}) {print statement...}.
  
  The part where i'm stuck on is how to assign the data into 
 a hash and do the
  comparison, could one of you help me with the Perl's syntax 
 or point in the
  right direction?
  
  pid|us_size|euro_size
  1|10|34
  2|11|35
  3|12|37
  4|13|
 
 Another question that skips the /problem/! Are you aware that 
 you can store
 multiple values - even another hash or array - as the value 
 of a hash element?
 
 At a guess, you need to be able to access a US and EU size 
 for a given PID, and
 I would write a loop like this
 
   my %pidsizes;
 
   while () {
 chomp;
 my ($pid, $us, $eu) = split /\|/;
 $pidsizes{$pid}{US} = $us;
 $pidsizes{$pid}{EU} = $eu;
   }
 
 Does that help? Are the PIDs in your file unique? Is the 
 missing Euro size for
 PID 4 a mistake or a special case?
 
 Rob
 
 

 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How do I find the key of a specific hash element?

2008-05-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: jshock [mailto:[EMAIL PROTECTED] 
 Sent: Monday, May 19, 2008 07:20
 To: beginners@perl.org
 Subject: How do I find the key of a specific hash element?
 
 For example:
 
 my %weekdays = (
   0  = SUN,
   1 = MON,
   2 = TUE,
   3 = WED,
   4 = THU,
   5 = FRI,
   6 = SAT,
 );
 $weekdays{2}; # gives TUE
 
 But what if I know TUE and want to find out what the key is? Is
 there a construct like $weekdays{TUE} that gives 2
 
It depends on what information you will have and how big and how
often will you need to access that data. You can either search the
weekdays hash looking for the value or build a hash that has the the
keys turned around(ie, the SAT is the key and 6 is the value.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: problem using backslash on brackets in regular expressions

2008-04-22 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Daniel McClory [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, April 22, 2008 16:06
 To: beginners@perl.org
 Subject: problem using backslash on brackets in regular expressions
 
 Hi,
 
 I have files which contain sentences, where some lines have extra  
 information inside brackets and parentheses.  I would like to delete  
 everything contained within brackets or parentheses, including the  
 brackets.  I know that I am supposed to use the backslash to 
 turn off  
 the metacharacter properties of brackets and parentheses in a 
 regular  
 expression.
 
 I am trying to use the s/// operator to remove it, by doing this:
 
 while(INPUT)
{
  $_ =~ s/\[*\]//;
What you are saying here is the first bracket can have zero or
more occurances followed by a ], which is what you are seeing in your
output(ie, the / before the ] is not a [ okay, then ] and replace the ]
with nothing.

 s/\[[^\]]+]//;
  $_ =~ s/\(*\)//;
 s/\([^\)]+)//;

No reason to do the $_ =~ as by default that is what is going to
be done anyway.

Wags ;)

  print $_;
}
 
 so if the input is:
 *MOT:   I'm gonna first [//] first I wanna use em all up .
 
 then the output I'd like to get is:
 *MOT:   I'm gonna first first I wanna use em all up .
 
 but instead what I get is:
 *MOT:   I'm gonna first [// first I wanna use em all up .
 
 It only deletes the last piece, the ] bracket.  How can I erase the  
 whole thing?
 
 Thanks.
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: CSV duplicate

2008-04-16 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: Manoj [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, April 16, 2008 12:00
 To: 'Perl Beginners'
 Subject: CSV duplicate
 
 Hello List,
 
  
 
 Scenario:
 
 CSV file
 
 Host=Nirus,TCPIP,inxcp011,connected,Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp2
 
 Host=Rome,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp3
 
 Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp
 
 Host=Spring,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
 Host=Nirus,TCPIP,inxcp011,connected, Serv=rxmcpp1
 
  
 
 Required output is 
 
 Nirus
 
 Spring
 
  
So what are you searching on or looking at to determine that you
want only those two? The last depends on the number of rcds and are you
only concerned with the server name?

Wags ;)

 
 There is one more requirement I need to sort the 5th column 
 and sort them
 and fetch which ever is duplicate. So in this one I need to print 
 
 rxmcpp1 to screen.
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Example of FTP w/o Input file? Is it possible to do or not?

2008-04-10 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas. Owens [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, April 09, 2008 13:05
 To: Wagner, David --- Senior Programmer Analyst --- WGO
 Cc: beginners@perl.org
 Subject: Re: Example of FTP w/o Input file? Is it possible to 
 do or not?
 
 On Wed, Apr 9, 2008 at 3:55 PM, Wagner, David --- Senior Programmer
 Analyst --- WGO [EMAIL PROTECTED] wrote:
 snip
  No. I want to do a put of a file, but without 
 having to write
   the file first
   and then doing put(Filein,fileout). I could write out the 
 60 plus files
   each time, but
   I am trying to get the data to a file on the remote server without
   having a file on
   the input side.
  Understand?
 snip
 
 Ah, now it becomes clear.  According to the Net::FTP docs the put
 method accepts a file or a filehandle as the LOCAL_FILE argument.  You
 can create a filehandle out of a scalar like this (in Perl 5.8 and
 later*):
 
 open my $fh, , \$scalar
 or die could not create a filehandle for the data [$scalar]: $!;
 
 Since the filehandle will not have a name you will need to use the
 optional REMOTE_FILE argument:
 
 $ftp-put($fh, $filename);
 
Works like a charm and makes it a much easier setup verses
having to
Create and then send the file.

I appreciate the assistance.

Wags ;)

 * There is another method for earlier versions of Perl, but it does
 not come readily to mind.  I believe you needed IO::String to do it
 and there were problems with versions of Perl less than 5.6.
 
 -- 
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Example of FTP w/o Input file? Is it possible to do or not?

2008-04-09 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I have a hash which contains for each entry the email which I
need to ftp to a particular location with a specified name. I could
write out the file and then do the ftp. But since I have the necessary
data in an audittrail report, I was wondering if I can ftp from a
variable using ftp commands? 

I took a look at the doc on Net::FTP, but nothing stood out and
did not find an example.

I am running AS 5.8.8 build 820 on XP w/ service pack 2.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Example of FTP w/o Input file? Is it possible to do or not?

2008-04-09 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas. Owens [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, April 09, 2008 12:33
 To: Wagner, David --- Senior Programmer Analyst --- WGO
 Cc: beginners@perl.org
 Subject: Re: Example of FTP w/o Input file? Is it possible to 
 do or not?
 
 On Wed, Apr 9, 2008 at 1:56 PM, Wagner, David --- Senior Programmer
 Analyst --- WGO [EMAIL PROTECTED] wrote:
  I have a hash which contains for each entry the 
 email which I
   need to ftp to a particular location with a specified name. I could
   write out the file and then do the ftp. But since I have 
 the necessary
   data in an audittrail report, I was wondering if I can ftp from a
   variable using ftp commands?
 
  I took a look at the doc on Net::FTP, but nothing 
 stood out and
   did not find an example.
 snip
 
 I don't fully understand what you desire to do.  It sounds like you
 wish to FTP to a machine using a user and password retrieve by the
 Perl program (that fact that is stored in a hash is irrelevant) and
 maintain a log of the fact that you are making this FTP connection.

No. I want to do a put of a file, but without having to write
the file first 
and then doing put(Filein,fileout). I could write out the 60 plus files
each time, but
I am trying to get the data to a file on the remote server without
having a file on 
the input side.
Understand?
Thanks.

Wags ;)

 This is simple in Perl:
 
 #warning untested code as I don't maintain and FTP servers anymore
 (they are insecure, use scp or sftp instead)
 #!/usr/bin/perl
 
 use strict;
 use warnings;
 use Net::FTP;
 use POSIX;
 
 sub log {
my $log = shift;
print $log map { strftime %Y-%m-%d %H:%M:%S $_\n, 
 localtime() } @_;
 }
 
 my $host = localhost;
 my $user = foo;
 my $pass = bar;
 
 open my $log, , path/to/audit.log
or die could not open audit log: $!;
 
 $SIG{__DIE__} = sub { log($log, shift) };
 
 my $ftp = Net::FTP-new($host)
   or die Cannot connect to $host: $@;
 
 log($log, connected to $host);
 
 $ftp-login($user, $pass)
   or die Cannot login as $user: , $ftp-message;
 
 log($log, logged in as $user);
 
 #do ftp stuff you need to do, logging as you go
 
 $ftp-quit;
 
 log($log, logged out as $user on $host);
 
 -- 
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Looking for example of how to keep an FTP processing running if the Ip Address is down or unavailable

2008-03-24 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I have a polling process that runs 24x7 ( internal site ) and for the
most part has no problems except that they shutdown the the internal
site every three or four weeks and my process then dies.

I have a simple setup:

$MyFtp = Net::FTP-new($GlblInfo{ipaddr}, Debug = 1);

$MyFtp-login($GlblInfo{logon},$GlblInfo{pw});

Yes. There is no checking on the new and what happens is that
new fails and then when it tries the login, I get a failure for the
method login.  So how do I surround the new so that if it fails, I can
go to sleep for say five minutes and then try again until I hit some
limit or timeframe?

Any thoughts or insights would be gratly appreciated.   

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Looking for example of how to keep an FTP processing running if the Ip Address is down or unavailable

2008-03-24 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas. Owens [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 24, 2008 11:42
 To: Wagner, David --- Senior Programmer Analyst --- WGO
 Cc: Perl Beginners
 Subject: Re: Looking for example of how to keep an FTP 
 processing running if the Ip Address is down or unavailable
 
 On Mon, Mar 24, 2008 at 2:25 PM, Wagner, David --- Senior Programmer
 Analyst --- WGO [EMAIL PROTECTED] wrote:
  I have a polling process that runs 24x7 ( internal site ) 
 and for the
   most part has no problems except that they shutdown the 
 the internal
   site every three or four weeks and my process then dies.
 
  I have a simple setup:
 
  $MyFtp = Net::FTP-new($GlblInfo{ipaddr}, Debug = 1);
 
  $MyFtp-login($GlblInfo{logon},$GlblInfo{pw});
 
  Yes. There is no checking on the new and what 
 happens is that
   new fails and then when it tries the login, I get a failure for the
   method login.  So how do I surround the new so that if it 
 fails, I can
   go to sleep for say five minutes and then try again until 
 I hit some
   limit or timeframe?
 snip
 
 Throw the login into an eval {} to prevent the die from killing the
 script and use a loop for max tries:
 
 use constant MAX_TRIES = 3;
 use constant WAIT_BEFORE_RETRY = 60*5;
 
 my $try = 1;
 until (eval { $MyFtp-login($GlblInfo{logon},$GlblInfo{pw}; 1}) {
 die login to $GlblInfo{ipaddr} as $GlblInfo{logon} failed (try
 $try): $@; if ++$try == MAX_TRIES;
 warn login to $GlblInfo{ipaddr} as $GlblInfo{logon} 
 failed (try $try): $@;
 sleep WAIT_BEFORE_RETRY;
 }
 
 -- 
 Chas. Owens
 wonkden.net
 The most important skill a programmer can have is the ability to read.
 
Chas,
I tried the following text script setup and am using a good and
bad ip addr. When it is a good Ip Addr, it connects and then quits. When
I try the bad ip addr, it just waits a moment and gets out. Obviously I
have something wrong, but it is not apparent from the output given to
me. You can replace the good.ip.addr.com with a valid ip addr to connect
to.

Nothing prints out except debug prints of 'trying ipaddr' and if
$MyFtp is defined, then prints that out otherwise nothing on a failure.
None of the other commands within the sleep, ertc.
Wags ;)

==

#!perl

use strict;
use warnings;
use Net::FTP;

use constant MAX_TRIES = 3;
use constant WAIT_BEFORE_RETRY = 5*5;

my @MIA = qw(good.ip.addr.com bad.ip.addr.com);
my $MyIpAddr = [EMAIL PROTECTED];

my $MyWrkIpAddr  = q[];

my @TI = ();
my $TimeInfo = [EMAIL PROTECTED];
my $diff = 0;
get_time( $TimeInfo );
my $MyWrkIdx;
my $try;
my $MyFtp;

while ( 1 ) {
set_indx($MyWrkIdx);
$MyWrkIpAddr = $MyIpAddr-[$MyWrkIdx];

$try = 1;
printf *1*Trying IpAddr: $MyWrkIpAddr\n;
until (eval { $MyFtp = Net::FTP-new($MyWrkIpAddr, Debug = 1); 1} )
{
die Connecting to $MyWrkIpAddr failed (try $try): $@; 
if (++$try == MAX_TRIES ) {
warn Connecting to $MyWrkIpAddr failed (try $try): $@;
sleep WAIT_BEFORE_RETRY;
set_indx($MyWrkIdx);
$MyWrkIpAddr = $MyIpAddr-[$MyWrkIdx];
 }
 }
printf Connected to $MyWrkIpAddr successfully.\n if ( defined
$MyFtp );
last;

 }
#
##
###
##
#

sub set_indx {
my ($MyWrkIdx) = @_;

get_time($TimeInfo);
if ( $TimeInfo-[0] % 2 ) {
$MyWrkIdx = 1;
 }
 else {
$MyWrkIdx = 0;
 }
$_[0] = $MyWrkIdx;

1;
 }

sub get_time {
my ( $TimeInfo, $MyUseTime ) = @_;
$diff = 86400 * $diff;
#012 3 45 6 7 8
#   ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time - $diff);
#   9 = YearModulo
#  10 = Time used in calculations
#
my $MyPointInTime = time - $diff;
$MyPointInTime = $MyUseTime if ( defined $MyUseTime );
@{$TimeInfo} = localtime( $MyPointInTime );
$TimeInfo-[4]++;
$TimeInfo-[9] = $TimeInfo-[5] % 100; # Year Modulo, last two
digits of year
$TimeInfo-[10] = $MyPointInTime;

$diff = 0;
 
1;
 }  # end of get_time

#
##
###
##
#

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: lstat and its uses

2008-02-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas. Owens [mailto:[EMAIL PROTECTED] 
 Sent: Monday, February 11, 2008 13:21
 To: Michael Barnes
 Cc: beginners@perl.org
 Subject: Re: lstat and its uses
 
 On Feb 11, 2008 4:17 PM, Michael Barnes [EMAIL PROTECTED] wrote:
  I thought about using lstat to get the size of a file for file
  comparisons.  I see that lstat always returns a list of 
 thirteen values.
   The references I find appear to require assignment of 
 those 13 values
  to variables, even though I only want to use one.
 
  Do I really have to put
 
  ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
   $atime,$mtime,$ctime,$blksize,$blocks)
 = lstat($filename);
 
  Just to get the $size variable populated with the file size?
 
  My ultimate goal is to check the size of huge files copied 
 to a folder.
   Once I get the $size to come back the same three times in a row,
  indicating the file is all there, then I can move on with 
 playing with
  the file.
 snip
 
 The lstat function returns a list, so you can use the splice 
 operator on it:
 
 my $size = (lstat $filename)[7];
 

If only after the size, then could use -s as part of the processing as:
my $size = -s $filename;
if 0 then does not exist otherwise returns size of the file.

Wags ;) ps I would be weary of checking three times to see if the same
and saying it is done. I would either look at whether the file is open
and/or some type of trigger from a processs that the copy was done
successfully. A thought.

 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: lstat and its uses

2008-02-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Kashif Salman [mailto:[EMAIL PROTECTED] 
 Sent: Monday, February 11, 2008 15:24
 To: David Moreno
 Cc: John W. Krahn; Perl Beginners
 Subject: Re: lstat and its uses
 
 I am not sure how to bring it up using the perldoc, I read it when I
 was going through the book Learning Perl. Maybe someone else here
 can point out how to find it in perldoc..

use perldoc -f stat
  you can use lstat, but soes not say much and really points you to stat
  stat is a perl builtin

type in perldoc -h
  gives more info on perldoc and what it can do for you. 
Wags ;)
 
 On Feb 11, 2008 3:16 PM, David Moreno [EMAIL PROTECTED] wrote:
  That is very interesting, actually. What piece of 
 documentation should I
  read to learn about this operators?
 
  Thanks.
  David.
 
 
 
  On Feb 11, 2008 6:14 PM, Kashif Salman 
 [EMAIL PROTECTED] wrote:
 
   Perl already has all the info from the previous lstat 
 command, using _
   is more efficient in that it doesn't have to do another 
 system call.
  
  
  
  
   On Feb 11, 2008 2:06 PM, David Moreno 
 [EMAIL PROTECTED] wrote:
On Feb 11, 2008 4:47 PM, John W. Krahn [EMAIL PROTECTED] wrote:
   
 lstat $filename;
 my $size = -s _;
   
   
Did you mean:
   
my $size = -s $_;
   
?
   
--
David Moreno - http://www.damog.net/
Yes, you can.
   
  
 
 
 
  --
 
 
  David Moreno - http://www.damog.net/
   Yes, you can.
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Module help

2007-12-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Andy Dixon [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, December 20, 2007 10:37
 To: Perl beginners
 Subject: Module help
 
 Hello,
 
 I have written a small module with a function that returns some text.
 
 However, when I run it, from a test script, I get:
 
 Undefined subroutine external::RETURN called at external.pm line 41.
 
 The subroutine is thus:
 
 sub test($) {
You are using I believe pro-typing and I believe you are better
off not using.

 
 my $data = @_;
 
 $data =~ s/cheese/ham/g;
 
 RETURN ($data);
it is return not RETURN

Wags ;)

 
 }
 
 
 I think I may have missed something.. Any help would be wonderful!
 
 Thanks!
 
 Andy
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




timeout in ftp

2007-12-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I have the following code:

$MyFTP-put($MyFtpFromFile , $MyFtpToFile );
if ( ! $MyFTP-ok() ) {
.
 }

On my audit log:

Net::FTP=GLOB(0x19c30c0) 125-Waiting for recall of data set
FTPTRGP.AMPD0407
Net::FTP=GLOB(0x19c30c0): Timeout at /d/src/pl545.pl line 3129
Net::FTP=GLOB(0x19c30c0) QUIT

But the ! $MyFTP-ok() does not seem to catch it ( line 3130 ).

Now I enclose all the ftp processing with in a loop of

login for ftp
process one file
close the ftp session

For the Login I do the following:

$MyFTP = Net::FTP-new( $GlblInfo{wrkftpipaddr}, 
Debug = 1, 
timeout = 60 * 10 );
$MyFTP-login( $GlblInfo{wrkftpusr},$MyWrkingPw );
my $MyReturn = 1;

if ( ! $MyFTP-ok() ) {
.
 }

Now I know that the login will capture failures because that
does happen.

Any ideas on why or what I am doing incorrectly? 

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: timeout in ftp

2007-12-11 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
 Behalf Of Tom Phoenix
 Sent: Tuesday, December 11, 2007 15:07
 To: Wagner, David --- Senior Programmer Analyst --- WGO
 Cc: beginners@perl.org
 Subject: Re: timeout in ftp
 
 On 12/11/07, Wagner, David --- Senior Programmer Analyst --- WGO
 [EMAIL PROTECTED] wrote:
 
  I have the following code:
 
  $MyFTP-put($MyFtpFromFile , $MyFtpToFile );
  if ( ! $MyFTP-ok() ) {
 
 Are you using Net::FTP? Does your version of the documentation for
 Net::FTP mention an ok() method? I don't see one here:
 
 http://perldoc.perl.org/Net/FTP.html
 
Within Net is Cmd  which is from Graham Barr and from that
processing is where I am pulling the ok() as 
ok ()
Returns non-zero if the last code value was greater than zero and
less than 400. This holds true for most command servers. Servers where
this does not hold may override this method.

I use it throughout my code and I may very well be using
incorrectly, but it does catch invalid logon and other related actions
from ftp. So I can try the 

if ( true ) { print in failure on put, msg code, etc }

but thought it could be used in this way from the doc.

Wags ;)

 It doesn't seem that you're using the module in the same way it's done
 in the documentation. As I read things, using the return value from
 the put() method as a Boolean value is the (only?) way to check for
 success. Is that the problem?
 
 Good luck with it!
 
 --Tom Phoenix
 Stonehenge Perl Training
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Writing DOS CRLF via Unix Perl

2007-11-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: C.R. [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, November 08, 2007 12:34
 To: beginners@perl.org
 Subject: Writing DOS CRLF via Unix Perl
 
 I run a script on unix Perl to write a text file. By default, 
 when Perl 
 writes \n it writes a line ending sequence which is native to the 
 current OS. How do I force this particular script to always write DOS 
 CRLF line endings? 
$/ is the input rcd separator
$\ is the output rcd separator
You can set as want them to be if other than the std defaults
are desired for a particular processing.
  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 
 Thanks.
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: average and standard deviation

2007-10-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO


  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -Original Message-
 From: Mahurshi Akilla [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, October 03, 2007 11:18
 To: beginners@perl.org
 Subject: average and standard deviation
 
 is there an easy way to get the average and standard deviation in perl
 (given an array of numbers).  i don't want to reinvent the wheel and
 write my own functions.
 
 i saw something for the average (see below). it works fine.  is there
 a similar quickie for std deviation (or perhaps, the median)
 
 use List::Util qw(sum);
 @array = (1, 1.5, 2);
 $average = sum(@array)/@array;
 print $average
 
 
You did not state which OS you are running and assuiming you can load
modules, but from ActivePerl for Windows (also on CPAN )
Statistics::Descriptive ( Loaded and took the example from the doc and
ran):
#!perl

use strict;
use warnings;

use Statistics::Descriptive;

my $stat = Statistics::Descriptive::Full-new();
$stat-add_data(1, 1.5, 2); 

my $mean = $stat-mean();
my $var  = $stat-variance();
my $tm   = $stat-trimmed_mean(.25);
my $std  = $stat-standard_deviation();
$Statistics::Descriptive::Tolerance = 1e-10;

printf Mean: %10.4f  Var: %10.4f  Std Dev: %10.4f  Trimmed mean:
%10.4f\n,
$mean,
$var ,
$std ,
$tm  ;
Output:
Mean: 1.5000  Var: 0.2500  Std Dev: 0.5000  Trimmed mean:
1.5000

Wags ;)
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: AFAIK

2007-09-24 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Somu [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 24, 2007 09:42
 To: Beginners@perl.org
 Subject: AFAIK
 
 What does it mean? AFAIK? I have seeing it a lot.. Earlier i've been
 seeing the HTH, and a guess gave the answer.. But this one, AFAIK...
 Are there any more such short forms?
 
As far as I know (AFAIK)

Wags ;)
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How to test for 0

2007-09-24 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Zachary Shay [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 24, 2007 11:04
 To: beginners@perl.org
 Subject: How to test for 0
 
 Is there a way to test for values where zero is valid?
 
 For instance:
 
 %a_Hash;
 $a_hash{user_id} = 0;
 $a_hash{user_name} = root if ($a_hash{user_id});
 
 print $a_hash{user_id} if ($a_hash{user_id});
 print $a_hash{user_name} if ($a_hash{user_name});
 
 Sometimes the user_id can be undef.  As a result, if there is 
 no user_id...I
 don't concern myself with trying to assign a user_name.  The 
 problem is that
 I believe the zero is being interpreted as false.  Is there a 
In Perl zero is false and non zero is true. You can try:
if ( exists $a_hash{user_id} ) {
# place what you want to do if the particular user_id
does exist
 } 

A thought.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 way to test
 these values so that only undef will return as false?
 
 Thanks,
 Zach
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: System

2007-09-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Somu [mailto:[EMAIL PROTECTED] 
 Sent: Friday, September 21, 2007 08:27
 To: Beginners@perl.org
 Subject: System
 
 About that PID problem, i found a program in Windows named tasklist,
 it prints all the processes running on the system with its id. I used
 the system command to execute the tasklist, like as
 
 my $data = system tasklist ;
 
 but i got nothing in $data. How can i get the data from the 
 system command?
system only returns whether it was successful or not ( ie 0 or
non zero ). If you want to capture that output, then use the
backtickslike

my $data = `tasklist`;

Now you can parse the list for what you are looking for.

Wags ; )
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Abnormal behavior of print / syswrite

2007-09-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Sundeep [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, September 19, 2007 05:50
 To: beginners@perl.org
 Subject: Abnormal behavior of print / syswrite
 
 A clue less problem for me...
 
 my $message = Completed CODE standards checks.\n.
   For details, refer to the file 
 $log_file_name.\n
 \n;
 print STDOUT $message;
 
Tried with and without STDOUT and all is working. Either the
value in the $log_file_name ( but said could print without the \n), or
non Perl related matter.

Havent't stated what platform or giving the snippet of where
this code is located.

From here under windows and AS 5.8.8, nothing comes to light.

Wags ;)

 I'm printing this message after some tests... and only message up to
 first new line is getting printed. When I remove first \n, whole
 message is printed in single line (as expected).
 
 I tried other options like
  giving 2 print statements each for one line of message,
 using $| = 1
 syswrite  (Though I can't use syswrite even if it works coz of code of
 conduct in my org).
 
 Not getting any clue what is wrong.
 The same code was working very well earlier (2 days back).
 
 Could anyone tell me what could be the problem (perl or non perl
 related)
 
 Thanks,
 Sundeep
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Using Perl Win 32 AS 5.8.x - Anyway to find the File Create Date/Time

2007-09-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: Rob Dixon [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 17, 2007 18:42
 To: beginners@perl.org
 Subject: Re: Using Perl Win 32 AS 5.8.x - Anyway to find the 
 File Create Date/Time
 
 Wagner, David --- Senior Programmer Analyst --- WGO wrote:
 
  stat will give me the mod time, but does not have the create
  time. From Windows Explorer, I notice that I can get the 
 Create Date.
  
  Anyway to accomplish this in Perl? I did a search against CPAN
  and also AS, but what I put in ( Perl create time file ) 
 did not seem to
  give me what I was looking for.
  
  Any ideas?
 
 Hi David
 
 It's
 
   (stat $file)[10]
 
 that you want, as Jenda has pointed out. But it's
 also worth noting that this is the same as
 
   -C $file
 
 HTH,
 
 Rob
 
Understood, but my Perl 5 Pocket Ref uses the same terminology
of inode change which would never have come to mind as it says nothing
about Creation date/time for Windows.  

I appreciate the insight and have made an entry in my cheat
sheets.

Thanks much.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: how to make use of $content in LWP

2007-09-17 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas Owens [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 17, 2007 10:14
 To: W. Sp.
 Cc: beginners@perl.org
 Subject: Re: how to make use of $content in LWP
 
 On 9/16/07, W. Sp. [EMAIL PROTECTED] wrote:
 snip
  regex worked fine in my case. But my question was: how to 
 specifically sift
  out a particular line number.
 snip
 
 
 There is a global variable named $. that stores the current line
 number.  So you can say things like
 
 perl -ne 'print $. if /this is found/' file.txt
 
 If you want to print a line that is on a given line number you can say
 
 perl -ne 'print if $. = 400' file.txt

$. == 400 and not $. = 400 ( assignment verses equality test ).
 Wags ;)

 
 Or if you want to print a range of lines you can use the flip-flop
 operator (.. in scalar context)
 
 perl -ne 'print if $. == 25 .. 50' file.txt
 
 snip
  Also, while using LWP modules, what type of
  data is $content = get($url)? Is it an array? Is there a 
 way to find out
  what kind of data a particular variable stores?
 snip
 
 Scalars hold strings, numbers, or references
 Arrays hold multiple scalar values and allow indexing by position
 Hashes hold multiple scalar values and allow indexing by key
 
 If a scalar holds a reference then the ref function will tell you what
 sort of reference it is (or its class if it is an object).
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Using Perl Win 32 AS 5.8.x - Anyway to find the File Create Date/Time

2007-09-17 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Jenda Krynicky [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 17, 2007 15:42
 To: beginners@perl.org
 Subject: Re: Using Perl Win 32 AS 5.8.x - Anyway to find the 
 File Create Date/Time
 
 From: Wagner, David --- Senior Programmer Analyst --- WGO 
   [EMAIL PROTECTED]
  stat will give me the mod time, but does not have the create
  time. From Windows Explorer, I notice that I can get the 
 Create Date.
 
 
 perldoc -f stat
 
 stat FILEHANDLE
 stat EXPR
 statReturns a 13-element list giving the status info for a file,
 either the file opened via FILEHANDLE, or named by EXPR. If 
 EXPR
 is omitted, it stats $_. Returns a null list if the stat 
 fails.
 Typically used as follows:
 
 ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)
= stat($filename);
 
 Not all fields are supported on all filesystem types. Here 
 are
 the meanings of the fields:
 
   0 dev  device number of filesystem
   1 ino  inode number
   2 mode file mode  (type and permissions)
   3 nlinknumber of (hard) links to the file
   4 uid  numeric user ID of file's owner
   5 gid  numeric group ID of file's owner
   6 rdev the device identifier (special files only)
   7 size total size of file, in bytes
   8 atimelast access time in seconds since the epoch
   9 mtimelast modify time in seconds since the epoch
  10 ctimeinode change time in seconds since the epoch (*)
  11 blksize  preferred block size for file system I/O
  12 blocks   actual number of blocks allocated
 
 (The epoch was at 00:00 January 1, 1970 GMT.)
 
 (*) Not all fields are supported on all filesystem types.
 Notably, the ctime field is non-portable. In particular, you
 cannot expect it to be a creation time, see Files and
 Filesystems in perlport for details.
 
 The docs are still pretty Unix-centric it seems. inode change time 
 ... lovely. In particular, under Windows, this is the creation time.
 
Thanks much, Jenda. I was going thru a number of hoops, but no
one had responded. I knew the inode, but this first time I have seen it
explained that this is Creation time on win32.

A really big help. I appreciate it very much.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Format Output

2007-09-17 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: VUNETdotUS [mailto:[EMAIL PROTECTED] 
 Sent: Monday, September 17, 2007 12:36
 To: beginners@perl.org
 Subject: Format Output
 
 I print some output in PERL. It is data in 3 columns. I use \t to add
 a tab space to make a column.
 However, \t may not produce the desired result. If the value is short
 in length, next column is not aligned correctly in the row. Something
 like this:
 
 123 12345 123456
 123 12345 123456
 1 1234 123456
 123 12345 123456
 
Use tmax size you want but right justify as in %4s or %4d for
the first column, want some space then add space, but then use %5d or s
and repeat the process.  Could look something like:

'%4d  %5s  %6s\n or %4d  %5d  %6d\n

Depends on what you are after, but this should be a start.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 How can I make a nicely formatted output?
 Thanks
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Using Perl Win 32 AS 5.8.x - Anyway to find the File Create Date/Time

2007-09-14 Thread Wagner, David --- Senior Programmer Analyst --- WGO
stat will give me the mod time, but does not have the create
time. From Windows Explorer, I notice that I can get the Create Date.

Anyway to accomplish this in Perl? I did a search against CPAN
and also AS, but what I put in ( Perl create time file ) did not seem to
give me what I was looking for.

Any ideas?

Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: a division warning

2007-08-27 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: lists user [mailto:[EMAIL PROTECTED] 
 Sent: Sunday, August 26, 2007 20:01
 To: beginners perl
 Subject: a division warning
 
 I run a perl command below,
 
 perl -Mstrict -Mwarnings -e 'eval {my $x=3;my 
 $y=$x-3;$x/$y};print hello'
 Useless use of division (/) in void context at -e line 1.
 hello
 
 I'm confused about the first warning.What's it?thanks.
You have the division, but there is no assignment for $x/$y. So
by adding $z = $x/$y; , then this msg will go away.

Wags ;)

 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: store more values in a hash array

2007-08-27 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: news [mailto:[EMAIL PROTECTED] On Behalf Of Andreas Moroder
 Sent: Sunday, August 26, 2007 23:37
 To: beginners@perl.org
 Subject: store more values in a hash array
 
 Hello,
 
 I have to store more then one value in a hash array. I tried 
 to store a 
 array as value in the hash. But when I try to retriev it I 
 don't get the 
 array I have stroed.
 
 Can anyone please help me.
 
 Thanks
 Andreas
Without some code, it is very hard to help. Provide at least a
some snippet of what you are trying, then the list should be able to
help. Since you are using the words hash array, then I envision a hash
with key and a array tied to it. 
Please provide something to work with.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: File Creator under WIN32 environment

2007-08-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Rob Dixon [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, August 23, 2007 03:38
 To: beginners@perl.org
 Cc: Wagner, David --- Senior Programmer Analyst --- WGO
 Subject: Re: File Creator under WIN32 environment
 
 David Wagner wrote:
 
  Need to get the individual who created the file I am looking at.
  I am using File::Find to get all files that are 4 days or 
 younger. I can
  get all info: Path, file name, file size, date modified 
 easily except
  owner. I have looked at the Perl doc ( using AS 5.8.8 build 
 820 ). I see
  that I can invoke from within the Perl 'ls -l' using 
 backticks, but is
  there any other way of getting that info besides this? The 
 File::Find is
  working great, but mssing that last piece. Looked at CPAN, 
 but either
  asking the wrong question or not narrowing it enough. It is 
 searching a
  300 gig disk and at this point I have been running remotely which is
  running at about 2.5 hours to go through all the files. I 
 hopefully will
  be able to run locally to accomplish the task.
 
  Any insights would be greatly appreciated on getting owner of a
  file under Win32.
 
 Hi David.
 
 I just put this together. Does it help? The 
 Win32::Security::NamedObject
 class is part of the Win32::Security module.
 
 Rob
 
 
 use strict;
 use warnings;
 
 print file_owner('C:\boot.ini');
 
 
 
 use Win32::Security::NamedObject;
 
 sub file_owner {
 
   my $file = shift;
 
   my $ob = Win32::Security::NamedObject-new('FILE', $file);
   return $ob-ownerTrustee;
 }
 
 
Rob,
Thanks. I installed, but it failed. Needed
Class::Prototyped ( at least 0.98 version ). Installed that and reran,
but this time failed on Data::Bitmask not being there. So installed that
and voila, got the owner.  I will try it with the processing I am doing.
At this point, I was using backticks and ls -l filename to get each file
I needed which seemed like a lot of overhead to just get the owner of a
file.

I appreciate the input and will give it a shot since I have one
set of files on a 300 gig DASD setup which I need to go through and the
owner is one of the requirements. Everything else I can get from
File::find or stat, but this which seems like it should be something
relative easy was not there.

Again thanks for the time and effort.

Wags ;)

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Any way to know if a particular file is open and being used ( Windows )

2007-08-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Rob Dixon pointed me to a module(Win32::Security::NamedObject)
which works, but when I tried a larger volume, it failed with the
following:

GetNamedSecurityInfo: The process cannot access the file because it is
being used by another process. at
C:/Perl/site/lib/Win32/Security/NamedObject.pm line 648 at
C:/Perl/lib/File/Find.pm line 918

So I was thinking if I can see if it is opened ( could try my
original processing of using ls -l to attempt to get the info I need).

I tried search on web and within CPAN, but not getting what I
was looking for.

Any thoughts or ideas?

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




File Creator under WIN32 environment

2007-08-22 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Need to get the individual who created the file I am looking at.
I am using File::Find to get all files that are 4 days or younger. I can
get all info: Path, file name, file size, date modified easily except
owner. I have looked at the Perl doc ( using AS 5.8.8 build 820 ). I see
that I can invoke from within the Perl 'ls -l' using backticks, but is
there any other way of getting that info besides this? The File::Find is
working great, but mssing that last piece. Looked at CPAN, but either
asking the wrong question or not narrowing it enough. It is searching a
300 gig disk and at this point I have been running remotely which is
running at about 2.5 hours to go through all the files. I hopefully will
be able to run locally to accomplish the task.
Any insights would be greatly appreciated on getting owner of a
file under Win32.
 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Ability to do numeric and alpha sort in one pass on data which is compirsed of both

2007-08-14 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I am attempting to sort data which has  a combination of both numeric
and alpah numeric data. Now it would not be so bad, but the numeric data
can be either 9 or 10 characters in length and no leading zero is
supplied in the numbers.

I have supplied some code I am playing with, but running into a mental
block in attempting to get it sorted.

Any thoughts on how to approach would be greatly appreciated?
Running on XP AS 5.8.8.Build 820. Trying to use core Perl verses adding
any modules if possible.

#!perl

use strict;
use warnings;
my %MPI = ();
my $MyProInfo = \%MPI;

my $MyIn = 0;
my $MyOut = 0;

my $MyWrkKey;
while ( DATA ) {
chomp;
$MyIn++;
next if ( /^\s*(#|$)/ );
next if ( /^\s/ );
$MyWrkKey = substr($_,0,13);
$MyProInfo-{$MyWrkKey} = 1;
$MyOut++;
 }

{
my $MyPrtKey;
foreach $MyPrtKey ( sort { $a-[1] = $b-[1] ||
   $a-[0] cmp $b-[0]
  }
map{[$_, /^[a-z]/i ? 0 : 1 ]}
keys %{$MyProInfo}
   ) {
printf MyPrtKey: %s\n,
$MyPrtKey-[0];
 }
 }
__DATA__
#
#   actual number or alpha is in positions 1 to 10 and when numeric can
be all ten
#   Would like to do a true numeric sort on the numbers and alpha sort
on the alpha
#
075991200 000 prod   440.32   033870148  Y
Y  0148
0964844694000 prod   065.56   000420001  Y
Y  0001
0964928823000 prod   059.36   000300001  Y
Y  0001   
990028300 000    064.98   000410001  Y
Y  0001
990028318 000    064.98   000410001  Y
Y  0001
990032732 000    051.84   000470001  Y
Y  0001
ALN-218435000    046.35   000290001  Y
Y  0001
ALN-244079000    047.36   000460001  Y
Y  0001
^-- Code ends here

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: calculating time difference with localtime

2007-08-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: timbo [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, August 08, 2007 07:03
 To: beginners@perl.org
 Subject: calculating time difference with localtime
 
 Once I calculate the difference between 2 epoch times, is there a way
 I can convert the difference into a proper time format?
 
 For example...
 
 $difference = 13452
 
 then convert it to show
 
 timedifference = 35 minutes
 
 Thanks in advance.
 
Either spin your own or find a CPAN module . Usually easier to
write your own little routine to take seconds and come back with hours,
minutes, seconds or if necessary days, hours, etc.

Wags ;)
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: slices

2007-08-08 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: oryann9 [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, August 08, 2007 13:44
 To: Perl List
 Subject: slices
 
 Trying to understand from perldoc perldata the diff
 between these 3 CLIs and why the 2nd CLI has no
 elements?
 
 $ perl -le 'use Data::Dumper; @c = (0,1)[1]; print
 Dumper([EMAIL PROTECTED]);'
 $VAR1 = [
   1
 ];
 
 $ perl -le 'use Data::Dumper; @c = (0,1)[2]; print
Stating to pull slice [2] when you only have [0] and [1] as
defined as defined between (). If you wanted slice [2] then would have
needed (0,1,2) at least to get [2].

Wags ;)

 Dumper([EMAIL PROTECTED]);'
 $VAR1 = [];
 
 
 $ perl -le 'use Data::Dumper; @c = (0,1)[0]; print
 Dumper([EMAIL PROTECTED]);'
 $VAR1 = [
   0
 ];
 
 

 __
 __
 Building a website is a piece of cake. Yahoo! Small Business 
 gives you all the tools to get online.
 http://smallbusiness.yahoo.com/webhosting 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How i convert a excel file to csv file ?

2007-08-07 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Use Spreadsheet::ParseExcel. I had a similar situation and by
just using the examples within was able to write out three csv for some
processing I am doing. If a single worksheet, then you coupld possbily
get away with using ParseExcel::Simple to accomplish the work.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -Original Message-
 From: Brown, Rodrick [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, August 07, 2007 07:29
 To: Santana; beginners@perl.org
 Subject: RE: How i convert a excel file to csv file ?
 
 
 There is a module on CPAN called Spreadsheet::WriteExcel you 
 can use to
 read xls data.  
 
 -Original Message-
 From: Santana [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, August 07, 2007 8:22 AM
 To: beginners@perl.org
 Subject: How i convert a excel file to csv file ?
 
 Hei friends,
 i'am new in newbie in Perl, and i need  how i convert a excel file in
 csv file in linx ?
 
 Can you help me, please ??
 
 Thanks,
 Paulito
 
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
 commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
 
 
 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
 - - - - - - - - - - - - -
 
 This message is intended only for the personal and 
 confidential use of the designated recipient(s) named above.  
 If you are not the intended recipient of this message you are 
 hereby notified that any review, dissemination, distribution 
 or copying of this message is strictly prohibited.  This 
 communication is for information purposes only and should not 
 be regarded as an offer to sell or as a solicitation of an 
 offer to buy any financial product, an official confirmation 
 of any transaction, or as an official statement of Lehman 
 Brothers.  Email transmission cannot be guaranteed to be 
 secure or error-free.  Therefore, we do not represent that 
 this information is complete or accurate and it should not be 
 relied upon as such.  All information is subject to change 
 without notice.
 
 
 IRS Circular 230 Disclosure:
 Please be advised that any discussion of U.S. tax matters 
 contained within this communication (including any 
 attachments) is not intended or written to be used and cannot 
 be used for the purpose of (i) avoiding U.S. tax related 
 penalties or (ii) promoting, marketing or recommending to 
 another party any transaction or matter addressed herein.
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How do I truncate or remove a trailing character

2007-08-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Bret Goodfellow [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, August 01, 2007 14:25
 To: beginners@perl.org
 Subject: How do I truncate or remove a trailing character
 
 Okay, I know this has to be simple, but because I am trying 
 to truncate
 or remove a special character I've run into a roadblock.  
 Here's what I
 want to do.  
  
 $value = 12345) ;
  
 How do I change $value so that the trailing ) is removed.  In
 otherwords with the given example, how do I manipulate $value so that
 its value is 12345?  Please keep in mind that $value may be variable
 in length, so I can't use substr($value, 0, 5).  Can split be 
 used to do
 this?  Stumped.
 
Will there always be non decimal number or it could be easier to
pull all the numbers:
if ( $value =~ /^(\d+)/ ) {
   $value = $1
 }
else {
   printf Expecting a numeric field, but got%s\n, $value;
   # now either back to the top of a loop or whatever

 }
 or if always want last character removed:
chop($value);   # removes last character
Or
$value = substr($value,0,length($value)-1);

You have to decide what edits or the data looks like, but something to
think about.

Wags ;)

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Distill some string from whole string

2007-07-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: jeanwelly [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, July 19, 2007 05:26
 To: beginners@perl.org
 Subject: Distill some string from whole string
 
 $my_string = a\nbbl.dghd\n/usr/command\n;
 
 I want to distill /usr/command and assign to a variable, how can I do?
 thanks!
You have not really said how you know that you want
/usr/command? Is it the / or usr or command or ?

Wags ;)
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Combining Records From Multiple Files based on Common Key Values

2007-07-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: country [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, July 18, 2007 06:00
 To: beginners@perl.org
 Cc: [EMAIL PROTECTED]
 Subject: Combining Records From Multiple Files based on 
 Common Key Values
 
 I have multiple CSV files (3 for this example) with
 identical record layouts except that each Server Name may not be in
 all of the files. Also the CSV files might not be sorted by Server
 Name.
 
 File A
 Server Name,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util
 WSOMQAVPRA05,93.75,95.87,66.67,68.13
 wsomdavpra03,90.39,94,65.77,68.51
 wsomddvfxa01,39.22,92.19,82.59,88.25
 
 File B
 Server Name,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util
 WSOMQAVPRA05,34.78,100,55.1,67.6
 wsomdavpra03,69.04,98.55,84.07,89.73
 wsomddvfxa01,92.44,97.54,67.72,71.69
 wsompapgtw05,48.77,96.9,92.1,93.55
 
 File C
 Server,Avg CPU,P95 CPU,Avg Mem Util,P95 Mem Util
 WSOMQAVPRA05,93.13,98.11,68.95,73.47
 wsomdavpra03,68.85,97.56,76.35,98.23
 wsomddvfxa01,46.97,96.29,88.23,94.02
 wsompapgtw05,30.66,93.74,39.89,71.35
 
 What I am trying to do is for each Server (in Column
 1) I want to get the Avg CPU (in Column 2) from each
 of the 3 files. In the files above this would produce
 
 
 File OUT
 WSOMQAVPRA05,93.75,34.78,93.13
 wsomdavpra03,90.39,69.04,68.85
 wsomddvfxa01,39.22,92.44,46.97
 wsompapgtw05,0,48.77,30.66
 
 
 Notice in File OUT for Server Name (wsompapgtw05),
 since wsompapgtw05 does not appear in File A, the
 value is replaced with '0'. How can I get perl to
 place a '0' in the output file when a particular
 server name appears in at least 1 of the input files,
 but not in all of the input files?
 
 The perl code I've written up to this point does not handle the
 missing server and Avg.CPU value.  I think that I need to add
 code to first build a hash which contains the server names in a
 key by going through all the files - 3 for this example - and then
 iterating over that list of servers in a while loop, inserting the
 value
 found in the respective file or a '0'.  You will see in my code, which
 follows I have created 1 hash.  I am not sure in perl how I might
 attempt to build this additional hash with a Server Name as key
 and then iterating over that list.  My code so far is:
 
no need to read thru the files multiple. Build the hash and one
way is to use an index and as you open the next file, add to the index.
Now when doing the print, you only need to check the array element and
if not defined, then zero is used.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 #!/usr/bin/perl
 
 use strict;
 use warnings;
 ###
 #   Create File with Average CPU Numbers
 ###
 my %resultacpu;
 
 for my $file (FileA,FileB,FileC) {
 
 open (my $fh,,$file) or die Can't open file $file: $!;
 $fh; # skip header line
 
 while (my $line = $fh) {
 my ($server,$cpua) = (split(,,$line))[0,1];
 push @{$resultacpu{$server}},$cpua;
 }
 
 close $fh or die Can't close file $file: $!;
 }
 
 open (my $nfh,,OUT) or die Can't open result file: $!;
 
 for my $server (sort keys %resultacpu) {
 print $nfh $server.,.join(,,@{$resultacpu{$server}}).\n;
 }
 close $nfh or die Can't close result file: $!;
 
 
 I would appreciate the assistance of any perl coders who might
 be able to help me with this problem
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Spreadsheet::WriteExcel problem with large file

2007-07-16 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: a_arya2000 [mailto:[EMAIL PROTECTED] 
 Sent: Monday, July 16, 2007 14:06
 To: beginners@perl.org
 Cc: a_arya2000
 Subject: Re: Spreadsheet::WriteExcel problem with large file
 
 By the way, my file size around 22 MB so, is it
 possible that Spreadsheet::WriteExcel::Big is not good
 enough for this size?
how many rows are you talking about? If over 65k, then need to
make multiple worksheets as you can not go over 65k rows per worksheet.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 
 --- a_arya2000 [EMAIL PROTECTED] wrote:
 
  Thank you very much for suggestions guys, I tried
  using Spreadsheet::WriteExcel::Big but still having
  the same issue. I am not sure, what I am doing
  wrong.
  My file size is indeed more than 7 MB.
  Thank you,
  Partha Dhar
   
  --- Raja Vadlamudi [EMAIL PROTECTED] wrote:
  
   Use Spreadsheet::Big module if the file size
  happens
   to be larger than 7 MB.
   The latest Spreadsheet module will have this Big
   module integrated, but if
   you are using older version, then you need to use
   this Big module.
   
   
   On 7/16/07 8:46 AM, Rob Dixon
  [EMAIL PROTECTED]
   wrote:
   
a_arya2000 wrote:

Hi, the problem is, when write large
  spreadsheets
   of 20,000 rows or
so, the module finishes without error, but when
  I
   try to open the
spreadsheet with Excel I get error messages
  about
   the spreadsheet
being 'unrecoverably scrambled'. I've never had
  a
   problem with it
except for these very large spreadsheets. It
   works great on smaller
ones.

Is there any work around for this? Or Is there
   any other module that
will do that work?

Try calling the 'close' method on your workbook,
   and see the module's
documentation on this - particularly with regard
   to garbage collection.

  $workbook-close;

HTH,

Rob

   
   
  
  
  
 
 
 __
 __
  Get the Yahoo! toolbar and be alerted to new email
  wherever you're surfing.
 
 http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
  
  -- 
  To unsubscribe, e-mail:
  [EMAIL PROTECTED]
  For additional commands, e-mail:
  [EMAIL PROTECTED]
  http://learn.perl.org/
  
  
  
 
 
 

 __
 __
 Get the Yahoo! toolbar and be alerted to new email wherever 
 you're surfing.
 http://new.toolbar.yahoo.com/toolbar/features/mail/index.php
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Need idea for doing automatic iteration, please.

2007-06-28 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Patrik Hasibuan [mailto:[EMAIL PROTECTED] 
 Sent: Thursday, June 28, 2007 12:55
 To: Milis CPAN-Perl-Beginners
 Subject: Need idea for doing automatic iteration, please.
 
 Dear my friends...
 
 I want my code does an action if it find a directory or file, 
 namely: storing the url/path of a file or a directory onto 
 mysql database.
Working too hard, just use File::Find and you can control how
deep you want to go, but if  you just want all files, then take a look
at the doc and with thexamples provided, should be very simple to do.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

 
 I am meaning, my code should look up every file/directory 
 name resides under the $rootdir iteratively for doing 
 storing onto mysql on each find.
 
 The algorithm For doing find from beginning to the end of the 
 1 level under $rootdir is still simple, it's only a while{..}{...}. 
 But the problem comes when the directory has a/some 
 directory/-es whereas my code should also find them and 
 stores them onto the mysql. 
 If every directory has a limited level (for instance maximum 
 only 3 level subdirectories below to the bottom) then all I 
 have to do is simply creating nested while(...)[..]  for 3 
 level. But in this case of course each directory may 
 unpredictably has hundreds or thousands subdirectories/files 
 in hundreds or thousands levels below to the bottom.
 
 Please suggest me some ideas where I can implement into my 
 codes in order to enable my code to find all subdirectories 
 and files where placed under $rootdir.
 A very simple code-sample is very..very...welcomed.
 
 Here is my current code under below. This code still only can 
 find 1 level, only exactly 1 level under $rootdir.
 -
 package iterdir;
 use kueri;
 
 sub baru{
   my $kelas = shift if @_;
   print Nama superkelas: $kelas \n;
   return( bless{} );
 }
 
 sub bukadir{
   my $kelas = shift;
   $rootdir=/home/patrikh/sementara/tes;
   opendir(dirku, $rootdir);
   $statusp=chdir($rootdir);
   if ($statusp){
 print berhasil membuka direktori--$rootdir\n;
 while ($entridir=readdir(dirku)){
   print entridir: $entridir\n;
   $sqlku=kueri-baru;
   $sqlku-konek;
   if (($entridir ne '.') and ($entridir ne '..')){
   my $strsql = insert into tblarsip (location) values 
 ('.$entridir.');
   print strsql: $strsql\n;
   $sth=$kueri::dbh-prepare($strsql);
   $sth-execute;
   $sth-finish;
   }
 }
   } else{
 print gagal membuka direktori yang diinginkan: $rootdir\n;
 exit 1;
   }
 }
 
 1;
 
 -- 
 Patrik Hasibuan [EMAIL PROTECTED]
 Junior Programmer
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




FTP to IBM ZOS/390

2007-06-15 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Has anyone done any FTP'ing to IBM ZOS/390 machine.  As you can
see in the output there was a timeout due to waiting for a file to
recalled from tape to disk.

Output:
Net::FTP=GLOB(0x15f35c) STOR FREQ0407
Net::FTP=GLOB(0x15f35c) 125-Waiting for recall of data set
FTPTRGP.FREQ0407
Net::FTP=GLOB(0x15f35c): Timeout at pl545.pl line 2612
Net::FTP=GLOB(0x15f35c) QUIT
Net::FTP=GLOB(0x15f35c) 125 Storing data set FTPTRGP.FREQ0407


Now the script has the following:

$MyFTP-put($MyFtpFromFile , $MyFtpToFile );
if ( ! $MyFTP-ok() ) {
my $MyMsg  = $MyFTP-message() ;
my $MyCode = $MyFTP-code();
...

but I know that I am not hitting this code, since the next
portion of the script would send an error msg if there was one, but it
goes on to normal completion.   The TIMEOUT that is being displayed is
the 'put' above.

The code is running on:
v5.8.3 built for sun4-solaris

Any ideas or suggestions to see what is happening would be
greatly appreciated.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**



RE: FTP to IBM ZOS/390

2007-06-15 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Chas Owens [mailto:[EMAIL PROTECTED] 
 Sent: Friday, June 15, 2007 16:50
 To: Wagner, David --- Senior Programmer Analyst --- WGO
 Cc: beginners@perl.org
 Subject: Re: FTP to IBM ZOS/390
 
 On 6/15/07, Wagner, David --- Senior Programmer Analyst --- WGO
 [EMAIL PROTECTED] wrote:
  Has anyone done any FTP'ing to IBM ZOS/390 machine. 
  As you can
  see in the output there was a timeout due to waiting for a file to
  recalled from tape to disk.
 snip
 
 My only suggestion is to increase your timeout (the default 
 is 2 minutes).
 
 my $MyFTP = Net::FTP-new($host, timeout = 60 * 10)
 
Never even thought of that. I will do that, but it seems like
this should have generated some type of msg, maybe not an error, but at
least is there way to check warnings?

I will change give it a shot.

Thanks.

Wags ;)

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Win32 script cannot read command line argument.

2007-05-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: Vladimir Lemberg [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, May 02, 2007 14:01
 To: beginners@perl.org
 Subject: Win32 script cannot read command line argument.
 
 Hi All,
 
 My script is unable to read argument when I'm executing it 
 as: script.pl argument.
 However, when I'm running it as: perl script.pl argument - 
 it works fine.
  
 I did associate perl scripts with Perl as explained in 
 ActivePerl-Winfaq4.htm
 All my scripts, which doesnt require any arguments works file. 
Your folder assocation looks like:

C:\Perl\bin\perl.exe %1 %*
If like this, then should be working. Been using this for what
seems like forever.
  
 I have WinXP with Service Pack 2. 
  
 All appriciate any help to resolve it.
  
 Thanks,
 Vladimir

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: What's HTH?

2007-04-25 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Believe it is 'Hope this helps!'.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On 
 Behalf Of Tom Phoenix
 Sent: Wednesday, April 25, 2007 09:01
 To: yitzle
 Cc: Beginners Perl
 Subject: What's HTH?
 
 On 4/25/07, yitzle [EMAIL PROTECTED] wrote:
 
  P.S. What's HTH?
 
 http://www.google.com/search?q=What+does+hth+stand+for%3F
 
 Cheers!
 
 --Tom Phoenix
 Stonehenge Perl Training
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: substitute and assign in one line

2007-04-17 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Karyn Williams [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, April 17, 2007 15:14
 To: Perl Beginners
 Subject: substitute and assign in one line
 
 This is probably very simple, but I'm not seeing it. I want to do the
 following:
 
 
 my $lfirst = $first;
 $lfirst =~ s/[^a-zA-Z]//g;
 
 in one line. I tried :
 
 my $lfirst = ($first =~ s/[^a-zA-Z]//g); 
close, but try
(my $lfirst = $first) =~ s/[^a-zA-Z]//g;
 Wags ;)

 
 but it returned either a blank or null.
 
 I want to maintain the state of $first and store the alpha 
 only version in
 $lfirst.
 
 TIA.
 
 
 
 -- 
 
 Karyn Williams
 Network Services Manager
 California Institute of the Arts
 [EMAIL PROTECTED]
 http://www.calarts.edu/network
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Exiting loops

2007-03-29 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Karyn Williams [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, March 28, 2007 17:54
 To: beginners@perl.org
 Subject: RE: Exiting loops
 
 At 04:10 PM 3/28/07 -0700, Wagner, David --- Senior 
 Programmer Analyst ---
 WGO wrote:
  take the o off the /o This is in essence saying you only have to
 compile this once for the processing going on. Take that off and see
 what happens. I believe you would use /o if you have regex has no
 variables which are changing with each iteration.
 
   If you have any problems or questions, please let me know.
 
 
 Looks like that was it. I had added that because I read 
 somewhere it was
 supposed to speed up the search. Is there another way to speed it up ?
 
Karyn, The real question is how often are you doing this? How
many users are involved? Would reading the data once and collecting the
info into a hash and then reporting off the hash make sense. You are
going through the file 5 times if you input 5 ids, 10 times if you have
10 ids, etc. 

So step back and look at what is needed and then see if reading
the data once and using a hash or related data field will give you the
boost you need.

  Thanks.
 
   Wags ;)
 David R Wagner
 Senior Programmer Analyst
 FedEx Freight
 1.408.323.4225x2224 TEL
 1.408.323.4449   FAX
 http://fedex.com/us 
  
 
  -Original Message-
  From: Karyn Williams [mailto:[EMAIL PROTECTED] 
  Sent: Wednesday, March 28, 2007 15:54
  To: beginners@perl.org
  Subject: Exiting loops
  
  I have a sh script as follows. The script worked OK until the 
  year rolled
  over. My (now deleted) simple sh way of figuring the month 
  and year blew
  up. I decided to rewrite the script in perl because of the 
 date/time
  functions. It takes multiple commandline args (usernames) and 
  checks for
  various information on them. Since the maillogs are so large 
  I want to exit
  the first loop as soon as it is determined that the user has 
  checked their
  mail. 
  
  #!/bin/sh
  
  ext=`date +%Y%m`
  
  month1=200702
  month2=200701
  month3=200612
  month4=200611
  month5=200610
  month6=200609
  month7=200608
  
  for i in $* ; do
  
  echo $i
  
  if test -r /export/home/$i/.forward ; then echo $i 
  has forward file
  ; continue ;
  elif [ `fgrep -c user=$i /var/adm/maillog` -gt 
  0 ] ; then
  echo $i checked mail month 0 ;  continue ;
  elif [ `fgrep -c user=$i 
 /export/home/archives/maillog.$month1`
  -gt 0 ] ; then echo $i checked mail month 1 ; continue;
  elif [ `fgrep -c user=$i 
 /export/home/archives/maillog.$month2`
  -gt 0 ] ; then echo $i checked mail month 2 ; continue;
  elif [ `fgrep -c user=$i 
 /export/home/archives/maillog.$month3`
  -gt 0 ] ; then echo $i checked mail month 3 ; continue;
  elif [ `fgrep -c user=$i 
 /export/home/archives/maillog.$month4`
  -gt 0 ] ; then echo $i checked mail month 4 ; continue;
  elif [ `fgrep -c user=$i 
 /export/home/archives/maillog.$month5`
  -gt 0 ] ; then echo $i checked mail month 5 ; continue;
  elif [ `fgrep -c user=$i 
 /export/home/archives/maillog.$month6`
  -gt 0 ] ; then echo $i checked mail month 6 ; continue;
  else echo $i has not checked mail in the last 6 months ;
  fi
  
  echo checking last for 2007 ; last -3 $i
  echo checking 2007 dial-up ; fgrep -c P${i}
  /var/adm/radacct/pleiades/detail
  echo checking for last modified file ; ls -lrt 
  /export/home/$i |
  tail -2
  echo checking for newest file in public_html ; ls -lrt
  /export/home/$i/public_html | tail -2 
  ls -lsu /export/mail/$i
  quota -v $i
  finger -m $i
  
  done
  
  This is what I have so far in perl:
  
  # cat tt.pl
  #!/usr/bin/perl -w
  
  use POSIX;
  
  # Get the current month and year
  my ($mon,$year) = (localtime)[4,5];
  
  # Seed nmonth
  
  my @nmonth = (1,1,1,1,$mon,$year,0,0);
  
  my $sec  =  1;
  my $min  =  1;
  my $hour =  1;
  my $day  =  1;
  my $wday =  0;
  my $yday =  0;
  
  # Put the loop here
  my $a = 1;
  while ($a  7) {
   
  my $current = mktime($sec, $min, $hour, $day, $nmonth[4],
  $nmonth[5], $wday, $yday); # Make new timestamp for the first
  @nmonth = localtime($current);  # Make an 
  array out of the
  timestamp to get the month and year
  my $ext_mon = ($nmonth[4] + 1); # Pull the 
  month out of the
  array and add 1 to get month number
  my $ext_year = ($nmonth[5] + 1900); # Pull the 
  year and add
  1900 to get the actual year
  if ($ext_mon = 9) {# Make the 
  month have two
  places and write the var $ext
  $ext = $ext_year . '0' . $ext_mon;
  }
  else {
  $ext = $ext_year . $ext_mon;
  }
  
  push (@flist, $ext);
  $current = $current - 86400;# Subtract one day 
  from the first

RE: Exiting loops

2007-03-28 Thread Wagner, David --- Senior Programmer Analyst --- WGO
take the o off the /o This is in essence saying you only have to
compile this once for the processing going on. Take that off and see
what happens. I believe you would use /o if you have regex has no
variables which are changing with each iteration.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -Original Message-
 From: Karyn Williams [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, March 28, 2007 15:54
 To: beginners@perl.org
 Subject: Exiting loops
 
 I have a sh script as follows. The script worked OK until the 
 year rolled
 over. My (now deleted) simple sh way of figuring the month 
 and year blew
 up. I decided to rewrite the script in perl because of the date/time
 functions. It takes multiple commandline args (usernames) and 
 checks for
 various information on them. Since the maillogs are so large 
 I want to exit
 the first loop as soon as it is determined that the user has 
 checked their
 mail. 
 
 #!/bin/sh
 
 ext=`date +%Y%m`
 
 month1=200702
 month2=200701
 month3=200612
 month4=200611
 month5=200610
 month6=200609
 month7=200608
 
 for i in $* ; do
 
 echo $i
 
 if test -r /export/home/$i/.forward ; then echo $i 
 has forward file
 ; continue ;
 elif [ `fgrep -c user=$i /var/adm/maillog` -gt 
 0 ] ; then
 echo $i checked mail month 0 ;  continue ;
 elif [ `fgrep -c user=$i 
/export/home/archives/maillog.$month1`
 -gt 0 ] ; then echo $i checked mail month 1 ; continue;
 elif [ `fgrep -c user=$i 
/export/home/archives/maillog.$month2`
 -gt 0 ] ; then echo $i checked mail month 2 ; continue;
 elif [ `fgrep -c user=$i 
/export/home/archives/maillog.$month3`
 -gt 0 ] ; then echo $i checked mail month 3 ; continue;
 elif [ `fgrep -c user=$i 
/export/home/archives/maillog.$month4`
 -gt 0 ] ; then echo $i checked mail month 4 ; continue;
 elif [ `fgrep -c user=$i 
/export/home/archives/maillog.$month5`
 -gt 0 ] ; then echo $i checked mail month 5 ; continue;
 elif [ `fgrep -c user=$i 
/export/home/archives/maillog.$month6`
 -gt 0 ] ; then echo $i checked mail month 6 ; continue;
 else echo $i has not checked mail in the last 6 months ;
 fi
 
 echo checking last for 2007 ; last -3 $i
 echo checking 2007 dial-up ; fgrep -c P${i}
 /var/adm/radacct/pleiades/detail
 echo checking for last modified file ; ls -lrt 
 /export/home/$i |
 tail -2
 echo checking for newest file in public_html ; ls -lrt
 /export/home/$i/public_html | tail -2 
 ls -lsu /export/mail/$i
 quota -v $i
 finger -m $i
 
 done
 
 This is what I have so far in perl:
 
 # cat tt.pl
 #!/usr/bin/perl -w
 
 use POSIX;
 
 # Get the current month and year
 my ($mon,$year) = (localtime)[4,5];
 
 # Seed nmonth
 
 my @nmonth = (1,1,1,1,$mon,$year,0,0);
 
 my $sec  =  1;
 my $min  =  1;
 my $hour =  1;
 my $day  =  1;
 my $wday =  0;
 my $yday =  0;
 
 # Put the loop here
 my $a = 1;
 while ($a  7) {
  
 my $current = mktime($sec, $min, $hour, $day, $nmonth[4],
 $nmonth[5], $wday, $yday); # Make new timestamp for the first
 @nmonth = localtime($current);  # Make an 
 array out of the
 timestamp to get the month and year
 my $ext_mon = ($nmonth[4] + 1); # Pull the 
 month out of the
 array and add 1 to get month number
 my $ext_year = ($nmonth[5] + 1900); # Pull the 
 year and add
 1900 to get the actual year
 if ($ext_mon = 9) {# Make the 
 month have two
 places and write the var $ext
 $ext = $ext_year . '0' . $ext_mon;
 }
 else {
 $ext = $ext_year . $ext_mon;
 }
 
 push (@flist, $ext);
 $current = $current - 86400;# Subtract one day 
 from the first
 timestamp to get the month before
 @nmonth = localtime($current);  # Make an 
 array out of the
 new timestamp for the next round
 }
 continue {
 $a++;
 }
 
 # This is the part I am having trouble with :
 
 foreach $k (@ARGV) {
 
 if (-e (/export/home/$k/.forward)) { 
 print User $k has a forward file.\n\n ; next ;
 } else {
 
 open MAILLOG, /var/adm/maillog or die couldn't 
 open maillog :
 $!\n;
 if ($count = grep /user=$k/o, MAILLOG ) {
 print $k checked mail $count times in
 /var/adm/maillog.\n; next ;
 } else {
 close MAILLOG; 
 
 open MAILLOG, /export/home/archives/maillog.$flist[1] or die
 couldn't open maillog.$flist[1] : $!\n;
 if ($count = grep /user=$k/o, MAILLOG ) {
 print $k checked mail $count times in
 maillog.$flist[1].\n; next ;
 } else {
 close MAILLOG; 
 
 open MAILLOG, 

RE: File::Find again

2007-03-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Matt Herzog [mailto:[EMAIL PROTECTED] 
 Sent: Friday, March 23, 2007 15:00
 To: Begin Perl
 Subject: File::Find again
 
 Hello All.
 
 I can see why people hate this module but I can't seem to let go.
 I point this script at a deep dir structure that has java .properties 
 files sprinkled throughout it. Right now when I have my regex 
 hard coded
 in the file, (.properties$) the search works fine. I need to 
 be able to use
 the variable $searchstring at the command line. Is this even 
 possible? If
 not, is there a way to exclude directories from being returned?
 
 
 Thanks.
 
 use strict;
 use warnings;
 use File::Find;
 use Getopt::Std;
 use vars qw/ %opt /;
 use diagnostics;
 
 my $args = 't:s:a:';
 getopts( $args, \%opt );
 my $targetdir = $opt{t};
 my $searchstring = $opt{s};
 my $append = $opt{a};
 
 find(\mod, $targetdir);
 
 sub mod {
   return unless ($_ =~ /\.properties$/);
   print $_\n
   }
 
change to  
return unless ( /\.properties/ );   # don't need the $_
already implied
return if ( -d $_ );# if directory return
You should have no problem using the searchstring, just make
sure what is being passed is what you expecting.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -- 
 Monkeys are superior to men in this:
 when a monkey looks into a mirror, he sees a monkey.
 
 -- Malcolm De Chazal
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: capture stdin and stderr

2007-03-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Vladimir Lemberg [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, March 20, 2007 15:21
 To: beginners@perl.org
 Subject: capture stdin and stderr
 
 Hi All,
 
  
 
 My script is calling a Win32 program with two arguments:
 
 system ( $ARGV[0]\\program.exe, $File::Find::name, 
 $ARGV[0]\\source);
 
  
 
 I want to capture STDOUT and STDERR from the program to log file
 
  
 
 system ( $ARGV[0]\\program.exe, $File::Find::name, 
 $ARGV[0]\\source, 1$ARGV[0]\\log.txt, 21 );
 
  
 
 Compiler gave me syntax error. And for sure the problem with 
 this part: 1$ARGV[0]\\log.txt, 21.
 
 I was trying to double quote it and put commas but it didn't help.
 
 Is there any way to accomplish this task under Win32 environment?
If using ActiveState, then see perlfaq8 and header How can I
capture STDERR from an external command?

If not AS, then reply back and I can that portion of the doc.
 
 Thanks in advance,
 Vladimir
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How do I create this string?

2007-03-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Not tested:

while ( 1 ) {
printf Please enter length of variable(ex:exit out): ;
chomp(my $MyInp = STDIN );
last if ( $MyInp =~ /^ex$/i );
if ( $MyInp !~ /\d+/ ) {
   print Expecting only digits, but got $MyInp. ,
\n;
   next;
 }
my $MyVar = q[a]x$MyInp;
printf %s\n, $MyVar;
 }

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -Original Message-
 From: Travis Thornhill [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 19, 2007 14:37
 To: beginners@perl.org
 Subject: How do I create this string?
 
 I need to make strings of variable length for testing inputs.
   The strings can contain any letter, say 'a', and I need to 
 be able to create the string with
   255, 256 or any length.

   Is there a quick and easy way to do this with perl?
 
  
 -
 Never miss an email again!
 Yahoo! Toolbar alerts you the instant new Mail arrives. Check it out.
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: STDOUT

2007-03-19 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: hOURS [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 19, 2007 13:17
 To: Perl Beginners
 Subject: Re: STDOUT
 
 
 
 Jenda Krynicky [EMAIL PROTECTED] wrote:  From: hOURS 
  Hi,
   I wrote to the list with this issue before and got some 
 suggestions,  but nothing worked. I ended up shelving it, but 
 now would like to try  again.
  I have a thousand scripts I'd like to check for syntax  
 errors. (Long story that.) All I need is a list of which ones 
 have  errors.
Some code suggested by John seemed very promising:
my $return = do 'PossError1.pl';
   $return has a value of 1 if the syntax is fine, and the 
 error message  otherwise. My problems come when I loop. When I try:
for($number = 1; $number 1000; $number +=1) {
  $progname = PossError . $number . .pl;
  my $return = do  $progname;
  print $return\n;
}
   I get two difficulties. 1) It doesn't do all one thousand 
 scripts. For  some reason it decides nine is plenty. I see 
 nine 1s on my screen and  the computer thinks it's done. 2) 
 If one of the scripts has an error,  it won't even do nine. 
 If the 7th one has an error I'll see 6 1s, an  error message, 
 and then the program hangs.
Any suggestions?
Fred
 
 There are two problems with this implementation.
 
 First it doesn't check the syntax, it executes the scripts!
 And second it (tries to) executes the scripts all in one process. So 
 whatever changes in global data does one script make, the later ones 
 see.
 
 I think you want something like this:
 
 for my $number (1 .. 1000) {
  my $progname = PossError . $number . .pl;
  if (!-e $progname) {
   print $progname doesn't exist!\n;
   next;
  }
  my $return = `perl -c $progname`;
  if ($return =~ / syntax OK$/) {
   print $progname is OK\n;
  } else {
   print $progname has errors\n;
  }
 }
 
 HTH, Jenda
 
 
 
   Thanks Jenda,
   I definitely do just want to check syntax and not execute 
 the scripts.
 
   I ran your code.  I think we're getting close.  Here's what 
 happened:
   For the first 64 scripts, I got either a syntax OK message 
 or an error  message, followed, in all 64 cases, by the has 
 errors print  out.  The remaining 936 scripts all gave just 
 the has errors  print out.  Why would the program make that 
 choice (the else  portion of the if/else) every time?  Only 
 about 5% of the scripts  have errors.  I happened to know in 
 advance that #17 was the only  one amongst the first 20 with 
 an error.  There seemed to be 4  amongst those first 64 
 scripts.  But even the 60 that gave me a  'syntax OK' message 
 followed it up with the has errors choice.   I thought 
 perhaps that second $, between the slashes, in the line:
if ($return =~ / syntax OK$/) {
  shouldn't be there, (after all it doesn't show up on my 
 screen) but deleting that had no effect.
 
   I'd rather not print out the syntax OK or error message.  
 It's  redundant info with the subsequent if/else choice.  In 
 any event I  can't imagine why the first 64 behaved 
 differently from the last 936,  though I wouldn't be 
 surprised if 64 being a power of 2 is part of the  explanation.
   Oh let me also mention I'm using Windows, in case that matters.
 
If you are on windows, then see perlfaq8 if ActiveState perl for
how to redirect STDOUT and STDERR when doing backticks. Believe where
you want to be at.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 
   Thanks much!
   Fred
 
  
 -
 Now that's room service! Choose from over 150,000 hotels 
 in 45,000 destinations on Yahoo! Travel to find your fit.
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: polling a directory

2007-03-14 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Beginner [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, March 14, 2007 10:56
 To: beginners@perl.org
 Subject: polling a directory
 
 Hi,
 
 I am trying to find a means of monitoring a directory for activity. I 
 would like a perl process to aware if a file has been dropped into a 
 specific folder and then take some action.
 
 In the past I have used cron for this but I was thinking this isn't 
 the best choice because 1) You have to spawn a very frequently to try 
 to achieve real-time action 2) The high frequency spawning of a perl 
 script is quite expensive in terms of resources 3) There is the 
 potential for one process to collide with another.
 
 One way would be to have a script that did while (1) and a sleep when 
 nothing was found but again this seems primitive. Is this something 
 that a daemon module might help with? Does anyone have an idea that 
 might help? 
 
 TIA,
 Dp.
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
I have a couple of different pollers which do exactly that: run
in background ( not really as daemon, thouh that could be done), either
view a particular directory or multiple directories and when I find
something, then spawn some other Perl scripts to do the acutal work. Now
for me, I am doing ftp from an IBM mainframe and also from Solaris.
Together these two processes handle around 100k of internal emails a
month for the business covering a wide band of topics. I have the output
of the processing going to a file and I have an audittrail if problems
occur.

You state cron, so assuming you are on a unix type setup. That
is what I am running under. All very doable for you.

  If you have any problems or questions, please let me know.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Removing blank lines

2007-03-12 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Beginner [mailto:[EMAIL PROTECTED] 
 Sent: Monday, March 12, 2007 11:16
 To: beginners@perl.org
 Subject: Re: Removing blank lines
 
 On 12 Mar 2007 at 11:09, Grant wrote:
 
  Hello,
  
  I'm having a lot of trouble figuring out how to remove blank lines
  from my HTML.  The lines are generated by my shopping cart.  I use
  (and highly recommend) interchange:
  
  http://www.icdevgroup.org
  
  I basically want to wrap all of my code in [filter
  no_blank_lines][/filter].  no_blank_lines is defined this way:
  
  CodeDef no_blank_lines Routine EOR
  sub {
  my $val = shift;
  #$val =~ s/\s+//g;
  #$val =~ s/\s*\n+\s*/\n/g;
  #$val =~ s/[^\S\n]*\n\s*\n/\n/g;
  $val =~ s/\n\n+/\n/g;
  return $val;
  }
  EOR
 
 This is untested but usually works for me
 
 $val =~ s/^$//g
 
I would chg ^$ to ^\s*$ which says if you by chance only
whitespace between the start and end of line, consider a blank line. The
works, but any whitespace will leave what appears to the eye as a blank
line.

A thought.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 
 not sure you'll need the gobal switch if you'r reading line by line 
 but it can't hurt.
 
  Those are all regexp's I've tried.  They all seem to do 
 nothing except
  the first one removes all whitespace including the spaces in between
  characters in my code which obviously breaks everything.  Can anyone
  suggest a solution?
 
 HTH,
 Dp.
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Where can I download the Perl Mail::Sendmail library module

2007-03-07 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 From: Michael Goopta [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, March 07, 2007 12:13
 To: beginners@perl.org
 Subject: Where can I download the Perl Mail::Sendmail library module
 
 Hi Chas,
 
 Thanks a lot for your help. It did get me started. It had time
 module.
 Now, when I started writing a simple sendmail routine, I find
 that I do not have Mail/sendmail.pm file.
 (It was not included in the download)
 Can you please help me by telling me where I can download it
 from.
 
 I work on a Windows XP professional box.
 
 Regards to all
 Michael
 
if you are using activeperl, then use ppm and search for
sendmail and load.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 
 --- Chas Owens [EMAIL PROTECTED] wrote:
  
   On 3/6/07, Chas Owens [EMAIL PROTECTED] wrote:
On 3/6/07, Michael Goopta [EMAIL PROTECTED] wrote:
 Hi
 I am very new to perl. I could download perl.exe for my
   PC. But
 I do not have the library modules, such as time.pm etc.

 For this reason, when I use any use  command (eg.
  use
 Time::localtime) the module is not found.

 Can anybody tell me the site where I can download the
   essential
 perl library modules.
snip
   
The Time::localtime is part of core Perl.  If you do not
   have it then
you do not have a proper installation of Perl.  Given the
   fact that
you refer to the executable as perl.exe I am guessing  you
   are using
some form of MS Windows.  You can download an installer
  for
   Windows
from ActiveState:
   
  
 
 http://downloads.activestate.com/ActivePerl/Windows/5.8/Active
 Perl-5.8.8.820-MSWin32-x64-274739.msi
   
   
   Whoops, that is the 64-bit version.  This the normal
  version:
  
 
 http://downloads.activestate.com/ActivePerl/Windows/5.8/Active
 Perl-5.8.8.820-MSWin32-x86-274739.msi
   
   -- 
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
   http://learn.perl.org/
   
   
   
  
  
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: what does a lone percent sign mean?

2007-03-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Tony Heal [mailto:[EMAIL PROTECTED] 
 Sent: Tuesday, March 06, 2007 10:43
 To: beginners@perl.org
 Subject: what does a lone percent sign mean?
 
 I am trying to determine how this does what it does.
 
  
 
 sub IsLeapYear
 
 {
 
my $year = shift;
 
return 0 if $year % 4;
 
return 1 if $year % 100;
 
return 0 if $year % 400;
 
return 1;
 
 }
 
  
 
 But I do not understand, and I can not find what a single, 
 lone % means.
 
  
 
 Anyone know?
 
  
 
 Tony
 
 
modulo which is use the remainder after division by the number. 

First is divide year by 4 so take 2007 / 4 which will give you a
remainder 3. So if 3 ( true ) then return 0. 

You can take the next two.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Compound variable names

2007-03-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 From: Kevin Viel [mailto:[EMAIL PROTECTED] 
 Sent: Friday, March 02, 2007 09:10
 To: beginners@perl.org
 Subject: Compound variable names
 
 Greetings,
 
I have been struggling with this one for a while.  How can 
 I create a 
 variable name composed of two or more variables?  I suspect I 
 have to I 
 have to use a reference:
 
 my $var1 = part ;
 my $var2 = 2;
 
 my $compound = $var1_$var2 ;
 
 Thanks,
 
 Kevin
 
 
 -- 
 Kevin Viel
 Department of Genetics   [EMAIL PROTECTED]
 Southwest Foundation for Biomedical Research phone:  (210)258-9884
 P.O. Box 760549  fax:(210)258-9444
 San Antonio, TX 78245-0549
 
 Kevin Viel
 PhD Candidate
 Department of Epidemiology
 Rollins School of Public Health
 Emory University
 Atlanta, GA 30322
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

Setup a hash and use the combined variable names as the key.
Control the case as you create and read and you are in the control seat
then.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 

 -Original Message-

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: print if variable matches key

2007-02-28 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Brian Volk [mailto:[EMAIL PROTECTED] 
 Sent: Wednesday, February 28, 2007 12:24
 To: Brian Volk; beginners@perl.org
 Subject: RE: print if variable matches key 
 
 
 
  -Original Message-
  From: Brian Volk [mailto:[EMAIL PROTECTED]
  Sent: Wednesday, February 28, 2007 1:34 PM
  To: beginners@perl.org
  Subject: print if variable matches key
  
  Hello,
  
  
  
  I'm trying to print a tab delimited file based on a colon 
 separated file
  matching a key in %hash.  I've attempted a few different 
 things w/ the
  colon separated file (splitting it into to variables, 
 making it %hash2)
  but I'm not having any luck.
  
  
  
  I'm trying to match up a text file, created from an email 
 form, into the
  correct tabbed column. The %hash contains all the fields 
 possible that
  could come over in the emailed form... the email (text file) only
  contains fields that were completed.
  
  
  
 [Brian Volk] Sorry to respond to my own post... but I think 
 I'm getting
 closer... The file is printing okay...I just need to know how 
 to print a tab
 if the $emailField is not in EMAIL ...I guess that is the 
 tricky part. :-)
 I should probably sort to keep the same field order... 
 [Brian Volk] 
 
 my $email = c:/brian/AX/vendor/email_file_new_less.txt; 
 open(EMAIL, $email) or die Can't open the $email: $!\n;
 
  
 while(EMAIL){
 chomp $_;
 my($emailField, $emailValue) = split(/\:/,$_);
 if (exists $hash{$emailField}) { 
 print NEW $emailValue \t;
 } else {
 print NEW blank \t;
   }   
 }
 
 Any pointers would be greatly appreciated.
 
 Thanks!
 
 Brian 
 
I am jusmping into the middle, so not real certain on what the
output looks like, but the problem comes from what a\t does under the
current shell setup you are using. If you print $emailValue and it is 20
characters plus \t will not look the same if you print 5 characters plus
a \t. You could use printf and then size appropriately and \t will do
what you want.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE:

2007-02-26 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 -Original Message-
 From: Matt Herzog [mailto:[EMAIL PROTECTED] 
 Sent: Monday, February 26, 2007 12:28
 To: Begin Perl
 Subject: $.: 
 
 What does $.: mean?
 -- 
 Ubuntu eh? I'm not really into Pokemon.
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/
 
 
 

The current input line number of the last filehandle read.


  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 
 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Deleting hash keys, but ending up with other keys

2007-02-17 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I have two hashes and each is made up of two keys. One has only
a numeric value and the the second one has the detail. If I find out
that I have right situation, I change the numeric value in the first
hash. I have done data dumper where I create the hash and as I update
the hash value and everything looks like I would expect it. 
 
So I decided to delete the keys from hash 1 and 2 if the numeric
value on hash 1 is not what I want. I print this out with Data::Dumper
and I have hash setup I am not understanding.

Here is a portion of Data::Dumper:
  'VNM' = {
'LVR' = 9,
'NVN' = 9
  },
  'BKF' = {
'FTV' = 9,
'SVX' = 1,
'SYO' = 9,
'BMT' = 9
  },

but after I get done,it would look like this:

  'VNM' = {},
  'BKF' = {
'SVX' = 1,
  },

Here is the code which is doing the delete. I am getting the
right output I need to work with, but I don't understand the {} entries:

foreach $MyPrtKeya ( keys %{$MyVPEPRelationships} ) {
foreach $MyPrtKeyb ( keys
%{$MyVPEPRelationships-{$MyPrtKeya}} ) {
next if (
$MyVPEPRelationships-{$MyPrtKeya}{$MyPrtKeyb} == 1 );

delete($MyVPEPMTs-{$MyPrtKeya}{$MyPrtKeyb});
 
delete($MyVPEPRelationships-{$MyPrtKeya}{$MyPrtKeyb});
}
 }  

The code is run under strict and warnings and I get no warnings
etc.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**



RE: pattern match

2007-02-12 Thread Wagner, David --- Senior Programmer Analyst --- WGO

 -Original Message-
 From: Vladimir Lemberg [mailto:[EMAIL PROTECTED] 
 Sent: Monday, February 12, 2007 12:33
 To: beginners@perl.org
 Subject: pattern match
 
 Hi,
 
 I have a script, which suppose to find all *.xml files under 
 the specified directory then process them.
 I'm facing the pattern match problem:
 
 use strict;
 use warnings;
 use Win32;
 use File::Find;
 
 @ARGV = Win32::GetCwd() unless @ARGV;
 
 
 my @dirs;
 
 find (\FindXml, $ARGV[0]);
 
 sub FindXml 
 {
 return if !stat || -d;
 ( my $xml_file = $File::Find::name ) =~ /^.+\.xml$/;
 push ( @dirs, $xml_file );

Then only get the files you want by:

return if $File::Find::name !~ /^.+\.xml$/;
  push ( @dirs, $File::Find::name );

and push the  $File::Find::name

Wags ;)


 }
 
 In this examples the pattern match /^.+\.xml$/ is not working 
 and all files regardless of the extension have been assigned 
 to $xml_file variable.
 
 #
 
 However, if I change parenthesis to count the matching, the 
 pattern seems to work.
 
 sub FindXml 
 {
 return if !stat || -d;
 my $xml_file = ( $File::Find::name  =~ /^.+\.xml$/ );
 print $xml_file;
 }
 
 I'll be really grateful for any help here.
 
 Thanks in advance,
 Vladimir
 
 
 
 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: while loop problem

2007-01-31 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Brad Cahoon wrote:
 Hi Perl Masters
 
 I have a problem with a script which is suposed to open a huge text
 file and take 70 lines, create a file, then take the next 70 lines
 create a file and so on until it has parsed the whole file. My code
 just doesn't work and my brain cannot figure out while{while{}} loops
 Help please.
 
 Thanks
 Brad
 
 
 Code:
 
  #!  /usr/bin/perl
 
 my $input = 'test12.txt';
 my $end= '.txt';
 my $fileno=1;
 my $lineno=1;
 open BIG, test12.txt, or die can't $!;
 
 while (BIG) {
 
 print $lineno;
 $newfile = $fileno$end;
 $fileno++;
 open  NEW  , $newfile;
 
 while ($lineno  71){
 $lineno++;
 print NEW  $_;
 }}

There are number of things not quite right: Out loop read and inner
write loop, but only doing one read. Should close after writing the
file.
Here is a sample that I put together. Also should use warnings and
strict. Also no error checks on the open.

#!  /usr/bin/perl

my $input = 'test12.txt';
my $end= '.txt';
my $fileno=1;
my $lineno=1;
#open BIG, test12.txt, or die can't $!;
my $newfile;
my $MyWrkLoc = q[output location for the files];

opensub();

while (DATA) {

if ( $lineno = 71 ) {
close NEW;
opensub();
 }
print NEW  $_;
$lineno++;
 }

sub opensub {
$newfile = sprintf %09d%s,
$fileno++,
$end;
open  NEW  ,q[] . $MyWrkLoc . $newfile;
$lineno = 1;

 }
Should get you farther
  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Trying to re-arrange output of email with a list of items

2007-01-25 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I currently have  data for group1 which has x entries associated
with it. As I currently put out the email, the data is going down the
page. Well with the data being displayed, I thought why not have all on
same line like following:

EE Eenural   148ED Easuern   185NO Noruhern   49
YO Youuhern  185

   EGI 4   DQE 4   DYE 8
DNG 8
   FRO15   DEN49   EUG 4
FTD84
   NOD 2   LVY43   NED 1
GDR 4
   ODK43   PGX45   POR25
IVN28
   PET 4   YLE45   YED 5
LOY14
   RNO28   TUE 4   YPO 5
OTN 1
   YDE15   TDE 2
OXN 8
   YDL 2
YDO 5
   YJE18
YFV 8
   YLO 1
WGT43
   YTK21   

Under the old display, ED would have been under EE and NO would
have been under ED, etc.

There could be anything from 1 to 4 groups of data and the sizes
can be of any finite size. The data is in a hash with totals and EE
grouping has each of its subgroups(EGI FRO, etc) as a semi-colon
separated list. The subgroups have hashes which hold the counts in them.

I am at loss at how to proceed. I start one way and then it just
seems to get TOO complicated and it may be hard, but  it shouldn't cause
the brain to freeze, I would think.

Line 1 of EE, ED seems pretty easy, but how to do a variable
size print and keep the columns lined up?

Any thoughts on it would be greatly appreciated.

I do NOT have any code at this point, but am trying to get
handle on how to re-arrange or  the data to print out.

 Thanks for any input!!

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**



Trying to read two files using a sub to get the data, but 2nd read on the 2nd file goes to EOF

2007-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Here is a snippet of the code:
my $MyFileHand;
my $MyFileHand1;

open($MyFileHand,$MyFileIn)   || diet (3, $MyFileIn, $!);
open($MyFileHand1,$MyFileIn1) || diet (3, $MyFileIn1, $!);



proc_getrcd( $MyFileHand , $MyEOFProd, $MyWorkp, $MyInp ,
$GlblInfo{compcnt}, $MyUnpackSw );
proc_getrcd( $MyFileHand1, $MyEOFTest, $MyWorkt, $MyInt ,
$GlblInfo{compcnt}, $MyUnpackSw );
 

Subroutine being called:
sub proc_getrcd {
#0  1   2 3 4  5
my ( $MyFileHand, $MyEOF, $MyWork, $MyIn, $MyRunningCnt, $MyUnpack )
= @_;

return if ( $MyEOF );

my $MyData = $MyFileHand;
if ( ! defined $MyData ) {
$_[1] = 1;
printf EOF hit on read: %7d\n,
$MyIn;
return;
 }
 
$_[3]++;
$_[4]++;

chomp($MyData);

$MyData =~ s/[[:cntrl:]]/ /g if ( $MyData =~ /[[:cntrl:]]/ );

if ( $MyUnpack ) {
@{$MyWork} = unpack($GlblInfo{unpackv},$MyData);
 }
 else {
$MyWork-[0] = substr($MyData,10,16);
$MyWork-[1] = substr($MyData,1126,10);
$MyWork-[0] =~ s/\s+//g;
 }

 }  # end of proc_getrcd
 
I have three main subs that I am using to print and then compare
the data:

sub 1   reads the first 10 rcds of the Test file and
prints out the data
sub 2   reads the first 10 rcds of the Prod file and
prints out the data
  Now these subs use the the same above sub, but is doing the
unpack into the passed array. I have checked the output in the different
elements and they are different in value and the key for each record is
there so I know it has gottent the next rcd.

sub 4   is the compare and reading of both files, but always
ends up only doing the read

Know I am mssing something very basic, but escapes me.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**



RE: Trying to read two files using a sub to get the data, but 2nd read on the 2nd file goes to EOF

2007-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I am just trying to read text files which are delimited by a
regular end of line. I usually only read one file at a time, but thought
it should not be that big a thing to have two file handles open and pass
the filehandle to the sub.

Can I not ready two different text files at the same time using
two different filehandles?


  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Tom Phoenix
Sent: Tuesday, January 23, 2007 11:51
To: Wagner, David --- Senior Programmer Analyst --- WGO
Cc: Beginner Perl
Subject: Re: Trying to read two files using a sub to get the data, but
2nd read on the 2nd file goes to EOF

On 1/23/07, Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:

 $MyData =~ s/[[:cntrl:]]/ /g if ( $MyData =~ /[[:cntrl:]]/ );

Why the if clause?

I'm not sure I understand your difficulty. But it sounds as if you're
not using seek() (or something similar) to get back to the correct
data position in your file, when you call your subroutine the second
time. If that's not it, can you identify which line of code isn't
doing what you think it should?

Hope this helps!

--Tom Phoenix
Stonehenge Perl Training

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Trying to read two files using a sub to get the data, but 2nd read on the 2nd file goes to EOF

2007-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
It is two different files. Sub1 and sub2 read from 1 file for 10
rcds and then closes the files and goes on to the next sub? If I have
two different filehandles pointing at two different files, why would I
have to do a seek? I am just trying to read two text files at the same
time and determine if key fields are equal or not. If not, then
determine the lower of the two, add the numeric field, read the next rcd
from this file and go back to top of the loop again and start the
compare process over.


  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Tom Phoenix
Sent: Tuesday, January 23, 2007 12:03
To: Wagner, David --- Senior Programmer Analyst --- WGO
Cc: Beginner Perl
Subject: Re: Trying to read two files using a sub to get the data, but
2nd read on the 2nd file goes to EOF

On 1/23/07, Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:

 I am just trying to read text files which are delimited by a
 regular end of line. I usually only read one file at a time, but
thought
 it should not be that big a thing to have two file handles open and
pass
 the filehandle to the sub.

 Can I not ready two different text files at the same time
using
 two different filehandles?

What you describe should be possible.

How are you relocating the file position to the correct place in the
file, when you wish to re-read the data after the first time? Does the
subroutine use seek(), or is it the caller's responsibility?

--Tom Phoenix
Stonehenge Perl Training

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: Trying to read two files using a sub to get the data, but 2nd read on the 2nd file goes to EOF

2007-01-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Sorry, but it was a logic problem and onthing else.

I apologize for missing it, but I did.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, January 23, 2007 12:13
To: Tom Phoenix
Cc: Beginner Perl
Subject: RE: Trying to read two files using a sub to get the data, but
2nd read on the 2nd file goes to EOF

It is two different files. Sub1 and sub2 read from 1 file for 10
rcds and then closes the files and goes on to the next sub? If I have
two different filehandles pointing at two different files, why would I
have to do a seek? I am just trying to read two text files at the same
time and determine if key fields are equal or not. If not, then
determine the lower of the two, add the numeric field, read the next rcd
from this file and go back to top of the loop again and start the
compare process over.


  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of
Tom Phoenix
Sent: Tuesday, January 23, 2007 12:03
To: Wagner, David --- Senior Programmer Analyst --- WGO
Cc: Beginner Perl
Subject: Re: Trying to read two files using a sub to get the data, but
2nd read on the 2nd file goes to EOF

On 1/23/07, Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:

 I am just trying to read text files which are delimited by a
 regular end of line. I usually only read one file at a time, but
thought
 it should not be that big a thing to have two file handles open and
pass
 the filehandle to the sub.

 Can I not ready two different text files at the same time
using
 two different filehandles?

What you describe should be possible.

How are you relocating the file position to the correct place in the
file, when you wish to re-read the data after the first time? Does the
subroutine use seek(), or is it the caller's responsibility?

--Tom Phoenix
Stonehenge Perl Training

**
This message contains information that is confidential and proprietary
to FedEx Freight or its affiliates.  It is intended only for the
recipient named and for the express  purpose(s) described therein.  Any
other use is prohibited.
**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




RE: How to pull Text from a PDF using Perl?

2007-01-05 Thread Wagner, David --- Senior Programmer Analyst --- WGO
-Original Message-
From: Dave Gray [mailto:[EMAIL PROTECTED] 
Sent: Thursday, January 04, 2007 17:01
To: beginners@perl.org
Cc: Wagner, David --- Senior Programmer Analyst --- WGO
Subject: Re: How to pull Text from a PDF using Perl?

On 1/4/07, Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
 I need to look at the text from page 1 of a couple of thousand
pdf's and do a regex on searching for the data.
 Before sending I tried a number of other things, but either
died or showed me data like the above.

 Any insight or simple script which will display the text would
be greatly appreciated.

I had to do this the other day and got frustrated with the modules I
found and ended up using pdftotext which comes with xpdf, like so:

  my @pages = split /^L/, `$pdftotext -layout $inputfile -`;
  for my $page (@pages) {
# do stuff
  }

Without the -layout switch, parsing any sort of tabular data becomes a
lot more annoying.

Cheers,
Dave
-

Thanks much, David. I searched on internet and found the
download site. Brought it down and unzipped. Then made a initial run and
it got the data expected. Now will give it try on a larger scale.

I aprpeciate the time and response.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




How to pull Text from a PDF using Perl?

2007-01-04 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I have tried both PDF::API2 and CAM::PDF and I must be misunderstanding how to 
use these modules. Here is the way I attempted using CAM::PDF

Source portion:
…
use CAM::PDF;


$MyPDF = CAM::PDF-new($MyFileIn); # a PDF file which has text

$MyPDFPgCnt = $MyPDF-numPages();

my $contentTree = $MyPDF-getPageContentTree(1);
$contentTree-render(CAM::PDF::Renderer::Text);

I get a lot of blank lines and the characters I do get, look like:

 3 U L Q W ♥ ' D W H ↔ ♥ ¶ § ↕ § § ↕ § ‼ ‼ ↓


K L O G ♥ $ F F R 
X Q W V
7 L P H ↔ ♥ ¶ § ↔ ¶ ∟ 3 0
I need to look at the text from page 1 of a couple of thousand pdf's 
and do a regex on searching for the data.
Before sending I tried a number of other things, but either died or 
showed me data like the above.

Any insight or simple script which will display the text would be 
greatly appreciated.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**



RE: line position

2006-11-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 If you provide some data and/or what you have attempted, it will go
much farther in getting some assistance. Otherwise the list is guessing
at what you are really trying to do.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 09:38
To: beginners@perl.org
Subject: line position

All,

I need to parse lines from a file and at a certain position test to see
if it is what a want, if so I need to grab information from other
positions in the line and drop it into a file.  As I have never done
this before, can someone point me in the right direction as to get
started?

Thanks for the help!
Tim

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: line position

2006-11-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
So what makes up a line? CME through the next CME? You can
concatenate all the data together if desired( do a chomp first) and
check if CME or What denotes the next rcd? Then you could either do a
equal(ie, 
  if ( next rcd ) {
if ( substr($MyData,70,2) eq q[xx] ) {
# now pull what I need, place in another file or
print
 }
$MyData = q[]; # clear the buffer and get ready for next
data
   }

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 10:30
To: Wagner, David --- Senior Programmer Analyst --- WGO;
beginners@perl.org
Subject: RE: line position

Here is an example of the lines I am reading in below.  This is one
continuous line.  I need information from positions 70-71, if they match
what I want then print that and position 92(also sub-positions C,P,D).

Being that I have never had to do this before I'm not sure what to use
to step me through this file to get the information that I need.

Tim

CME008885071BIOH72006102816122900MO002006091415300020070316083000BQB
IOH7   FE 50





11 00 00USD1
00010500USD 00 00100100
200610271008258000860800079080
BQF6
000137501605F00 00  F
0002400 1BQ  101100
00 0050200703BIO
0102000500201E00
000

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 12:16 PM
To: Tim Wolak; beginners@perl.org
Subject: RE: line position

 If you provide some data and/or what you have attempted, it will go
much farther in getting some assistance. Otherwise the list is guessing
at what you are really trying to do.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 09:38
To: beginners@perl.org
Subject: line position

All,

I need to parse lines from a file and at a certain position test to see
if it is what a want, if so I need to grab information from other
positions in the line and drop it into a file.  As I have never done
this before, can someone point me in the right direction as to get
started?

Thanks for the help!
Tim

**
This message contains information that is confidential and proprietary
to FedEx Freight or its affiliates.  It is intended only for the
recipient named and for the express  purpose(s) described therein.  Any
other use is prohibited.
**




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: line position

2006-11-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
If it is only one line and it is record separator is carriage
return as defined by your system, then a simple loop like:

while: ( MYFILEIN ) { 
chomp;
if ( substr($_,70,2) =~ /(xx|xy|xz)/I ) {
# substr starts at zero vs 1
print MYFILEOUT substr($),70,2) .
Substr($_,91,1) . \n;
 }
 }

simple format and should be straight forward.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 11:05
To: Wagner, David --- Senior Programmer Analyst --- WGO;
beginners@perl.org
Subject: RE: line position

The whole thing below is the line, its just word wrapped in scrt.  I
can't concatenate it because everything is in a specific position for
what I need.  Is the seek module what I need to be using?  I just need
to collect the two characters in position 70 and 71, test if they are
GE,E$,E0,etc.. If they are then I need the data from position 92 and
write the line to a file that consists of positions 70-71 and position
92, then go on to the next line.

Tim

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 12:49 PM
To: Tim Wolak; beginners@perl.org
Cc: Wagner, David --- Senior Programmer Analyst --- WGO
Subject: RE: line position

So what makes up a line? CME through the next CME? You can
concatenate all the data together if desired( do a chomp first) and
check if CME or What denotes the next rcd? Then you could either do a
equal(ie, 
  if ( next rcd ) {
if ( substr($MyData,70,2) eq q[xx] ) {
# now pull what I need, place in another file or
print
 }
$MyData = q[]; # clear the buffer and get ready for next
data
   }

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 10:30
To: Wagner, David --- Senior Programmer Analyst --- WGO;
beginners@perl.org
Subject: RE: line position

Here is an example of the lines I am reading in below.  This is one
continuous line.  I need information from positions 70-71, if they match
what I want then print that and position 92(also sub-positions C,P,D).

Being that I have never had to do this before I'm not sure what to use
to step me through this file to get the information that I need.

Tim

CME008885071BIOH72006102816122900MO002006091415300020070316083000BQB
IOH7   FE 50





11 00 00USD1
00010500USD 00 00100100
200610271008258000860800079080
BQF6
000137501605F00 00  F
0002400 1BQ  101100
00 0050200703BIO
0102000500201E00
000

-Original Message-
From: Wagner, David --- Senior Programmer Analyst --- WGO
[mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 12:16 PM
To: Tim Wolak; beginners@perl.org
Subject: RE: line position

 If you provide some data and/or what you have attempted, it will go
much farther in getting some assistance. Otherwise the list is guessing
at what you are really trying to do.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 09:38
To: beginners@perl.org
Subject: line position

All,

I need to parse lines from a file and at a certain position test to see
if it is what a want, if so I need to grab information from other
positions in the line and drop it into a file.  As I have never done
this before, can someone point me in the right direction as to get
started?

Thanks for the help!
Tim

**
This message contains information that is confidential and proprietary

RE: line position

2006-11-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Sorry, but I was just giving quick code and had NOT run. Using
of strict and warnings is the only way to go. I was writing and doing
other things. I apologize for not catching, but was supplying the open
for th input or output, etc. just a inkling on what he could do to get
started. 

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: D. Bolliger [mailto:[EMAIL PROTECTED] 
Sent: Friday, November 03, 2006 14:19
To: beginners@perl.org
Subject: Re: line position

Wagner, David --- Senior Programmer Analyst --- WGO am Freitag, 3.
November 
2006 22:16:
   If it is only one line and it is record separator is carriage
 return as defined by your system, then a simple loop like:

Hello David and Tim,

The below code is a good example why one should happily place:

  use strict; 
  use warnings; 

at the beginning.

   while: ( MYFILEIN ) {

You meant: 

  while ( MYFILEIN ) {

   chomp;

Just omit the chomp and the code behaves the same.

   if ( substr($_,70,2) =~ /(xx|xy|xz)/I ) {

The modifier should be /i, not /I. With /I, the code doesn't even
compile.

If you want to use a regex, then it might be better to:
- anchor the pattern (not completely shure though if 
  that makes a difference *here*)
- stop the matching process immediately after the first char does 
  not match
- use non-capturing parenthesis (?:) to decrease the work 
  of the regex engine, since the matched string is not used
- Then, since the same substring is used below, it might (not shure) 
  be appropriate to store the extracted string into a variable 

That would leed to [untested]:

  if ( (my $s=substr($_,70,2)) =~ /^x(?:x|y|z)/i ) {

   print MYFILEOUT substr($),70,2) .

You meant '$_', not '$'.

  print MYFILEOUT $s . # see above alternative

 Substr($_,91,1) . \n;

You meant:

  substr ($_,91,1) . \n;

}
}

   simple format and should be straight forward.

Dani

[snipped top-posting history]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




Switching from FTP to SCP processing

2006-10-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I found out this week that within our organization, FTP will be
no longer allowed and that in its place, scp ( secure copy over SSH )
will take it's place. I have a couple of polling modules which use FTP
to look for trigger files in specific locations on remote machines. I
then ftp the data from these machines onto my Perl machine, process the
files and generate internal emails. All this is handled by Perl.

From my understanding of scp, one has login rights to the remote
machine and you login and work from there. At this point, I am lost in
how one would handle what I am doing now using this new method of
processing.

Any suggestions and/or examples on how one attempt to accomplish
a task like this?

Thanks.

  Wags ;)


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**



RE: More Info About $| = 1;

2006-10-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 
I copied and ran without the $|=1 and it displays the text What
is your name? and I enter na d it completes.

I tried both from the cmd.exe and a kornshell and both wroked
the same way.

Might it have something to do with Eclipse?

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Chris Share [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, October 18, 2006 15:54
To: beginners@perl.org
Subject: More Info About $| = 1;

Hi,

I'm a C programmer teaching myself Perl. I'm working on Windows XP using
ActivePerl and Eclipse (EPIC).

I've got a question about $| = 1;

If I run the following program:

#!/usr/local/bin/perl

use strict;
use warnings;

print What is your name? ;
my $name = STDIN;
chomp $name;
print Hello, $name!\n;

the command line does nothing until I enter some text, at which point
the program runs and outputs the following:

Test
What is your name? Hello, Test!

What I don't get is why the print statement doesn't execute?

If I add $| = 1; at the top of the program this fixes the problem and
the program runs as expected.

Could someone explain what's going on here, or point me to an
explanation.

Cheers,

Chris


--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
http://learn.perl.org/first-response



**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: grouppin in the regular expressions

2006-10-13 Thread Wagner, David --- Senior Programmer Analyst --- WGO
use !~ vs =~ which is if not so
if ( $line !~ /\(xxx\)/ ) {
# does not contain (xxx)
 }else {
# does contain
   } 

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: I.B. [mailto:[EMAIL PROTECTED] 
Sent: Friday, October 13, 2006 12:03
To: beginners@perl.org
Subject: grouppin in the regular expressions

Hi nice people,


how to specify using regular expressions: match everything but string
(xxx)

i would do this :

$line =~ /[^(xxx)]+/;

but, as it was mentioned before () inside character class is not
working.
what is solution here?

thank you!

~i

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Subroutine returning 2 arrays

2006-10-12 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 Believe you want to do as a reference otherwise it justs returns the
data as a flat file or stream of data.
Here is a snippet. Would get away from a and b since the $a and $b are
used by sort. Know that it is an array, but would get away from that.
Also use strict and warnings.

#!perl

use strict;
use warnings;

sub TEST
{
 my @c = (a1,a2,a3,a4,a5,a6,a7);
 my @d = (b1,b2,b3,b4,b5,b6,b7);
 return ([EMAIL PROTECTED], [EMAIL PROTECTED]);
}
 
my($lala,$baba) = TEST;
print @{$lala};
print \n\nNext array:\n;
print @{$baba};

Output:
a1a2a3a4a5a6a7

Next array:
b1b2b3b4b5b6b7

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Gallagher, Tim F (NE) [mailto:[EMAIL PROTECTED] 
Sent: Thursday, October 12, 2006 08:55
To: Perl Beginners
Subject: Subroutine returning 2 arrays

From a subroutine I would like to return 2 separate arrays like this
 
sub TEST
{
 @a = (a1,a2,a3,a4,a5,a6,a7);
 @b = (b1,b2,b3,b4,b5,b6,b7);
 return (@a, @b);
}
 
my(@lala,@baba) = TEST;
print @lala;
 
 
The problem is that @lala will return a1a2a3a4a5a6a7b1b2b3b4b5b6b7 and
@baba will return nothing. How can I return 2 arrays and have the info
look like this:
print @lala would return a1a2a3a4a5a6a7
print @baba would return b1b2b3b4b5b6b7
 
 
 

Thank you,


Tim


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: dates

2006-10-10 Thread Wagner, David --- Senior Programmer Analyst --- WGO
The same you your doing $year, $mon, $mday use %02d which tells
sprintf to add leading zeros as need to keep the size correct. So
\_$hour\:$min\:$sec becomes \_%02d\:%02d\:%02d and you add the $hour,
$min and $sec after the $mday.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: Tim Wolak [mailto:[EMAIL PROTECTED] 
Sent: Tuesday, October 10, 2006 11:55
To: beginners@perl.org
Subject: dates

Just a quick easy one, while printing localtime, how do I get it to
print the full minutes and seconds, i.e. :02??

Thanks,
Tim

my $date;
my ($sec,$min,$hour,$mday,$mon,$year) = (localtime) [0,1,2,3,4,5];
$year=$year+1900; $mon=$mon+1; $date =
sprintf(%02d%02d%02d\_$hour\:$min\:$sec, $year,$mon,$mday);


--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
http://learn.perl.org/first-response



**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Modules to extract calendar info from Exchange

2006-09-15 Thread Wagner, David --- Senior Programmer Analyst --- WGO
 
Can't answer the first, but on the second:

I send text messages to my ATT cingular phone using sendmail to
send the text. This gives me heads up when I have problems. Now I am
also starting sending to another phone number using cingular, but it is
a blackberry. This user receives the text, but it is messed up. I never
got around to correcting. For cinuglar node in my location, it is
@mmode.net and the other cingular is in Colorado and has a completely
different node ( @mobile.mycingular.com ).

It can be done and I have been running in this mode for 5 or
more years at least.

  If you have any problems or questions, please let me know.

 Thanks.

  Wags ;)
David R Wagner
Senior Programmer Analyst
FedEx Freight
1.408.323.4225x2224 TEL
1.408.323.4449   FAX
http://fedex.com/us 

-Original Message-
From: D. Bolliger [mailto:[EMAIL PROTECTED] 
Sent: Friday, September 15, 2006 13:26
To: beginners@perl.org
Subject: Re: Modules to extract calendar info from Exchange

Sorry:

  Is there a perl module(s) that can extract calendar infrom from an 
  MS Exchange server.  I need to extract appmnts, meetings, etc such
that I
  can SMS these message to a person(s) cellphone.   Which modules are
  available, and how easy is it?

 No idea (and no other answers)
[...]
... to your *second* post

Dani

--
To unsubscribe, e-mail: [EMAIL PROTECTED] For additional
commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
http://learn.perl.org/first-response



**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: get only filenames and not directory names under a specific path.

2006-07-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Nishi Bhonsle wrote:
 I tried it but didnt work.
  my @new;
 
   find(sub {push @new, $_}, $path);
find(sub {push(@new,$_) if ( !/^\.{1,2}/ ) }, $path);

If not 1 or 2 periods push on to @new;
Wags ;)
 
   open FILE,$logfile;
 
   print FILE $_\n foreach @new;
   close FILE;
 
 In addition to printing filenames and directories, it also printed
 the . The log file contained
 .
 file1.txt
 file2.txt
 
 How can I not include the . ?
 
 Thanks!
 
 -Nishi.
 
 On 7/21/06, Rob Dixon [EMAIL PROTECTED] wrote:
 
 Nishi Bhonsle wrote:
 Hi:
 I am starting a new thread based of an older thread just because
 there was a lot of different things that were requested for and it
 had gotten a bit confusing. 
 
 I got a lot of help from all you experts to write the below code
 that takes an argument path C:\build\Sample\NewDir that contains--
 
 C:\build\Sample\NewDir\File1.txt
 C:\build\Sample\NewDir\File2.txt
 C:\build\Sample\NewDir\NewSubDirectory
 C:\build\Sample\NewDir\NewSubDirectory\11.txt
 
 and prints out the following into the output file --
 File1.txt
 File2.txt
 NewSubDirectory
 
 use strict;
 use warnings;
 
  my $path = $ARGV[0];
 
  opendir DIR, $path or die Can't open $path: $!;
 
  my @new = grep { $_ ne . and $_ ne .. } readdir DIR;  closedir
 DIR; 
 
  open FILE,c:/buildlist2.txt;
  print FILE $_\n foreach @new;
  close FILE;
 
 Can I modify the above code so that no directory name is printed in
 the ouputfile but only filenames are printed. ie File1.txt and
 File2.txt are printed in the output file without the
 NewSubDirectory printed in it? I am looking for some way that
 before getting the entries into the new array, i can remove the
 entries that stand for directory names. 
 
 I tried using find(sub {push @new, $_ if -f}, $path);  but that
 prints all the filenames under NewDir as well as NewSubDirectory
 together which is not what i need. For getting files under
 NewSubDirectory, I will issue a separate command with argument path
 as C:\build\Sample\NewDir\NewSubDirectory and hence this command
 does not work since it clubs files and directories and files within
 sub-directories. 
 
 I tried using find(sub {push @new, $File::Find::name}, $path); but
 that prints the directories and files along with their
 complete/absolute paths, which is not what i need.
 
 Just change it to
 
   find(sub {push @new, $_}, $path);
 
 Rob
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response



Wags ;)
WGO: x2224

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: get only filenames and not directory names under a specific path.

2006-07-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Wagner, David --- Senior Programmer Analyst --- WGO wrote:
 Nishi Bhonsle wrote:
 I tried it but didnt work.
  my @new;
 
   find(sub {push @new, $_}, $path);
 find(sub {push(@new,$_) if ( !/^\.{1,2}/ ) }, $path);
 
   If not 1 or 2 periods push on to @new;
 Wags ;)

Sorry I missed your directories being printed. Depending on whether you 
want to go into the other directories looking for files that will affect what 
you want to do.  If only the current directory and it's files, then I would use 
opendir and readdir. If going into other directories and pulling those files 
also then add:

and ! -d $_ to the if

Wags ;) 
 
   open FILE,$logfile;
 
   print FILE $_\n foreach @new;
   close FILE;
 
 In addition to printing filenames and directories, it also printed
 the . The log file contained
 .
 file1.txt
 file2.txt
 
 How can I not include the . ?
 
 Thanks!
 
 -Nishi.
 
 On 7/21/06, Rob Dixon [EMAIL PROTECTED] wrote:
 
 Nishi Bhonsle wrote:
 Hi:
 I am starting a new thread based of an older thread just because
 there was a lot of different things that were requested for and it
 had gotten a bit confusing. 
 
 I got a lot of help from all you experts to write the below code
 that takes an argument path C:\build\Sample\NewDir that contains--
 
 C:\build\Sample\NewDir\File1.txt
 C:\build\Sample\NewDir\File2.txt
 C:\build\Sample\NewDir\NewSubDirectory
 C:\build\Sample\NewDir\NewSubDirectory\11.txt
 
 and prints out the following into the output file --
 File1.txt
 File2.txt
 NewSubDirectory
 
 use strict;
 use warnings;
 
  my $path = $ARGV[0];
 
  opendir DIR, $path or die Can't open $path: $!;
 
  my @new = grep { $_ ne . and $_ ne .. } readdir DIR; 
 closedir DIR; 
 
  open FILE,c:/buildlist2.txt;
  print FILE $_\n foreach @new;
  close FILE;
 
 Can I modify the above code so that no directory name is printed in
 the ouputfile but only filenames are printed. ie File1.txt and
 File2.txt are printed in the output file without the
 NewSubDirectory printed in it? I am looking for some way that
 before getting the entries into the new array, i can remove the
 entries that stand for directory names.
 
 I tried using find(sub {push @new, $_ if -f}, $path);  but that
 prints all the filenames under NewDir as well as NewSubDirectory
 together which is not what i need. For getting files under
 NewSubDirectory, I will issue a separate command with argument path
 as C:\build\Sample\NewDir\NewSubDirectory and hence this command
 does not work since it clubs files and directories and files
 within sub-directories. 
 
 I tried using find(sub {push @new, $File::Find::name}, $path); but
 that prints the directories and files along with their
 complete/absolute paths, which is not what i need.
 
 Just change it to
 
   find(sub {push @new, $_}, $path);
 
 Rob
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 
 Wags ;)
 WGO: x2224
 
 **
 This message contains information that is confidential and
 proprietary to FedEx Freight or its affiliates.  It is intended only
 for the recipient named and for the express  purpose(s) described
 therein.  Any other use is prohibited.
 **



Wags ;)
WGO: x2224

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: array help

2006-07-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Sayed, Irfan (Irfan) wrote:
 Hi,
 
 I have written following line. but i am getting error
 
 my @test  = (/test , /playground);
 print @test;
 
 i am getting output as follows
 
 /test/playground
 
 i need the output in following fasion
 
 /test
 /playground
 
 can you please tell me what is wrong?
 
 Regards
 Irfan.

Change the print to :

print join(\n, @test);

Wags ;)
WGO: x2224

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: Rel help in array

2006-07-20 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Sayed, Irfan (Irfan) wrote:
 Hi,
 
 I have one array called as @array1 which has some data
 
 I have another @array2 which also has some data.
 
  now for each element / value of both these arrays i need to a run a
 specific command at a time , not one by one. means that for every
 element of both these arrays i have to run specific command , once
 that command is executed properly then again for second element /
 value of both the array i need to execute same command and so on .
 
   suppose that command is `ct lsreplica` .
 
   and the output of this command i need to save in another array.
 
  How do i achieve this.
 
  Please let me know.
 
  Regards
  Irfan.

use backticks into an array and save into a file or place into total array. 
With backticks you would get all the output generated and then can parse that 
if necessary:

my @myoutput = `ct lsreplica $myvar`;

Now @myoutput has the output of the backtick going against what was in 
$myvar.

A start.

Wags ;)
WGO: x2224

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: reg ex problem

2006-06-27 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Ryan Moszynski wrote:
 i have this string extracted from a text file i'm writing a program
 to process: 
 
  test_freq = 1.0001;
 
 and i have to extract the 1.0001
 
 i can't count on the whitspace being where it now is.
 
 I would like to change this line of perl
 
  $getTestFRQ =~ s/\D+//g;
 
 so that instead of killing all non digit characters, it will kill all
 non digit characters except for the period.
 
 How do i do this?
 
if ( /=\s*([\d\.]+)/ ) {
   $MyNbr = $1;
   }
  if always with a ; then
if ( /=\s*([^;\s]+)/ ) {
   $MyNbr = $1;
   }
 The first one would be my choice, but just a thought.
 thanks, ryan

Wags ;)
WGO: x2224

**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: reading a line at a time inefficient?

2006-05-16 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Bryan Harris wrote:
 If I'm reading in many-megabyte files, is it considered to be more
 efficient to read it into an array, then loop over the array?  Or is
 reading a line at a time okay?
 
Depends really on the size and what you trying to do. Almost all that I 
do, I read a line at time, but others will swallow in the file. Most of my 
regex's deal with single lines or a single line will start another set of 
sequences.

Wags ;)
 e.g.
 
 **
 while () {
   # do some process with each line
 }
 **
 
 or...
 
 **
 @lines = ;
 foreach (@lines) {
   # do some process with each line
 }
 **
 
 I realize the second will use more memory, but what's a few megabytes
 in today's computers?  I'm more worried about the OS having to go
 back to the disk a couple hundred-thousand times -- seems like it'd
 be hard on the disk. 
 
 TIA.
 
 - Bryan


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




RE: hash assign not working

2006-05-16 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Smith, Derek wrote:
 My hash creations are not working as I expected:  %hash = ( @mir,
 @mir2 );
 
 Why?
 
To populate a hash requires two fields: Key and data. What you are 
assuming is that it will take one from @mir and one from @mir2 which is a wrong 
assumption. Yes the second works because you do take the key and data, but one 
from each array.

Could do something like:

while ( @mir ) {
   $hash{shift(@mir)} = shift(@mir2);
   }

Did a quick test and does work.

Wags ;)

 But do work at %hash = ( $mir[0], $mir2[0] );
 
 
 
 Obviously I need the entire arrays and their associated key/value
 pairs, 
 and have tried various methods unsuccessfully from Programming Perl CD
 such as array of hashes.
 
 The end result for my key/value pair should look like
 
 
 
 Mirror copies   1   : /dev/vg00/lvol3
 
 
 
 Which is the printed output of the individual element assignment as
 %hash = ($mir[0],$mir2[0]);
 
 But cannot get %hash = (@mir,@mir2); to work.  Plz help.
 
 
 
 my (%hash,@mir,@mir2)= ();
 
 my ($key2,$value2)   = 0;
 
 foreach my $lv (@lvs) {
 
 push @mir = (grep /mirror/i, `lvdisplay $lv`);
 
 push @mir2 = (grep s/^LV Name\s*//, `lvdisplay $lv`);
 
 chomp (@mir,@mir2);
 
 }
 
 
 
 #%hash = (@mir,@mir2);   ## This does not work the
 way I expect, so I tried the foreach in the next line.
 
 foreach (@mir) {
 
 foreach (@mir2) {
 
 ($key2,$value2) = [ split ];
 
 $hash{$key2}= $value2;
 
 }
 
 }
 
 
 
 while (($key2,$value2) = each %hash) {
 
 #($key2,$value2) = [ split ];
 
 print $key2\t:$value2;
 
 }
 
 
 
 
 
 
 
 Derek Bellner Smith
 
 Unix Systems Engineer
 
 Cardinal Health Dublin, Ohio
 
 614-757-5000 Main
 
 614-757-8075 Direct
 
 614-757-8120 Fax
 
 [EMAIL PROTECTED]
 
 
 
 
 Cardinal Health -- Working together. For life. (sm)
 _
 
 This message is for the designated recipient only and may contain
 privileged, proprietary, or otherwise private information. If you
 have received it in error, please notify the sender immediately and
 delete the original. Any other use of the email by you is prohibited.
 
 Dansk - Deutsch - Espanol - Francais - Italiano - Japanese -
 Nederlands - Norsk - Portuguese - Svenska:
 www.cardinalhealth.com/legal/email  


**
This message contains information that is confidential and proprietary to FedEx 
Freight or its affiliates.  It is intended only for the recipient named and for 
the express  purpose(s) described therein.  Any other use is prohibited.
**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




  1   2   3   4   5   >