Please help... struggling beginner.

2003-06-23 Thread Denham Eva
Hello,

I am very much a novice at perl and probably bitten off more than I can chew
here. 
I have a file, which is a dump of a database - so it is a fixed file format.
The problem is that I am struggling to manipulate it correctly. I have been
trying for two days now to get a program to work. The idea is to remove the
duplicate records, ie a record begins with Name and ends with Values End.
The program that I have thus far, is  pathetic in the sense I have opened
three files, the file below, a data file for cleaned data, and a file for
capturing the usernames already processed. But I have got stuck on how to
compare and work through the file line for line and then only to capture the
lines that are not duplicated.
Please help - I am running out of time.

Here is the file format

File Begins
#DB dumped
#DB version 8.0
#SW version 2.6(1.10)
#---
--
Name  : system
Some stuff here... 
many lines
Of different format... 
such as line below...
User Count: 0
##--- User End
Lots of text here...
Until...
We get line below...
##--- Values End
#---
--
Name  : ###profile0
Some stuff here... 
many lines
Of different format... 
such as line below...
User Count: 188
##--- User End
Lots of text here...
Until...
We get line below...
##--- Values End
#---
--
Name  : vermaakm
Some stuff here... 
many lines
Of different format... 
such as line below...
User Count: 0
##--- User End
Lots of text here...
Until...
We get line below...
##--- Values End
#---
--
Name  : TFMC\vanzylm
Some stuff here... 
many lines
Of different format... 
such as line below...
CounterRst_01 : 2acac9101c335c8
##--- User End
Lots of text here...
Until...
We get line below...
##--- Values End
#---
--
#End Of Dump
File Ends



Denham Eva
Oracle DBA
Linux like TeePee... No Windows, No Gates and Apache inside!


_
This e-mail message has been scanned for Viruses and Content and cleared 
by MailMarshal

For more information please visit www.marshalsoftware.com
_

#
Note:
This message is for the named person's use only.  It may contain confidential,
proprietary or legally privileged information.  No confidentiality or privilege
is waived or lost by any mistransmission.  If you receive this message in error,
please immediately delete it and all copies of it from your system, destroy any
hard copies of it and notify the sender.  You must not, directly or indirectly,
use, disclose, distribute, print, or copy any part of this message if you are not
the intended recipient. TFMC and any of its subsidiaries each reserve
the right to monitor all e-mail communications through its networks.

Any views expressed in this message are those of the individual sender, except where
the message states otherwise and the sender is authorized to state them to be the
views of any such entity.

Thank You.

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



Log into a site and do stuff

2003-06-23 Thread Aman Thind
Hi

I am working on a module that occasionally needs to raise alarms by sending
sms to concerned ppl.

For this, I would like to login to the site : www.sms.ac

The login page is http://www.sms.sc/login.asp

Then I have to go to the main page , fill the To: and Message: textboxes and
send sms.

I have no prior experience with LWP and couldn't make much use of perldoc
lwpcook

Could someone please tell me how I can accomplish this feat.

A pointer towards a newbie resource on this perl feature or some sample code
will surely help.

Thanks
aman

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



Re: Please help... struggling beginner.

2003-06-23 Thread Tassilo von Parseval
On Mon, Jun 23, 2003 at 10:43:07AM +0200 Denham Eva wrote:

 I am very much a novice at perl and probably bitten off more than I can chew
 here. 
 I have a file, which is a dump of a database - so it is a fixed file format.
 The problem is that I am struggling to manipulate it correctly. I have been
 trying for two days now to get a program to work. The idea is to remove the
 duplicate records, ie a record begins with Name and ends with Values End.
 The program that I have thus far, is  pathetic in the sense I have opened
 three files, the file below, a data file for cleaned data, and a file for
 capturing the usernames already processed. But I have got stuck on how to
 compare and work through the file line for line and then only to capture the
 lines that are not duplicated.

Keeping a couple of files around is not necessarily pathetic. I think
you don't need a file for the processed usernames. But the original file
and one for the processed data is a totally common pattern.

 Here is the file format
 
 File Begins
 #DB dumped
 #DB version 8.0
 #SW version 2.6(1.10)
 #---
 --
 Name  :   system
 Some stuff here... 
 many lines
 Of different format... 
 such as line below...
 User Count:   0
 ##--- User End
 Lots of text here...
 Until...
 We get line below...
 ##--- Values End
 #---
 --

So, #-... is essentially the record separator? A fixed separator
is good because it makes processing rather easy. It might be handy to
both set the input record separator to this value:

#! /usr/bin/perl -w

use strict;

local $/ = 
#-\n;

open IN, old_database or die $!;
open OUT, new_database or die $!;

# keep track of what records have already been seen
my %records_seen;

# this is the 'header', that is: what is before the first record
print OUT scalar IN;  

while (IN) {
if (/Name\s+:\s+(\S+)/) {
#^^^
# $1 is record name
next if $records_seen{ $1 }++;
print OUT $_;
}
}

print OUT #End Of Dump\n;

close IN;
close OUT;

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval


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



Re: Please help... struggling beginner.

2003-06-23 Thread Paul Johnson

Denham Eva said:
 Hello,

 I am very much a novice at perl and probably bitten off more than I can
 chew
 here.
 I have a file, which is a dump of a database - so it is a fixed file
 format.
 The problem is that I am struggling to manipulate it correctly. I have
 been
 trying for two days now to get a program to work. The idea is to remove
 the
 duplicate records, ie a record begins with Name and ends with Values End.
 The program that I have thus far, is  pathetic in the sense I have opened
 three files, the file below, a data file for cleaned data, and a file for
 capturing the usernames already processed. But I have got stuck on how to
 compare and work through the file line for line and then only to capture
 the
 lines that are not duplicated.
 Please help - I am running out of time.

You forgot to attach your code.  If you let us see what you've done it
is usually easier to provide relevant help.

I'm not sure I completely understand your problem, but here is a script
which will remove records with duplicate names.


#!/bin/perl -w

use strict;

$/ = #. - x 77 . \n;

my %seen;

while ()
{
if (my ($name) = /^Name  : +(\S+)/)
{
next if $seen{$name};
$seen{$name}++;
}
print;
}

__END__


The trick is to set $/ to the line which is separating your records so
that each record is read in as a whole.  Then I simply extract the name
from the record and don't print it if it has been seen already.  I
suspect that your actual requirements will differ here.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


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



Why

2003-06-23 Thread Scott_G
Hello. I am new to Perl. I used to program in C years ago (not C++ # etc)

I have the simplest question. I am running active state perl 5 on Win XP.

I'm using OpenPERL Ide 1.0

#!k:/perl/bin/perl.exe
#
# Camel-Learning Perl
# Exercise 2-4
# Input a  b from Console STDIN
# Then multiply  print them
#
print Enter an integer: ,$a=STDIN;# This don't work
#
print Enter an integer: \n;# Neither does this
$a=STDIN;# ...

This program excerpt above is driving me crazy! I can NOT get the PROMPT to appear 
BEFORE the program waits for input. I have tried several different ways to do this. No 
matter what I do, the screen stays blank, until I enter a value, THEN the prompt is 
printed! This works for me, but when I get into a larger program, the USER is going to 
have to read the PROMPT BEFORE they know what to type in!

Can you help me out here?

Thank you,
Scott Graham


###
# #
#   SGM Systems  -  Scott Graham  #
# #
#   Professional Web Development  Hosting Services   #
#   Professional E-Mail  List Hosting Services   #
# #
#Contact:  [EMAIL PROTECTED] #
#Visit: http://www.sgmsys.com #
# #
###




context, printing, and concatenation

2003-06-23 Thread Peter
I'm on the first few chapters of Learning Perl and came up with a
question. Given:

-

#!/usr/bin/perl

@array = qw ( one two three );
print @array . \n;
print @array;

-

Can you explain why the first print statement prints 3 (and a carriage
return) while the second prints onetwothree?  My understanding is that
the first print sees the array in scalar context while the second sees
it in list context, but if so I don't understand why.  Can someone break
it down what the concatenation operator is doing here?

Thanks.

-- 
You can't waste a life hating people, because all they do is live their
life, laughing, doing more evil.
 -- Alpha Robertson, whose daughter was killed in a Birmingham church
 bombing in 1963. 

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



installing modules

2003-06-23 Thread mario kulka
How can I install the MD5 module on the server where I'm hosting my website?

_
MSN 8 helps eliminate e-mail viruses. Get 2 months FREE*.  
http://join.msn.com/?page=features/virus

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


installing modules

2003-06-23 Thread mario kulka
Could anyone give me step by tep instructions on how to install a perl 
module (MD5) on my host server. How come they don't have it installed? Isn't 
popular enough?

Sorry if I sent the same message for the second time, but the prvious one 
doesn't came through on my list.

Mariusz

_
Add photos to your messages with MSN 8. Get 2 months FREE*.  
http://join.msn.com/?page=features/featuredemail

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


Re: context, printing, and concatenation

2003-06-23 Thread Paul Johnson

Peter said:

 I'm on the first few chapters of Learning Perl and came up with a
 question. Given:

 -

 #!/usr/bin/perl

 @array = qw ( one two three );
 print @array . \n;
 print @array;

 -

 Can you explain why the first print statement prints 3 (and a carriage
 return) while the second prints onetwothree?  My understanding is that
 the first print sees the array in scalar context while the second sees
 it in list context, but if so I don't understand why.  Can someone break
 it down what the concatenation operator is doing here?

Your understanding is correct.  Concatenation works on scalars, so the
array is evaluated in scalar context, returning 3, which is concatenated
with \n and then printed.

In the second line, print takes a list, so the array is evaluated in list
context.

-- 
Paul Johnson - [EMAIL PROTECTED]
http://www.pjcj.net


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



perl reg exp problem

2003-06-23 Thread Robin Garbutt
Hi all,

I have a string that is a random sequence like the following:-

ACGTCGTCGTCACACACACGCGTCTCTATACGCG

I want to be able to parse the string, picking out any TATA sequences, colour them in 
red and make a not of where ther lie in the sequence.

Is this possible with perl?

cheers

Rob.

===
Netnorth Limited
7-8 Queensbrook
Bolton Technology Exchange
Bolton
BL1 4AY

d/l: 01204 900714
tel: 01204 900700
Fax: 01204 900777

email: [EMAIL PROTECTED]

===

~~

Why not try our dial-up ? 
Modem Tel: 0845 055 0006
Username: netnorthdial
Password: netnorthdial

All formats supported, including V90, ISDN, ISDN dual channel, Mobile Phones

~~

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



Re: perl reg exp problem

2003-06-23 Thread Janek Schleicher
Robin Garbutt wrote at Mon, 23 Jun 2003 11:40:47 +0100:

 I have a string that is a random sequence like the following:-
 
 ACGTCGTCGTCACACACACGCGTCTCTATACGCG
 
 I want to be able to parse the string, picking out any TATA sequences,
 colour them in red and make a not of where ther lie in the sequence.
 
 Is this possible with perl?

Yes, but you have to explain in what matter you want to colorize.
As output in a terminal window, as html/xml, as a picture, as a word
document ... .

If you would have in a pseudo-xml with the tag red.../red,
you would perhaps do it as:

$string =~ s/(TATA)/red$1/red/g;


Greetings,
Janek

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



Re: installing modules

2003-06-23 Thread Janek Schleicher
Mario Kulka wrote at Mon, 23 Jun 2003 03:40:03 +:

 Could anyone give me step by tep instructions on how to install a perl 
 module (MD5) on my host server. How come they don't have it installed? Isn't 
 popular enough?

BTW, the MD5 module is deprecated. It is recommended to install
Digest::MD5 instead.

The simplest way to install it is to type
perl -MCPAN -e 'install Digest::MD5'

The other, more classical way to install is to get the
package from cpan
(http://search.cpan.org/CPAN/authors/id/G/GA/GAAS/Digest-MD5-2.24.tar.gz)
to unpack it and then to follow the normal way
perl Makefile.PL
make
make test
make install
 (last as root)

Please read also
perldoc perlmodinstall
to get a more detailed explication.


Greetings,
Janek

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



RE: perl reg exp problem

2003-06-23 Thread Robin Garbutt
what does shift do in perl?

cheers

Rob.

 -Original Message-
 From: Janek Schleicher [mailto:[EMAIL PROTECTED]
 Sent: 23 June 2003 08:52
 To: [EMAIL PROTECTED]
 Subject: Re: perl reg exp problem
 
 
 Robin Garbutt wrote at Mon, 23 Jun 2003 11:40:47 +0100:
 
  I have a string that is a random sequence like the following:-
  
  ACGTCGTCGTCACACACACGCGTCTCTATACGCG
  
  I want to be able to parse the string, picking out any TATA 
 sequences,
  colour them in red and make a not of where ther lie in the sequence.
  
  Is this possible with perl?
 
 Yes, but you have to explain in what matter you want to colorize.
 As output in a terminal window, as html/xml, as a picture, as a word
 document ... .
 
 If you would have in a pseudo-xml with the tag red.../red,
 you would perhaps do it as:
 
 $string =~ s/(TATA)/red$1/red/g;
 
 
 Greetings,
 Janek
 
 -- 
 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: Why

2003-06-23 Thread Janek Schleicher
Scott_g wrote at Sun, 22 Jun 2003 15:21:24 -0500:

 Hello. I am new to Perl. I used to program in C years ago (not C++ #
 etc)
 
 I have the simplest question. I am running active state perl 5 on Win
 XP.
 
 I'm using OpenPERL Ide 1.0
 
 #!k:/perl/bin/perl.exe
 #
 # Camel-Learning Perl
 # Exercise 2-4
 # Input a  b from Console STDIN
 # Then multiply  print them
 #
 print Enter an integer: ,$a=STDIN;# This don't work

Perl interpretes this as
print( Enter an integer: , $a=STDIN ); So it can executes print only
when both arguments are evaluated first, forcing you to enter $a before
you see the prompt.

 #
 print Enter an integer: \n;# Neither does
 this $a=STDIN;# ...
 
 This program excerpt above is driving me crazy! I can NOT get the PROMPT
 to appear BEFORE the program waits for input. I have tried several
 different ways to do this. No matter what I do, the screen stays blank,
 until I enter a value, THEN the prompt is printed! This works for me, but
 when I get into a larger program, the USER is going to have to read the
 PROMPT BEFORE they know what to type in!

Try instead the explicit
print(Enter an integer: ),$a=STDIN;

allthough I still would prefer in most cases to write the semicolon
instead of the comma
(but of course in some cases it's very useful like
 print(...),$x=STDIN unless defined($x);
)


Greetings,
Janek

PS: $a is a bad name for a variable as it is a global variable used for
sortings. (Read perldoc perlvar for details).

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



Re: There has to be a way to do this

2003-06-23 Thread scott . e . robinson

I don't have code to do what I want, but here's the pieces I'm trying to
string together:

Abbreviation dictionary consists of a file like this:

SRED. SREDNE
SEV.  SEVERN
etc.

Each abbreviation is turned into four regexes, like this (doubtless they
could be made more efficient, but they work well enough at present):

# Sred. = SREDNE
$cgname =~ s/^SRED\.(?=[\W\s\-\d]+)/SREDNE:/g ;   # Match it at
beginning of line
$cgname =~ s/[\W\s\-]+SRED\.(?=[\W\s\-\d]+)/:SREDNE:/g ;  # Match it
within the line
$cgname =~ s/[\W\s\-]+SRED\.$/:SREDNE:/g ;  # Match it at end
of line
$cgname =~ s/^SRED\.$/:SREDNE:/g ;  # Match if it
begins  ends line

# Sev.  = SEVERN
$cgname =~ s/^SEV\.(?=[\W\s\-\d]+)/SEVERN:/g ;# Match it at
beginning of line
$cgname =~ s/[\W\s\-]+SEV\.(?=[\W\s\-\d]+)/:SEVERN:/g ;   # Match it
within the line
$cgname =~ s/[\W\s\-]+SEV\.$/:SEVERN:/g ;   # Match it at end
of line
$cgname =~ s/^SEV\.$/:SEVERN:/g ;   # Match if it
begins  ends line

etc.

Right now I'm generating the regexes in a standalone script, then inserting
the output code into the subroutine that processes names into a matchable
form.

What I'd like to be able to do is take a *set* of abbreviation
dictionaries, concatenate them together and dynamically generate the
regex code in the routine that is going to execute it.

Thanks,

Scott

Scott E. Robinson
SWAT Team
UTC Onsite User Support
RR-690 -- 281-654-5169
EMB-2813N -- 713-656-3629


   

  David Kirol

  [EMAIL PROTECTED]To:  [EMAIL PROTECTED]   
  
   cc:

Subject:   Re: There has to be a 
way to do this
   

  06/20/03 08:38 PM

   

   




Scott,
 Sounds like a fun problem. Can you post some code and an
(abbreviated) set
of example data?
David

Scott E Robinson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]...
 I'm still working on the well-name matching program that I've brought up
 here before.  I've received invaluable help to solve the toughest
questions
 in its development, for which I'm very grateful.

 Now I'm trying to automate some steps which were previously manual in the
 process, to make it more end-user-friendly.  There has to be a way to do
 this with Perl.

 The script uses a dictionary of abbreviations to aid its matching.  The
 abbreviations are implemented as a series of substitutions with the s
 operator.  I have a Perl script which builds the substitution statements
 from a tab-delimited list of abbreviations and their equivalent long
forms.
 I then manually insert these statements into the subroutine that uses
them.

 I kept the abbreviation translation hardcoded into the subroutine for
 performance reasons (this thing compares 14,000 unknown well names
against
 680,000 match candidates).  Is there a way in Perl to read the
abbreviation
 dicitionary (the tab-delimited list), generate the code, insert it into
the
 right subroutine, and start executing the program, all in one script?
 (Maybe you can tell me that the performance hit from using variables in
the
 substitution statements is negligible, and if so, I'd be happy to go that
 route.)

 Thanks in advance,

 Scott

 Scott E. Robinson
 Data SWAT Team
 UTC Onsite User Support
 RR-690 -- 281-654-5169
 EMB-2813N -- 713-656-3629







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



RE: Why

2003-06-23 Thread Charles K. Clarkson
Scott_G [EMAIL PROTECTED] wrote:
: 
: Hello. I am new to Perl. I used to program in C
: years ago (not C++ # etc)
: 
: I have the simplest question. I am running active
: state perl 5 on Win XP.
: 
: I'm using OpenPERL Ide 1.0
: 

It's probably your IDE.

This works from a console:

print Enter an integer: \n;
my $answer = STDIN;

print Enter another integer: \n;
$answer = STDIN;


It fails in my editor because the editor is
using a method that captures i/o from a console
under windows XP. Open a console (DOS prompt)
and type the following (change where appropriate).

perl path/to/script/script.pl


: This works for me, but when I get into a larger
: program, the USER is going to have to read the
: PROMPT BEFORE they know what to type in!

If you force your window users to use a console,
this is most likely how they will access it. Not
through your IDE. Using a command line interface on
a windows platform would really lower the usage of
your program though. Windows users want GUIs.


HTH,

Charles K. Clarkson
-- 
Head Bottle Washer,
Clarkson Energy Homes, Inc.
Mobile Home Specialists
254 968-8328














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



Re: perl reg exp problem

2003-06-23 Thread Rob Anderson

Robin Garbutt [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]
what does shift do in perl?

cheers

Rob.

 -Original Message-
 From: Janek Schleicher [mailto:[EMAIL PROTECTED]
 Sent: 23 June 2003 08:52
 To: [EMAIL PROTECTED]
 Subject: Re: perl reg exp problem


 Robin Garbutt wrote at Mon, 23 Jun 2003 11:40:47 +0100:

  I have a string that is a random sequence like the following:-
 
  ACGTCGTCGTCACACACACGCGTCTCTATACGCG
 
  I want to be able to parse the string, picking out any TATA
 sequences,
  colour them in red and make a not of where ther lie in the sequence.
 
  Is this possible with perl?

 Yes, but you have to explain in what matter you want to colorize.
 As output in a terminal window, as html/xml, as a picture, as a word
 document ... .

 If you would have in a pseudo-xml with the tag red.../red,
 you would perhaps do it as:

 $string =~ s/(TATA)/red$1/red/g;


 Greetings,
 Janek

 --
 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: perl reg exp problem

2003-06-23 Thread Rob Anderson
Opps double clicked first time round, I blame my mouse :-)

Robin, perl has online documentation for all it's functions and much more.
try the following

perldoc -f shift

and

perldoc perldoc

for more general advice

HTH


Rob Anderson [EMAIL PROTECTED] wrote in message
news:[EMAIL PROTECTED]

 Robin Garbutt [EMAIL PROTECTED] wrote in message
 news:[EMAIL PROTECTED]
 what does shift do in perl?

 cheers

 Rob.

  -Original Message-
  From: Janek Schleicher [mailto:[EMAIL PROTECTED]
  Sent: 23 June 2003 08:52
  To: [EMAIL PROTECTED]
  Subject: Re: perl reg exp problem
 
 
  Robin Garbutt wrote at Mon, 23 Jun 2003 11:40:47 +0100:
 
   I have a string that is a random sequence like the following:-
  
   ACGTCGTCGTCACACACACGCGTCTCTATACGCG
  
   I want to be able to parse the string, picking out any TATA
  sequences,
   colour them in red and make a not of where ther lie in the sequence.
  
   Is this possible with perl?
 
  Yes, but you have to explain in what matter you want to colorize.
  As output in a terminal window, as html/xml, as a picture, as a word
  document ... .
 
  If you would have in a pseudo-xml with the tag red.../red,
  you would perhaps do it as:
 
  $string =~ s/(TATA)/red$1/red/g;
 
 
  Greetings,
  Janek
 
  --
  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: Can LWP::Simple tranfer image urls?

2003-06-23 Thread Dan Muey
 Finally, some usefull stuff in Perl ;-))


Finally? This is the Perl list not the PHP list ;p

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



Process question

2003-06-23 Thread Steve Blumenkrantz
Since I didn't get any responses on my last question about process creation
and the killing of child processes I thought that maybe I'd switch gears a
bit and ask:

On Unix  does one know how I can get the process id of a process kicked off
from within a perl script via the back-tic (`) syntax?  Or a module which
allows the running of sub programs which also will return the process id of
the sub program?

Thanks,

Steve



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



SSH Problem

2003-06-23 Thread Rudolf Kliemstein
Hi all,

i have the following problem with the following script:

#!/usr/bin/perl -w
# $Id: cmd.pl,v 1.4 2001/02/22 00:14:48 btrott Exp $

use strict;

use Net::SSH::Perl;
use Net::SSH::Perl::Cipher;

chomp(my $this_host = `hostname`);
print Enter a host name to connect to: [$this_host] ;
chomp(my $host = STDIN);
print \n;

print Enter the port number of the remote sshd: [ssh] ;
chomp(my $port = STDIN);
print \n;

print Choose a cipher from the list:\n;
my $supp = Net::SSH::Perl::Cipher::supported();
for my $ciph (sort @$supp) {
printf [%d] %s\n, $ciph, Net::SSH::Perl::Cipher::name($ciph);
}
printf Enter a number: [%d] , Net::SSH::Perl::Cipher::id('IDEA');
chomp(my $c = STDIN);
print \n;
my $ssh = Net::SSH::Perl-new($host || $this_host,
port = $port || 'ssh',
cipher = Net::SSH::Perl::Cipher::name($c),
debug = 1);

my $this_user = scalar getpwuid($);
print Enter your username on that host: [$this_user] ;
chomp(my $user = STDIN);

use Term::ReadKey;

print And your password: ;
ReadMode('noecho');
chomp(my $pass = ReadLine(0));
ReadMode('restore');
print \n;

$ssh-login($user || $this_user, $pass);

print Enter a command to execute: [ls -l] ;
chomp(my $cmd = STDIN);

my($out, $err) = $ssh-cmd($cmd || ls -l);
print $out;each time i run the script it gets me the error that the input into the 
crypt-module must be 8 byte long.when i replace the $cmd with a plain command e.g.: 
ls -l it works.Pls help me out.ThxRudi


RE: Quick CGI query_string() question

2003-06-23 Thread Dan Muey

  So if $q above is : hi=byelove=hateone=twoetc=etc
 
 Hmmm.  Do you work for the State Department or something?  Or 
 the White House Press office?

That was a good one

 
  I want to remove, say 'love', so it'd be: hi=byeone=twoetc=etc
 
  I know I could do a regex but I'd like a CGI way to do
 
 Why mess with it?  If you need a string without the 
 particular parameters, you could easily regex them out:in the 
 variable itself, but the query string of the CGI object is 
 basically meant as a read-only attribute.  Why not just work 
 with the variable $q?  Since the CGI module is basically 
 object-oriented, the CGI way to do it would be to just let 
 the internals of the CGI object be, use what you need, and 
 leave the rest.
 
 It would probably help to know what actual effect you are 
 trying to achieve that you see as requiring manipulation of 
 the query string.

Well what I wanted to do was this:

Take the value of a param, remove it and replace it with something else based on what 
the original param was:

Joe=mamado=this
If($do = 'this') { $work = 'hard'; } else { $work = 'lazy'; }
Joe=mamawork=$work

Then I use this string to as an argument to a backtick execution.

It's to verify input and an extra layer to keep evil things out.

The CGI delete() function did the trick for this.

Thanks

Dan


 
 Joseph
 
 

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



RE: Can LWP::Simple tranfer image urls?

2003-06-23 Thread Dan Muey
 
 Do I need to change the http header for transfering image 
 urls?  I get errors 

Yes.
And what do you mean by 'transfer'?
You may want Net::FTP

 when I transfer a jpg:
 picture cannot be displayed because it contains errors.
 

Try this:

#!/usr/bin/perl -w

use strict;
use LWP::Simple;
print Content-type: image/gif\n\n;
print get(http://www.google.com/images/logo.gif;);


Use warnings and strict to track down errors.

HTH

DMuey

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



Re: context, printing, and concatenation

2003-06-23 Thread Jeff 'japhy' Pinyan
On Jun 22, Peter said:

print @array . \n;
print @array;

Can you explain why the first print statement prints 3 (and a carriage
return) while the second prints onetwothree?  My understanding is that
the first print sees the array in scalar context while the second sees
it in list context, but if so I don't understand why.  Can someone break
it down what the concatenation operator is doing here?

The concatenation operator joins two SCALARS together.  That means that
its two arguments will be evaluated in scalar context, so it's like saying

  print( (scalar(@array) . \n) );

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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]



CHOMP and {$query-param( question...

2003-06-23 Thread Gregg O'Donnell
I have a Publication Order Form, with checkboxes beside each title. The list needs to 
be emailed to ONLY the department that carries the publication ordered (not all 
departments).
 
I think I should I grab the form data, use CHOMP to get only fire from fire-01 but 
then how do I get it into {$query-param(  (see snip3) so I can associate it with 
the email address?
 
Many thanks,
Gregg
 
snip1
##
# Assigned variables (left of =) from FORM INPUT (right of =)
##
my $ri_001 = $query-param('oreports001');   # not required
my $ri_002 = $query-param('oreports002');   # not required
##
# Variables - Forest Management section  
##
my $mgt_01 = $query-param('mgt-01');# not required
my $mgt_02 = $query-param('mgt-02');# not required
##
# Variables - Forest Protection section  
##
my $fire_01 = $query-param('fire-01');# not required
my $fire_02 = $query-param('fire-02');# not required
/snip1
snip2
my %divisions = (
Fire = { 
  contact = '[EMAIL PROTECTED]',
  Abbrev = 'Fire',
},
'Resource Info' = {
  contact = '[EMAIL PROTECTED]',
  Abbrev = 'RI',
},
Management = {
  contact = '[EMAIL PROTECTED]',
  Abbrev = 'MGT',
}
/snip2
snip3
# return EMAIL ADDRESS for VDOF DIVISIONS
my $contact = $divisions{$query-param('??')}-{contact} || '';
/snip3
 


-
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!

Re: perl reg exp problem

2003-06-23 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Janek Schleicher 
wrote:

 Robin Garbutt wrote at Mon, 23 Jun 2003 11:40:47 +0100:
 
 I have a string that is a random sequence like the following:-
 
 ACGTCGTCGTCACACACACGCGTCTCTATACGCG
 
 I want to be able to parse the string, picking out any TATA sequences,
 colour them in red and make a not of where ther lie in the sequence.
 
 Is this possible with perl?
 
 Yes, but you have to explain in what matter you want to colorize.
 As output in a terminal window, as html/xml, as a picture, as a word
 document ... .

And for those of us who want to do this as an exercise, what does make a 
note mean - something like:

Line   : Char
Line 01: 27

or a multi-line char count (27,38,42,157...)?

And will there ever be a CGCGTCTCTATATACG... (overlapping) and if so, 
should one list both starting points (or just non-overlapping matches)?

As far as the color, I'm just going to use ANSI terminal codes.



-- 
Kevin Pfeiffer
International University Bremen

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



Re: There has to be a way to do this

2003-06-23 Thread Jeff 'japhy' Pinyan
On Jun 23, [EMAIL PROTECTED] said:

SRED. SREDNE
SEV.  SEVERN

# Match it at beginning of line
$cgname =~ s/^SRED\.(?=[\W\s\-\d]+)/SREDNE:/g ;

Three things -- the + modifier on the [...] isn't needed, you don't need
to put \s and - in a character class you've already put \W in, and the /g
modifier is totally worthless here... there's only ONE beginning of the
line!

  $cgname =~ s/^SRED\.(?=[\W\d])/SREDNE:/;

# Match it within the line
$cgname =~ s/[\W\s\-]+SRED\.(?=[\W\s\-\d]+)/:SREDNE:/g ;

I have a feeling you want to use \b instead of [\W\s-].  It's cleaner and
doesn't actually absorb a character.

  $cgname =~ s/\bSRED\.(?=[\W\d])/:SREDNE:/g;

# Match it at end of line
$cgname =~ s/[\W\s\-]+SRED\.$/:SREDNE:/g ;

Again, use \b, but there's no need for /g here.

  $cgname =~ s/\bSRED\.$/:SREDNE:/;

# Match if it begins  ends line
$cgname =~ s/^SRED\.$/:SREDNE:/g ;

Ah, here's an interesting case.  This is actually already handled by my
modifications.  The problem is that you were using

  /[\W\s\-]+SRED\.$/

but if the string is SRED., then [\W\s\-] can't match anything.  So
that's why using a word boundary (\b) is smarter.  Also, we can change the
look-aheads to go from positive to negative.

Instead of saying and I am followed by a non-letter, why not say and I
am NOT followed by a letter?

  $cgname =~ s/^SRED\.(?![A-Za-z])/SREDNE:/; # front
  $cgname =~ s/\bSRED\.(?![A-Za-z])/:SREDNE:/g;  # middle
  $cgname =~ s/\bSRED\.$/:SREDNE:/;  # end

If you're worried about hardcoding the letter set (A-Za-z), then you can
use this character class instead:  [^\W\d_].  It means match anything
that's not:  a non-word character, a digit, or an underscore.  It's a
sneaky way of matching anything that would be matched by \w WITHOUT
matching \d or _.

  $cgname =~ s/^SRED\.(?![^\W\d_])/SREDNE:/; # front
  $cgname =~ s/\bSRED\.(?![^\W\d_])/:SREDNE:/g;  # middle
  $cgname =~ s/\bSRED\.$/:SREDNE:/;  # end

Right now I'm generating the regexes in a standalone script, then inserting
the output code into the subroutine that processes names into a matchable
form.

What I'd like to be able to do is take a *set* of abbreviation
dictionaries, concatenate them together and dynamically generate the
regex code in the routine that is going to execute it.

So you want to take the dictionary files, and use them to create a
function that does all the regexes on its input?

-- 
Jeff japhy Pinyan  [EMAIL PROTECTED]  http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
stu what does y/// stand for?  tenderpuss 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]



Logging to a file or FH?

2003-06-23 Thread deb
I've got a script which opens a filehandle to write print statments to a file.
But, I'm also running some system commands, and I would also like to send
stdout and stderr to that filehandle.  I could just echo text to a file, or I
could use a filehandle.  Which would be better?


my $log = /tmp/log.$$;

open(LOG, $log);
print LOG Commencing maintenance\n;


But, here's how I've handled stdout and stderr in a system statement:

my $log = /tmp/log.$$;

system(path-to-command  $log 21);


Is there a way to use a filehandle instead?  Seems I'd have to take care of
block and non-blocking I/O.  Methinks it may be simpler just to stick with
printing directly to $log and not the FH, LOG.


Any advise is welcome!

deb


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



simple script

2003-06-23 Thread Tso, Joseph - eSpeed
Hi, I really green to perl and would like suggestions on creating a script
that would allow users to modify a certain file from a web page.  This file
is a list of customers a particular sales person will cover.  So, the web
page will allow this sales person to add, delete and update this customer
list at his or her discretion.  Of course, it would also be nice to assign a
password for each sales person.  Any suggestions welcome.


CONFIDENTIAL: This e-mail, including its contents and attachments, if any, are 
confidential. If you are not the named recipient please notify the sender and 
immediately delete it. You may not disseminate, distribute, or forward this e-mail 
message or disclose its contents to anybody else. Copyright and any other intellectual 
property rights in its contents are the sole property of eSpeed, Inc.
 E-mail transmission cannot be guaranteed to be secure or error-free. The sender 
therefore does not accept liability for any errors or omissions in the contents of 
this message which arise as a result of e-mail transmission.  If verification is 
required please request a hard-copy version.
 Although we routinely screen for viruses, addressees should check this e-mail and 
any attachments for viruses. We make no representation or warranty as to the absence 
of viruses in this e-mail or any attachments. Please note that to ensure regulatory 
compliance and for the protection of our customers and business, we may monitor and 
read e-mails sent to and from our server(s). 

For further important information, please see 
http://www.espeed.com/full-disclaimer.html


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



RE: simple script

2003-06-23 Thread Dan Muey

 Hi, I really green to perl and would like suggestions on 
 creating a script that would allow users to modify a certain 
 file from a web page.  This file is a list of customers a 
 particular sales person will cover.  So, the web page will 
 allow this sales person to add, delete and update this 
 customer list at his or her discretion.  Of course, it would 
 also be nice to assign a password for each sales person.  Any 
 suggestions welcome.

Well you can use open(), or if the file size isn't extremely huge
The File::Slurp Module is nice,
But you may also want to look into using the DBI Module and storiing your data
In a mysql database (or other db for that matter).

As far as the password goes it depends on how you implememt it, 
You could store it along with the data somehow and check it in the script or
Use your webserver's auth methods like htaccess to verify them and then 
Only let $ENV{'REMOTE_USER'} manage their own data.

HTH

DMuey

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



Re: installing modules

2003-06-23 Thread zentara
On Mon, 23 Jun 2003 03:40:03 +, [EMAIL PROTECTED] (Mario Kulka)
wrote:

Could anyone give me step by tep instructions on how to install a perl 
module (MD5) on my host server. How come they don't have it installed? Isn't 
popular enough?

Sorry if I sent the same message for the second time, but the prvious one 
doesn't came through on my list.

There are 2 different MD5 modules available: one has a compiled
component, and one is pure perl.

You probably want the pure perl version, Digest-Perl-MD5-1.5.
On most servers, users don't get access to a c compiler, so you
won't be able to compile the preferred and faster MD5 module.

So this is what you do.
1. Get the pure perl MD5 module Digest-Perl-MD5-1.5 from http://cpan.org
2. Since it is pure perl, all you should need to do is install it on
your local machine, then upload the MD5.pm to your homedir on the
server, and put it  somewhere like /home/yourname/perl5lib/MD5.pm
3. Then in your .bashrc put a line 
 export PERL5LIB='/home/yourname/perl5lib'

Now you can say use MD5.pm at the top of your scripts.

There are other ways to do it, but that is the simplest.
You can upload the whole tgz package to your homedir,
and actually install it in your homedir, you just specify your
install path to be /home/yourname as explained in the install docs.





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



Logging to a file or FH?

2003-06-23 Thread deb
(Apologies if this gets out to you more than once...)

I've got a script which opens a filehandle to write print statments to a file.
But, I'm also running some system commands, and I would also like to send
stdout and stderr to that filehandle.  I could just echo text to a file, or I
could use a filehandle.  Which would be better?


my $log = /tmp/log.$$;

open(LOG, $log);
print LOG Commencing maintenance\n;


But, here's how I've handled stdout and stderr in a system statement:

my $log = /tmp/log.$$;

system(path-to-command  $log 21);


Is there a way to use a filehandle instead?  Seems I'd have to take care of
block and non-blocking I/O.  Methinks it may be simpler just to stick with
printing directly to $log and not the FH, LOG.


Any advise is welcome!

deb


-- 
  o  _ _ _
  _o /\_   _ \\o  (_)\__/o  (_)
_ \_   _(_) (_)/_\_| \   _|/' \/
   (_)(_) (_)(_)   (_)(_)'  _\o_
   http://zapatopi.net/afdb.html







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



Re: Process question

2003-06-23 Thread John W. Krahn
Steve Blumenkrantz wrote:
 
 Since I didn't get any responses on my last question about process creation
 and the killing of child processes I thought that maybe I'd switch gears a
 bit and ask:
 
 On Unix  does one know how I can get the process id of a process kicked off
 from within a perl script via the back-tic (`) syntax?  Or a module which
 allows the running of sub programs which also will return the process id of
 the sub program?

perldoc -f open
perldoc perlopentut
perldoc perlipc
perldoc IPC::Open2
perldoc IPC::Open3


John
-- 
use Perl;
program
fulfillment

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



CGI header() and print question

2003-06-23 Thread Dan Muey

I think this is ok but I want to make sure I'm not missing some obvious thing.

If I do some headers with print and then do a CGI header(), that will work ok right?

IE:

use CGI qw(:standard);
print Set-Cookie: $c\n;
print header();
...

OR

use CGI qw(:standard);
print Set-Cookie: $c\n;
print header('image/gif');
...

Assuming $c is valid cookie dough...
Both ways will set a cookie if the browser allows it and then display the 
image or html the rest of the script does, right?

Thanks

Dan

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



using FIle::Find::name if regex to filter

2003-06-23 Thread magelord
hi, how can i use a real regex with this:

File::Find::name if -x?

the filetestops are working fine, but how can i filter things like
.gz$? i tried many ways, but all failed. any idea? thanks!!

bye andreas

-- 
.::Please visit my homepage::.
http://www.math55.de.vu

.::A very good JAVA site (worth a visit)::.
http://www.javaCore.de

.::Please visit the ANTI - TCPA homepage::. 
http://www.antitcpa.com

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



reading file into hash?

2003-06-23 Thread Tim McGeary
I'm still very green to perl, so please forgive this possibly stupid 
question.

I want to setup a configuration file to have a list of alpha codes 
delimiter and a unique number that will match the code e.g.

PACT | 23
PART | 24
etc
How is the best way to read such a file into my program (hash ?) so that 
I can:
a.) use the alpha codes to sort out data from another file
b.) organize that data to later include that unique number.

The end result will be 2 files:
1.) list # (chronological # from the list) | unique code #
2.) list # | data
Tim

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


Parsing a file

2003-06-23 Thread Morrison, Trevor (Trevor)
Hi,

I am new to using Perl to parse a file.  What I am trying to do is parse a file that 
is made of online orders.  I have written some code using for and if statements that 
will go through the file line by line and using regex I try to match the information 
with the variables so that I can write it to a MySQL database.  This works fine as 
long as each order has their information  where it is supposed to be?  Is there an 
easier way of doing this?  I get half way through processing the file and the arrays 
turn to jibberish!  I have included my script if it helps any.  TIA


Trevor 


open(Order, c:\\maverick\\test2.TXT) || die (Cannot find the file test2.TXT);
flock(Order,2);

@miva_orders=Order;
@order_number = ();
@date = ();
@time = ();
@bill_first_name = ();
@bill_last_name = ();
@ship_first_name = ();
@ship_last_name = ();
@emai_address = ();
@phone_number = ();
@phone_number2 = ();
@business_name = ();
@sold_to_street = ();
@bill_to_street = ();
@bill_to_city = ();
@bill_to_state = ();
@bill_to_zip = ();
@ship_to_city = ();
@ship_to_state = ();
@ship_to_zip = ();
@contry = ();
@code = ();
@name = ();
@quantity = ();
@price_each = ();
@shipping_method = ();
@shipping_amount = ();

#shift @miva_orders;
#shift @miva_orders;
print Arrya[0] is: $miva_orders[0]\n;

[EMAIL PROTECTED];
print $length\n;

for ($n=1; $n$length; $n=$n+26) {

print N : $n and value of $miva_orders[$n]\n;

if ($order_number[$n] eq ){

if ($miva_orders[$n+3] =~ /^Order Number\s?:\s?(\d+)/) {
#$order_number = $1;
$order_number[$n] = $1;
#push(@order_number,$order_number);
print Order number is $order_number[$n]\n;
}

}

if ($date[$n] eq   $time[$n] eq  ) {
if ($miva_orders[$n+4] =~ m/Placed\s+: (\d+\/\d+\/\d+)\s(\d+:\d+:\d+)/) {
$date[$n] = $1;
$time[$n] = $2;
print Date and Time is $1 $2\n;
}
}

if ($bill_first_name[$n]  eq   $bill_last_name[$n] eq   $ship_first_name[$n] 
eq   $ship_last_name[$n] eq ) {
if($miva_orders[$n+7] =~ /^(\w+)\s(\w+)\s+(\w+)?\s?(\w+)?/) {
$ship_first_name[$n] = $1;
$ship_last_name[$n] = $2;
$bill_first_name[$n] = $3;
$bill_last_name[$n] = $4;

print Ship First name : $ship_first_name[$n]\n;
print Ship Last name  : $ship_last_name[$n]\n;
print Bill Last name  : $bill_first_name[$n] \n;
print Bill Last name  : $bill_last_name[$n] \n;
}
}
if ($email_address[$n] eq ) {
if($miva_orders[$n+8]=~ /([EMAIL PROTECTED])/) {
$email_address[$n] = $1;
print Email address : $email_address[$n]\n;
}

}
if( $phone_number[$n] eq ) {
if($miva_orders[$n+9] =~ /(\d{3}\s?-?\d{3}\s?-?\d{4})/) {
$phone_number[$n]=$1;
print Phone Number $phone_number[$n]\n;
}
}
if( $phone_number2[$n] eq ) {
if($miva_orders[$n+10] =~ / \s+(\d{3}\s?-?\d{3}\s?-?\d{4})? / ) {
$phone_number2[$n]=$1;
print Phone Number2 $phone_number2[$n]\n;
}
}

if($business_name[$n] eq  ) {
if ($miva_orders[$n+11] =~ /^\s+(\w+.*)/) {
$business_name[$n] = $1;
$business_name[$n] =~ s/^\s+//;
print Business Name $business_name[$n]\n;
}
}

if ($sold_to_street[$n] eq ) {
if($miva_orders[$n+12] =~ /(.*)\s{2,}/) {
$sold_to_street[$n] =  $1;
print Sold To Street :$sold_to_street[$n] \n;
}

}

if ($bill_to_street[$n] eq ) {
if($miva_orders[$n+12] =~ /\s{2,}(.*)/) { 
$bill_to_street[$n] =  $1;
print Bill To Street :$bill_to_street[$n] \n;
}
}   
if ($bill_to_city[$n]  eq   $bill_to_state[$n] eq   $bill_to_zip[$n] eq ) {
if ($miva_orders[$n+13] =~ /(\w+\s?\w+)\s?(.{2})\s?(\d{5}(\W)?(\d{4})?)/) {
$bill_to_city[$n] =  $1;
$bill_to_state[$n] =  $2;
$bill_to_zip[$n] =  $3;
print Bill to City, State and Zip  : $bill_to_city[$n] 
$bill_to_state[$n] $bill_to_zip[$n] \n;
}
}

if ($ship_to_city[$n]  eq   $ship_to_state[$n] eq   $ship_to_zip[$n] eq ) {
if($miva_orders[$n+13] =~ /\s{2,}(\w+\s?\w+)\s?(\w{2})\s?(\d{5}(\W)?(\d{4})?)/) {
$ship_to_city[$n] =  $1;
$ship_to_state[$n] =  $2;
$ship_to_zip[$n] =  $3;
print Ship TO City, State and Zip : $ship_to_city[$n] 
$ship_to_state[$n] $ship_to_zip[$n] \n;
}
}

if ($bill_to_country[$n] eq ) {
if ($miva_orders[$n+14] =~ /(\w+)/) {
$bill_to_country[$n] =  $1;
print Country $bill_to_country[$n] \n;
}
}

if ($code[$n] eq ) {
if ($miva_orders[$n+18] =~ /(.{1,15})/) {   
$code[$n] = $1;
print Code : $code[$n]\n;
}
}

if ($name[$n] eq ) {
if ($miva_orders[$n+18] =~ /(\s{2,}.{2,40})/) { 
$name[$n] = $1;
$name[$n] =~ s/^\s+//;

Passing control to another perl program....

2003-06-23 Thread Hamish Whittal
Hi all,

I have this scenario:
I have a 'main' program that needs to call on progA under condtions A,
progB under conditions B, etc.

Now, I would like the progA, progB, progC to remain independent of the
'main' program at all times. The only thing I would like to connect them
is the paramteres
Yes, I know this sounds like the place to use Modules and Packages,
however, I don't think a module can have a 'main' program of it's own.
The reasons for keeping this independence is to keep the whole system
portable and modular. At runtime, the users may choose to leave out
progC and hence the program will not even load this 'program' or set of
programs

Can this be done?

I am not sure I am explaining this correctly, so if not, I will try
again.

Thanks in advance.
Hamish


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



Re: perl reg exp problem

2003-06-23 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], 
Robin Garbutt wrote:

 Hi all,
 
 I have a string that is a random sequence like the following:-
 
 ACGTCGTCGTCACACACACGCGTCTCTATACGCG
 
 I want to be able to parse the string, picking out any TATA sequences,
 colour them in red and make a not of where ther lie in the sequence.
 
 Is this possible with perl?

And much more (though not necessarily from me ;-))

Here is my version using a terminal window and with output something like 
this (hits in red):
Line# : Char# : Matches
1 :11 : AGTGTAGAGTTCTTCATTACGGACGGTCCGACCGCTGGATCTAGAG
1 :44 : AGTGTAGAGTTCTTCATTACGGACGGTCCGACCGCTGGATCTAGAG
5 : 7 : CTGTATTCTTGAAAGTCAGCATCCAGGCCATTATCGAATATCGACT
6 : 3 : TTTCTTGCAAGTTAATGGTAGACCTACAGTTAACTGAGTATCCCAG

Notice I print same-line multiple hits on separate lines. I suppose the 
fancier format would be something like:

Line# : Char# : Matches
1 : 11,44 : AGTGTAGAGTTCTTCATTACGGACGGTCCGACCGCTGGATCTAGAG
5 : 7 : CTGTATTCTTGAAAGTCAGCATCCAGGCCATTATCGAATATCGACT
6 : 3 : TTTCTTGCAAGTTAATGGTAGACCTACAGTTAACTGAGTATCCCAG

I used the substr function (then afterwards remembered that index might be 
better/easier for this); I also imagine that the slicker way to do this is 
probably with regexes (cue, John Krahn one-liner enters from stage 
left...). ;-)

-K (as always, advice, criticism welcome)


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

# find_substring

# I have a string that is a random sequence like the following:-
#
# ACGTCGTCGTCACACACACGCGTCTCTATACGCG
#
# I want to be able to parse the string, picking out any TATA sequences,
# colour them in red and make a not of where ther lie in the sequence.

while (@ARGV) {

   my $sequence = 'TATA';   #what we are looking for

   my $data = shift;
   open FH,  , $data
 or die Couldn't open datafile $data for reading: $!\n;

   printf \nLine# : Char# : Matches\n;# print heading

   while (FH) {
  chomp;
  print matches($., $_, $sequence);
   }
}

# end  main #
# begin sub #

sub matches{
   my @matches;
   my ($line_nbr, $line, $seq) = @_;

   for (0 .. (length($line) - length($seq)) ) {
  my $char_position = $_;
  my $substring = substr $line, $char_position, length $seq;
  if ($substring eq $seq) {
 my $hilite_line = hilite($line, $char_position, $seq);
 $_++;  # add 1 to char position
 push @matches, sprintf %5d : %5d : %s\n, $line_nbr, $_, 
$hilite_line;
  }
   }
   return @matches;
}

sub hilite {
   my $color_on = \e[31;1m;
   my $color_off = \e[0m;
   my ($line, $char_pos, $seq) = @_;
   substr($line, $char_pos, length($seq), $color_on$seq$color_off);
   return $line;
}
## end ##


-- 
Kevin Pfeiffer
International University Bremen

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



RE: Passing control to another perl program....

2003-06-23 Thread Dan Muey

 Hi all,

Howdy

 
 I have this scenario:
 I have a 'main' program that needs to call on progA under 
 condtions A, progB under conditions B, etc.
 
 Now, I would like the progA, progB, progC to remain 
 independent of the 'main' program at all times. The only 
 thing I would like to connect them is the paramteres Yes, 
 I know this sounds like the place to use Modules and 
 Packages, however, I don't think a module can have a 'main' 
 program of it's own. The reasons for keeping this 
 independence is to keep the whole system portable and 
 modular. At runtime, the users may choose to leave out progC 
 and hence the program will not even load this 'program' or 
 set of programs
 
 Can this be done?

Sure, I think this is what you mean:

In Main prog:

if(...) { print qx(./progA.pl 'joe=mama'); }
elsif(...) { print qx(./progB.pl 'ben=doevr'); }
elsif(...) { print qx(./progC.pl 'foo=bar'); }

HTH

DMuey

 
 I am not sure I am explaining this correctly, so if not, I 
 will try again.
 
 Thanks in advance.
 Hamish
 
 
 -- 
 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: reading file into hash?

2003-06-23 Thread Madhu Reddy
This will do ...
alpha_hash is u r hash...

-
my %alpha_hash = ();
open(FH_D,$d_list) || die File opening $d_list\n;
@file_list = FH_D;
foreach $record (@file_list) {
@t_array = split(/\|/, $record);
$alpha_hash{$t_array[0]} = $t_array[1];
}
close(FH_D);




--- Tim McGeary [EMAIL PROTECTED] wrote:
 I'm still very green to perl, so please forgive this
 possibly stupid 
 question.
 
 I want to setup a configuration file to have a list
 of alpha codes 
 delimiter and a unique number that will match the
 code e.g.
 
 PACT | 23
 PART | 24
 etc
 
 How is the best way to read such a file into my
 program (hash ?) so that 
 I can:
 a.) use the alpha codes to sort out data from
 another file
 b.) organize that data to later include that unique
 number.
 
 The end result will be 2 files:
 1.) list # (chronological # from the list) | unique
 code #
 2.) list # | data
 
 Tim
 
 
 -- 
 Tim McGeary
 [EMAIL PROTECTED]
 
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: reading file into hash?

2003-06-23 Thread Madhu Reddy
This will do ...
alpha_hash is u r hash...

-
my %alpha_hash = ();
open(FH_D,$d_list) || die File opening $d_list\n;
@file_list = FH_D;
foreach $record (@file_list) {
@t_array = split(/\|/, $record);
$alpha_hash{$t_array[0]} = $t_array[1];
}
close(FH_D);




--- Tim McGeary [EMAIL PROTECTED] wrote:
 I'm still very green to perl, so please forgive this
 possibly stupid 
 question.
 
 I want to setup a configuration file to have a list
 of alpha codes 
 delimiter and a unique number that will match the
 code e.g.
 
 PACT | 23
 PART | 24
 etc
 
 How is the best way to read such a file into my
 program (hash ?) so that 
 I can:
 a.) use the alpha codes to sort out data from
 another file
 b.) organize that data to later include that unique
 number.
 
 The end result will be 2 files:
 1.) list # (chronological # from the list) | unique
 code #
 2.) list # | data
 
 Tim
 
 
 -- 
 Tim McGeary
 [EMAIL PROTECTED]
 
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 


__
Do you Yahoo!?
SBC Yahoo! DSL - Now only $29.95 per month!
http://sbc.yahoo.com

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



Re: Logging to a file or FH?

2003-06-23 Thread John W. Krahn
Deb wrote:
 
 I've got a script which opens a filehandle to write print statments to a file.
 But, I'm also running some system commands, and I would also like to send
 stdout and stderr to that filehandle.  I could just echo text to a file, or I
 could use a filehandle.  Which would be better?
 
 my $log = /tmp/log.$$;
 
 open(LOG, $log);
 print LOG Commencing maintenance\n;
 
 But, here's how I've handled stdout and stderr in a system statement:
 
 my $log = /tmp/log.$$;
 
 system(path-to-command  $log 21);
 
 Is there a way to use a filehandle instead?  Seems I'd have to take care of
 block and non-blocking I/O.  Methinks it may be simpler just to stick with
 printing directly to $log and not the FH, LOG.

You could do something like this:

use IPC::Open3;

my $log = /tmp/log.$$;

open LOG, '', $log or die Cannot open $log: $!;
print LOG Commencing maintenance\n;

my $pid = open3( 0, 'LOG', 0, 'path-to-command' );



John
-- 
use Perl;
program
fulfillment

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



basic question: handling input to TCP/IP server

2003-06-23 Thread McMahon, Christopher x66156
Hello all...
I've implemented the TCP/IP server at the top of p.441 of The Camel (3rd
edition) Chapter 16, and it's working fine.  That is, it opens the port I
tell it to, and other processes connect to it and happily send it stuff.
(This is using IO::Socket::INET).  
But now I'm a little confused about how to handle I/O over the TCP/IP
connection.  The first thing I'd like to do is to print incoming data to
STDOUT.  It seems that I have to manipulate the accept() statement, and I
probably have to use the angle operators, but I'm struggling to truly
understand what's going on here in order to get the syntax correct.  (I
figure if I can get a handle on manipulating the input, output will be
easy.)   
I'm continuing to hack at this, but any pointers to (simple!) TCP/IP
server behavior to speed me on my way would be welcome.  
Thanks, 
-Chris   

_
This message and any attachments are intended only for the use of the addressee and
may contain information that is privileged and confidential. If the reader of the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.


Re: using FIle::Find::name if regex to filter

2003-06-23 Thread John W. Krahn
[EMAIL PROTECTED] wrote:
 
 hi, how can i use a real regex with this:
 
 File::Find::name if -x?
 
 the filetestops are working fine, but how can i filter things like
 .gz$? i tried many ways, but all failed. any idea? thanks!!

File::Find puts the current file name into $_ in the callback sub so if
want to see if a file name ends with '.gz' you don't have to use
File::Find::name.


John
-- 
use Perl;
program
fulfillment

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



Re: reading file into hash?

2003-06-23 Thread John W. Krahn
Tim McGeary wrote:
 
 I'm still very green to perl, so please forgive this possibly stupid
 question.
 
 I want to setup a configuration file to have a list of alpha codes
 delimiter and a unique number that will match the code e.g.
 
 PACT | 23
 PART | 24
 etc
 
 How is the best way to read such a file into my program (hash ?) so that
 I can:
 a.) use the alpha codes to sort out data from another file
 b.) organize that data to later include that unique number.
 
 The end result will be 2 files:
 1.) list # (chronological # from the list) | unique code #
 2.) list # | data

Perhaps you need one of the config modules from CPAN:

http://search.cpan.org/search?query=configmode=module


John
-- 
use Perl;
program
fulfillment

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



RE: basic question: handling input to TCP/IP server

2003-06-23 Thread Gupta, Sharad
Something like this worked for me in the past:

use strict;
use IO::Socket::INET;
my $sock = IO::Socket::INET();

while(1) {
my $output;
my $n = sysread($sock,$output,1000);
last if(!defined($n));
print STDOUT $output;
}

And using syswrite() for writing.

perldoc -f sysread
perldoc -f syswrite

-Sharad

-Original Message-
From: McMahon, Christopher x66156 [mailto:[EMAIL PROTECTED]
Sent: Monday, June 23, 2003 3:06 PM
To: [EMAIL PROTECTED]
Subject: basic question: handling input to TCP/IP server


Hello all...
I've implemented the TCP/IP server at the top of p.441 of The Camel (3rd
edition) Chapter 16, and it's working fine.  That is, it opens the port I
tell it to, and other processes connect to it and happily send it stuff.
(This is using IO::Socket::INET).  
But now I'm a little confused about how to handle I/O over the TCP/IP
connection.  The first thing I'd like to do is to print incoming data to
STDOUT.  It seems that I have to manipulate the accept() statement, and I
probably have to use the angle operators, but I'm struggling to truly
understand what's going on here in order to get the syntax correct.  (I
figure if I can get a handle on manipulating the input, output will be
easy.)   
I'm continuing to hack at this, but any pointers to (simple!) TCP/IP
server behavior to speed me on my way would be welcome.  
Thanks, 
-Chris   

_
This message and any attachments are intended only for the use of the addressee and
may contain information that is privileged and confidential. If the reader of the 
message is not the intended recipient or an authorized representative of the
intended recipient, you are hereby notified that any dissemination of this
communication is strictly prohibited. If you have received this communication in
error, please notify us immediately by e-mail and delete the message and any
attachments from your system.

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



Re: Logging to a file or FH?

2003-06-23 Thread deb
Cool.  I didn't know about the IPC::Open3 module.  Will look at it.

Thanks for the pointer!

deb

At 15:04:25, on 06.23.03:
Cracks in my tinfoil beanie allowed John W. Krahn to seep these bits into my brain:,
 Deb wrote:
  
  I've got a script which opens a filehandle to write print statments to a file.
  But, I'm also running some system commands, and I would also like to send
  stdout and stderr to that filehandle.  I could just echo text to a file, or I
  could use a filehandle.  Which would be better?
  
  my $log = /tmp/log.$$;
  
  open(LOG, $log);
  print LOG Commencing maintenance\n;
  
  But, here's how I've handled stdout and stderr in a system statement:
  
  my $log = /tmp/log.$$;
  
  system(path-to-command  $log 21);
  
  Is there a way to use a filehandle instead?  Seems I'd have to take care of
  block and non-blocking I/O.  Methinks it may be simpler just to stick with
  printing directly to $log and not the FH, LOG.
 
 You could do something like this:
 
 use IPC::Open3;
 
 my $log = /tmp/log.$$;
 
 open LOG, '', $log or die Cannot open $log: $!;
 print LOG Commencing maintenance\n;
 
 my $pid = open3( 0, 'LOG', 0, 'path-to-command' );
 
 
 
 John
 -- 
 use Perl;
 program
 fulfillment
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
  o  _ _ _
  _o /\_   _ \\o  (_)\__/o  (_)
_ \_   _(_) (_)/_\_| \   _|/' \/
   (_)(_) (_)(_)   (_)(_)'  _\o_
   http://zapatopi.net/afdb.html







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



Re: reading file into hash?

2003-06-23 Thread Steve Grazzini
On Mon, Jun 23, 2003 at 01:39:49PM -0700, Madhu Reddy wrote:

A little unasked-for code review :-)

 my %alpha_hash = ();
 open(FH_D,$d_list) || die File opening $d_list\n;
^   ^

You don't need to quote the variable.

 @file_list = FH_D;
 foreach $record (@file_list) {

And in this case it's not necessary to read the file into
a temporary array:

  while (FH_D) {

   @t_array = split(/\|/, $record);
   $alpha_hash{$t_array[0]} = $t_array[1];

If you only need two fields, it's more efficient to assign
split() to a list.

my ($key, $value) = split /\|/;
$alpha_hash{$key} = $value;

The split() operator is clever/lazy enough to notice that you 
only need the first two chunks, and it does the least amount 
of work necessary to provide them.

(Roughly speaking, it does split /\|/, $_, 3.)

-- 
Steve

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



Help needed on XML Files

2003-06-23 Thread Remo, Sherwin
List,

 

I would like to write a script that would check the correct syntax of an XML
file.  Need to check if the file is XML compliant.  Is there a module that I
can use to do this?  Thanks!

 

 



Re: perl reg exp problem

2003-06-23 Thread Kevin Pfeiffer
In article [EMAIL PROTECTED], Janek Schleicher 
wrote:

 Robin Garbutt wrote at Mon, 23 Jun 2003 11:40:47 +0100:
 
 I have a string that is a random sequence like the following:-
 
 ACGTCGTCGTCACACACACGCGTCTCTATACGCG
 
 I want to be able to parse the string, picking out any TATA sequences,
 colour them in red and make a not of where ther lie in the sequence.
 
 Is this possible with perl?
 
 Yes, but you have to explain in what matter you want to colorize.
 As output in a terminal window, as html/xml, as a picture, as a word
 document ... .
 
 If you would have in a pseudo-xml with the tag red.../red,
 you would perhaps do it as:
 
 $string =~ s/(TATA)/red$1/red/g;

Here is my script using the regex substitution:

(I wonder if there is a way to report the starting char position for regex 
matches like this?)

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

# find_substring2

# I have a string that is a random sequence like the following:-
#
# ACGTCGTCGTCACACACACGCGTCTCTATACGCG
#
# I want to be able to parse the string, picking out any TATA sequences,
# colour them in red and make a not of where ther lie in the sequence.

while (@ARGV) {

   my $sequence = 'TATA';  #what we are looking for
   my $data = shift;

   open FH,  , $data
 or die Couldn't open datafile $data for reading: $!\n;

   while (FH) {
  chomp;
  print matches($., $_, $sequence);
   }
}

# end  main #
# begin sub #

sub matches{
   my @matches;
   my ($line_nbr, $line, $seq) = @_;

   my $start_tag = \e[31;1m;
   my $stop_tag  = \e[0m;

   $line =~ s/($seq)/$start_tag$1$stop_tag/g;

   push @matches, sprintf %5d : %s\n, $line_nbr, $line;

   return @matches;
}


-- 
Kevin Pfeiffer
International University Bremen

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



Re: Parsing a file

2003-06-23 Thread John W. Krahn
Trevor Morrison wrote:
 
 Hi,

Hello,

 I am new to using Perl to parse a file.  What I am trying to do is
 parse a file that is made of online orders.  I have written some code
 using for and if statements that will go through the file line by line
 and using regex I try to match the information with the variables so
 that I can write it to a MySQL database.  This works fine as long as
 each order has their information  where it is supposed to be?

Are the records separated by something or are they all 26 lines long?

 Is there an easier way of doing this?

Probably, if we could see an example of what the data looks like.

 I get half way through processing
 the file and the arrays turn to jibberish!  I have included my script if
 it helps any.  TIA
 
 

You should enable warnings and strict to let perl help you find
mistakes.

use warnings;
use strict;


 open(Order, c:\\maverick\\test2.TXT) || die (Cannot find the file test2.TXT);

You should include the $! variable in you error message so you know why
it failed.


 flock(Order,2);

You should use the flock constants from the Fcntl module.

use Fcntl ':flock';

flock Order, LOCK_EX or die Cannot flock c:\\maverick\\test2.TXT: $!;


 @miva_orders=Order;

It is not necessary to read the whole file into memory in order to
process the data.


 @order_number = ();
 @date = ();
 @time = ();
 @bill_first_name = ();
 @bill_last_name = ();
 @ship_first_name = ();
 @ship_last_name = ();
 @emai_address = ();
 @phone_number = ();
 @phone_number2 = ();
 @business_name = ();
 @sold_to_street = ();
 @bill_to_street = ();
 @bill_to_city = ();
 @bill_to_state = ();
 @bill_to_zip = ();
 @ship_to_city = ();
 @ship_to_state = ();
 @ship_to_zip = ();
 @contry = ();
 @code = ();
 @name = ();
 @quantity = ();
 @price_each = ();
 @shipping_method = ();
 @shipping_amount = ();

It might make more sense to use a single data structure instead of
multiple separate variables.


 #shift @miva_orders;
 #shift @miva_orders;
 print Arrya[0] is: $miva_orders[0]\n;
 
 [EMAIL PROTECTED];
 print $length\n;
 
 for ($n=1; $n$length; $n=$n+26) {

You don't really need the $length variable.

for ( my $n = 1; $n  @miva_orders; $n += 26 ) {


 print N : $n and value of $miva_orders[$n]\n;
 
 if ($order_number[$n] eq ){
 
 [snip]
 
 flock(order,8);
 close(order);

You don't need to unlock the file as closing it will automatically
unlock it.  Also you are trying to unlock and close a different file
handle then the one you opened.


John
-- 
use Perl;
program
fulfillment

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



Re: Passing control to another perl program....

2003-06-23 Thread Tassilo von Parseval
On Mon, Jun 23, 2003 at 10:04:22PM +0200 Hamish Whittal wrote:

 I have this scenario:
 I have a 'main' program that needs to call on progA under condtions A,
 progB under conditions B, etc.
 
 Now, I would like the progA, progB, progC to remain independent of the
 'main' program at all times. The only thing I would like to connect them
 is the paramteres
 Yes, I know this sounds like the place to use Modules and Packages,
 however, I don't think a module can have a 'main' program of it's own.
 The reasons for keeping this independence is to keep the whole system
 portable and modular. At runtime, the users may choose to leave out
 progC and hence the program will not even load this 'program' or set of
 programs
 
 Can this be done?
 
 I am not sure I am explaining this correctly, so if not, I will try
 again.

I think you will have to explain a little more. Why is it important that
each of your parts needs to have a 'main' program? From your description
it still sounds as though a module would be a good idea. Take these two
modules:

# modA.pm
package modA;
use strict;
use base qw(Exporter);
@modA::EXPORT = qw(main);

sub main {
my $parms = @_;
...
}
1;

# modB.pm
package modB;
use strict;
use base qw(Exporter);
@modA::EXPORT = qw(main);

sub main {
my $parm = @_;
...
}
1;

And in your main program you use require() to pull in either of the two:

# main.pl
...
if ($conditionA) {
require modA;
modA-import;
main(foo);
}
if ($conditionB) {
require modB;
modB-import;
main(bar);
}

Using require() instead of use() has two implications: The first being
that it happens at run-time. Had you used use(), both modules would have
been loaded. In the above case this would have been a problem because
both modules have and export a main() function.

Secondly, require() wont automatically trigger the exporting of symbols
from a module so you have to do that manually. This is done with
PACKAGE-import. The import() method is inherited by your modules from
the Exporter module. It exports everything that is in @PACKAGE::EXPORT
to the caller (which is main.pl in this case).

Tassilo
-- 
$_=q#,}])!JAPH!qq(tsuJ[{@tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?=sub).+q#q!'qq.\t$.'!#+sexisexiixesixeseg;y~\n~~;eval


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



Re: Running Perl programs on a machine that does not have Perl installed

2003-06-23 Thread Asif Iqbal
I think there is something called perl2exe . Try googling it.

On Mon, 23 Jun 2003, Dave Mamanakis wrote:

 I have a perl program that I need to be able to run on all kinds of machines.
 However, I cannot install perl on each of these machines.
 It has to be run locally, not over a network (too many issues with security)
 How can this be done?
 I know with several other languages, you can make an EXE or copy 4-6 files to
 that machine and have your program run.  How does Perl deal with this?

 I am currently using the latest build of Active Perl...

 Thanks for the help.

 --DM




-- 
Asif Iqbal
http://pgpkeys.mit.edu:11371/pks/lookup?op=getsearch=0x8B686E08
There's no place like 127.0.0.1


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