comparing file dates from different servers

2002-08-20 Thread shawn_milochik

Hi.  I'm new to Perl (just a couple of weeks).

I'm trying to write a script which will check the date of a local file,
compare it to a remote file (on another server on the same network), and
copy the local over if it is newer.  I'm currently using the 'stat'
function.  Here is part of the script:


#This is the source directory, where the file is built.
$sourceDir = 'c:\alldata\Godiva\slsmgtsp\rtsmarts';
$sourceFile = 'c:\alldata\Godiva\slsmgtsp\rtsmarts\rtsales.exe';
$sourceTimestamp =(stat($sourceFile))[9];

#This is the destination directory, where the file put for downloading
$destDir =  '\\170.230.133.17\c$\inetpub\wwwroot\emp\files';
$destFile = '\\170.230.133.17\c
$\inetpub\wwwroot\emp\files\rtsales.exe';
$destTimestamp = (stat($destFile))[9];

However, whenever I do this, the $destTimestamp comes back blank (null,
zero-length-string, I'm not sure).  I've resorted to copying the local file
into the directory where the script is kept each time I copy the file to
the server.  Then at each run, I compare the local source file with the
local file kept in the script directory:

#This is the local directory, where the script is kept.
$localDir = 'c:\alldata\Godiva\slsmgtsp\rtsmarts';
$localFile = 'c:\alldata\rtsmarts\rtsales.exe';
$localTimestamp =(stat($localFile))[9];

I compare $localTimestamp to $sourceTimestamp because comparing
$sourceTimestamp to $destTimestamp.  Is there a smarter way to do this?

By the way, this is COMPLETELY unrelated, but I received a really cool Perl
script with my latest issue of Linux Format magazine.  It will split a
large mp3 into smaller, individually playable mp3s.  (Useful:  I can split
my 500mb audiobook mp3s into 5mb pieces, so that I can listen on my cd/mp3
player.)  If anyone wants it, I'll e-mail it, or put up a link.  The file
was created by Sean M. Burke of CPAN.org.

Thanks,
Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: comparing file dates from different servers

2002-08-20 Thread shawn_milochik

Oops.  That was a typo.  The script does not have this error.

Shawn




   
  
matt.wasserman@
  
citrix.com To: Shawn Milochik/US/GODIVA/CSC@CSC, 
[EMAIL PROTECTED]  
   cc: 
  
08/20/2002 bcc:
  
10:06 AM   Subject: RE: comparing file dates from 
different servers  
   
  
   
  





Not for nothing, and I am no expert, but you have a space between c and $
in
your $destFile variable...

-Original Message-
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, August 20, 2002 9:56 AM
To: [EMAIL PROTECTED]
Subject: comparing file dates from different servers




$destFile = '\\170.230.133.17\c
$\inetpub\wwwroot\emp\files\rtsales.exe';




In the actual script, it reads:

$destFile = '\\170.230.133.17\c$\inetpub\wwwroot\emp\files\rtsales.exe';

I just wonder if there a problem because it's not retrieving the date/time
stamp from the other machine?  Something I read led me to believe that it's
possible that the epoch may be different on the two machines, but shouldn't
I get some kind of result back from the 'stat' function?


Thanks,
Shawn





**
This e-mail and any files transmitted with it may contain
confidential information and is intended solely for use by
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not
disclose its contents to others and delete it from your
system.

**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Is there a way to do cron on windows?

2002-08-20 Thread shawn_milochik

If you can write a Perl script to detect whether the program is running,
then to start it if it isn't, then you can run the Perl script in a loop,
using the 'sleep()' function to make it run every (up to you) seconds.

Just be aware that, if you use Task Scheduler in Windows, you will need to
schedule the job, then go into the GUI Task Scheduler interface, and tell
the script to "run as" a user with rights to do whatever it is you want to
do.  You will need to enter a password for that user.  Otherwise, when the
Task Scheduler launches the task, it will run as some kind of "system
user", who has basically no rights.  The task does NOT inherit the rights
of the user who scheduled the task.

Shawn




   

felix_geerinckx@h  

otmail.com   To: [EMAIL PROTECTED]

 cc:   

08/20/2002 10:16 bcc:Shawn Milochik/US/GODIVA/CSC  

AM   Subject: Re: Is there a way to do 
cron on windows?
   

   






on Tue, 20 Aug 2002 14:05:19 GMT, [EMAIL PROTECTED] (Daryl J.
Hoyt) wrote:

>  I am looking for a way to run something like a cron job on
>  windows.



Take your pick.

--
felix

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl on the AS/400

2002-08-20 Thread shawn_milochik

We have an AS/400 here at work, and we use IBM's Net.Data macro language
for server-side scripting.  I've done some searching in the Net.Data forum,
but I can't find documentation on how to set up Perl so that it can be
called from Net.Data.

A Net.Data function is written like this:

%MACRO_FUNCTION testFunction(){
(insert some tedious code here)
%}

To do an SQL statement, you must call @DTW_SQL:

%function (DTW_SQL) RptOpen(in StartDate){
select regon, SUM(salety), SUM(tranty), SUM(salely), SUM(tranly),
SUM(csalty), SUM(csally) from $(f_RetailSales2) WHERE slsdt=$(StartDate)
GROUP BY regon ORDER BY regon

%REPORT{
 (something to be done once, at the top)
%ROW{
 (something to be done for each row returned)
}
 (something to be done once, at the end)
   }

  (end of report block)

%}

Net.Data allows you to write code in a few other languages, including Perl.
It is done like this:

%function(DTW_PERL) TestPerlFunction(){
print "Hello\n";
%}

That stuff I know, but does anyone know what you have to do to the AS/400
web server in order for this to work?

Thank you,
Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: SQL question

2002-08-20 Thread shawn_milochik

No.  If you want to get the fields in a certain order from an SQL query,
you MUST do:
 select fieldname, fieldname, fieldname from table

As long as you're doing:
 select * from table

You're always going to get the fields in the order in which they exist in
the table.

Shawn




   

[EMAIL PROTECTED]  

is.uci.edu   To: [EMAIL PROTECTED] 

 cc: [EMAIL PROTECTED]

08/20/2002 03:16 bcc:Shawn Milochik/US/GODIVA/CSC  

PM   Subject: RE: SQL question 

   

   






Yes I want to have the columns come out in a sorted order without
specifying them like "select col1, col2, col3 from database" because I
have too many columns (close to 80).  Is there ways to select a table w/o
specifically telling the SQL server which ones I want?

Thanks!

Eric

On Tue, 20 Aug 2002, Bob Showalter wrote:

> > -Original Message-
> > From: Bob Showalter [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, August 20, 2002 2:24 PM
> > To: 'learn perl'; [EMAIL PROTECTED]
> > Subject: RE: SQL question
> >
> >
> > > -Original Message-
> > > From: learn perl [mailto:[EMAIL PROTECTED]]
> > > Sent: Tuesday, August 20, 2002 1:38 PM
> > > To: [EMAIL PROTECTED]
> > > Subject: SQL question
> > >
> > >
> > > Hi guys,
> > >
> > > just wondering how to sort the columns in order using SQL.
> > > Does anybody
> > > have any clue?  for instance, my column headings are [1] [3]
> > > [2] [4] [2],
> > > is there a way to SELECT the table with the columns sorted in order?
> >
> > Look at your database's SQL documentation under "ORDER BY"
>
> Hmm, I read that question as "sort the rows". But if you mean "How do I
get
> the columns to come out in a certain order?", that is controlled by the
> order in which you list them in your select clause.
>
> SELECT * FROM table will give you the columns in the order defined in the
> database. If you want a different order, you need to explicitly list the
> columns:
>
> SELECT col1, col3, col2, col4 FROM table
>


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Regex to split router ifDescr up

2002-08-21 Thread shawn_milochik

Oops, I think you confused me with someone else.  I did not ask this
question.

Shawn




   

[EMAIL PROTECTED]  

gTo: [EMAIL PROTECTED]

 cc:   

08/20/2002   bcc:Shawn Milochik/US/GODIVA/CSC  

04:43 PM Subject: Re: Regex to split router 
ifDescr up 
   

   






Shawn wrote:
>
> So, I have an interesting question and a bit of code. I didn't really
> know whether this was the right forum or not, but here goes.
>
> I have two goals I would like help with:
>   1. Optimize/simplify the regex
>   2. Recognize where the regex would produce false positives on some
>  ifDescrs which don't actually have a real hardware path
>
> Really, #1 is most befitting this mailing list, but if anyone wants to
> help with #2 that's great.
>
> For those of you who are famimliar, a cisco router's SNMP ifDescr can
> contain what i would describe as the hardware path of whatever interface
> you are querying. For example, "Ethernet1/0", "T3 3/0/2", "POS2/0/1".
> Juniper routers have a similar thing.
>
> Now, I have the following regex to split these up into four pieces.
> /^([^0-9]+)([0-9]+ |)([0-9]+\/[^\s]+)(.*)$/
> $1 : Is a required match of some non-numeric chars. This would
>  match "Ethernet", or the "T" in T3 or T1
> $2 : An optional match which would catch the "3 " in ifDescrs
>  like "T3 3/0/1"
> $3 : string starting with one or more numerics, then a "/", then
>  all non-whitespace
> $4 : the rest
>
> In all cases I've seen, the text before the hardware path will only end
> in a numeric char if there is a space terminating it. Hence, "T3 3/0/2"
> returning $3 == "3/0/2" and "Ethernet0/1" returning $3 == "0/1".
>
> Now, can anyone see how the regex could be simplified?

You can use \d instead of [0-9], \D instead of [^0-9] and \S instead of
[^\s].

/^(\D+)(\d+ |)(\d+\/\S+)(.*)$/



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: IDE's

2002-08-22 Thread shawn_milochik

Textpad, from www.textpad.com -- I use it for Perl, Javascript, ASP,
Net.Data, text, etc.  It has tons of features, allows you to have multiple
documents open at once, sytax highlighting (and you can make your own
syntax files), line numbers, and several other cool things.

Shawn




   

stan@projecti  

ons1.com To: [EMAIL PROTECTED]

 cc:   

08/22/2002   bcc:  

01:55 PM Subject: IDE's

   

   





I'm using Komodo from Active State and find it very slow when running code.
Can anyone recommend a Windows based app that provides an IDE that I can
run
perl code in?  I'm totally new to perl and would prefer not using notepad
to
write perl code and then using the dos window for output.  Any help?

Thanks,
Stan


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Printing perldocs

2002-08-27 Thread shawn_milochik

If you were to type:

perldoc -f chomp

to see the info you want, then try this:

perldoc -f chomp > chompdoc.txt

That will print the results to a text file, which you can read, print, etc.

Shawn




   
 
j.campbell@iop 
 
.kcl.ac.ukTo: [EMAIL PROTECTED]   
 
  cc:  
 
08/27/2002bcc: 
 
08:45 AM  Subject: Printing perldocs   
 
   
 
   
 




Hi all

Dumb question but... Does anyone know how to print a perldoc page displayed
in the Windows DOS prompt?

I can't seem to find the html version of a page I need to print.

Hope one of you can help
cheers
James


 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
James Campbell
Tel: +44-(0)20-7848-5111
Email: [EMAIL PROTECTED]
 =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

'Where shall I begin, please your Majesty?' He asked
'Begin at the beggining,' the King said gravely, 'and go on
till you come to the end: then stop.'

Lewis Carroll, Alice's Adventures in Wonderland.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: general confusion...

2002-09-03 Thread shawn_milochik

I am a beginner, so list members -- correct me if I'm wrong here, but I
think that the mathematical symbols (<>=) will only work with variables
containing numbers.  For strings, you have to use gt, lt, le, eq.  Hope
this is helpful.



Shawn




   

ametcalfe@bui  

ldview.com   To: [EMAIL PROTECTED]

 cc:   

09/02/2002   bcc:  

02:28 PM Subject: general confusion... 

   

   






I'm a MS and Java developer, trying to debug some perl code.

I'm generally confused over a few syntax issues

In the line:

   my $self = {
   LOCATION => {
  USERNAME => $options{user_field} || 'username',
  BILLING => $options{bill_field} || 'accounts',
  INACTIVE => $options{inactive_field} || 'inactive',
   },

All fields are strings.  I imagine "=>" is simply "equal or greater to",
but
I'm confused as to what this returns with strings...?

I'm also seeing code like:

  if ($self->{PRESENT}->{$self->{LOCATION}{INACTIVE}} &&
$user_data->{$self->{LOCATION}{INACTIVE}}
  ){
  .deletia.
  }

Again, what is the significance of "->" in this comparator?  Again, all
fields are strings.

Thanks,

_Am



--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




code to parse out HTML tags

2002-09-27 Thread shawn_milochik

I have some code that I've been working on.  I know it will be painfully
obvious to you that I'm not very experienced yet with Perl, because I know
I'm not taking advantage of the full text-processing power it has.  What I
want to do is to read an HTML file and find  all occurrences of an unclosed
tag, like a  without an .  So far, the code lets me know how many
tags aren't closed, but not which ones, which I think will be more
complicated, because I'll have to use some hashes to keep track every time
I enter a new  tag.

I'm not asking anyone to finish this functionality.  If someone can just
trim the fat to show me how to do better what I've completed so far, I'd
appreciate it.

Another thing I want to do soon is to be able to read an HTML file and
parse out contents of a drop-down box into a .CSV.

Example:


   first thing
   Fred
   rhyme


I'd like a Perl script to return a .CSV containing:

*
1, first thing
fred, Fred
Jack & Jill, rhyme
*
Can anyone point me towards the proper functions in Perl to read up on so
that I can:
1.  Get the value from the option, regardless of whether it is surrounded
by single quotes, double quotes, or nothing.
2.  Get the listing from between the  and  tags.

Thank you,
Shawn


Follows:  My code for the first question:


%%
Beginning of code
%%

#!/usr/bin/perl

open(FILE, @ARGV[0]);

@data = ;

$position = 0;  #Current position within the string I'm reading.
$tagCount = 0;  #number of tags found so far
$brhrInput = 0; #Number of tags with no closers (, , , ,
, etc...
$openFormatting = 0;#Number of $formattingTags which are openers 
$closeFormatting = 0;   #Number of $formattingTags which are closers 

foreach (@data){

$position = 0;
while ($position < length()){

s/(br|hr|input)/\U$1/gi;

if (substr($_, $position, 1) eq "<"){
# Increment by one
$tagCount ++;


#Checking for non-formatting tags (those which require not
closing tags)
if ((substr($_, $position, 4) eq "")||(substr($_,
$position, 4) eq "")||(substr($_, $position, 6) eq "\", \"
\" or \"


The Perl Journal Magazine -- any good?

2002-09-27 Thread shawn_milochik

Is this a good magazine for someone interested in Perl, or just for a
hard-core user who uses it every day?

Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl to download files from an AS/400 running OS/400 -- to replace Rumba software

2002-10-03 Thread shawn_milochik

Is there a Perl module which can be used to download files from an AS/400?
We are currently using Rumba software, and we don't want to install it on
the machine which we want to use for this project.

The Rumba software allows us to create a .rto file, which tells the program
the exact format we need the data in.  If we have to reformat the data with
Perl, then I suppose that that would be okay, but anything automatic is
better, since I'm kind of "toying" with Perl on the side, and nobody wants
me to spend much time on it (except for me).

Also, is there a module which simplifies writing to an existing Access 97
database?  I really don't know much about modules, as the only one I have
ever used
is Net::FTP.

Sorry if the questions are too beginnerish, but I'm still fairly
inexperienced with Perl.

Thank you,
Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Perl to download files from an AS/400 running OS/400 -- to replace Rumba software

2002-10-03 Thread shawn_milochik

I have the file downloading fine using FTP.  Now, I need to convert it from
(I believe) binary into ASCII characters.  I've been looking at 'binmode'
and 'stat $filename', but I don't get a response from 'print "File is
binary.\n" if -B;' and the 'binmode HANDLE' results in getting no output if
I try to print the file contents, instead of jibberish.

Could someone give me an actual example of a script which converts a binary
file to ascii?  Also, does anyone have an idea of what the proper delimiter
should be?  When I set a line of the file to a variable, I end up with a
total of 1 line.

Do I need a module for this?

Thank you,
Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Net::POP3

2002-10-08 Thread shawn_milochik

I was just playing with Net::POP3 this past weeked.  Here's a working
script.  It's not great, but I got the basics working, and you can mess
with it.

Shawn


#|/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\|
# Code
#|/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\|

#!/usr/bin/perl


#use Net::FTP;
use Net::POP3;
$result = undef;

print "Enter the server name:\n";
$popServer = ;

print "Enter your user name:\n";
$popUser = ;

print "Enter your password:\n";
$popPass = ;

chomp($popServer);
chomp($popUser);
chomp($popPass);


@message = undef;

$pop = Net::POP3->new($popServer);

$result = $pop->user($popUser);
print "POP3 logon successful.\n" if $result == 1;

$numMessages = $pop->pass($popPass);
print "Number of messages: $numMessages.\n\n";

if ($numMessages > 0){

   for ($x=1;$x<=$numMessages;$x++){

  $result = $pop->get($x);
  @message = @$result;

  print "\nInfo for message $x of $numMessages:\n";

  foreach $message (@message){

 print $message if $message =~ /subject:/i;
 print $message if $message =~ /from:/i;
  }
  print "\n\n";
   }
}



$result = $pop->quit();
print "POP3 logout successful.\n" if $result == 1;


#|/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\|
# End of Code
#|/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\||/-\|




**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Net::POP3

2002-10-08 Thread shawn_milochik

Thanks for the suggestions.  I'm pretty new to Perl, as you can tell.  I
came from Javascript most recently, and (sorry) Visual Basic.  I am a linux
user and fan, although I'm writing this from work, where I have to use
Windows.  I mainly posted this script to try to help the person who posted
a Net::POP3 question a couple of days ago.

Shawn




   

bigj@kamelfre  

und.de   To: [EMAIL PROTECTED]

 cc:   

10/08/2002   bcc:  

02:14 PM Subject: Re: Net::POP3

   

   





Shawn Milochik wrote:

> I was just playing with Net::POP3 this past weeked.  Here's a working
> script.  It's not great, but I got the basics working, and you can mess
> with it.
>


It's a nice script, the only things that could be improved is to write
it more Perlish :-)


> #!/usr/bin/perl


use strict;
use warnings;


> #use Net::FTP;
> use Net::POP3;
> $result = undef;


Define the variables where you need them.


> print "Enter the server name:\n";
> $popServer = ;
>
> print "Enter your user name:\n";
> $popUser = ;
>
> print "Enter your password:\n";
> $popPass = ;
>
> chomp($popServer);
> chomp($popUser);
> chomp($popPass);



You could also write a little bit  shorter way with
print "Enter the server name:\n";
chomp( my $pop_server =  );






> @message = undef;
>
> $pop = Net::POP3->new($popServer);
>
> $result = $pop->user($popUser);
> print "POP3 logon successful.\n" if $result == 1;


Or
$pop->user($popUser) or die "POP3 logon wasn't succesful";


>
> $numMessages = $pop->pass($popPass);
> print "Number of messages: $numMessages.\n\n";
>
> if ($numMessages > 0){


It's also enough to ask for messages :-):
if ($num_messages) { ...


>
>for ($x=1;$x<=$numMessages;$x++){


foreach my $x (1 .. $num_messages) {


>   $result = $pop->get($x);
>   @message = @$result;


 my @msg_line = @{$pop->get($x)};


>
>   print "\nInfo for message $x of $numMessages:\n";
>
>   foreach $message (@message){
>
>  print $message if $message =~ /subject:/i;
>  print $message if $message =~ /from:/i;
>   }


Or
print grep {/subject:/i || /from:/i} @message;


>   print "\n\n";
>}
> }
>
>
>
> $result = $pop->quit();
> print "POP3 logout successful.\n" if $result == 1;


$pop->quit or die "POP3 logout didn't succeed\n";


Cheerio,
Janek


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Odd and even numbers

2002-10-09 Thread shawn_milochik

$x++ if $x%2;

This increments $x if $x is odd.

Shawn




   
  
robert.zielfelder@tycoelect
  
ronics.com To: [EMAIL PROTECTED]  
  
   cc: 
  
10/09/2002 10:58 AMbcc:
  
   Subject: Odd and even 
numbers 
   
  




Greetings,

I am trying to write a script that at one point needs to look at a number
and divide it by two.  The results must always be an integer, but the
numerator can potentially be an odd number.  What I want to do is if the
numerator is odd, increment it to the next highest even number.  Is there a
function in PERL that will allow me to test weather or not an integer is
odd
or even so that I can increment the number before I do the division?

Rz


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Using Perl to write to an Access 97 database (*.mdb)

2002-10-11 Thread shawn_milochik

Is there a module for this?  I have some comma-separated files I need to
input to an Access 97 format mdb.  I do not need to define any tables or
anything -- just pump data into an existing structure.

Thank you,
Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Using Perl to write to an Access 97 database (*.mdb)

2002-10-11 Thread shawn_milochik

By the way, I've already looked around search.cpan.org, and I couldn't find
anything.  Possibly due to the fact that there are about 500 modules which
include the word "access" in the name.  If you know of a specific module,
please send me a link or the name.  "Try cpan" will not help this time.

Thank you again,
Shawn




   
  
shawn_milochik@godi
  
vachoc.com To: [EMAIL PROTECTED]  
  
   cc: 
  
10/11/2002 03:19 PMbcc:
  
   Subject: Using Perl to write to an 
Access 97 database (*.mdb) 
   
  




Is there a module for this?  I have some comma-separated files I need to
input to an Access 97 format mdb.  I do not need to define any tables or
anything -- just pump data into an existing structure.

Thank you,
Shawn





**
This e-mail and any files transmitted with it may contain
confidential information and is intended solely for use by
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not
disclose its contents to others and delete it from your
system.

**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]






-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: good text editor

2002-10-23 Thread shawn_milochik

Textpad (www.textpad.com) is great.  It's not free, but it does have syntax
highlighting and you can modify/create your own syntax rules.  Multiple
documents open at once, great find/replace and "find in files" features.

If anyone knows of a free text editor with customizable syntax
highlighting, I'd like to know about it.

Shawn




   

  mkubis22@hotmail 

  .com To:  [EMAIL PROTECTED] 

   cc: 

  10/22/2002 07:58 bcc:

  PM   Subject: good text editor   

   

   





Can someone recommend a good text editor for perl cgi scripting? I've been
using notepad, but was wondering if there is something a little better but
still simple like notepad. I wanted to change the background color (I heard
green is friendlier to the eyes) and be able to see the line numbers.

Thanks,
Mariusz

ps. Nice if it doesn't use too much resources.







**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: How to run -- some notes

2002-10-23 Thread shawn_milochik

I have Active Perl installed on Windows 2000, and to run the script, I only
need to type "script.pl".  "perl script.pl" works also, but isn't
necessary.  On a Windows NT machine I have found that, when using the 'at'
command to schedule a script, I can't use "perl script.pl" or it fails --
"script.pl" works, though.

Shawn




   

  [EMAIL PROTECTED] 

   To:  [EMAIL PROTECTED], 
[EMAIL PROTECTED] 
  10/23/2002 05:38 cc: 

  AM   bcc:

  Please respond   Subject: RE: How to run 

  to beau  

   

   





Hi -

1) get ActiveState perl at http://www.activestate.com/Products/ActivePerl/
click the download button at the upper left, follow the
instructions, use the defaults - easy, fast, simple.

2) normally use the extension .pl for perl scripts.

3) to run your script, open a command prompt and type

perl myscript.pl [arguments...]

ActiveState also has a mailing list for win32/ActivePerl
users.

Welcome to the wonderful world of Perl!

Aloha => Beau.

-Original Message-
From: Sent To [mailto:sento@;mail.com]
Sent: Tuesday, October 22, 2002 3:08 PM
To: [EMAIL PROTECTED]
Subject: How to run


Hi

How can I run perl scrip on windows?
Is ther any software I need to install and what file extension should i
use?
Thanks

regards
sentor
--
__
Sign-up for your own FREE Personalized E-mail at Mail.com
http://www.mail.com/?sr=signup


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]








**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: Looking for some Documentation

2002-10-23 Thread shawn_milochik

Chris,

I'm still new to Perl, but here's some code that writes to an Access
database.  Maybe it will be a starting point.  You will need the
module 'DBD::ODBC', which you can find at search.cpan.org, or, if you have
ppm installed, run ppm and type "install DBD::ODBC".

You will also need to set up an ODBC connection to the Access database.  I
did this in Windows.  If you're trying to do it on another OS, then I don't
know how that is done.  Hope this is helpful.

Shawn


BEGINNING OF CODE

#!/usr/bin/perl




use DBI;

$data_source = "dbi:ODBC:rtsales";
$driver_name = "ODBC";

@driver_names = DBI->available_drivers;
@data_sources = DBI->data_sources($driver_name, \%attr);


$dbh = DBI->connect($data_source, $username, $auth, \%attr);


$log = "db_log.log";
if (@ARGV[0] ne ""){
$log = @ARGV[0];
}
open (LOG, ">>$log");


print LOG "Database write script launched.\n";

@inFile = ("rtstr", "rtslsd", "rtsal", "rtsales", "rtweek", "rtwhist",
"rtrates");

foreach $inFile (@inFile){

open (IN, "<$inFile" . ".csv") || die "Could not open $inFile.\n";


$count = 0;
$errors = 0;

print LOG "\nBeginning insert into table $inFile...   \n";

while (){
$_ =~ s/\'/\''/g;
$_ =~ s/\"/\'/g;
#$statement = "insert into rtstr
(regon,name,mangr,store,sname,design,area,smngr,sphon,smgr,sopen,sadd1,sadd2,scity,sstat,szipc)

values ($_)";
$statement = "insert into $inFile values ($_)";
$result  = $dbh->do($statement);
if ($result != 1){
print LOG "Result of $statement is: $result.\n";
$errors++;
}
$count++;
break;
}

print LOG "Completed insert of $count records into table $inFile,
$errors errors.\n";

close IN;

}

$statement = "UPDATE RTSAL INNER JOIN RTSALES ON (RTSAL.STORE =
RTSALES.STORE) AND (RTSAL.FISMM = RTSALES.FISMM) AND (RTSAL.FISYY =
RTSALES.FISYY) SET RTSAL.SALESTY = [rtsales].[salesty], RTSAL.SALESBUDTY
= [rtsales].[salesbudty]";
$result  = $dbh->do($statement);
print LOG "Result of $statement is: $result.\n";







$dbh->disconnect;
print LOG "Writing rttime.html now.\n";
$result = `rttime.pl`;
print LOG "Launching Epix & AS/400 FTPs now.\n";
$result = `epix_ftp.pl $log`;


END OF CODE




**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




How can I open and read two files at once in a loop?

2002-10-18 Thread shawn_milochik
I want to do something like this:




open (FIRSTIN, "<$FIRSTINFile");
open (FIRSTOUT, ">$FIRSTOUTFile");

open (SECONDIN, "<$rtsalFIRSTIN");
open (SECONDOUT, ">$rtsalFIRSTOUT");

while (){

 #assume $otherData would be the $_ from 

 print FIRSTOUT "$_\n";
 print SECONDOUT "$otherData, $_\n";

}

I have working code which opens two files (1 read, 1 write), then parses
the text from the file FIRSTIN to a particular format, then prints it to
the FIRSTOUT file.

I need to add to this the capability to open SECONDIN line for line with
FIRSTIN, and just print the same thing I took from SECONDIN to SECONDOUT,
along with a couple of pieces of data I have parsed from FIRSTIN.

I hope I have explained this well enough.

Thank you,
Shawn





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




parsing help (hex conversion, perhaps?)

2002-10-18 Thread shawn_milochik
I have a file which contains some hex data.  When I unpack it using "H", it
gives me what I want, almost.

Original file:
rtrates.rtrates

Perl Script:
rtrates.pl

Results:
rtrates.out

What the results are supposed to look like:
rtrates.txt

The problem I'm having is that although the first two fields come out fine
(one is a 2-digit number, and the other is a 4 digit number), the other
fields are odd.

Examples:

Number should be   unpack returns
..6700  8f00
..6800  8d00
..6900  8b00
..7000  7000
..7100  7100
..7200  7800
..7300  7900

I spent several hours on this yesterday.  I noticed that the '3' in 7300
becomes a '9', which is the square.  The '2' in 7200 comes out as an '8',
which is the cube.  No pattern there, though.  Both the pairs (7200 - 7800)
and (7300 - 7900) are a difference of 600, which doesn't happen in any of
the other pairs.  If the letters in the other numbers are hex, then how
come they increment by 2 instead of one ('b to d', instead of 'b to c' or
'b to a'?)  I even tried some old algebra from high school, and tried
(using the last two listed there) [7x + 9y = 7300] and [7x + 8y = 7200],
and solved for x and y, but got useless numbers as a result (at least, they
weren't whole numbers, so they seemed useless to me).

Does anyone have any ideas?  I've asked some of the AS/400 people here at
work (the original file comes from an AS/400, and is downloaded via FTP
using the ASCII formatting), and they don't know.  When I look at the
file's raw data on the AS/400 it looks the same as it does in the included
rtrates.rtrates file.

I know this is only peripherally related to Perl, but I know that there are
a lot of really talented people in this group, so I thought one of you
might have a magic answer.

Thank you,
Shawn


(See attached file: rtrates.txt)(See attached file: rtrates.pl)(See
attached file: rtrates.out)(See attached file: rtrates.rtrates)


Shawn
(Anything following this line is crap thrown in by my company's e-mail
system.  Please ignore it.  I hate e-mail footers that sound threatening.)


**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**




rtrates.txt
Description: Binary data


rtrates.pl
Description: Binary data


rtrates.out
Description: Binary data


rtrates.rtrates
Description: Binary data
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


Re: How can I open and read two files at once in a loop? -- Thanks, and also here's a snippet someone may fine useful...

2002-10-18 Thread shawn_milochik
Japhy:  Thanks very much for the answer.


Everybody:

I am working on a project which involves downloading files via FTP from an
AS/400, and I had to write a couple of functions because of the weird way
IBM does things.

The first function takes a value, and dependent upon the final character,
does something to it.


Rules:
1.  If it is a letter, the letter represents a specific decimal amount, and
the number is negative.
example: 4L = -3.7, or 6R = -6.3  <-- Note: these are not the actual
numbers corresponding to the letters, I have the sub figure that out.

2. The close curly-brace '}' denotes that the value is negative.
example: 4} = -4

3.  All numeric means that the final character is the decimal amount.
example 43 = 4.3

The second function checks to see if the final character is numeric.  If it
is not, the final character is a stand-in for a digit, and the entire
statement is negative.  Otherwise, the number stays as is.
examples:  345M = -3452, 5634 = 5634

Hope this is useful to someone.  If not, maybe someone already has a
resource for converting "mainframe" data types.  If they do, I'd like to
know about it.


sub parseFrom400 {
my $value = @_[0];
my $delimiter = substr($value, 3, 1);
if ($delimiter =~ /[0-9]./){
$value = substr($value, 0, 3);
}
if ($delimiter =~ /[J-R]/){
my $tempChar = ord($delimiter) - 73;
$value += ($tempChar/10);
$value = 0 - $value;
}else{
if ($delimiter eq "}"){
$value = 0 - $value;
}else{
$value = $value/10;
}
}

return $value;
}

sub parseFrom400_2 {
my $value = @_[0];
my $delimiter = substr($value, 7, 1);

if ($delimiter =~ /[J-R]/){
my $tempChar = ord($delimiter) - 73;
$value *= 10;
$value += $tempChar;
$value = 0 - $value;
}

return $value;
}

Shawn




   

japhy@perlmon  

k.orgTo: [EMAIL PROTECTED] 

 cc: [EMAIL PROTECTED]

10/17/2002   bcc:  

11:53 AM Subject: Re: How can I open and read two 
files at once in a loop? 
Please 

respond to 

japhy  

   

   





On Oct 17, [EMAIL PROTECTED] said:

>while (){
> #assume $otherData would be the $_ from 
> print FIRSTOUT "$_\n";
> print SECONDOUT "$otherData, $_\n";
>
>}

Like so:

  while () {
my $otherData = ;
print FIRSTOUT $_;
print SECONDOUT $otherData, $_;
  }

--
Jeff "japhy" Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
 what does y/// stand for?   why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: How can I open and read two files at once in a loop?

2002-10-18 Thread shawn_milochik
In my case, both files had an equal number of lines.  The both contained
comma-separated values to be imported into database tables.  One table
needed two additional fields which were contained in the second table.  I
had intended on opening both and appending the two fields I wanted.

In the end, I avoided doing this manually and executed a SQL 'UPDATE' query
on the database to fill in the two fields, after importing both .csv files.
Thanks for all the insight, though.  Every time you guys answer a question,
you throw in some interesting snippets which are very helpful to a beginner
like me.

Shawn




   

[EMAIL PROTECTED]  

gTo: [EMAIL PROTECTED]

 cc:   

10/17/2002   bcc:  

06:49 PM Subject: Re: How can I open and read two 
files at once in a loop? 
   

   





Michael Fowler wrote:
>
> You did, but you don't mention what should happen when one of the input
> filehandles reaches EOF before the other, or if that's possible.
>
> The solution I would use would go something like this:
>
> while (1) {
> my $first_in = ;
> last unless defined $first_in;
>
> my $second_in = ;
> last unless defined $second_in;
>
> print FIRSTOUT "$first_in\n";
> print SECONDOUT "$second_in, $first_in\n";
> }
>
> The loop stops when EOF is reached in either filehandle; you may want to
> stop it only when it's reached in both handles, or in one of the handles
> only.

If you want to stop at EOF you should test for EOF.  :-)

while (1) {
my $first_in = ;
last if eof( FIRSTIN );

my $second_in = ;
last if eof( SECONDIN );

print FIRSTOUT "$first_in\n";
print SECONDOUT "$second_in, $first_in\n";
}



John
--
use Perl;
program
fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Clarification on a previous e-mail.

2002-10-18 Thread shawn_milochik
Just a couple of questions about your corrections:  (All snippets are taken
from
the e-mail below.)


Shawn:
> sub parseFrom400 {
> my $value = @_[0];
  ^
John:
You want a scalar here, not an array slice.

 my $value = $_[0];

Shawn:
Okay.  I just put this in because I saw the syntax somewhere else.  Why is
this better?  It works fine as it is.



Shawn:
> my $delimiter = substr($value, 3, 1);
> if ($delimiter =~ /[0-9]./){
  ^
John:
Do you want to match any character except newline here or a literal
dot?  Since $delimiter only contains one character trying to match two
characters will never work.

  if ( $delimiter =~ /\d/ ) {

Shawn:
I wanted to find out if the character is numeric.  I see that your line
above is exactly what I really wanted.  It seems to be working, though.
The database I'm
ultimately populating with this data seems to be okay.  Does what I wrote
do the same thing, although in an ugly way?





Thank you,
Shawn




   

[EMAIL PROTECTED]  

gTo: [EMAIL PROTECTED]

 cc:   

10/17/2002   bcc:  

04:57 PM Subject: Re: How can I open and read two 
files at once in a loop? --  
 Thanks, and  also here's a snippet someone 
may fine useful... 
   





Shawn Milochik wrote:
>
> I am working on a project which involves downloading files via FTP from
an
> AS/400, and I had to write a couple of functions because of the weird way
> IBM does things.
>
> The first function takes a value, and dependent upon the final character,
> does something to it.
>
> Rules:
> 1.  If it is a letter, the letter represents a specific decimal amount,
and
> the number is negative.
> example: 4L = -3.7, or 6R = -6.3  <-- Note: these are not the actual
> numbers corresponding to the letters, I have the sub figure that out.
>
> 2. The close curly-brace '}' denotes that the value is negative.
> example: 4} = -4
>
> 3.  All numeric means that the final character is the decimal amount.
> example 43 = 4.3
>
> The second function checks to see if the final character is numeric.  If
it
> is not, the final character is a stand-in for a digit, and the entire
> statement is negative.  Otherwise, the number stays as is.
> examples:  345M = -3452, 5634 = 5634
>
> Hope this is useful to someone.  If not, maybe someone already has a
> resource for converting "mainframe" data types.  If they do, I'd like to
> know about it.
>
> sub parseFrom400 {
> my $value = @_[0];
  ^
You want a scalar here, not an array slice.

 my $value = $_[0];


> my $delimiter = substr($value, 3, 1);
> if ($delimiter =~ /[0-9]./){
  ^
Do you want to match any character except newline here or a literal
dot?  Since $delimiter only contains one character trying to match two
characters will never work.

  if ( $delimiter =~ /\d/ ) {


> $value = substr($value, 0, 3);
> }
> if ($delimiter =~ /[J-R]/){
> my $tempChar = ord($delimiter) - 73;
> $value += ($tempChar/10);
> $value = 0 - $value;
   ^^^
No need for the zero here.

  $value = -$value;


> }else{
> if ($delimiter eq "}"){
> $value = 0 - $value;

  $value = -$value;

> }else{
> $value = $value/10;

Can be shortened to:

  $value /= 10;

> }
> }
>
> return $value;
> }
>
> sub parseFrom400_2 {
> my $value = @_[0];

  my $value = $_[0];

> my $delimiter = substr($value, 7, 1);
>
> if ($delimiter =~ /[J-R]/){
> my $tempChar = ord($delimiter) - 73;
> $value *= 10;
> $value += $tempChar;
> $value = 0 - $value;

  $value = -$value;

> }
>
> return $value;
> }






John
--
use Perl;

Re: Single Quote marks in a string

2002-10-18 Thread shawn_milochik
Here is something for a very similar case:

I am reading in lines from a file, and writing them into a database.
Before I do, I do these two lines:

$_ =~ s/\'/\''/g;  #Replace any single quotes with a pair of single
quotes.
$_ =~ s/\"/\'/g;  #Replace any double quotes with single quotes
(SQL likes them better that way).

In practice (full working script, no substitutions or snips):

#!/usr/bin/perl

use DBI;

$data_source = "dbi:ODBC:rtsales";
$driver_name = "ODBC";

@driver_names = DBI->available_drivers;
@data_sources = DBI->data_sources($driver_name, \%attr);


$dbh = DBI->connect($data_source, $username, $auth, \%attr);


#The following lines decide what to use
#as a log file.  If one was supplied as an
#argument at the command line, we'll use
#it.  If not, default to "db_log.log"
$log = "db_log.log";
if (@ARGV[0] ne ""){
$log = @ARGV[0];
}
open (LOG, ">>$log");


print LOG "Database write script launched.\n";

@inFile = ("rtstr", "rtslsd", "rtsal", "rtsales", "rtweek", "rtwhist",
"rtrates");

foreach $inFile (@inFile){

open (IN, "<$inFile" . ".csv") || die "Could not open $inFile.\n";


$count = 0;
$errors = 0;

print LOG "\nBeginning insert into table $inFile...   \n";

while (){
$_ =~ s/\'/\''/g;
$_ =~ s/\"/\'/g;

#Note:  The following 'insert' sytax works ONLY if you are trying
to
#insert the same number of fields that exists in the table.
$statement = "insert into $inFile values ($_)";
$result  = $dbh->do($statement);
if ($result != 1){
print LOG "Result of $statement is: $result.\n";
$errors++;
}
$count++;
break;
}

print LOG "Completed insert of $count records into table $inFile,
$errors errors.\n";

close IN;

}

#This statement populates two fields of the table RTSAL with the values
of two fields in RTSALES.  In the application I replaced, a fat client
#(Rumba software) downloaded the RTSAL data file with the two fields
using a 'JOIN' from the DB2 tables RTSAL and RTSALES.  Since
#I use FTP to get this data, I don't have that option.
$statement = "UPDATE RTSAL INNER JOIN RTSALES ON (RTSAL.STORE =
RTSALES.STORE) AND (RTSAL.FISMM = RTSALES.FISMM) AND (RTSAL.FISYY =
RTSALES.FISYY) SET RTSAL.SALESTY = [rtsales].[salesty], RTSAL.SALESBUDTY
= [rtsales].[salesbudty]";
$result  = $dbh->do($statement);
print LOG "Result of $statement is: $result.\n";







$dbh->disconnect;

#The rest of this stuff is part of the rest of the application, which
is a series of scripts which each do their
#part, then call the next part.  The first script of the lot opens LOG
with a single '>', the rest with a '>>', so that
#each time the application is started, I create a new log file, but
each segment of the app appends to the same.
print LOG "Writing rttime.html now.\n";
$result = `rttime.pl`;
print LOG "Launching Epix & AS/400 FTPs now.\n";
$result = `epix_ftp.pl $log`;

#end of code

Hope this is helpful to someone.  I'm looking forward to all the "here's a
better way to do such-and-such" e-mails I know I'll get.  :o)  I really
appreciate those things.

Shawn




   

felix_geerinckx@h  

otmail.com   To: [EMAIL PROTECTED]

 cc:   

10/18/2002 02:24 bcc:  

PM   Subject: Re: Single Quote marks in a 
string   
   

   





on do, 17 okt 2002 08:01:07 GMT, Andrew Hubbard wrote:

>  I'm having problems with a text file I'm working on. I need to
>  get
> the descriptions in from the text file and into a
> string for use in an SQL statement however some of the descriptions
> use a single quote mark in the description.
> This of course stops the sql statement from working.
>
> How can I get around this? I don't want to remove the quote.

Use placeholders, like so:

my $sth = $dbh->prepare("INSERT INTO atable VALUES(?,?)");
my $value1 = "Looks like 'single' quotes";
my $value2 = "No single quotes here";
$sth->execute($value1, $value2);

my $rset = $dbh->selectall_arrayref( qq{
SELECT
atable.afield,
atable.anotherfield
FROM atable
WHERE
at

Re: truncation of decimal places.

2002-10-22 Thread shawn_milochik

Perhaps this is really clumsy, but maybe this will help.  If not, the
others on the list will fix us right up.

until (length($a) - index($a, '.') < 8){
$a = substr($a, 0, (length($a)-1))
}

Shawn




   

  prabhakn77@yahoo 

  .com To:  [EMAIL PROTECTED] 

   cc: 

  10/22/2002 02:15 bcc:

  PM   Subject: truncation of decimal places.  

   

   






Hi,

I have a really simple question.I have two numbers

say $a = 1.55

$b=1.55

how do I compare them to exactly 6 decimals without doing a round off.I
used sprintf but it does a round off.

thank you.



-
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: truncation of decimal places.

2002-10-22 Thread shawn_milochik

I neglected to ask:
You did not mention what you would like done to a number with less than six
decimal places.  Do you want them padded with zeroes?

I was in too much of a hurry to be the one helping someone else, rather
than asking for help, that I fired this script right off as soon as I could
test it. ;o)

Shawn




   
  
  shawn_milochik@god   
  
  ivachoc.comTo:  [EMAIL PROTECTED] 
  
 cc:  [EMAIL PROTECTED]   
  
  10/22/2002 02:41   bcc:  
  
  PM Subject: Re: truncation of decimal 
places.  
   
  
   
  





Perhaps this is really clumsy, but maybe this will help.  If not, the
others on the list will fix us right up.

until (length($a) - index($a, '.') < 8){
$a = substr($a, 0, (length($a)-1))
}

Shawn





  prabhakn77@yahoo

  .com To:  [EMAIL PROTECTED]

   cc:

  10/22/2002 02:15 bcc:

  PM   Subject: truncation of
decimal places.







Hi,

I have a really simple question.I have two numbers

say $a = 1.55

$b=1.55

how do I compare them to exactly 6 decimals without doing a round off.I
used sprintf but it does a round off.

thank you.



-
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site






**
This e-mail and any files transmitted with it may contain
confidential information and is intended solely for use by
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not
disclose its contents to others and delete it from your
system.

**


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]







-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: truncation of decimal places.

2002-10-22 Thread shawn_milochik

No, mine does no padding.  It's a very simple loop which just chops off the
last character if there are more than six characters after the decimal
point.  Come to think of it, you could probably replace it with a chop()
command:

old:
until (length($a) - index($a, '.') < 8){
$a = substr($a, 0, (length($a)-1))
}

new:
until (length($a) - index($a, '.') < 8){
chop $a;
}

Yep, it works!  ;o)

I like it this way for readability, but you could also make it one line:

  until (length($a) - index($a, '.') < 8){chop $a;}

Shawn




   

  prabhakn77@yahoo 

  .com To:  [EMAIL PROTECTED]  

   cc: 

  10/22/2002 03:36 bcc:

  PM   Subject: Re: truncation of decimal 
places.  
   

   





I think what I need is numbers with less than 6 decimals should be left as
it is.


Does your solution pad them with zeroes.thanks naveen





 [EMAIL PROTECTED] wrote:

 I neglected to ask:
 You did not mention what you would like done to a number with less than
 six
 decimal places. Do you want them padded with zeroes?

 I was in too much of a hurry to be the one helping someone else, rather
 than asking for help, that I fired this script right off as soon as I
 could
 test it. ;o)

 Shawn





 shawn_milochik@god
 ivachoc.com To: [EMAIL PROTECTED]
 cc: [EMAIL PROTECTED]
 10/22/2002 02:41 bcc:
 PM Subject: Re: truncation of decimal places.







 Perhaps this is really clumsy, but maybe this will help. If not, the
 others on the list will fix us right up.

 until (length($a) - index($a, '.') < 8){
 $a = substr($a, 0, (length($a)-1))
 }

 Shawn





 prabhakn77@yahoo

 .com To: [EMAIL PROTECTED]

 cc:

 10/22/2002 02:15 bcc:

 PM Subject: truncation of
 decimal places.







 Hi,

 I have a really simple question.I have two numbers

 say $a = 1.55

 $b=1.55

 how do I compare them to exactly 6 decimals without doing a round off.I
 used sprintf but it does a round off.

 thank you.



 -
 Do you Yahoo!?
 Y! Web Hosting - Let the expert host your web site






 **
 This e-mail and any files transmitted with it may contain
 confidential information and is intended solely for use by
 the individual to whom it is addressed. If you received
 this e-mail in error, please notify the sender, do not
 disclose its contents to others and delete it from your
 system.

 **


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]







 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]



Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site









-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: LOCALTIME question

2002-10-22 Thread shawn_milochik

I think "net time" will return UCT, or Universal Coordinated Time, which
used to be known as Greenwich Mean Time.

If you were to just type "time" at the DOS prompt or "date" at the *nix
prompt, the time should agree with LOCALTIME.


Shawn




   

  Kristi.Goodman@a 

  cxiom.comTo:  [EMAIL PROTECTED] 

   cc: 

  10/22/2002 02:38 bcc:

  PM   Subject: LOCALTIME question 

   

   





My localtime function returns this:  Tue Oct 22 18:30:53 2002


I am in the Central Time zone and my machine time (net time at DOS prompt)
returns this: 10/22/2002 1:37 PM


Does anyone have any idea why my localtime is 5 hours ahead?

Thanks,
Kristi

Kristi Goodman


Technical Support Specialist

AECMS, O/ITS

[EMAIL PROTECTED] 






**
The information contained in this communication is
confidential, is intended only for the use of the recipient
named above, and may be legally privileged.
If the reader of this message is not the intended
recipient, you are hereby notified that any dissemination,
distribution, or copying of this communication is strictly
prohibited.
If you have received this communication in error,
please re-send this communication to the sender and
delete the original message or any copy of it from your
computer system. Thank You.








**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Perl on a Palm?

2002-10-24 Thread shawn_milochik
Does anyone know if it's possible to execute Perl scripts on the Palm OS?
Does anyone here do any Palm OS programming of any kind?  What free toolkit
is available for it?

Shawn






**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




help make me more "perlish"

2002-10-31 Thread shawn_milochik
I have written a script which is very useful for me day-to-day.  It checks
table structure in HTML files.  The script is working, but I would
appreciate any comments, especially as to how this can be better written.

Thank you,
Shawn

Code follows:
:::
#!/usr/bin/perl

#This script looks for bad table
#structure in HTML pages.  When using
#server-side scripting, do not run this
#on the source page -- load the page in
#a browser, view source, and save the source
#as a file.

#This script does not take into account client-side
#scripting on the page.  For example, if a Javascript
#function writes out table elements in a loop, this
#script will report an error.  This is just a helpful
#tool for the web programmer who already knows what
#they are doing.

#Created by Shawn Milochik, Oct 31 2002.  Released
#free of any restrictions, and without any warranty.

#execution:  checktables.pl filename.html

open (IN, "<" . $ARGV[0]) || die "Could not open input file.\n";

$line = 0;
$last = undef;

#Open each line of the file.
while (){
#Keep track of the line number, so we
#can tell the user which line of the HTML has
#the problem.
$line++;
#Split the line on the > character.
@data = split />/, $_;
while (@data){
#Take the portion of the line containing an HTML tag
chomp($test = lc(shift(@data)));

if (($test =~ /) block

print "Check complete.\n";

:::
End of Code





**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




uniq & sort (GNU apps) for Windows -- http://unxutils.sourceforge.net/

2004-05-10 Thread shawn_milochik




Just an FYI, after reading one of the posts in the digest I receive for
this list.

There are 121 GNU command-line apps for the Win32 environment.
The download is a .zip file, about 3.2 megs.  I hope some of you find joy
in
your Windows use with it.


http://unxutils.sourceforge.net/

Including:

uniq
sort
grep & egrep
tar

And plenty of others.  I just throw them all into my c:\windows\system32
directory.
I am a Linux user, but I have to use Windows at work.  These tools make it
bearable.

Note:
If you are using Windows XP, some files (such as find.exe) will
automatically
be overwritten by XP with the Windows find.exe, which is pretty useless.  I
copy
the GNU find.exe as lfind.exe (Linux Find, although I suppose gfind would
be
more appropriate).


Shawn




**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




counting & sorting HTML tags

2003-08-14 Thread shawn_milochik
Hi.  I'm still very much a Perl beginner, but I'm reading "Mastering
Regular Expressions" by Friedl, so I expect to be able to at least help the
group out with regexs when I'm a few more chapters in.  ;o)

I've just created a script which, when run like this:

tags.pl filename.html

Produces results like this:

#snipped for brevity
, 1 occurrances
, 81 occurrances
, 1 occurrances
, 23 occurrances
, 10 occurrances
, 1 occurrances
, 1 occurrances
, 1 occurrances

Re: document creation. (HTML page breaks)

2003-08-14 Thread shawn_milochik
   
  
  excellence_personified@  
  
  hotmail.comTo:   [EMAIL PROTECTED]   
 
 cc:   
  
  08/10/2003 11:17 PMSubject:  Re: document creation.  
  
   
  
   
  









- Original Message -
From: "Wiggins D'Anconia" <[EMAIL PROTECTED]>
Newsgroups: perl.beginners
To: "Chris Knipe" <[EMAIL PROTECTED]>
Cc: <[EMAIL PROTECTED]>
Sent: Saturday, August 09, 2003 5:07 PM
Subject: Re: document creation.


> Chris Knipe wrote:
> > Lo all,
> >
> > I want to create large number of documents (mainly invoices) using
perl.
In
> > a couple of months, I should be creating a few hundred documents per
month
> > with a few million records in total for the documents (Telecoms
> > implementation).
> >
> > Now, preferably, I wanted to create MS Word documents for this, but
alas, a
> > stick was shoved into that idea.  Win32::OLE doesn't work from *Nix,
and
> > RTF::Document has like zero documentation (very help full thanks)...
> >
>
> MS Word, thats portable, not to mention the size and lack of revision
> control, ick.  Open source is your friend. Not enough documentation,
> open the code and have a look yourself...
>
>
> > What's my alternatives???
> >
>
> What is your end goal? You just say that you need to create documents,
> etc for storage but you don't say how they will be used.
>
> > Please keep in mind where possible, I'd like to automatically print the
> > invoices prior to archiving the hard documents.  The documents is also
quite
> > complex layout wise, with allot of graphs (Images) and about 95% table
> > based... Is HTML really the only alternative here??  I'm not sure
whether
> > printing HTML will be a very good idea...
> >
>
> HTML is one option but not the only one. XML would be the naturally most
> portable and upgradeable probably.

XML probably is your best bet assuming you are proficient in the use of
XSL.
I'll assume you're not when I say you'd do best using SGML, but then you
may
not be proficient in that either.  Deprived of alternatives, learn the
basics of CSS. Page breaks do work in CSS, and there are many quick and
dirty tutorials online if you need it soon.  So your documents will be HTML
and CSS, which isn't your very best bargain but which you can still work
with.

K.P.
_





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Just in case this is helpful to anyone:

HTML/CSS page breaks.  This is the easiest way I've found to do this.

How to make a printer do a form feed using HTML, in order
to allow the browser app to do page-breaks.

If the following CSS exists:


#break
{
page-break-AFTER: always;
}



Then the following HTML will force a page break while printing:






Shawn




**
This e-mail and any files transmitted with it may contain 
confidential information and is intended solely for use by 
the individual to whom it is addressed.  If you received
this e-mail in error, please notify the sender, do not 
disclose its contents to others and delete it from your 
system.

**


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]