[Perl-unix-users] Problems with Net::SMTP

2003-01-23 Thread david
I am attempting to write a mailing script using Net::SMTP. My code looks
something like this:

$smtp = Net::SMTP->new("foohost");
$smtp->mail("david");#This is line #53 in my program

And I get the following error:

Can't call method "mail" on an undefined value at C:\mailit.pl line 53.

So, I take it that the Net::SMTP->("foohost") did not establish a SMTP connection.
However, I can do this from the command line:

$ telnet foohost 25
220 foohost Microsoft ESMTP MAIL Service, Version: 5.0.2195.5329 ready at
 Thu, 23 Jan 2003 09:47:19 -0500
HELO
250 foohost Hello [xxx.xxx.xxx.xxx]
...
...

So, I know that there is a smtp daemon running on foohost, and that the
machine I am running on can communicate with it. I would like to try other
hosts (like my personal smtp server), but port 25 is locked out by our company's
firewall, so I can use internal systems.

Is there anything I can try to see where this error might be coming from?

BTW, I have no problems with Net::ftp.

--
David Weintraub
[EMAIL PROTECTED]
BusinessEdge Solutions

WARNING: [8 line legal mumble-jumble that my company wants me to append
to  each and every email I send out, but I don't feel like typing out each
time since they're forcing me to use webmail to access my account, and I
have no way of creating boiler template sigs]

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: [Perl-unix-users] Stopping pdf from cacheing

2001-01-09 Thread Cassell . David

Jacob Joseph wrote:
> Copy the original.pdf to newlocation.pdf and redirect to
> http://www.yourdomain/newlocation.pdf

Excuse me, but how will that keep the user from caching the document?
It still goes via HTTP to the user's browser and can be captured there.
No pragma can prevent the user from capturing the document, when the user
can turn off any pragma at his/her/its end - if not within the browser, 
then through the use of a tiny Perl program that would serve as an HTTP
filter between the browser and the webserver.  I use The Proxomitron
for such purposes, and it can do pretty much anything you can write a
rule for.  So I don't see how the original poster's problem can be solved
by Perl.  A client-side solution in Java may be possible...

David
-- 
David Cassell, OAO Corp.   [EMAIL PROTECTED]
Senior computing specialist
mathematical statistician
___
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users



Re: [Perl-unix-users] use of carraige return \r

2001-06-06 Thread David Owen

Charles Lu wrote:
> foreach(1..10){
>   print "$_";
>   sleep(1);#delay so i can see the change
>   print "\r";
> }
> 
> This code works only for increasing numbers, but when
> I try to go from 2-digit to 1 digit i.e. (11,10,9)the
> final output would be "90".  It appears that only the

Instead of printing just a "9" print either " 9" or "9 " (which ever
looks best to you).  The extra space would overwrite the other
digit of the 2 digit string leaving just the single nine on the 
screen.  If you were counting down from an arbitrarily high number
you could pack spaces to pad the shorter numbers to be the same (fixed)
width as the largest (first) number printed.  Alternatively, there are 
some fairly standard routines for clearing a line on a screen.  I am
not sure how well they work on Windows/NT shells, but they should do.

dowen
-- 
David Owen Midsomer Consultants Inc.  [EMAIL PROTECTED]
Maintainer of the Sybase FAQ: http://www.isug.com/Sybase_FAQ
___
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users



Re: [Perl-unix-users] Problems with Net::SMTP

2003-01-23 Thread David Weintraub
Connecting with it and being able to send mail from it are two 
different
things. Did you try setting the Hello option to something you know will
work? Did you turn on the Debug option? What does it say?

I was able to send email telnetting to the SMTP daemon, so I know it 
was doing more than just connecting.

I finally found the error when I realized that SMTP had a Debug 
parameter. I was going to actually hack through the SMTP module when I 
saw the reference to the Debug parameter in the code. I rechecked the 
documentation and realized that the Debug parameter was in fact 
mentioned in it.

Once I used the Debug parameter, I suddenly realized I had the wrong 
machine name in the program. Changing the machine name fixed the 
problem.

On Thursday, January 23, 2003, at 10:14  AM, Thomas_M wrote:

$ telnet foohost 25
220 foohost Microsoft ESMTP MAIL Service, Version:
5.0.2195.5329 ready at  Thu, 23 Jan 2003 09:47:19 -0500 HELO
250 foohost Hello [xxx.xxx.xxx.xxx] ... ...

So, I know that there is a smtp daemon running on foohost,
and that the machine I am running on can communicate with it.
I would like to try other hosts (like my personal smtp
server), but port 25 is locked out by our company's firewall,
so I can use internal systems.

Is there anything I can try to see where this error might be
coming from?


Connecting with it and being able to send mail from it are two 
different
things. Did you try setting the Hello option to something you know will
work? Did you turn on the Debug option? What does it say?

--
Mark Thomas[EMAIL PROTECTED]
Internet Systems Architect User Technology Associates, Inc.

$_=q;KvtuyboopuifeyQQfeemyibdlfee;; y.e.s. ;y+B-x+A-w+s; ;y;y; 
;;print;;




--
David Weintraub   _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
[EMAIL PROTECTED] _/_/
[EMAIL PROTECTED] _/ I am the Great and Powerful Oz*_/
BusinessEdge Solutions _/_/
  _/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
   (*Pay no attention to the man behind the curtains)

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



Re: [Perl-unix-users] parsing multiple arrays

2004-08-17 Thread David Greenberg
It's not recursive, but it should do the job...

my %ids = ();
foreach (@arr1) { $ids{$_}++;}
...
foreach (@arr8) { $ids{$_}++;}
foreach (keys(%ids)) { print $_ if $ids{$_} == 8; }

This assumes that each array contains only unique ids.

-David

On Tue, 17 Aug 2004 08:53:21 -0500, Mehta, Perdeep
<[EMAIL PROTECTED]> wrote:
> Hi,
> 
> I have a set of 8 1D arrays each containing around 100 to 150 ids. I want to 
> recursive parse each array to find what is common and unique across all 8 arrays and 
> print that out. Does any one know of an algorithm or has an idea that recursively 
> could do the task?
> 
> Thanks in advance for your thoughts and time.
> perdeep
> 
> Perdeep K. Mehta, PhD
> Hartwell Center for Bioinformatics & Biotechnology
> St. Jude Children's Research Hospital
> Memphis, TN 38105-2794
> 
> ___
> Perl-Unix-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [Perl-unix-users] V100/Blade2500 Vs Ultra10

2004-08-20 Thread David Greenberg
It all depends on exactly what the script is doing and the exact specs
of the V100 or Blade2500 that you're getting, but I have worked on
both and would guess you're probably looking at drastic improvement.

When I upgraded from an Ultra10 to a Blade1500, I everything was
overwhelmingly faster (not surprisingly).

I would think that it should at least run in less than 1/2 hour, but
Sun could probably give you a better rating.

-David

On Fri, 20 Aug 2004 12:39:37 +0530, Sandeep Deshpande
<[EMAIL PROTECTED]> wrote:
> Dear All,
> I am working on a very low end machine Ultra10. For some reasons, I need to
> run a Perl script on 900-1000 files in a sequential manner, almost on daily
> basis. This process takes lot of time. I am thinking of changing my
> workstation. I think V100 Server or Sun Blade 2500 would be the better
> option (Also I can afford them).
> 
> Could anybody tell me if a specific Perl script takes 3 Hrs on Ultra10 ,
> then how much time would the same script take on V100 or Blade2500?
> 
> Thanks & Regards,
> Sandeep Deshpande
> 
> ___
> Perl-Unix-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
>
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: RE: [Perl-unix-users] Odd problems from shell commands run via RP C service

2004-08-20 Thread David Greenberg
Is it possible that the process is being killed externally.  If that
happens, the output using backticks might be lost while some or all of
the output will still be written to a file. Maybe it's something along
these lines?

-David


- Original Message -
From: vega, james <[EMAIL PROTECTED]>
Date: Fri, 20 Aug 2004 10:39:52 -0400
Subject: RE: [Perl-unix-users] Odd problems from shell commands run via RP
C service
To: "[EMAIL PROTECTED]"
<[EMAIL PROTECTED]>

 
That's what we're doing.  As I said, it's only sporadically that these
commands don't return STDOUT.  For the most part, they work, but
sometimes we have problems.  One way that we've worked around the
STDOUT problem is by redirecting STDOUT to a file and then reading
back the file, but that shouldn't be necessary.  I've stepped through
the code and run the command directly on the host when I see the
problem occur in our script to see if it's something odd happening on
the system itself, but no luck there.
 
 
-Original Message-
From: Dragos CIULICA [mailto:[EMAIL PROTECTED] 
Sent: Friday, August 20, 2004 9:54 AM
To: vega, james
Cc: '[EMAIL PROTECTED]'
Subject: RE: [Perl-unix-users] Odd problems from shell commands run
via RP C service

Donn't know about return code ...
Have you tried:

my $command_output = `some_system_command_here`;   #look carefully
here ... it is <<`>>, not <<'>>
print "output:\n" . $command_output;

Good Luck,
Dragos CIULICA.




On Fri, 2004-08-20 at 16:33, vega, james wrote: 
> -Original Message- > From: Anthony Ettinger [mailto:[EMAIL PROTECTED] > > I 
> don't know about RPC, but I usually use this syntax > when calling an external 
> command: > > system($cmd) == 0 or die "system @args failed: $?" > > perldoc -f 
> system Thanks for the reply, but I'm afraid that doesn't address my problem. We need 
> to capture the output from the command as well as be able to access the return code. 
> system() just returns the return code, hence why I said we are using backticks. 
> Sorry if my first explanation wasn't clear about that. > > --- "vega, james" <[EMAIL 
> PROTECTED]> wrote: > > > I'm having a couple interesting issues with > > backticked 
> commands performed > > via RPC[1] calls to another host. The first problem > > is 
> that we will > > sporadically not get back the STDOUT from the > > process. The 
> second problem > > is that, after a certain point, we will stop getting > > back 
> proper return > > codes. It will just return -1. This seems to occur > > afte!
 r we've fork()ed > > and then called a Perl script from within the fork > > (problems 
with reentrant > > libraries?). Both of these have occurred with Perl > > 5.8.x. These 
problems > > have been seen on HPUX, AIX, and Suse. This has > > never occurred on any 
of > > the Windows hosts that I've used. Thanks in advance > > for any help. This has 
> > been a real mind boggler. > > > > James > > > > [1]. The RPC service I'm using is 
the example > > service given in Chapter 13 of > > Advanced Perl Programming. 
___ Perl-Unix-Users mailing list [EMAIL 
PROTECTED] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs 

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


[Perl-unix-users] DBM functionality via tie & untie

2001-10-03 Thread david . b . deline


I'm using 'tie' & 'untie' in manipulating DBM files for IPC
(Inter-Process Communication).
I know I have to implement a 'locking' strategy to ensure not to corrupt
my DBM files.

1) If I 'tie' to the same DBM file in each of my processes do I ever
need to 'tie' again with in each process...? I'm pretty sure the answer
is No.
2) (Related to question 1) Do I have to 'tie' to obtain the most current
information from a DBM file...? I'm pretty sure the answer is No, the
initial 'tie' should be enough.
3) (Related to question 2) Do I have to 'untie' to "submit" any changes
made to the 'tied hash'...? I'm pretty sure the answer is No.

I'm really looking for some advise/confirmation...

All of the documentation I've read is pretty straight forward in dealing
with only ONE process.  Whenever it begins to deal with IPC it jumps
right in to locking strategies...  Any help/advise you could provide is
greatly appreciated...

Frustrated,
Dave


___
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users



RE: [Perl-unix-users] (no subject)

2001-11-01 Thread david . b . deline

Look into DBM files.
I've created a process that is similar to yours (parent process forks
child processes) and they are all daemons.  I used a DBM file to
communicate between them.  The only draw back was you will have to
implement a file locking schema to prevent corrupting your DBM file.

Regards,
Dave DeLine


-Original Message-
From: mogikan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 01, 2001 2:34 AM
To: perl-unix-users
Cc: mogikan
Subject: [Perl-unix-users] (no subject)



 Dood day!
 I wrote a server which listens on a specific port and 
for each client splits child proccess (using fork()). 
I need to exchange between them (proccesses). I tried 
to use pipe (used socketpair function), but can create 
only one.   
 I have such a general question: How to organize 
interconnection between proccesses though server? How 
does server know which client sends data (proccess 
identification) and how can it send data to a cpecific 
client?
 Thank you.
 
P.S. Used IO::Socket

/Vadim/  
mailto:[EMAIL PROTECTED]
___
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users


___
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users



RE: [Perl-unix-users] Frameset

2001-09-27 Thread david . b . deline

Well Jeb,

(If I understand your question correctly...)

You can accomplish this by imbedding JavaScript in your query & response
HTML.
You will need to have named FORMs in each of your FRAMEs to use the
following JavaScript examples:

Say you have a text object in your query frame.
You can update the text object in your query frame from your response
frame by using the following JavaScript code:
  parent.query.document.form_name.text_object_name.value = "updated
text";
or you could append to the query's text object with the following
JavaScript code:
  parent.query.document.form_name.text_object_name.value += "append
text";

Please note that in the above examples "form_name" should be replaced
with the actual FORM NAME  in your HTML &
"text_object_name" should be replaced with the actual NAME given to the
 object.

You can also obtain similar results through hidden objects and forcing a
submit on the frame.  This would work very similarly to the above
examples...
Example: In your FORM on your query frame you would include a hidden
object 
You could then access this hidden object from the response frame through
the following JavaScript code:
  parent.query.document.form_name.h_text.value = "updated text";
Then cause the FORM on your query frame submit and refresh according to
the value in your hidden "h_text" object:
  parent.query.document.form_name.submit();

Hope this helps...

Regards,
Dave

-Original Message-
From: jaouad.jeb [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, September 26, 2001 6:13 PM
To: perl-unix-users
Subject: [Perl-unix-users] Frameset


Hi Folks,

I am using the Frame.cgi script from activeperl, here a copy of it:

sub print_frameset {
$script_name = $query->script_name;
print <$TITLE




EOF
;
exit 0;
}


The problem I have is the following:

I do want to append result to the RESPONSE frame and not only show the
last 
result submited, how can I do that? I do have two different submition 
Buttons in the query part one to submit just the last Calculation done
and 
the second one to ADD the result to the precious one, can some one help
in 
this topic? if you do have other alternative please share with me, I am
new 
to perl and programming.

thanks

jeb

_
Get your FREE download of MSN Explorer at
http://explorer.msn.com/intl.asp

___
Perl-Unix-Users mailing list. To unsubscribe go to
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users


___
Perl-Unix-Users mailing list. To unsubscribe go to 
http://listserv.ActiveState.com/mailman/subscribe/perl-unix-users



RE: [Perl-unix-users] Frameset

2001-09-27 Thread david . b . deline

Jeb, 

I sounds like you should be able to incorporate the "HIDDEN"
object/variable method I mentioned in my previous email.
I use this technique all of the time to ensure I "keep my data around"
between submissions...

Example:

  #!/usr/bin/perl
  
  use strict;
  use CGI qw(:standard);
  
  my $cgi_dir="http://kcfinp04b/dsscgi/dave";;
  my $query = new CGI;
  
  my $h_var1 = $query->param('h_var1');
  
  print <<"EOF";
  Content-type: text/html\n\n
  
  
  
  
  
  
  document.dave.h_var1.value = "jeb";
  
  
  EOF
  
  exit(0);

In the above example, the first time the script is executed $h_var1 will
be empty (You can see this when you 'view the source' and see that the
VALUE section of the HIDDEN line is 'VALUE=""'
When you submit however, $h_var1 will be 'jeb' since the JavaScript
section initialized it's value. (You can verify this by 'viewing the
source' again and now 'VALUE="jeb"')

Now I know this is a very simple example, but this concept can be
carried forward.
Say you change the ACTION to another script then your HIDDEN values will
be passed on that script, etc, etc, ...

Anyway, you can use this concept to communicate between your two
frames...

Regards,
Dave.

-Original Message-
From: jaouad.jeb [mailto:[EMAIL PROTECTED]]
Sent: Thursday, September 27, 2001 1:10 PM
To: david.b.deline
Cc: perl-unix-users
Subject: RE: [Perl-unix-users] Frameset



thanks david for your answer, but what i want to do is a repetitive 
submision (unlimited) from The QUERY frame to the RESPONSE Frame.

What I am doing is:

drawing a structure in the Query frame, and then send it to the RESPONSE
by 
the button ADD that is equal to a submit, so the structure get processed
and 
some other calculation are done, and finally printed in the RESPONSE
frame, 
but know the i wnat to send another structure and see the results and
copare 
them with the first calculations, so i need to append the new result to
the 
old one, right? and so on so i can have unlimeted number of structure to

compare, thought the need of appending to the RESPONSE frame.


so it's possible to append directly to the RESPONSE frame?
I know the answer is no, because when i submit the second structure and 
submit it my script is called again so i loose all my old variables,
hashes, 
arays, etc is that right?  or am i wrong?
how can i remediate to that?

if i did understand well your java proposition, these can work only for
one 
or two submission, is that right?

thanks

jeb


From: [EMAIL PROTECTED]
To: [EMAIL PROTECTED], [EMAIL PROTECTED]
Subject: RE: [Perl-unix-users] Frameset
Date: Thu, 27 Sep 2001 10:35:03 -0500
MIME-Version: 1.0
Received: from [209.17.183.249] by hotmail.com (3.2) with ESMTP id 
MHotMailBD7C927000B24004374AD111B7F9F9100; Thu, 27 Sep 2001 08:36:16
-0700
Received: (qmail 12033 invoked from network); 27 Sep 2001 15:36:02 -
Received: from localhost (HELO shot.ActiveState.com) (127.0.0.1)  by 
localhost with SMTP; 27 Sep 2001 15:36:02 -
Received: (qmail 11960 invoked from network); 27 Sep 2001 15:35:44 -
Received: from espresso.activestate.com (HELO smtp1.ActiveState.com) 
(192.168.2.150)  by listserv1.activestate.com with SMTP; 27 Sep 2001 
15:35:44 -
Received: from damgwp01.corp.sprint.com (parker2.sprint.com 
[199.14.91.106])by smtp1.ActiveState.com (8.11.6/8.11.6) with ESMTP id 
f8RFZhl31927for <[EMAIL PROTECTED]>; Thu, 27 Sep
2001 
08:35:43 -0700
Received: from kcmgwp02.corp.sprint.com (kcmgwp02 [10.185.6.93])by 
damgwp01.corp.sprint.com (Switch-2.1.3/Switch-2.1.0) with ESMTP id 
f8RFbd317885;Thu, 27 Sep 2001 10:37:39 -0500 (CDT)
Received: from kcopmp06.corp.sprint.com (KCOPMP06.corp.sprint.com 
[10.74.0.81])by kcmgwp02.corp.sprint.com (Switch-2.1.3/Switch-2.1.0)
with 
ESMTP id f8RFZbq10542;Thu, 27 Sep 2001 10:35:37 -0500 (CDT)
Received: from localhost (root@localhost)by kcopmp06.corp.sprint.com
(8.8.6 
(PHNE_17190)/8.8.6) with ESMTP id KAA22880;Thu, 27 Sep 2001 10:35:36
-0500 
(CDT)
>From [EMAIL PROTECTED] Thu, 27 Sep 2001 
08:37:54 -0700
Return-Path: <[EMAIL PROTECTED]>
Delivered-To: [EMAIL PROTECTED]
X-OpenMail-Hops: 1
Message-Id: <Hc140d6f5b7c.1001604902.kcopmp06@MHS>
X-Filtered-By: PerlMx makes it fast and easy.  See 
http://www.ActiveState.com/Products/PerlMx/Header
Sender: [EMAIL PROTECTED]
Errors-To: [EMAIL PROTECTED]
X-BeenThere: [EMAIL PROTECTED]
X-Mailman-Version: 2.0.5
Precedence: bulk
List-Help: 
<mailto:[EMAIL PROTECTED]?subject=help>
List-Post: <mailto:[EMAIL PROTECTED]>
List-Subscribe: 
<http://listserv.ActiveState.com/mailman/listinfo/perl-unix-users>,
List-Id: 
List-Unsubscribe: 
<http://listserv.ActiveState.com/mailman/listinfo/perl-unix-users>,
List-Archive:
<http://m

RE: [Perl-unix-users] Please help on GREP command

2002-02-18 Thread david . b . deline

Is that the exact line...?
Try:
$var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
Remember to put your shell commands in back-tics...

Dave.

-Original Message-
From: ba2984 [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 1:23 PM
To: perl-unix-users
Subject: [Perl-unix-users] Please help on GREP command


Hi listers,

I am using the following command in my perl script. But when I execute
the
script I am getting the error 

"Unrecognized file test: -E at test.pl line 9."

grep -E -i -c "abc|xyz|pqr" test.txt ;

Can someone please tell me what I am doing wrong here ?

All I wanted to do is to search for any of the stings abc, xyz or pqr in
the
file test.txt.

Thanx..
-Bheem
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: [Perl-unix-users] Please help on GREP command

2002-02-18 Thread david . b . deline

The back-tics will automatically execute the grep command.
So,
  $var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
will execute the grep command just like from the shell command line.
The output from the grep command will be captured in $var.
You can check the value of $? for the return value from grep.

Example:
$var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
die "ERROR: Problem executing grep, ($!), stopped" if ( $? != 0 );

Try this...
First execute
  grep -E -i -c "abc|xyz|pqr" test.txt
from you shell command prompt.
Then write a perl script to the following and compare results:
  #!/usr/bin/perl
  $var`grep -E -i -c "abc|xyz|pqr" test.txt`;
  die "ERROR: Problem executing grep, ($!), stopped" if ( $? != 0 );
  print $var;
  exit(0);

Dave.

-Original Message-
From: ba2984 [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 2:52 PM
To: david.b.deline
Cc: perl-unix-users
Subject: RE: [Perl-unix-users] Please help on GREP command


Then how do I execute the command in $var ? I want to check the return
code
of that grep command. Please help me. I am new to PERL.

Thanx..
-Bheem

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 11:47 AM
To: AITHA, BHEEMSEN (SBCSI)
Cc: [EMAIL PROTECTED]
Subject: RE: [Perl-unix-users] Please help on GREP command


Is that the exact line...?
Try:
$var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
Remember to put your shell commands in back-tics...

Dave.

-Original Message-
From: ba2984 [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 1:23 PM
To: perl-unix-users
Subject: [Perl-unix-users] Please help on GREP command


Hi listers,

I am using the following command in my perl script. But when I execute
the
script I am getting the error 

"Unrecognized file test: -E at test.pl line 9."

grep -E -i -c "abc|xyz|pqr" test.txt ;

Can someone please tell me what I am doing wrong here ?

All I wanted to do is to search for any of the stings abc, xyz or pqr in
the
file test.txt.

Thanx..
-Bheem
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: [Perl-unix-users] Please help on GREP command

2002-02-18 Thread david . b . deline

Sorry All...

The 'die' command should have read:
  die "ERROR: Problem executing grep, ($!), stopped" if ( $? == 2 );

grep return codes: 0=Found Match; 1=No Match Found; 2=Error.

Dave.

-Original Message-
From: Deline, David B. 
Sent: Monday, February 18, 2002 3:08 PM
To: 'ba2984'
Cc: 'perl-unix-users'
Subject: RE: [Perl-unix-users] Please help on GREP command


The back-tics will automatically execute the grep command.
So,
  $var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
will execute the grep command just like from the shell command line.
The output from the grep command will be captured in $var.
You can check the value of $? for the return value from grep.

Example:
$var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
die "ERROR: Problem executing grep, ($!), stopped" if ( $? != 0 );

Try this...
First execute
  grep -E -i -c "abc|xyz|pqr" test.txt
from you shell command prompt.
Then write a perl script to the following and compare results:
  #!/usr/bin/perl
  $var`grep -E -i -c "abc|xyz|pqr" test.txt`;
  die "ERROR: Problem executing grep, ($!), stopped" if ( $? != 0 );
  print $var;
  exit(0);

Dave.

-Original Message-
From: ba2984 [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 2:52 PM
To: david.b.deline
Cc: perl-unix-users
Subject: RE: [Perl-unix-users] Please help on GREP command


Then how do I execute the command in $var ? I want to check the return
code
of that grep command. Please help me. I am new to PERL.

Thanx..
-Bheem

-Original Message-
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 11:47 AM
To: AITHA, BHEEMSEN (SBCSI)
Cc: [EMAIL PROTECTED]
Subject: RE: [Perl-unix-users] Please help on GREP command


Is that the exact line...?
Try:
$var=`grep -E -i -c "abc|xyz|pqr" test.txt`;
Remember to put your shell commands in back-tics...

Dave.

-Original Message-
From: ba2984 [mailto:[EMAIL PROTECTED]]
Sent: Monday, February 18, 2002 1:23 PM
To: perl-unix-users
Subject: [Perl-unix-users] Please help on GREP command


Hi listers,

I am using the following command in my perl script. But when I execute
the
script I am getting the error 

"Unrecognized file test: -E at test.pl line 9."

grep -E -i -c "abc|xyz|pqr" test.txt ;

Can someone please tell me what I am doing wrong here ?

All I wanted to do is to search for any of the stings abc, xyz or pqr in
the
file test.txt.

Thanx..
-Bheem
___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



RE: [Perl-unix-users] extract the last character or a string

2002-04-11 Thread david . b . deline

Kwabena,

Here is an example of how to pull off the last character of a string and
print it.
You could also store the value returned by the substr function into a
variable...
$dir='d:/abs/fez';
print substr($dir, length($dir)-1) . "\n";

Here is an example of checking the last character of a string for a '/'
using regular expressions.
print "$dir is a directory..." if ( $dir =~ /[\/]$/ );

Hope this helps...

Regards,
Dave.

-Original Message-
From: kwabena.asare [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 11, 2002 8:55 AM
To: perl-unix-users
Subject: [Perl-unix-users] extract the last character or a string




Hi,

How do you extract the last character of a string

I basically want to see if a list of directory strings have a slash at
the end
or not.

For eg if

$dir = 'd:/abs/fez';

I know can use the length function to get the length of $dir but how do
I
extract the last character ie. z and then do my tests ?

Any help appreciated.

Thanks
Kwabena




_

This transmission has been issued by a member of the HSBC Group 
"HSBC" for the information of the addressee only and should not be 
reproduced and / or distributed to any other person. Each page attached 
hereto must be read in conjunction with any disclaimer which forms part 
of it. Unless otherwise stated, this transmission is neither an offer
nor the 
solicitation of an offer to sell or purchase any investment. Its
contents are 
based on information obtained from sources believed to be reliable but
HSBC makes no representation and accepts no responsibility or liability
as 
to its completeness or accuracy.

___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



[Perl-unix-users] How to append specified files into a big file

2004-07-20 Thread Nguyen, David M








I have all the files below under /mydir directory, I want to
append ONLY the files highlighted into a big file names “bigfile.txt”. 
How do I accomplish this?

 

Meas.atl00.1040.0705

Meas.atl00.1040.0706

Meas.atl00.1040.0707

Meas.atl00.1040.0708

Meas.atl00.1040.0709

Meas.atl00.1040.0710

Meas.atl00.1040.0711

Meas.atl00.1040.0712

Meas.atl00.1040.0713

Meas.atl00.1040.0714

Meas.atl00.1040.0715

Meas.atl00.1040.0716

Meas.atl00.1040.0717

Meas.atl00.1040.0718

Meas.atl00.1040.0719

Meas.atl00.1040.0720

 

Thanks in advance,

David

 






___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: [Perl-unix-users] How to append specified files into a big file

2004-07-20 Thread Nguyen, David M
Title: Message









Thanks, Jay.  This makes sense but I
need to write a script to prompt for user input, a start date and a begin
date.  For example, if user input start date is “0710” and end
date is “0716” then I want the program to append all the files
between that date range.  Is there a way?

 

For example:

$myperl.pl 

 

Enter start date:  0710

Enter end date:   0716

 

Thanks again,
David

 

-Original Message-
From: Jason Vincent
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 20, 2004 12:31
PM
To: Nguyen, David M;
'[EMAIL PROTECTED]'; '[EMAIL PROTECTED]'
Subject: RE: [Perl-unix-users] How
to append specified files into a big file

 



 





 





@files = ( 

'Meas.atl00.1040.0710,

'Meas.atl00.1040.0711',

'Meas.atl00.1040.0712',

'Meas.atl00.1040.0713',

'Meas.atl00.1040.0714',

'Meas.atl00.1040.0715',

'Meas.atl00.1040.0716');

 

open (OUT, '>>bigfile.txt')||die $!;

 

foreach (@files){

    open (IN, "$_")|| die
$!;

    while (){

    print
OUT $_;

    }

    close IN;

}

close OUT;





 





 



Regards,


Jay

 

 

-Original
Message-
From: Nguyen, David M
[mailto:[EMAIL PROTECTED] 
Sent: Tuesday, July 20, 2004 1:19
PM
To: [EMAIL PROTECTED];
[EMAIL PROTECTED]
Subject: [Perl-unix-users] How to
append specified files into a big file



I have all the files below under
/mydir directory, I want to append ONLY the files highlighted into a big file
names “bigfile.txt”.  How do I accomplish this?

 

Meas.atl00.1040.0705

Meas.atl00.1040.0706

Meas.atl00.1040.0707

Meas.atl00.1040.0708

Meas.atl00.1040.0709

Meas.atl00.1040.0710

Meas.atl00.1040.0711

Meas.atl00.1040.0712

Meas.atl00.1040.0713

Meas.atl00.1040.0714

Meas.atl00.1040.0715

Meas.atl00.1040.0716

Meas.atl00.1040.0717

Meas.atl00.1040.0718

Meas.atl00.1040.0719

Meas.atl00.1040.0720

 

Thanks in advance,

David

 








___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: [Perl-unix-users] changing time from database to CET?

2003-03-07 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Byrne, Dermot wrote:
> aha
> 
> so I'm using timelocal function now
> but I'm getting
> Undefined subroutine ::timelocal
> 
> does this mean there is a seperate timelocal module i need to install?
> 
> I've got
> /usr/lib/perl5/5.6.0/Time/Local.pm
> /usr/lib/perl5/5.6.0/Time/gmtime.pm
> /usr/lib/perl5/5.6.0/Time/localtime.pm
> /usr/lib/perl5/5.6.0/Time/tm.pm
> 
> 
> 
> 
> -Original Message-
> From: $Bill Luebkert [mailto:[EMAIL PROTECTED]
> Sent: 07 March 2003 14:09
> To: Byrne, Dermot
> Cc: '[EMAIL PROTECTED]'
> Subject: Re: [Perl-unix-users] changing time from database to CET?
> 
> 
> Byrne, Dermot wrote:
>> Hello
>> 
>> As Bill suggested, here is what I have at the moment
>> 
>> $startFormatted is the date that comes out of database
>> (formatted with DATE_FORMAT( datetime, '%S %i %H %w %m %Y'))
>> 
>> # I have module
>> use Time::localtime;
>> 
>> # firstly i split variable into parts
>> my ($sec, $min, $hour, $day, $month, $year) = split(/
>> +/,$startFormatted); 
>> 
>> # but if I put into localtime function
>> my($localisedsec, $localisedmin, $localisedhour, $localisedday,
>> $localisedmonth, $localisedyear) = localtime ($sec, $min, $hour,
>> $day, $month, $year); 
>> 
>> # i get 'Too many arguments for localtime ' error
> 
> localtime takes one optional arg - an epoch time.
> Maybe you want timelocal instead ?
> 
>> when I put into localtime function like this
>> my($localisedsec, $localisedmin, $localisedhour, $localisedday,
>> $localisedmonth, $localisedyear) = localtime ($startFormatted);
>> 
>> # i doesn't mind however
>> 
>> 
>> # the statements
>> print $ENV{TZ};
>> print "$startFormatted ";
>> print "$sec, $min, $hour, $day, $month, $year ";
>> print "$localisedsec, $localisedmin, $localisedhour, $localisedday,
>> $localisedmonth, $localisedyear";
>> 
>> #produce this output
>> CET
>> 00 00 14 0 03 2003
>> 00, 00, 14, 0, 03, 2003
>> 0, 0, 1, 1, 0, 70

Add the following at start of script and should clear up problem:

use Time::Local;

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.


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] foreach and an array of hashes

2003-03-13 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: foreach and an array of hashes



    learn to use Data::Dumper to see what your data looks 
like.
@emp looks like:
$VAR1 = [  
{    
'position' => 
'Cook',    
'age' => 
50,    'name' 
=> 'Bob'  
},  
{    
'position' => 
'Receptionist',    
'age' => 
20,    'name' 
=> 'Jane'  
},  
{    
'position' => 
'Cashier',    
'age' => 
25,    'name' 
=> 'Joe'  
}    ];
 
Your print    print $curemp{name}; should 
look like    print $curemp->{name}; 
Also might want a linefeed otherwise they all come 
together.
 
Wags ;)


  -Original Message-From: Markham, Richard 
  [mailto:[EMAIL PROTECTED]Sent: Thursday, March 13, 2003 
  13:13To: 
  '[EMAIL PROTECTED]'Subject: 
  [Perl-unix-users] foreach and an array of hashes
  is it possible to foreach through and array of hashes 
  and reference the objects attributes? In testing I am just trying to print each employee name. 
  my @emp; 
  $emp[0]=new_employee("Bob",50,"Cook"); $emp[1]=new_employee("Jane",20,"Receptionist"); $emp[2]=new_employee("Joe",25,"Cashier"); 
  foreach my $curemp (@emp) {    print $curemp{name}; } 
  sub new_employee {     
  my ($name, $age, $starting_position) = @_;     my $r_employee = 
  {  
  # Create a unique object     
  "name" => 
  $name,    # 
  using an anonymous hash     
  "age"  => $age,     "position" => 
  $starting_position     };       return 
  $r_employee; 
  # Return "object" } 
  TIA 

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





[Perl-unix-users] How to keep Perl in sync over a large number of servers?

2003-03-21 Thread Wagner, David --- Senior Programmer Analyst --- WGO
I was asked this question and I have no real answer for the individual. 
(Outside of my company)

It is group of Unix flavor servers(group greater 100 servers) and each server 
has it's own Perl setup.  How do you keep everything in sync?

I would assume you have a test setup and from that keep one server as default. 
Then you would load into the default after verifying that changed modules work as 
before. Then from the base system, some how you come up with differences and load in 
new modules as necessary.

That is the way I would view it, but how would one actually do it? Are there 
Perl Unix modules which can do this? Or do we need to write modules to handle this?

I would appreciate any insight.  If this is the wrong list, then if someone 
could point me to the right list, that would also be appreciated.

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.


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] RFC: Unix Sysadmin perl snippets

2003-09-29 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> Subject: [Perl-unix-users] RFC: Unix Sysadmin perl snippets
> 
> 
> Hello everyone,
> 
> I do system administration and programming, and I rely heavily on
> Perl to do both these duties.  I find that, in the course of my work,
> I routinely create one-off scripts - snippets of perl code,
> one-liners, etc - that I use to short-cut around some of the messier
> aspects of my job. 
> 
> Most of these scripts when I'm done with them just get deleted in my
> all-too-infrequent home directory cleanups, or scroll off my
> ~/.bash_history. 
> 
> Would anyone in this list be interested in recieving cookbook-style
> sample routines?  I know some newbies hang out here, and might
> appreciate seeing how other sysadmins go about their work.  I'm sure
> other experts in this list might have something they can contribute,
> even if it's just a "Wow, this is neat" or a "Aren't I cool?  This
> just saved me six hours of work" sort of email.
> 
> Thoughts? Comments?
Why re-invent the wheel if some aspect of what you are doing can possibly help 
others. I would enjoy seeing what is going on!

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.



___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] Removing files older than 10 days from a directory

2003-11-07 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: RE: [Perl-unix-users] Removing files older than 10 days from a directory



 if ( int( -M 
$file) > $days || $days == 0 ) 
The only thing to be careful is if you 
decide to make this a service or constantly running script, using the -M is 
the point in time that the script started! You have to update the Global 
variable as it relates to -M otherwise you wonder why the files are not getting 
deleted. Got caught on that.
 
    Just something to watch out for.
 
Wags ;)

  -Original Message- From: Craig 
  Sharp [mailto:[EMAIL PROTECTED]] 
  Sent: Friday, November 07, 2003 2:45 PM To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: RE: [Perl-unix-users] Removing files older than 10 days from 
  a directory 
  Travis, 
  The attachment did not come through.  Please try again or 
  you can just send it by email. 
  Thanks, 
  Craig 
  >>> Travis Hoyt <[EMAIL PROTECTED]>   11/07/03 01:57PM >>> 
  Here's our version for Oracle being backed up by Veritas 
  NetBackup. 
  I tried to just cut and paste this but it isn't keeping the 
  tabbing right.  I'll upload it as a text   attachment. 
  Our version is more complicated than previous versions offered 
  but there is a great deal more accounted for with 
  threadholds, alerting and other such items that are 
  beneficial in a commercial environment.  If you 
  have any questions about the script please feel free to e-mail me. 
  Travis 
  ___   Perl-Unix-Users mailing list [EMAIL PROTECTED] To 
  unsubscribe: http://listserv.ActiveState.com/mailman/mysubs 


**
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: [Perl-unix-users] Index of array element

2003-12-03 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: RE: [Perl-unix-users] Index of array element



    You have it as an array, but if unique, then why not 
setup as hash and you would not have to do any searching, but would know right a 
way with just a simple test vs searching the whole array each 
time.
 
Wags ;)

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of 
  Jason VincentSent: Wednesday, December 03, 2003 
  10:50To: Craig Sharp; 
  [EMAIL PROTECTED]Subject: RE: 
  [Perl-unix-users] Index of array element
  @array = ('a','b','c'); 
  for($i=0;$i<=$#array;$i++){ 
      print "index is 
  $i\n" if $array[$i] eq 'b'; } 
  J 
  -Original Message- From: Craig 
  Sharp [mailto:[EMAIL PROTECTED]] 
  Sent: Wednesday, December 03, 2003 10:00 AM 
  To: [EMAIL PROTECTED] Subject: [Perl-unix-users] Index of array element 
  I have an array of names.  I need to find the 
  corresponding index for a particular name.  How can I do this? 

  Thanks, 
  Craig ___ Perl-Unix-Users mailing list 
  [EMAIL PROTECTED] To 
  unsubscribe: http://listserv.ActiveState.com/mailman/mysubs 


**
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: [Perl-unix-users] conversion between exponential and corresponding integer value

2004-02-27 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: RE: [Perl-unix-users] conversion between exponential and corresponding integer value



   depending on the format of 
the exponential value, it may be as simple as: 
print int(10e5); print 
int(-10e5); 
This doesn't appear to work, though, if formatted as 10e-5, so 
you'd need to create a sub something like:  
I think you may be making it too hard. Remember this is 
Perl.
#!perl -w
while ( 1 ) {    printf "Plase enter number: 
";    chomp(my $MyAns = );    
last if ( $MyAns =~ /^\s*(qu|en)/i );    my $MyNbr = sprintf 
"%e", 
$MyAns;#1#    
$MyNbr =~ 
/^(\d+)/;  
#1#    my $MyDigits = 
$1;   #1# 
printf "%s  
%s\n",    
$MyNbr,    
$MyDigits; }
 
output:
Please enter number: 1051.05e+002  1Please enter number: 
.004564.56e-003  4
    Even mine seems harder than it should be, but it is a start 
and only the #1# are needed to get the digit you desire.
Wags ;)
sub exp2int { 
    $_ = shift; 
    my ($num,$exp) = 
split(/e/,$_); 
    if ($exp > 0)     { 
    
    $num *= 10; 
    
    for (my $i = 1; $i < 
$exp; $i++)     
    { 
    
    
    $num *= 10; 
    
    } 
    } 
    elsif ($exp < 
0)     { 
    
    $num *= -10; 
    
    for (my $i = -1; $i > 
$exp; $i--)     
    { 
    
    
    $num *= 10; 
    
    } 
    } 
    return($num); 
} 
#here's the inverse 
sub int2exp { 
    my $num = shift;     my 
$count; 
    while(($num < -10) 
|| ($num > 10))     {     
    $num = $num / 10; 
    
    $count++;     } 
    $new = 
"${num}e${count}";     return($new); } 
# end 
Of course, there may be a really simple answer to this 
puzzle. 
HTH, Pete 
> -Original Message- > 
From: Mehta, Perdeep [mailto:[EMAIL PROTECTED]] 
> Sent: Friday, February 27, 2004 12:36 PM > To: [EMAIL PROTECTED] > Subject: [Perl-unix-users] conversion between exponential and 
> corresponding integer value > 
> > Dear Perl 
Gurus, > > I need help to 
convert an exponential value such as 10e-5 to > its 
integer value and vice versa in a perl script. > 
> Thanks in advance for any help. > perdeep > > 
Perdeep K. Mehta > Hartwell Center for Bioinformatics 
& Biotechnology > St. Jude Children's Research 
Hospital > Memphis, TN 38105-2794 > Tel: 901-495 3774 > http://www.hartwellcenter.org > 
> > > ___ > Perl-Unix-Users mailing list > [EMAIL PROTECTED] > To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs > 

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



___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: [Perl-unix-users] Net::FTP question

2004-03-18 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> Hello all.
> 
> I'm trying to return the "ls" method from Net::FTP to an array like
> so: @myarray = $FTP->ls() ;
Change @myarray to $myarray
> 
> foreach (@myarray) {
@{$myarray} for @myarray

> print "$_\n";
> }
> 
> However, I'm getting in return the following :
> ARRAY(0x2046a1a0)



  Any questions and/or problems, please let me know.

  Thanks.

Wags ;)
Int: 9-8-002-2224
Ext: 408-323-4225x2224



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



___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] Simple question about split string

2004-07-27 Thread Wagner, David --- Senior Programmer Analyst --- WGO



  -Original 
Message-From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED]On Behalf Of 
Márcio OliveiraSent: Tuesday, July 27, 2004 09:13To: 
[EMAIL PROTECTED]Subject: [Perl-unix-users] 
Simple question about split string
    Hi all.
 
   I have a simple (I guess) question 
about spliting strings in perl.
 
   I need to split a string like this: 
"10.10.2.131 - - [27/Jul/2004:08:20:43 -0300] "GET http://lalala/chiclete_01.jpg HTTP/1.0" 
407 1399 TCP_DENIED:NONE" (a squid log) in some parts:
 
$ip = 10.10.1.131
$date =  [27/Jul/2004:08:20:43 
-0300]
$url_info = http://lalala/chiclete_01.jpg 

$state = TCP_DENIED:NONE
 
   How i can extract this parts 
from a var eq that string?
   This is the script I use to read the file and get 
the string ($linha) one per line:
 
#!/usr/bin/perluse strict;
 
my ($linha);open (FILE,"
 
while ( defined ($linha = ) ) {   
chomp $linha;
   
   # what i can use ? 
  Here is a start. I use the ! to let me know that I failed as part 
of the regex, but you may just want to write to another log file for you to peruse and make cahnges to your regex to capture them.  Like I say, it is a 
starting point only.
 
use strict;use warnings;
 
$_ = '10.10.2.131 - - [27/Jul/2004:08:20:43 -0300] "GET http://lalala/chiclete_01.jpg HTTP/1.0" 407 1399 
TCP_DENIED:NONE';
 
if ( ! /^(\S+).+\[([^\]]+)\]\s+"get\s+([^"]+)"\s+\d+\s+\d+\s+(\S+)/i ) 
{    printf "Expecting a hit, but did not recieve on on this 
data.\n";    printf "Data:\n<%s>\n", 
$_;    die "Verify regex and try 
again" } my $MyIpAddr = $1;my $MyTime   = 
$2;my $MyURL    = $3;my $MyMsg    = 
$4;
 
printf "IP Addr: %s\nTime: %s\nUrl: %s\nMsg: 
%s\n",    
$MyIpAddr,    
$MyTime,    
$MyURL,    
$MyMsg;    

 
Output:
IP Addr: 10.10.2.131Time: 27/Jul/2004:08:20:43 -0300Url: http://lalala/chiclete_01.jpg HTTP/1.0Msg: 
TCP_DENIED:NONE
 

where
/^(\S+).+\[([^\]]+)\]\s+"get\s+([^"]+)"\s+\d+\s+\d+\s+(.+)/i  
^- 
start of variable
(\S+)- Capture 
NON Space
 .+\[- skip until you hit 
[
[([^\]]+)  - capture until you hit a 
]
]\s+"get\s+ - skip by the 
get
([^"]+) - cpature untilyou hit 
"    Note: This will have the HTTP/1.0. Uncertain if it can be 
aything else
\s+\d+\s+\d+\s+  - space(s) Number(s) 
Space(s) Number(s)
(.+) - Capture to end of 
variable 
 
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.
***


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: [Perl-unix-users] sorting hash values

2004-07-29 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> hi!
> 
> I need to organize a list of values i a hash, but i don't know how.
> 
> ex:
> 
> my %urls;
> 
> $urls{uol} = 1;
> $urls{aol} = 2;
> $urls{txt} = 3;
> 
> ## if i use this:
> 
> @num = sort keys(%url};
> 
> foreach $number(@num) {
>print $number."\n";
> }

try:
foreach my $MyKey (sort {$urls{$a} <=> $urls{$b} } keys %urls) {
printf "%3d %s\n",
$urls{$MyKey},
$MyKey;
   }

Output:
  1 uol
  2 aol
  3 txt

WAGs ;)

> 
> ## I have this output:
> 
> aol
> txt
> uol
> 
> ## how i can organize the values and print the values hash "key",
> with this output (sorted by hash values):
> 
> 1 uol
> 2 aol
> 3 txt
> 
> thank's
> 
> Atenciosamente,
> 
> Márcio Oliveira
> LPIC-1
> 
> 
> ___
> Perl-Unix-Users mailing list
> [EMAIL PROTECTED]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



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


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] sorting hash values

2004-07-29 Thread Wagner, David --- Senior Programmer Analyst --- WGO



They are the default variables used by sort for their processing.  
That is why you want to be careful if you are using the variables $a and $b and 
playing with sort besides.
 
Wags ;)  ps to get a descending sort then switch where a and b are 
used and it now becomes a descending sort verses an ascending 
sort.
 
-Original Message-From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED]On Behalf Of 
Márcio OliveiraSent: Thursday, July 29, 2004 12:04To: 
[EMAIL PROTECTED]Subject: RE: 
[Perl-unix-users] sorting hash values
this solution perfectly work to me:
foreach ( sort { $urls{$a} <=> $urls{$b} } keys %urls ) 
{   print LOG "$urls{$_} $_\n";}
 
thank' to all;
 
but I'm a beginner in perl programing world and i'd like to know how the $a 
and $b vars work in this case. 
 
thank's again!
 
Márcio Oliveira
LPIC-1

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


___
Perl-Unix-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: [Perl-unix-users] split on array

2005-06-02 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> Hi,
> 
> I am not able to split a string and build an array. I am reading the
> lines from a file. I could not understand what I am doing wrong here.
> 
> My code is below:
> 
> #!/usr/bin/perl -w
> #
> 
> --
> my $spool_file="gwcd";
> my $gwcd_file="/appl/loopqual/ait/log/$spool_file.lst";
> my ($wc_cd,$ind,$dm1,$dm2,$row_ct,$row);
> my (@wc,@source_ind,@dummy1,@dummy2,@wc_row_ct,@data);
> 
>   print "open $gwcd_file\n";
>   open(GWCDIN, "< $gwcd_file");  #|| die "can't open $gwcd_file: $!";
>   if ($? == 0)
>   {
> print "open successful\n";
> while ()
> {
>   $row = $_;
>  ( $wc_cd, $ind, $dm1, $row_ct, $dm2 ) = split(/\s*/,$row);

Believe it is breaking on each character since you state it can or can 
not be there.  Similar to //.  Change to \s+ and you will get the the first 
number, but don't see where you would get that second number. Believe from your 
code it should be 471453 and not 725906.

Wags ;) ps I made assumption that the 2 on the separate line was all part of 
one line. Changed into __DATA__ and ran the test for printing.


>  push(@wc,$wc_cd);
>  push(@source_ind,$ind);
>  push(@wc_row_ct,$row_ct);
> }  # end while
> 
> print "$wc[10]\n";
> print "$wc_row_ct[10]\n";
>   }
> close GWCDIN;
> 
> The input file is below:
> 
> 313222   A 12/02/2003  44453
> 2
> 630620   A 02/28/2005 826240
> 2
> 847464   A 02/28/2005  29155
> 2
> 847576   A 02/28/2005  14147
> 2
> 847286   A 02/28/2005   5274
> 2
> 630323   A 03/01/2005 785867
> 2
> 708387   A 03/01/2005 725906
> 2
> 815932   A 03/01/2005 644998
> 2
> 616249   A 03/01/2005 620161
> 2
> 513422   A 03/01/2005 488744
> 2
> 708335   A 03/01/2005 471453
> 2
> 419422   A 03/01/2005 469839
> 2
> 419865   A 03/01/2005 389593
> 2
> 
> When I print, I was expecting the program to print 708335 and 725906
> on two separate lines. But the program is printing 7 and 3 on two
> separate lines.
> 
> Any help is really appreciated.
> 
> Thanx..
> -Bheem
> 
> ___
> Perl-Unix-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



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


___
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] Printer perl module printing on same line

2005-09-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> My problem is that arrays are being printed all on one line (as much
> as it can) instead of one line per element.  What do I need to do
> with the data?
> 
> use Printer;
> 
> my @data = ('This is line one','This line two');
Need to add \n for each line or see if Printer has a way to associate 
\n with each element. You could add the following:
  my @data = ('This is line one' . "\n" ,'This line two' . "\n" );
Wags ;)

> 
> $prn = new Printer();
> $prn->use_default;
> $prn->print(@data);
> 
> #---
> #perl 5.86
> #printer 0.98
> #Win32-Printer 0.90 (if this problem is related to Win32 modules, my
> apologies)
> ___
> Perl-Unix-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



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


___
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


RE: [Perl-unix-users] File Find

2006-02-23 Thread Wagner, David --- Senior Programmer Analyst --- WGO



    Then do a opendir and readdir instead of the 
file::find.
 
Wags ;)

  -Original Message-From: 
  [EMAIL PROTECTED] 
  [mailto:[EMAIL PROTECTED]On Behalf Of 
  Sharp, CraigSent: Thursday, February 23, 2006 
  12:26To: 
  [email protected]: [Perl-unix-users] 
  File Find
  
  I have a script that uses 
  file::find to create a list of files within a subdirectory.  Depending on 
  the size of the directory, find can be very resource intensive.  I need 
  to find a better way to generate a list of files within a subdirectory for 
  comparison to a time for deletion.
   
  TIA
   
   
  Best regards,
  Craig 
  Sharp
   
   
  Quicken 
  Loans | Unix Engineer 
  | Direct: 734.805.7839 
  | Fax: 734.805.5513 
  | [EMAIL PROTECTED]
  
  The contents of this e-mail are 
  intended for the named addressee only. It contains information that may be 
  confidential. Unless you are the named addressee or an authorized designee, 
  you may not copy or use it, or disclose it to anyone else. If you received it 
  in error please notify us immediately and then destroy it.
   

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


___
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

RE: [Perl-unix-users] Populating a spreadsheet from files

2006-03-06 Thread Wagner, David --- Senior Programmer Analyst --- WGO
[EMAIL PROTECTED] wrote:
> Hi,
> Not sure if that is what you want, but I did it once by retrieving
> information from MySQL database and then writing it to .csv file. 
> When user clicks in .csv file link, it opens in Excel (IE only)
> Worked for me,
> Regards,
> VM
The real question is what do you want the Excel spreadsheet to be? if 
you have formulas, etc, then would use Spreadsheet::WriteExcel. But if you can 
populate the rows the way you want, then the .csv is the easiest way to do the 
processing. As along as you provide the necessry key fields on each line, then 
the user can do whatever they want with the data.

Wags ;)
> 
>   -Original Message-
>   From: [EMAIL PROTECTED] on behalf of
>   Sharp, Craig Sent: Mon 3/6/2006 4:09 PM
>   To: [email protected]
>   Cc:
>   Subject: [Perl-unix-users] Populating a spreadsheet from files
> 
> 
> 
>   Hi all,
> 
> 
> 
>   Does anyone have an example of using Perl to populate an excel
> spreadsheet with data from multiple files.  I need to do this
> automatically.  
> 
> 
> 
>   Best regards,
> 
>   Craig Sharp
> 
> 
> 
> 
> 
>   Quicken Loans | Unix Engineer | Direct: 734.805.7839 | Fax:
> 734.805.5513 | [EMAIL PROTECTED] 
> 
>   
> 
>   The contents of this e-mail are intended for the named addressee
> only. It contains information that may be confidential. Unless you
> are the named addressee or an authorized designee, you may not copy
> or use it, or disclose it to anyone else. If you received it in error
> please notify us immediately and then destroy it.
> 
> 
> 
> 
> 
> 
> = 
> 
>  Please note that this e-mail and any files transmitted with it
>  may be privileged, confidential, and protected from disclosure
>  under applicable law. If the reader of this message is not the
>  intended recipient, or an employee or agent responsible for
>  delivering this message to the intended recipient, you are
>  hereby notified that any reading, dissemination, distribution,
>  copying, or other use of this communication or any of its
>  attachments is strictly prohibited.  If you have received this
>  communication in error, please notify the sender immediately by
>  replying to this message and deleting this message, any
>  attachments, and all copies and backups from your computer.
> 
> ___
> Perl-Unix-Users mailing list
> [email protected]
> To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs



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


___
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs


Re: [Perl-unix-users] Regular expression question

2006-08-01 Thread Wagner, David --- Senior Programmer Analyst --- WGO
Title: Regular expression question



From: 
[EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED] On Behalf Of 
Cai, Lucy (L.)Sent: Monday, July 31, 2006 17:21To: 
Cai, Lucy (L.); [email protected]; 
[email protected]; 
[EMAIL PROTECTED]; 
[EMAIL PROTECTED]Subject: Regular 
_expression_ question

I have a file such as: 
My $file = "c:\temp\zips\ok.txt"; 
How can I split the $file to get the only 
path: 
My $dir = "c:\temp\zips"; My $file = "ok.txt"; 
Thanks in advance! 
Lucy  
Better to use File::Basename which will break it out for you. Comes 
as part of std Perl.
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.
**
 
___
Perl-Unix-Users mailing list
[email protected]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs