RE: CGI.pm *with* a templating system?

2004-01-23 Thread Silent Zed
 Is it possible to use CGI.pm in conjunction with a templating system?

I think somebody may have already posted this module, but it seems it was
overlooked.
Take some time out, and look at this: http://html-template.sourceforge.net/
--(Highly Recommended)

Regards, Keith Szlamp
if ( (2*$b) || (!2*$b) ) { $uri-explore('http://szlamp.com/') };


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




File not downloading - off topic

2004-01-23 Thread Octavian Rasnita
Hi,

Sorry for this off topic subject, but I don't even know where to ask about
this problem.

A program on my site saves some email messages and let me download them
later, and I use the .eml file extension for those files.
When I try to access the URL to one of those messages, Internet Explorer 6
doesn't let me to download it if the files have a .eml extension.
If I choose another extension, (.zip for example), I can download them
without problems.

I've tried that on localhost also, and it happends the same.

For example, I've tried accessing:
http://localhost/z.eml

And the result follows below.

Thank you for any tips why is this happening.

Teddy

Invalid syntax error

The page cannot be displayed

The page you are looking for might have been removed or had its name
changed.

Please try the following:
. Open the
localhost
home page, and then look for links to the information you want.
. If you typed the page address in the Address bar, make sure that it is
spelled correctly.

If you still cannot open the page, click the Internet Explorer
search.gif (114 bytes)Search
button to look for similar sites.


Thanks.
Teddy,


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




OT: Re: File not downloading - off topic

2004-01-23 Thread Wiggins d Anconia

 Hi,
 
 Sorry for this off topic subject, but I don't even know where to ask about
 this problem.

M$.com?

 
 A program on my site saves some email messages and let me download them
 later, and I use the .eml file extension for those files.
 When I try to access the URL to one of those messages, Internet Explorer 6
 doesn't let me to download it if the files have a .eml extension.
 If I choose another extension, (.zip for example), I can download them
 without problems.
 

I suspect that .eml is a recognized extension that is supposed to have
some specific format, maybe IE thinks it is in the XML class because of
the 'ml'. This is usually handled by the mime-type listing in the
browser, and possibly on the server end which determines the
content-type header based on extension when the response chain isn't CGI
based.  Out of curiousity why not just use '.txt' since e-mail is in
plain text anyways?

http://danconia.org

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




Re: LWP get with no cache (code)

2004-01-23 Thread J. Alejandro Ceballos Z.
J #!/usr/bin/perl
J #
J # Load modules
J use CGI::Carp qw(fatalsToBrowser);
J use LWP::Simple;
J use integer;
 Huh?  Why?

	Ok, I agree with your cuestion about CGI::Carp(fatals.. and integer. My 
mistake.

J #
J # Read Input
J ReadInput(*cInput);
Eeek!  use CGI.  use CGI.  use CGI.  Not this stuff.
 I didn't read any further.  My mind rejects CGI scripts that are
 written this poorly.
	If you see CGI.pm, ReadInput and ReadParse works exactly the same way.

	Anyway thank you.

--

saludos,

 J. Alejandro Ceballos Z.   |
 ---+---
 http://alejandro.ceballos.info |
  [EMAIL PROTECTED] |  A menudo la razón comete errores
 ---+  pero nunca lo hace a conciencia.
|
|   -- Josh Billings 



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



Re: LWP get with no cache (code)

2004-01-23 Thread Randal L. Schwartz
 J == J Alejandro Ceballos Z [EMAIL PROTECTED] writes:

J #
J # Read Input
J ReadInput(*cInput);
 Eeek!  use CGI.  use CGI.  use CGI.  Not this stuff.

 I didn't read any further.  My mind rejects CGI scripts that are
 written this poorly.


J  If you see CGI.pm, ReadInput and ReadParse works exactly the same way.


No.  CGI.pm works better.  Much better.  use CGI.pm, please.


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

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




image link

2004-01-23 Thread scriptmonkey
I have having difficulty with my brain lately.  I need to display an image
that is a link.  I cannot find an example anywhere.

Thanks,
Rod.


--
Iowa Telecom WebMail (http://www.iowatelecom.net)


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




Re: image link

2004-01-23 Thread Wiggins d Anconia
 I have having difficulty with my brain lately.  I need to display an image
 that is a link.  I cannot find an example anywhere.
 
 Thanks,
 Rod.
 

Huh?  Slow down, breathe, then give us that again coherently

http://danconia.org

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




Re: image link

2004-01-23 Thread Andrew Gaffney
scriptmonkey wrote:
I have having difficulty with my brain lately.  I need to display an image
that is a link.  I cannot find an example anywhere.
a href=somepage.htmlimg src=someimage.gif alt=Some Image border=0/a

--
Andrew Gaffney
System Administrator
Skyline Aeronautics, LLC.
776 North Bell Avenue
Chesterfield, MO 63005
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Covert Date to week number

2004-01-23 Thread Owen
On Thu, 22 Jan 2004 19:28:24 +
[EMAIL PROTECTED] wrote:

 Is their a way in PERL to covert a date to a week number
 

Try this;


#!/usr/bin/perl
use Date::Calc qw(Week_Number Week_of_Year);

@t=localtime;

$week = Week_Number($t[5]+1900,$t[4]+1,$t[3]);   #Deprecated
print  From Date::Calc Week Number is  $week \n;

($week,$year) = Week_of_Year($t[5]+1900,$t[4]+1,$t[3]);  #Preferred
print  From Date::Calc Week of Year is  $week \n;







 Cheers
 
 Neill
 
 
 
 
 
 
 IMPORTANT NOTICE  This email (including any attachments) is meant only for the 
 intended recipient. It may also contain confidential and privileged information.  If 
 you are not the intended recipient, any reliance on, use, disclosure, distribution 
 or copying of this email or attachments is strictly prohibited. Please notify the 
 sender immediately by email if you have received this message by mistake and delete 
 the email and all attachments. 
 
 Any views or opinions in this email are solely those of the author and do not 
 necessarily represent those of Trinity Mirror PLC or its associated group companies 
 (hereinafter referred to as TM Group). TM Group accept no liability for the 
 content of this email, or for the consequences of any actions taken on the basis of 
 the information provided, unless that information is subsequently confirmed in 
 writing. Although every reasonable effort is made to keep its network free from 
 viruses, TM Group accept no liability for any virus transmitted by this email or any 
 attachments and the recipient should use up-to-date virus checking software. Email 
 to or from this address may be subject to interception or monitoring for operational 
 reasons or for lawful business practices. 
 
 Trinity Mirror PLC is the parent  company of the Trinity Mirror group of companies 
 and is registered in England No 82548, with its address at One Canada Square, Canary 
 Wharf, London E14 5AP. 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 http://learn.perl.org/ http://learn.perl.org/first-response
 
 
 


-- 
Owen


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




Re: Date and Time

2004-01-23 Thread Owen
On Thu, 22 Jan 2004 17:06:58 -0800
Larry Guest [EMAIL PROTECTED] wrote:


 
 But rsync does not know how to handle this string, I think when its
 passed to rsync its not text as I see it on the screen.  It cant make
 the dir and pukes.
 
 I have seen a bunch of stuff out there for sprintf, etc  but no clear
 small little script to do this.
 
 Thanks
 


This will give you and answer like MMDDhhmmss for your directory name. Maybe watch 
line wrap

--

#!/usr/bin/perl

$dirname = dirname();
print $dirname\n;

sub dirname{

my @t=localtime;
my $mon = $t[4]+1;my $yr = $t[5]+1900;
return (sprintf(%04d%02d%02d%02d%02d%02d,$t[5] +1900,$t[4]
+1,$t[3],$t[2],$t[1],$t[0]));

}





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


-- 
Owen


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




Reading tab delimited File sort everything according item 5 of every line

2004-01-23 Thread Bjorn Van Blanckenberg
let say that the file contains these items (every item is seperated 
with a tab)

one  title   state   name   code1   number
two  title2   state2   name2   code2   number2
one  title3   state3   name3   code3   number3
four  title4   state4   name4   code4   number4
six  title5   state5   name5   code1   number5
dip  title6   state6   name6   code1   number6
fun  title7   state7   name7   code2   number7
the thing i'am looking for is that it is sorted by item 5 and writes 
back to the file
with an extra line if item 5 is different

so I would come up with:

one  title   state   name   code1   number
six  title5   state5   name5   code1   number5
dip  title6   state6   name6   code1   number6
two  title2   state2   name2   code2   number2
fun  title7   state7   name7   code2   number7
one  title3   state3   name3   code3   number3

four  title4   state4   name4   code4   number4

Is there someone that can help me
--
  Oooo.
 oooO( )
 ( )   )   /
  \   (   (_/
\_)
thanks
Bjorn Van Blanckenberg
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Reading tab delimited File sort everything according item 5 of every line

2004-01-23 Thread Randy W. Sims
On 01/23/04 03:36, Bjorn Van Blanckenberg wrote:
the thing i'am looking for is that it is sorted by item 5 and writes 
back to the file
with an extra line if item 5 is different
A variation on the Swartzian transform: (read from bottom up)

#!/usr/bin/perl

use strict;
use warnings;
print map { $_-[1] . \n }
  sort  {$a-[0] cmp $b-[0]}
  map { chomp; [(split /\t/, $_)[4], $_] }
  DATA;
__DATA__
one title   state   namecode1   number
two title2  state2  name2   code2   number2
one title3  state3  name3   code3   number3
fourtitle4  state4  name4   code4   number4
six title5  state5  name5   code1   number5
dip title6  state6  name6   code1   number6
fun title7  state7  name7   code2   number7
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: Reading tab delimited File sort everything according item 5 of every line

2004-01-23 Thread Owen
On Fri, 23 Jan 2004 09:36:00 +0100
Bjorn Van Blanckenberg [EMAIL PROTECTED] wrote:

 let say that the file contains these items (every item is seperated 
 with a tab)
 
 one  title   state   name   code1   number
 two  title2   state2   name2   code2   number2
 one  title3   state3   name3   code3   number3
 four  title4   state4   name4   code4   number4
 six  title5   state5   name5   code1   number5
 dip  title6   state6   name6   code1   number6
 fun  title7   state7   name7   code2   number7
 
 the thing i'am looking for is that it is sorted by item 5 and writes 
 back to the file
 with an extra line if item 5 is different
 
 so I would come up with:
 
 one  title   state   name   code1   number
 six  title5   state5   name5   code1   number5
 dip  title6   state6   name6   code1   number6
 
 two  title2   state2   name2   code2   number2
 fun  title7   state7   name7   code2   number7
 
 one  title3   state3   name3   code3   number3
 
 four  title4   state4   name4   code4   number4


Well you can try;
-



#!/usr/bin/perl -w

chomp(@fields = DATA); # slurp in the file
$lastbit=1;

 @sorted =
 map { $_-[0] }
 sort { $a-[5] cmp $b-[5] }
 map { [ $_ , (split /\t/) ] } @fields;#tab separated fields

foreach (@sorted){
@bits = split;
print \n if ($bits[4] ne $lastbit);
print $_\n;
$lastbit=$bits[4];
}

__DATA__
one title   state   namecode1   10
two title2  state2  name2   code2   21
one title3  state3  name3   code3   13
fourtitle4  state4  name4   code4   14
six title5  state5  name5   code1   number5
dip title6  state6  name6   code1   number6
fun title7  state7  name7   code2   number7

--
and it produces 


21:42:56 [~/perltest]#perl sortdata1.pl

one title   state   namecode1   10
six title5  state5  name5   code1   number5
dip title6  state6  name6   code1   number6

two title2  state2  name2   code2   21
fun title7  state7  name7   code2   number7

one title3  state3  name3   code3   13

fourtitle4  state4  name4   code4   14



 --
Owen

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




RE: Usage of Net:Telnet

2004-01-23 Thread Singh, Ajit p

Hello Friends,

I am trying to get the prompt parameter right for my Telnet connection.
Doesnt seem to be working...

can somebody help me out with this ...

The prompt from my remote host(cisco box) is as shown below:

W9-BAS-01  

$t = new Net::Telnet (Timeout = 10,
Input_log = $inlogfileg,
Output_log = $outlogfile,
Telnetmode = 1,
dump_log = $dmplog,
Timeout = $secs),
  Prompt = 'W9-BAS-01');


Error message:

syntax error at Bastelnet.pl line 18, near 'W9-BAS-01')
Execution of Bastelnet.pl aborted due to compilation errors.





regards,

Ajitpal Singh,

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




RE: Need help comparing lines in two files

2004-01-23 Thread EUROSPACE SZARINDAR

Hi Stuart,

Have a look on CPAN (www.cpan.org) there are two wonderfull packages to do
exactely what you are dreaming of :

Algorithm::Diff
Text::ParagraphDiff


Have a nice day
Michel



-Message d'origine-
De: Dan Anderson [mailto:[EMAIL PROTECTED]
Date: vendredi 23 janvier 2004 02:17
À: [EMAIL PROTECTED]
Cc: Perl Beginners
Objet: Re: Need help comparing lines in two files


Lets say file 1 is:

foo
bar
... continues on for 100 lines

And file 2 is:

foo
baz
bar
... continues on exactly the same 100 lines as file 1

Would file 2 be different from file 1 from line 2 and down?  Or would it
be different for line 2 and 3?

Also, the keywords:

next; Brings you to the next iteration in a loop
last; leaves the loop

Should help you iterate through a while loop (or empty loop)

i.e.

{
  # this is a loop, just two sets of brackets
  # put a last statement and it will leave.
  # put one of these in your for loops, or outside of your for loops.
}

Also you can get tricky by naming loops, i.e.:

FOO:
{
  print foo;
  BAR:
  {
last FOO;
  }
  # anything below here never executes
  print bar;
}


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


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




Re: Usage of Net:Telnet

2004-01-23 Thread Owen
On Fri, 23 Jan 2004 11:45:08 -
Singh, Ajit p [EMAIL PROTECTED] wrote:

Timeout = $secs),
   Prompt = 'W9-BAS-01');

What is the ) doing on line 17?

-- 
Owen


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




RE: Need help with a regex

2004-01-23 Thread stuart_clemons
Thanks very much Tim.  I just did a quick test on my real file and it 
worked perfectly. 

I definitely still have a lot to learn with both Perl and regex's, so I 
really appreciate the explanation as well.  Though your script is very 
compact, I learned a lot from it.  Such as how you initialized the array. 
I have a couple of scripts where I get warnings about either improper or 
uninitialized arrays, or something to that effect.  I tried to fix those, 
but was unsuccessful.  Those scripts produced the output I wanted, but the 
warnings are bothersome. I'll take another look at those scripts to see if 
initializing using my @arrayname = ( ); will help. 

Also, the push structure for adding elements to the array was very 
helpful.  I have a way to do it, and while my way works and is somewhat 
creative, my way is actually really embarrassingly bad  and inefficient 
coding.  So, I learned from that too.

It's funny how all this stuff is in the Perl books that I've been reading, 
but once I need to solve a problem, the exact right way to do it doesn't 
come to me.  I can spend hours trying to do some pretty simple stuff.  I 
can usually come up with a solution, but I know that it's not usually 
efficient nor is it really close to the right way to do it.   But, the 
good news is, if I think about where my Perl skills are today compared to 
a month ago, I'm making progress !

Anyway, sorry for being so looong winded.  The bottom line is that I 
really appreciate your help. 
 



Tim Johnson [EMAIL PROTECTED] 
01/23/2004 01:32 AM

To
Tim Johnson [EMAIL PROTECTED], [EMAIL PROTECTED], 
[EMAIL PROTECTED]
cc

Subject
RE: Need help with a regex






Ooh.  That's embarassing.  I didn't pay close enough attention to the OP. 
Some of the inside matches contain spaces.  My regex should have been:
 
/^\S+\s+(.+)\s+/
 
which would match:

*the beginning of the line (^)
*followed by one or more non-whitespace characters (\S+)
*followed by one or more whitespace characters (\s+)
*followed by one or more of any characters including 
whitespace (.+)
*followed by one or more whitespace characters (\s+)

because Perl will match the largest possible number of characters, the .+ 
will match everything between the two outside spaces.

 -Original Message- 
 From: Tim Johnson 
 Sent: Thu 1/22/2004 9:31 PM 
 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] 
 Cc: 
 Subject: RE: Need help with a regex
 
 

 Try this on for size:
 
 #
 use strict;
 use warnings;
 my @cities = ();
 open(INFILE,myfile.txt) || die Couldn't open 
myfile.txt for reading!\n;
 while(INFILE){
  $_ =~ /^\S+\s+(\S+)/;
  push @cities,$1;
 }
 #do something to @cities
 
 #
 
 which basically means to match:
 
 *   the start of the line (^)
 *   followed by one or more non-whitespace characters 
(\S+)
 *   followed by one or more whitespace characters 
(\s+)
 *   followed by one or more non-whitespace characters 
(\S+)
 
 the parentheses around the last non-whitespace match 
assign it to $1
 
 Note:  Check out perldoc perlre for the man pages.  It 
might be worth looking over real quick before you dig into the book.
 
 Or, for the quick and easy way without a regex, how bout:
 
 #
 
 use strict;
 use warnings;
 my @cities;
 open(INFILE,myfile.txt) || die Could not open 
myfile.txt for reading!\n;
 while(INFILE){
push @cities,(split /\s+/,$_)[1];
 }
 
 #
 
 which does a split on the line and returns the second 
element of the resulting list and assigns it to @cities.
 
 -Original Message-
 From: [EMAIL PROTECTED] 
[mailto:[EMAIL PROTECTED]
 Sent: Thu 1/22/2004 9:01 PM
 To: [EMAIL PROTECTED]
 Cc:
 Subject: Need help with a regex
 
 
 
 This newbie needs help with a regex.  Here's what 
the data from a text
 file looks like. There's no delimiter and the 
fields aren't evenly spaced
 apart.
 
 apples  San Antonio  Fruit
 oranges Sacramento Fruit
 pineapples Honolulu Fruit
  

reading a httpd.conf file

2004-01-23 Thread chad kellerman
Hello everyone,

I have a little issue that I am sure someone has come across here
once before and was wondering if I can get some pointers.

I am trying to read and grab values from  a messy httpd.conf
file.  What I am trying to do is grab the ServerName value and
DocumentRoot value for a given VirtualHost depending on the username I
have defined.

The httpd.conf file has many VirtualHost sections (50 +).  And each
section does not have the same order of directives as the next.  For
example:

VirtualHost domain1.com
ScriptAlias /cgi-bin/ /usr/www/htdocs/lee/domain1-www/cgi-bin/
DocumentRoot /usr/www/htdocs/lee/domain1-www
ServerAdmin [EMAIL PROTECTED]
ServerName domain1.com
User lee
/VirtualHost

VirtualHost domain4.com
User bob
DocumentRoot /usr/www/htdocs/bob/domain1-www
ServerAdmin [EMAIL PROTECTED]
ScriptAlias /cgi-bin/ /usr/www/htdocs/bob/domain1-www/cgi-bin/
ServerName domain4.com
/VirtualHost


  So I wanted to write a script that if I have a username I could use
that to get the ServerName and DocumentRoot from the correct VirtualHost
Section.  Here is what I have:

--code-
#!/usr/local/bin/perl
use strict;
use warnings;
use diagnostics;
$|++;

use vars qw(
 $httpd_conf_dir $httpd_conf_file $owner
 $servername $docroot $user
   );

$httpd_conf_dir = '/etc/httpd/conf';
$httpd_conf_file = $httpd_conf_dir/httpd.conf;
$user = 'lee';
$/ = 'V';

open (HTTPD, $httpd_conf_file) 
   or die cannot open $httpd_conf_file:$!;
while (HTTPD)
{
if (/irtualHost/)
{
$owner = $1 if /^User\s*(\d+)/m;
next if ($owner ne $user);
$servername = $1 if /^ServerName\s*(\w+)/m;
$docroot = $1 if /^DocumentRoot\s*(.+)/m;
}
}
close (HTTPD);

print $owner : $servername : $docroot\n;

--/code--

But this just doesn't work.  I get the last VirtualHost sections
servername (minus the .com) and the Docroot.  But the username isn't
there..



Can anyone steer me in the right direction?

THanks,
Chad



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




RE: Need help comparing lines in two files

2004-01-23 Thread stuart_clemons
Thanks Michael.  I'll take a look at those modules and see if my Perl 
skills are sufficient to understand how to use them.  Thanks again.




EUROSPACE SZARINDAR [EMAIL PROTECTED] 
01/23/2004 02:47 AM

To
[EMAIL PROTECTED]
cc
Perl Beginners [EMAIL PROTECTED]
Subject
RE: Need help comparing lines in two files







 Hi Stuart,

Have a look on CPAN (www.cpan.org) there are two wonderfull packages to do
exactely what you are dreaming of :

Algorithm::Diff
Text::ParagraphDiff


Have a nice day
Michel



-Message d'origine-
De: Dan Anderson [mailto:[EMAIL PROTECTED]
Date: vendredi 23 janvier 2004 02:17
À: [EMAIL PROTECTED]
Cc: Perl Beginners
Objet: Re: Need help comparing lines in two files


Lets say file 1 is:

foo
bar
... continues on for 100 lines

And file 2 is:

foo
baz
bar
... continues on exactly the same 100 lines as file 1

Would file 2 be different from file 1 from line 2 and down?  Or would it
be different for line 2 and 3?

Also, the keywords:

next; Brings you to the next iteration in a loop
last; leaves the loop

Should help you iterate through a while loop (or empty loop)

i.e.

{
  # this is a loop, just two sets of brackets
  # put a last statement and it will leave.
  # put one of these in your for loops, or outside of your for loops.
}

Also you can get tricky by naming loops, i.e.:

FOO:
{
  print foo;
  BAR:
  {
last FOO;
  }
  # anything below here never executes
  print bar;
}


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




Haiku Activestate Slashdot

2004-01-23 Thread Paul Kraus
http://slashdot.org/articles/04/01/22/2349200.shtml?tid=126tid=145tid=156;
tid=162tid=99


 Paul Kraus
 ---
 PEL Supply Company
 Network Administrator
 ---
 800 321-1264 Toll Free
 216 267-5775 Voice
 216 267-6176 Fax
 www.pelsupply.com
 ---


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


Re: Usage of Net:Telnet

2004-01-23 Thread Owen
On Fri, 23 Jan 2004 13:24:24 -
Singh, Ajit p [EMAIL PROTECTED] wrote:

 Thanks Owen for your reply.
 
 that was a typo, however i m getting the below error message now..
 
 $t = new Net::Telnet (Timeout = 10,
 Input_log = $inlogfileg,
 Output_log = $outlogfile,
 Telnetmode = 1,
 dump_log = $dmplog,
 Timeout = $secs,
  Prompt = 'W9-BAS-01');
  #Prompt = '/bash\$ $/');
 $t-open(hostname);
 
 Error message:
 ignoring bad Prompt argument W9-BAS-01: missing opening delimiter of match
 operator at Bastelnet.pl line 12

Please don't reply to me personally, reply to the list.

Try something like this

my $t = Net::Telnet-new(Host=hostname,
Timeout=$secs;
Dump_log=$dump_log); # assign $dump_log

$t-waitfor('/W9-BAS-01/') || die bad $1;
$t-print ($whatever);


Read perdoc Net::Telnet

Read the dumplog, it often contains clues as to what is happening




-- 
Owen


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




[meta] Please delete boilerplate! (was Re: Covert Date to week number)

2004-01-23 Thread Randal L. Schwartz
 Neill == Neill Taylor [EMAIL PROTECTED] writes:

Neill Is their a way in PERL to covert a date to a week number
Neill Cheers

Neill Neill

Neill  IMPORTANT NOTICE This email (including any
Neill attachments) is meant only for the intended recipient. It may
Neill also contain confidential and privileged information.  If you
Neill are not the intended recipient, any reliance on, use,
Neill disclosure, distribution or copying of this email or
Neill attachments is strictly prohibited. Please notify the sender
Neill immediately by email if you have received this message by
Neill mistake and delete the email and all attachments.

Neill Any views or opinions in this email are solely those of the
Neill author and do not necessarily represent those of Trinity Mirror
Neill PLC or its associated group companies (hereinafter referred to
Neill as TM Group). TM Group accept no liability for the content of
Neill this email, or for the consequences of any actions taken on the
Neill basis of the information provided, unless that information is
Neill subsequently confirmed in writing. Although every reasonable
Neill effort is made to keep its network free from viruses, TM Group
Neill accept no liability for any virus transmitted by this email or
Neill any attachments and the recipient should use up-to-date virus
Neill checking software. Email to or from this address may be subject
Neill to interception or monitoring for operational reasons or for
Neill lawful business practices.

Neill Trinity Mirror PLC is the parent company of the Trinity Mirror
Neill group of companies and is registered in England No 82548, with
Neill its address at One Canada Square, Canary Wharf, London E14 5AP.
Neill 

Let's see the stats:

Number of lines of original question: 1
Number of lines of closing salutation: 1
Number of lines of sig: 2

Number of lines of COMPLETELY USELESS LEGAL DISCLAIMER: 27 lines after wrapping

Here's my boilerplate to reply to your boilerplate:

You have exceeded the 4-line .sig boilerplate limit with a worthless
unenforcable disclaimer.  Please remove this text from future postings
to this mailing list.  If you cannot do so for mail from your domain,
please get a freemail account and rejoin the list from there.

And I do this publicly so that it goes into the archives, so others
will also see that people *do* object to these things, and that there
*is* a ready solution to it.

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

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




RE: complex data file parsing

2004-01-23 Thread Hughes, Andrew
Thanks for the information.  That was much more than I expected.

You right about the T line.  That was a typo.  The T is in the firth
position of the last line of each order block.

As far as your follow up question on the B lines, only line with a B in the
beginning in set?, I'm not sure if I understand.  If you mean that there
will only be 1 line per order (set of lines A-T) with a B in the first
position, you are correct.

Also, as far as your assumption, The way I do it assumes that the first and
only first line of each set beginns with an A (and falsly buts that A at the
end of the privious record, but 
doesnt matter for the aim her, does it?),  I'm not sure what you mean by
this either.  However, it sounds like you have it correct.  Lines that
indicate the beginning of an order block, will only ever start with an A in
the first position.

Finally, the final assumption, that The push assumes that there are always
exactly 5 records between B and email and that this is the only line with a
B in record (and comes before the lines 
with ADV_.  I think that this is correct.  An example line is
B,W29116,test,test,[EMAIL PROTECTED],  The positions are 0,1,2,3,4, so that
equals 5, and it will ALWAYS be five.  Finally, the B line will ALWAYS come
before the ADV_ lines.  This appears to be correct judging that the output
of the script is e-mail addresses.

I tested the script, and I was able to output e-mail addresses.  However,
using the data that I posted, it does not quite output exactly what I need.
Based on this sample of order.csv and the script that you sent me (I added
the line print @email to view the output):

  for (my $i=0; $i=$#fields; $i++){
 if ($fields[$i] eq B) {$b_index=$i; next;}
 elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; 
last;}
print @email;
 ):

A,W29073,Thu Apr 05 15:25:08 2001
B,W29073,Scott,S,[EMAIL PROTECTED],249 Tah Ave,,Sth San Francisco,CA,~US,5-
P,W29073,
X,W29073,Company Name,A,Department Name,San Francisco 00),Purchase Order
Number,254
S,W29073,UPS Next Day Air,Scott S,2 Tah Ave,,Sth San
Francisco,CA,~US,5-
I,W29073,AVHQ_101090lfbl,6.000,$28.50,$171.001.00,,2,0
I,W29073,AVHQ_101090xlfbl,4.000,$28.50,$114.001.00,,3,0
T,W29073,$285.00$53.09,$338.09,,10.00,
A,W29101,Wed Apr 11 07:43:33 2001
B,W29101,harold,m,[EMAIL PROTECTED],10 wind ridge parkway,,Atlanta,GA,~US,5
P,W29101,
X,W29101,Company Name,,Department Name,,Purchase Order Number,10252
S,W29101,UPS Regular Ground,harold m,10 wind ridge
parkway,,Atlanta,GA,~US,5
I,W29101,ADV_Carb-Natxxl,1.000,$16.50,$16.501.50,,4
T,W29101,$17.50,,7.000,$1.23,$9.28,$28.01,,1.50,
A,W29116,Thu Apr 12 11:42:21 2001
B,W29116,test,test,[EMAIL PROTECTED],test,,test,GA,~US,1
P,W29116,Credit,Offline,Visa,,04/04
X,W29116,Company Name,,Department Name,,Purchase Order Number,
S,W29116,UPS Regular Ground,test test,test,,test,GA,~US,1
I,W29116,ADV_1601,1.000,$14.00,$14.001.50,,3
T,W29116,$14.00,,7.000,$0.98,$9.94,$24.92,,1.50,

I would expect to see:

[EMAIL PROTECTED]@test.com

However, I see:

[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@masnc.n
[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@masnc
[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@mas
[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@m
[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]
@[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]
[EMAIL PROTECTED]@[EMAIL PROTECTED]@[EMAIL PROTECTED]@masnc.ne
[EMAIL PROTECTED]@masnc.net

What is going wrong?  Am I trying to view the output incorrectly?

Thanks for any additional direction.

Andrew



-Original Message-
From: wolf blaum [mailto:[EMAIL PROTECTED]
Sent: Thursday, January 22, 2004 3:28 PM
To: Hughes, Andrew; Perl Beginners Mailing List
Subject: Re: complex data file parsing


hi, 
 I know that each block always starts with and A in the first position of
 the first line and ends with a T in the last position of the last line.

isnt it a T in the first position of the last row of the set?

 I know that the second line starts with a B, and the data in the 5th space
 on this line is the e-mail address, which is what I ultimately want.
 However,...

only line with a B in the bigining in set?

 I am trying to get a list of email addresses for people who have ordered
 products that begin with ADV.  These can appear in multiple I lines.
 Therefore you can never predict how many lines make up 1 order block.

What about:

#! /usr/bin/perl
use strict;
use warnings;
my @email;

open (FH, complex.txt) or die $!;

local $/ = \nA,; # make \nA, the record seperator

while(FH){   # read the next record
  my @fields = split ,|\n, $_;   # split at , or \n
  my $b_index;# 0 for every new record
  for (my $i=0; $i=$#fields; $i++){
 if ($fields[$i] eq B) {$b_index=$i; next;}
 elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; 
last;}
  }
}

works on 

Simple Perl code/syntax question

2004-01-23 Thread Luinrandir Hernsen
Hallo everyone and thank you for your previous help

in basic the code would be

for x=1 to 100
Select Case
Case=10,20,30,40,50,60,70,80,90
then do this
else 
   else do this
end select
next x

how is this done in perl?

foreach (10,20,30,40,50,60,70,80,90);
{
do this;
}

 I think I need to unpack my books! (i'm moving)LOL
Lou

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




Use Strict Error

2004-01-23 Thread Bill Jastram
When I use the following portion of Perl code:
__

#!/usr/bin/perl
# use with:
# perl IfThenElse tfcfam (Use all of this at the command line!)

use strict;
use warnings;

print Search by name: ;

my $name = STDIN;
'egrep $name testing.txt'

#my(@col1, @col2, @col3);
my @col1;
my @col2;
my @col3;
my $col = 1;
my ($find);

__

I get the following error:

syntax error at trashthistest2 line 17, near my  
Global symbol @col1 requires explicit package name at trashthistest2 line 17. 
Global symbol@col1 requires explicit package name at trashthistest2 line 40. 
Global symbol @col1 requires explicit package name at trashthistest2 line 53.
Global symbol @col1 requires explicit package name at trashthistest2 line 59. 
Global symbol @col1 requires explicit package name at trashthistest2 line 81. 
Execution of trashthistest2 aborted due to compilation errors.

__

If I have declared my @col1 at line 17, why am I getting these errors?

Thanks for any assitance you can offer.

Bill J.


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




Re: Convert Date to week number

2004-01-23 Thread Rob Dixon
Neill Taylor wrote:

 Is their a way in PERL to covert a date to a week number

Why not write it yourself?

You need to know:

- Which day of the week is the 'first'.

- Which was the first week of the year that had four or more days.
  That's week one.

Then do the sums/arithmetic/math/mathematics/calculations (what /do/
people prefer?)

BTW I agree wholeheartedly with Randal. He may be a Yank but he's
not all bad :) I'm surprised the Mirror legaloids can be such
idiots. Sometimes I wish I could be anational instead of being
branded with rubbish like this. At least I read the Independent
instead!

Rob



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




RE: Use Strict Error

2004-01-23 Thread NYIMI Jose (BMB)
1. You are missing ; 
Type
`egrep $name testing.txt`;
And not
'egrep $name testing.txt'

Not the backticks and not quotes ...

HTH,

José.

-Original Message-
From: Bill Jastram [mailto:[EMAIL PROTECTED] 
Sent: Friday, January 23, 2004 4:00 PM
To: [EMAIL PROTECTED]
Subject: Use Strict Error


When I use the following portion of Perl code: 
__

#!/usr/bin/perl
# use with:
# perl IfThenElse tfcfam (Use all of this at the command line!)

use strict;
use warnings;

print Search by name: ;

my $name = STDIN;
'egrep $name testing.txt'

#my(@col1, @col2, @col3);
my @col1;
my @col2;
my @col3;
my $col = 1;
my ($find);

__

I get the following error:

syntax error at trashthistest2 line 17, near my  
Global symbol @col1 requires explicit package name at trashthistest2 line 17. 
Global symbol@col1 requires explicit package name at trashthistest2 line 40. 
Global symbol @col1 requires explicit package name at trashthistest2 line 53. Global 
symbol @col1 requires explicit package name at trashthistest2 line 59. 
Global symbol @col1 requires explicit package name at trashthistest2 line 81. 
Execution of trashthistest2 aborted due to compilation errors.

__

If I have declared my @col1 at line 17, why am I getting these errors?

Thanks for any assitance you can offer.

Bill J.


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




 DISCLAIMER 

This e-mail and any attachment thereto may contain information which is confidential 
and/or protected by intellectual property rights and are intended for the sole use of 
the recipient(s) named above. 
Any use of the information contained herein (including, but not limited to, total or 
partial reproduction, communication or distribution in any form) by other persons than 
the designated recipient(s) is prohibited. 
If you have received this e-mail in error, please notify the sender either by 
telephone or by e-mail and delete the material from any computer.

Thank you for your cooperation.

For further information about Proximus mobile phone services please see our website at 
http://www.proximus.be or refer to any Proximus agent.


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




RE: Use Strict Error

2004-01-23 Thread Wiggins d Anconia
Please bottom post.

 1. You are missing ; 
 Type
 `egrep $name testing.txt`;
 And not
 'egrep $name testing.txt'
 
 Not the backticks and not quotes ...
 

There's also no reason to use backticks in void context.

perldoc -f system

Please use full paths, error check, etc. if you are going to shell out,
which brings me to the next point, why shell out to 'egrep' in the first
place, you should either do it in Perl using open, while, a regex, etc.
or use a shell script

http://danconia.org

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




Re: Simple Perl code/syntax question

2004-01-23 Thread Wiggins d Anconia
 Hallo everyone and thank you for your previous help
 
 in basic the code would be
 
 for x=1 to 100
 Select Case
 Case=10,20,30,40,50,60,70,80,90
 then do this
 else 
else do this
 end select
 next x
 
 how is this done in perl?
 
 foreach (10,20,30,40,50,60,70,80,90);
 {
 do this;
 }
 
  I think I need to unpack my books! (i'm moving)LOL
 Lou
 

Well there is the FAQ about case statements:

perldoc -q 'switch or case'

In your case (pun intended) assuming the list is formed as you have it,
then you could do,

foreach my $index (1 .. 100) {
  unless ($index % 10) {
  # multiple of ten
  }
  else {
  # not a multiple of ten
  }
}

If your matches are not quite so nice,

my @list = (1, 15, 23, 67, 89);
foreach my $index (1 .. 100) {
  if (grep $index == $_, @list) {
 # case matched
  }
  else {
 # non match
  }
}

All code untested, HTH,

http://danconia.org

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




Re: Simple Perl code/syntax question

2004-01-23 Thread Ricardo SIGNES
* Luinrandir Hernsen [EMAIL PROTECTED] [2004-01-23T09:38:12]
 Hallo everyone and thank you for your previous help
 
 in basic the code would be
 Select Case
 ...
 end select
 
 how is this done in perl?

Well, this is a common question.  In fact, it's a frequently asked one
with an entry in the perlfaq.  This kind of construct is called, in many
languages, a switch.  You can see the FAQ's answer by running perldoc
-q switch or by looking for the switch/case question in perlfaq7.

Your example was specific, so I can give a specific answer or two:

for (1 .. 100)  {
  unless ($_ % 10) { 
print divisible by ten\n;
  }
}

That's about what you said, right?  For every number from 1 to 100, do
something at the ten's.  Of course, someone more familiar with C (or
with the syntax of 'for') might say:

for (my $i = 1; $i = 100; $i+=10) {
print $i is divisible by ten!\n;
}

This skips a condition, incrementing $i by ten every time.

See, Perl was designed knowing that there are a whole lot of ways to use
a switch, and a whole lot of ways one might implement it specifically.
So, rather than canonize one, a single switch statement is left out.
The best thing to do is figure out how to solve the problem the best
way.

There does exist a module called Switch that will give you a switch/case
statement, but it's not really for production use.  It's a neat idea,
but isn't ready for prime time.

Does that answer your question?

-- 
rjbs


pgp0.pgp
Description: PGP signature


Re: Need help with a regex

2004-01-23 Thread Jeff 'japhy' Pinyan
On Jan 23, [EMAIL PROTECTED] said:

This newbie needs help with a regex.  Here's what the data from a text
file looks like. There's no delimiter and the fields aren't evenly spaced
apart.

apples  San Antonio  Fruit
oranges Sacramento Fruit
pineapples Honolulu Fruit
lemonsCorona del Rey   Fruit

Basically, I want to put the city names into an array.  The first field,
the fruit name, is always one word with no spaces.

Anyone know how to do that ?

Well, there are many ways.  You could split the string on whitespace,
remove the first and last elements, and join the others with spaces:

  for (@data) {
my @fields = split;
shift @fields;
pop @fields;
push @cities, @fields;  # @array = join( , @array)
  }

Or, you could use a regex that gets SPECIFICALLY what you want:

  for (@data) {
push @cities, $1 if /^\S+\s+(\S+(?:\s+\S+)*)\s+\S+$/;
  }

That regex might need a bit of explanation:

  m{
^ # the beginning of the string
\S+   # one or more non-spaces
\s+   # one or more spaces
( # capture to $1:
  \S+   # first word of the city name
  (?: \s+ \S+ )*# *ALL* remaining words
)
\s+   # one or more spaces
\S+   # one or more non-spaces
$ # the end of the string
  }x;

What this does on a string like peach Georgia fruit is this: the first
\S+\s+ matches peach .  Then we capture Georgia fruit to $1.  However,
the REST of the regex still has to match, but it can't, so the (?:\s+\S+)*
backtracks -- it gives up one of the chunks it matched, so $1 is only
Georgia.  Then the last \s+\S+ can match  fruit.

-- 
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]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Need help with a regex

2004-01-23 Thread stuart_clemons
Thanks Jeff.  I hope to try this out later today.  I thought I had the 
solution earlier this morning, but I ran into a problem.  I hope this will 
solve it !  Thanks again.




Jeff 'japhy' Pinyan [EMAIL PROTECTED] 
01/23/2004 10:34 AM
Please respond to
[EMAIL PROTECTED]


To
[EMAIL PROTECTED]
cc
[EMAIL PROTECTED]
Subject
Re: Need help with a regex






On Jan 23, [EMAIL PROTECTED] said:

This newbie needs help with a regex.  Here's what the data from a text
file looks like. There's no delimiter and the fields aren't evenly spaced
apart.

apples  San Antonio  Fruit
oranges Sacramento Fruit
pineapples Honolulu Fruit
lemonsCorona del Rey   Fruit

Basically, I want to put the city names into an array.  The first field,
the fruit name, is always one word with no spaces.

Anyone know how to do that ?

Well, there are many ways.  You could split the string on whitespace,
remove the first and last elements, and join the others with spaces:

  for (@data) {
my @fields = split;
shift @fields;
pop @fields;
push @cities, @fields;  # @array = join( , @array)
  }

Or, you could use a regex that gets SPECIFICALLY what you want:

  for (@data) {
push @cities, $1 if /^\S+\s+(\S+(?:\s+\S+)*)\s+\S+$/;
  }

That regex might need a bit of explanation:

  m{
^ # the beginning of the string
\S+   # one or more non-spaces
\s+   # one or more spaces
( # capture to $1:
  \S+   # first word of the city name
  (?: \s+ \S+ )*# *ALL* remaining words
)
\s+   # one or more spaces
\S+   # one or more non-spaces
$ # the end of the string
  }x;

What this does on a string like peach Georgia fruit is this: the first
\S+\s+ matches peach .  Then we capture Georgia fruit to $1.  However,
the REST of the regex still has to match, but it can't, so the (?:\s+\S+)*
backtracks -- it gives up one of the chunks it matched, so $1 is only
Georgia.  Then the last \s+\S+ can match  fruit.

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




Re: reading a httpd.conf file

2004-01-23 Thread Wiggins d Anconia


 Hello everyone,
 
 I have a little issue that I am sure someone has come across here
 once before and was wondering if I can get some pointers.
 
 I am trying to read and grab values from  a messy httpd.conf
 file.  What I am trying to do is grab the ServerName value and
 DocumentRoot value for a given VirtualHost depending on the username I
 have defined.
 
 The httpd.conf file has many VirtualHost sections (50 +).  And each
 section does not have the same order of directives as the next.  For
 example:
 
 VirtualHost domain1.com
 ScriptAlias /cgi-bin/ /usr/www/htdocs/lee/domain1-www/cgi-bin/
 DocumentRoot /usr/www/htdocs/lee/domain1-www
 ServerAdmin [EMAIL PROTECTED]
 ServerName domain1.com
 User lee
 /VirtualHost
 
 VirtualHost domain4.com
 User bob
 DocumentRoot /usr/www/htdocs/bob/domain1-www
 ServerAdmin [EMAIL PROTECTED]
 ScriptAlias /cgi-bin/ /usr/www/htdocs/bob/domain1-www/cgi-bin/
 ServerName domain4.com
 /VirtualHost
 
 
   So I wanted to write a script that if I have a username I could use
 that to get the ServerName and DocumentRoot from the correct VirtualHost
 Section.  Here is what I have:
 
 --code-
 #!/usr/local/bin/perl
 use strict;
 use warnings;
 use diagnostics;
 $|++;
 
 use vars qw(
  $httpd_conf_dir $httpd_conf_file $owner
  $servername $docroot $user
);
 
 $httpd_conf_dir = '/etc/httpd/conf';
 $httpd_conf_file = $httpd_conf_dir/httpd.conf;
 $user = 'lee';
 $/ = 'V';
 
 open (HTTPD, $httpd_conf_file) 
or die cannot open $httpd_conf_file:$!;
 while (HTTPD)
 {
 if (/irtualHost/)
 {
 $owner = $1 if /^User\s*(\d+)/m;

In the above regex you are looking for \d+ as the username, but your
usernames consist of letters??  [A-Za-z]+ maybe more appropriate, or
maybe even \w+?

 next if ($owner ne $user);
 $servername = $1 if /^ServerName\s*(\w+)/m;
 $docroot = $1 if /^DocumentRoot\s*(.+)/m;
 }
 }
 close (HTTPD);
 
 print $owner : $servername : $docroot\n;
 
 --/code--
 

Have you considered CPAN, Apache::Admin::Config looks promising:

http://search.cpan.org/~rsoliv/Apache-Admin-Config-0.91/lib/Apache/Admin/Config.pm

http://danconia.org

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




Re: Learning to use map and grep

2004-01-23 Thread Rob Dixon
Paul Kraus wrote:

 This is a simple bit of code that scans through a file and determines the
 width setting for columns that will eventually be written out using
 spreadsheet::writexcel.  It works fine but I am curious if there is a way to
 do it with map or grep that would be better? This is more for learning the
 practicality. Thanks.

 my $count = 0;
 foreach ( @record ) {
   my $length = length( $_ );
   $widths[ $count ] = $length if ( $widths[ $count ]  $length );
   $count++;
   push ( @sheet, [ @record ] );
 }

No. Sadly. If only 'each' would work on an array then you'd be in
business, but you're trying to maintain two parallel arrays: @record and
@widths. Perl requiers that you have an artificial index, $count, that
is there only for the compiler's sake.

Cheers,

Rob




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




Re: Convert Date to week number

2004-01-23 Thread Tim
At 03:16 PM 1/23/04 +, you wrote:
...
Why not write it yourself?
You need to know:

- Which day of the week is the 'first'.

- Which was the first week of the year that had four or more days.
  That's week one.
Then do the sums/arithmetic/math/mathematics/calculations (what /do/
people prefer?)
.
Rob
This message thread made me curious about just what constitutes the first 
week of the year. Is there a standard definition or are we making one here?

Tim 

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



RE: Convert Date to week number

2004-01-23 Thread Bob Showalter
Tim wrote:
 At 03:16 PM 1/23/04 +, you wrote:
 ...
 Why not write it yourself?
 
 You need to know:
 
 - Which day of the week is the 'first'.
 
 - Which was the first week of the year that had four or more days.  
 That's week one. 
 
 Then do the sums/arithmetic/math/mathematics/calculations (what /do/
 people prefer?) 
 
 .
 Rob
 
 This message thread made me curious about just what constitutes the
 first week of the year. Is there a standard definition or are we
 making one here? 
 
 Tim

ISO8601 defines a standard, but not everyone follows it. See:

http://www.mcs.vuw.ac.nz/technical/software/SGML/doc/iso8601/ISO8601.html

Excerpt:

An ordinal date is identified by a given day in a given year. A week is
identified by its number in a given year. A week begins with a Monday, and
the first week of a year is the one which includes the first Thursday, or
equivalently the one which includes January 4.

Here's January, 2004:

 $ cal 1 2004
 January 2004
 Su Mo Tu We Th Fr Sa
  1  2  3
  4  5  6  7  8  9 10
 11 12 13 14 15 16 17
 18 19 20 21 22 23 24
 25 26 27 28 29 30 31

Since weeks start on Monday, the week ending on Sunday, January 4 was week
1.

The DateTime family of modules on CPAN supports this standard.

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




Array creation with a existing variable

2004-01-23 Thread Ravi Malghan
Hi: I have a existing variable called $router which is
192.168.1.1. I want to create a array which looks
like @Counter192.168.1.1. 

@Counter.$router does not seem to work. 

Thanks in advance
Ravi

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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




Re: Array creation with a existing variable

2004-01-23 Thread Wiggins d Anconia


 Hi: I have a existing variable called $router which is
 192.168.1.1. I want to create a array which looks
 like @Counter192.168.1.1. 
 
 @Counter.$router does not seem to work. 
 
 Thanks in advance
 Ravi

The first question is why?  I suspect first that the dots in the name of
the variable will not be allowed for obvious reason, second you are
trying to use symbolic references which are frowned upon, and prevented
assuming you are doing 'use strict' (you are aren't you?).

So what are you *really* trying to do?  I will suggest a hash as usually
this type of problem is solved by their use

http://danconia.org

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




Re: Array creation with a existing variable

2004-01-23 Thread Ravi Malghan
True. Since the value(s) for @Counter$router is going
to be array, manipulating that hash was making things
complex for me.

If I use a hash (%Counter), what do I have to do such
that the resulting value for $Counter{$router} is an
array.

Thanks
Ravi
--- Wiggins d Anconia [EMAIL PROTECTED] wrote:
 
 
  Hi: I have a existing variable called $router
 which is
  192.168.1.1. I want to create a array which
 looks
  like @Counter192.168.1.1. 
  
  @Counter.$router does not seem to work. 
  
  Thanks in advance
  Ravi
 
 The first question is why?  I suspect first that the
 dots in the name of
 the variable will not be allowed for obvious reason,
 second you are
 trying to use symbolic references which are frowned
 upon, and prevented
 assuming you are doing 'use strict' (you are aren't
 you?).
 
 So what are you *really* trying to do?  I will
 suggest a hash as usually
 this type of problem is solved by their use
 
 http://danconia.org


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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




Re: Array creation with a existing variable

2004-01-23 Thread Ravi Malghan
I may have found the answer, I could use
@{$Counter{$router}} . I will try this.

Thanks
Ravi
--- Ravi Malghan [EMAIL PROTECTED] wrote:
 True. Since the value(s) for @Counter$router is
 going
 to be array, manipulating that hash was making
 things
 complex for me.
 
 If I use a hash (%Counter), what do I have to do
 such
 that the resulting value for $Counter{$router} is an
 array.
 
 Thanks
 Ravi
 --- Wiggins d Anconia [EMAIL PROTECTED] wrote:
  
  
   Hi: I have a existing variable called $router
  which is
   192.168.1.1. I want to create a array which
  looks
   like @Counter192.168.1.1. 
   
   @Counter.$router does not seem to work. 
   
   Thanks in advance
   Ravi
  
  The first question is why?  I suspect first that
 the
  dots in the name of
  the variable will not be allowed for obvious
 reason,
  second you are
  trying to use symbolic references which are
 frowned
  upon, and prevented
  assuming you are doing 'use strict' (you are
 aren't
  you?).
  
  So what are you *really* trying to do?  I will
  suggest a hash as usually
  this type of problem is solved by their use
  
  http://danconia.org
 
 
 __
 Do you Yahoo!?
 Yahoo! SiteBuilder - Free web site building tool.
 Try it!
 http://webhosting.yahoo.com/ps/sb/
 
 -- 
 To unsubscribe, e-mail:
 [EMAIL PROTECTED]
 For additional commands, e-mail:
 [EMAIL PROTECTED]
 http://learn.perl.org/
 http://learn.perl.org/first-response
 
 


__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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




Re: Array creation with a existing variable

2004-01-23 Thread Wiggins d Anconia
Please bottom post...

 True. Since the value(s) for @Counter$router is going
 to be array, manipulating that hash was making things
 complex for me.
 
 If I use a hash (%Counter), what do I have to do such
 that the resulting value for $Counter{$router} is an
 array.
 

You still haven't told us what you are really after.  'Counter' is a
rather undescript variable name, and $router is just an IP address, so
are you trying to count the number of times the IP occurs in a log,
etc.?  You haven't stated why you need an array associated with $router
at all... the reason this is unclear is because of the name Counter
which implies just a count, which implies a number, which implies a
scalar, which if you really do need an array, this may suggest that your
variable name is not terribly stylish...

You have stumbled on references, which is a good thing in the end, but
you need to first establish if you truly need an array, if you have in
fact established this, then you should become familar with the core of
references before leading yourself down the path of lots of questions. A
look at,

perldoc perlreftut
perldoc perllol
perldoc perldsc
perldoc perlref

Will probably help you the most...

To specifically answer your question you can initialize the slot in
the hash with an anonymous array reference like so:

$Counter-{$router} = [];

Then as your other message suggests you can act on that array in ways
such as,

push @{$Counter-{$router}}, 'My latest value';
foreach my $value (@{$Counter-{$router}}) {  # do something }

Or individually as,

$Counter-{$router}-[0]... but seriously read the docs

http://danconia.org



 --- Wiggins d Anconia [EMAIL PROTECTED] wrote:
  
  
   Hi: I have a existing variable called $router
  which is
   192.168.1.1. I want to create a array which
  looks
   like @Counter192.168.1.1. 
   
   @Counter.$router does not seem to work. 
   
   Thanks in advance
   Ravi
  
  The first question is why?  I suspect first that the
  dots in the name of
  the variable will not be allowed for obvious reason,
  second you are
  trying to use symbolic references which are frowned
  upon, and prevented
  assuming you are doing 'use strict' (you are aren't
  you?).
  
  So what are you *really* trying to do?  I will
  suggest a hash as usually
  this type of problem is solved by their use
  


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




Re: Convert Date to week number

2004-01-23 Thread Rob Dixon
Timwrote:

 At 03:16 PM 1/23/04 +, you wrote:
 ...
 Why not write it yourself?
 
 You need to know:
 
 - Which day of the week is the 'first'.
 
 - Which was the first week of the year that had four or more days.
That's week one.
 
 Then do the sums/arithmetic/math/mathematics/calculations (what /do/
 people prefer?)

 This message thread made me curious about just what constitutes the first
 week of the year. Is there a standard definition or are we making one here?

I got this from the British 'Letts' diary manufacturer about ten years back.
Clearly it makes sense, as a week is, usefully, an odd number of days long
and can be assigned into either one year or the other. The big difference
is on which day a week starts, which is both nationally and culturally
variant.

Rob



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




Re: Convert Date to week number

2004-01-23 Thread Rob Dixon
Bob Showalter wrote:

 ISO8601 defines a standard, but not everyone follows it. See:

 http://www.mcs.vuw.ac.nz/technical/software/SGML/doc/iso8601/ISO8601.html

 Excerpt:

 An ordinal date is identified by a given day in a given year. A week is
 identified by its number in a given year. A week begins with a Monday, and
 the first week of a year is the one which includes the first Thursday, or
 equivalently the one which includes January 4.

 Here's January, 2004:

  $ cal 1 2004
  January 2004
  Su Mo Tu We Th Fr Sa
   1  2  3
   4  5  6  7  8  9 10
  11 12 13 14 15 16 17
  18 19 20 21 22 23 24
  25 26 27 28 29 30 31

 Since weeks start on Monday, the week ending on Sunday, January 4 was week
 1.

 The DateTime family of modules on CPAN supports this standard.

Thanks Bob. It's always nice to have a document to prod.

Strange though, since

 A week begins with a Monday

yet the tabulation starts on Sunday.

Rob



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




Re: Array creation with a existing variable

2004-01-23 Thread Randal L. Schwartz
 Ravi == Ravi Malghan [EMAIL PROTECTED] writes:

Ravi Hi: I have a existing variable called $router which is
Ravi 192.168.1.1. I want to create a array which looks
Ravi like @Counter192.168.1.1. 

No, you don't.  You really, really don't.  You may think you do,
if you're bringing techniques in from other languages.  But in Perl,
you don't.  You really really don't.

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

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




Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

2004-01-23 Thread John McKown
Unfortunately, if the person is writing from work, the disclaimer is 
likely required by his employer. I know that I have a similar one at work. 
And not including it is grounds for termination stupid.

The only way around this is to use a personal email, like I do. But he may 
need the help for work and at work. Supposedly, I cannot use my personal 
email from work. But I know ways and means around it and am stealthy 
enough that I am not likely to get caught.

I'm sitting at work now, but using my home email.

--
Maranatha!
John McKown



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




Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

2004-01-23 Thread Levon Barker
Except that John's boss is on the list too!

On Fri, 2004-01-23 at 14:37, John McKown wrote:
 Unfortunately, if the person is writing from work, the disclaimer is 
 likely required by his employer. I know that I have a similar one at work. 
 And not including it is grounds for termination stupid.
 
 The only way around this is to use a personal email, like I do. But he may 
 need the help for work and at work. Supposedly, I cannot use my personal 
 email from work. But I know ways and means around it and am stealthy 
 enough that I am not likely to get caught.
 
 I'm sitting at work now, but using my home email.
 
 --
 Maranatha!
 John McKown
 
 


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




Re: complex data file parsing

2004-01-23 Thread wolf blaum
Hi, 

 As far as your follow up question on the B lines, only line with a B in
 the beginning in set?, I'm not sure if I understand.  If you mean that
 there will only be 1 line per order (set of lines A-T) with a B in the
 first position, you are correct.

yes, thats what I meant.
Sorry about my lazyness. Adittionally I get to correct all my embarassing 
typos...

 Also, as far as your assumption, The way I do it assumes that the first
 and only first line of each set beginns with an A (and falsly buts that A
 at the end of the privious record, but
 doesnt matter for the aim her, does it?),  I'm not sure what you mean by
 this either.  However, it sounds like you have it correct.  Lines that
 indicate the beginning of an order block, will only ever start with an A in
 the first position.

Well, what that $/=\nA does is, it changes the amount of data the while 
(FH) reads into $_
Usually that is a line - in your case, the change of $/ gets it to read a 
whole order into $_: from A, to T,. end of line here. Thats what you 
need. However, I cheat: it acctually reads from A,... to T, \nA, into $_, 
so even the (A,) belongs to the next record, it ends up in the privious one. 
Thats kind of wrong, given your record structure but does not matter for the 
purpous you described. See the print $_ in the code below.

 Finally, the final assumption, that The push assumes that there are always
 exactly 5 records between B and email and that this is the only line with a
 B in record (and comes before the lines
 with ADV_.  I think that this is correct.  

well good:)

 I tested the script, and I was able to output e-mail addresses.  However,
 using the data that I posted, it does not quite output exactly what I need.
 Based on this sample of order.csv and the script that you sent me (I added
 the line print @email to view the output):

   for (my $i=0; $i=$#fields; $i++){
  if ($fields[$i] eq B) {$b_index=$i; next;}
  elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4];
 last;}
1 print @email;
  ):


 What is going wrong?  Am I trying to view the output incorrectly?

The line 1 is still in the for loop. So you print all emails seen so far for 
every field the split gave you.

Code with more debug in the right place:

---

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

my @email;
open (FH, complex.txt) or die $!;

local $/ = \nA,; # make \nA, the record seperator

while(FH){   # read the next record
  print This record holdes:\n$_ \n; 

  my @fields = split ,|\n, $_; # split at , or \n
  my $b_index; # 0 for every new record
  for (my $i=0; $i=$#fields; $i++){
 if ($fields[$i] eq B) {$b_index=$i; next;}
 elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; 
last;}
  } # end for

print End of record.\n\n
} # end while

print @email;  #last line in script

-

On my box that prints the 2 emails you wanted.
I hope I didnt get something totally screwed.

Let me know if that does it or not. Thx, 
Wolf




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




Loading and using modules using eval

2004-01-23 Thread Papo Napolitano
Hi all,

I have this piece of code:

my @modules = (
 'Module1', 'Module2', 'Module3',
 'ModuleX', 'ModuleY', 'Blah',
);
my $param1 = whatever;
my $param2 = 0;
for my $module (@modules) {
  $param2++;
  eval(require $module);
  if ($@) {
print $module Not found\n;
  } else {
eval(${module}::process('$param1', '$param2'));
  }
}

And it's working, but I wonder if there's any cleaner/better way to do this.
The main idea is to have a XML file like this:

xml
  file source=file1.txt module=TextFile parameters=1/
  file source=file2.csv module=TextFile parameters=2/
  file source=file3.xml module=XMLFile parameters=this and that/
/xml

To tell me I have to do:

TextFile::process('file1.txt', '1');
TextFile::process('file2.csv', '2');
XMLFile::process('file3.xml', 'this and that');

Got it? ;-)

Thanks!


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




modules and _DATA_

2004-01-23 Thread Eric Walker
I have some code I want to add a package in the same file.  I already
have some _DATA_ in the file.  Currently, the code is not seeing the
_DATA_.  How can I add a package in the same file then.

Thanks
perlknucklehead

example: 
while DATA{
  do something
}

_DATA_
this
is my
data
section



Re: modules and _DATA_

2004-01-23 Thread James Edward Gray II
On Jan 23, 2004, at 3:27 PM, Eric Walker wrote:

I have some code I want to add a package in the same file.  I already
have some _DATA_ in the file.  Currently, the code is not seeing the
_DATA_.  How can I add a package in the same file then.
I believe your DATA tag at the end is the problem.  It's supposed to be 
__DATA__.  That's underscore underscore D A T A underscore underscore.

Hope that helps.

James

example:
while DATA{
  do something
}
_DATA_
this
is my
data
section


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



Re: modules and _DATA_

2004-01-23 Thread Eric Walker
On Fri, 2004-01-23 at 14:34, James Edward Gray II wrote:

On Jan 23, 2004, at 3:27 PM, Eric Walker wrote:

 I have some code I want to add a package in the same file.  I already
 have some _DATA_ in the file.  Currently, the code is not seeing the
 _DATA_.  How can I add a package in the same file then.

I believe your DATA tag at the end is the problem.  It's supposed to be 
__DATA__.  That's underscore underscore D A T A underscore underscore.

Hope that helps.

James

 example:
 while DATA{
   do something
 }

 _DATA_
 this
 is my
 data
 section

sorry I was typing to fast, it is __DATA__ This program was working before but 

when I tried to add a package to it, I did some test and its not reading
the DATA anymore. Is there a certain order?




Re: modules and _DATA_

2004-01-23 Thread drieux
On Jan 23, 2004, at 1:27 PM, Eric Walker wrote:

I have some code I want to add a package in the same file.  I already
have some _DATA_ in the file.  Currently, the code is not seeing the
_DATA_.  How can I add a package in the same file then.
[..]

since the

__DATA__
vice
_DATA_
has been addressed, my pet favorite way to include a
package inside of a piece of code is
BEGIN {
package Foo::Bar;

}
That way it will be compiled early and so you can
place it above the __DATA__ section since it is
not 'data'.
ciao
drieux
---

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



Re: modules and _DATA_

2004-01-23 Thread Randy W. Sims
On 1/23/2004 4:36 PM, Eric Walker wrote:
when I tried to add a package to it, I did some test and its not reading
the DATA anymore. Is there a certain order?
__DATA__ must be in package main;

#!perl

use strict;
use warnings;
while (DATA) {
  print;
}
package Test;
sub a {}
1;
package main; # DATA must be in main

__DATA__
this
is my
data
section
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules and _DATA_

2004-01-23 Thread drieux
On Jan 23, 2004, at 1:36 PM, Eric Walker wrote:
[..]
when I tried to add a package to it, I did some test and its not 
reading
the DATA anymore. Is there a certain order?
[..]

How did you put the package in?

ciao
drieux
---

#!/usr/bin/perl -w
use strict;

my $foo = new Foo::Bar;

while(DATA){
$foo-showMe($_);
}

BEGIN {
package Foo::Bar;
use 5.006;
use strict;
use warnings;
our $VERSION = '0.01';
#-
# Our Stock Constructor
# note: http://www.perlmonks.org/index.pl?node_id=52089
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;

} # end of our simple new

#-
# so that AUTOLOAD finds one here
sub DESTROY {}
#
#
sub showMe
{
my ($me,$line) = @_;
print $line;

} # end of showMe


1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin

__DATA__
This line
and then the world.
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules and _DATA_

2004-01-23 Thread Eric Walker
On Fri, 2004-01-23 at 14:43, Randy W. Sims wrote:

On 1/23/2004 4:36 PM, Eric Walker wrote:
 
 when I tried to add a package to it, I did some test and its not reading
 the DATA anymore. Is there a certain order?

__DATA__ must be in package main;

#!perl

use strict;
use warnings;

while (DATA) {
   print;
}

package Test;
sub a {}
1;

package main; # DATA must be in main

__DATA__
this
is my
data
section

worked like a charm thanks, now its working but correctly time to get my handy 
dandy

print statement out...

Thanks..


can i do it with perl ?

2004-01-23 Thread Joe Echavarria

  I there, 

 I need to write a web database application using
perl, and i need a way that when the users logs into
the system  i download all the information regarding
to the user to its local computer and make all the
transaction locally.  After that, when the user logs
out of the system all the information and transaction
that were made by that user are then updated to the
database server.   Can i do it with perl ?, which
modules ?,  thanks.

__
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/

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




RE: can i do it with perl ?

2004-01-23 Thread Bob Showalter
Joe Echavarria wrote:
   I there,
 
  I need to write a web database application using
 perl, and i need a way that when the users logs into
 the system  i download all the information regarding
 to the user to its local computer and make all the
 transaction locally.  After that, when the user logs
 out of the system all the information and transaction
 that were made by that user are then updated to the
 database server.   

Why does it need to work that way?

 Can i do it with perl ?, 

Sure.

 which modules ?,  thanks.

Too soon to say.


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




RE: complex data file parsing

2004-01-23 Thread Hughes, Andrew
Thanks so much.  I've been tinkering around with this all afternoon.  I
think that it is there.  I'm going to mess around with it more over the
weekend.

I'll let you know how it goes.

Thanks so much, Wolf!

Andrew

-Original Message-
From: wolf blaum [mailto:[EMAIL PROTECTED]
Sent: Friday, January 23, 2004 3:30 PM
To: Hughes, Andrew; Perl Beginners Mailing List
Subject: Re: complex data file parsing


Hi, 

 As far as your follow up question on the B lines, only line with a B in
 the beginning in set?, I'm not sure if I understand.  If you mean that
 there will only be 1 line per order (set of lines A-T) with a B in the
 first position, you are correct.

yes, thats what I meant.
Sorry about my lazyness. Adittionally I get to correct all my embarassing 
typos...

 Also, as far as your assumption, The way I do it assumes that the first
 and only first line of each set beginns with an A (and falsly buts that A
 at the end of the privious record, but
 doesnt matter for the aim her, does it?),  I'm not sure what you mean by
 this either.  However, it sounds like you have it correct.  Lines that
 indicate the beginning of an order block, will only ever start with an A
in
 the first position.

Well, what that $/=\nA does is, it changes the amount of data the while 
(FH) reads into $_
Usually that is a line - in your case, the change of $/ gets it to read a 
whole order into $_: from A, to T,. end of line here. Thats what you

need. However, I cheat: it acctually reads from A,... to T, \nA, into
$_, 
so even the (A,) belongs to the next record, it ends up in the privious one.

Thats kind of wrong, given your record structure but does not matter for the

purpous you described. See the print $_ in the code below.

 Finally, the final assumption, that The push assumes that there are
always
 exactly 5 records between B and email and that this is the only line with
a
 B in record (and comes before the lines
 with ADV_.  I think that this is correct.  

well good:)

 I tested the script, and I was able to output e-mail addresses.  However,
 using the data that I posted, it does not quite output exactly what I
need.
 Based on this sample of order.csv and the script that you sent me (I added
 the line print @email to view the output):

   for (my $i=0; $i=$#fields; $i++){
  if ($fields[$i] eq B) {$b_index=$i; next;}
  elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4];
 last;}
1 print @email;
  ):


 What is going wrong?  Am I trying to view the output incorrectly?

The line 1 is still in the for loop. So you print all emails seen so far for

every field the split gave you.

Code with more debug in the right place:

---

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

my @email;
open (FH, complex.txt) or die $!;

local $/ = \nA,; # make \nA, the record seperator

while(FH){   # read the next record
  print This record holdes:\n$_ \n; 

  my @fields = split ,|\n, $_; # split at , or \n
  my $b_index; # 0 for every new record
  for (my $i=0; $i=$#fields; $i++){
 if ($fields[$i] eq B) {$b_index=$i; next;}
 elsif ($fields[$i] =~ /^ADV_.*/) {push @email, $fields[$b_index+4]; 
last;}
  } # end for

print End of record.\n\n
} # end while

print @email;  #last line in script

-

On my box that prints the 2 emails you wanted.
I hope I didnt get something totally screwed.

Let me know if that does it or not. Thx, 
Wolf



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




Re: modules and _DATA_

2004-01-23 Thread Eric Walker
On Fri, 2004-01-23 at 14:46, drieux wrote:

On Jan 23, 2004, at 1:36 PM, Eric Walker wrote:
[..]

 when I tried to add a package to it, I did some test and its not 
 reading
 the DATA anymore. Is there a certain order?
[..]

How did you put the package in?

ciao
drieux

---

#!/usr/bin/perl -w
use strict;

my $foo = new Foo::Bar;

while(DATA){
$foo-showMe($_);
}

BEGIN {
package Foo::Bar;
use 5.006;
use strict;
use warnings;
our $VERSION = '0.01';
#-
# Our Stock Constructor
# note: http://www.perlmonks.org/index.pl?node_id=52089
sub new
{
my $class = shift;
my $self = {};
bless $self, $class;

} # end of our simple new

#-
# so that AUTOLOAD finds one here
sub DESTROY {}
#
#
sub showMe
{
my ($me,$line) = @_;
print $line;

} # end of showMe


1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin

__DATA__
This line
and then the world.


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

while DATA{
do something;}

package ONE
 package stuff;
 1;

package main
   
 __DATA__
data stufff




Re: Loading and using modules using eval

2004-01-23 Thread drieux
On Jan 23, 2004, at 1:23 PM, Papo Napolitano wrote:
[..]
xml
  file source=file1.txt module=TextFile parameters=1/
  file source=file2.csv module=TextFile parameters=2/
  file source=file3.xml module=XMLFile parameters=this and 
that/
/xml

To tell me I have to do:

TextFile::process('file1.txt', '1');
TextFile::process('file2.csv', '2');
XMLFile::process('file3.xml', 'this and that');
[..]

Why not try something a bit more vanilla
where one does the
	use SomeModuleHere;

for all the modules you want to use. Then you
can use the no strict refs option IF you
really want to do the strictly functional approach.
I do not think that

	eval(${module}::process('$param1', '$param2'));

will do what you want it to do.

IF the Text::process and XML::process functions are things
that you are building out you may want to think about the
idea of doing the perl oo-ish aproach, as
	$foo-showMe($line);

will work without requiring the no strict refs.

ciao
drieux
---

Some code to play around with would be:

#!/usr/bin/perl -w
use strict;
my ($foo, $line) ;
while(DATA){
chomp;
/^([\w:]+)\s+(.*)/;
($foo, $line) = ($1,$2);
# this assumes that the Package is External
#   require $foo.pm if (!exists($INC{$foo.pm}));
# the way that will work by indirection
#$foo-showMe($line);
my $code = ${foo}::showMe;
no strict 'refs';
$code-($line);
# does not invoke the code
#eval{ ${foo}::showMe($line) };
if ($@)
{
print Error: had \$foo - $foo\n\t\$line - [EMAIL 
PROTECTED];
}

}
print and now a Procecural call:\n ;

Foo::showMe(Procedural\n$line\n);

BEGIN {
package Foo::Bar;

#
#
sub showMe
{
#my $me = shift if ( $_[0] eq __PACKAGE__);
my ($line) = @_;
print $line;
print \n unless $line =~ /\n/gim;

} # end of showMe

1;

package Foo;

#
#
sub showMe
{
#my $me = shift if ( $_[0] eq __PACKAGE__ or
#   ref($_[0]) eq __PACKAGE__ );
my ($line) = @_;
print foo sees:\n\t $line\n;

} # end of showMe


1; # so that the 'use Foo::Bar'
   # will know we are happy
} # end begin

__DATA__
Foo word up
Foo::Bar not that one.
Foo This is a Happy Line
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: modules and _DATA_

2004-01-23 Thread drieux
On Jan 23, 2004, at 2:47 PM, Eric Walker wrote:
[..]
while DATA{
do something;}
    package ONE
 package stuff;
 1;
    package main
  
 __DATA__
    data stufff
yes, one can do the reset back to package main.

part of the reason I opt for the

	BEGIN { package  }

approach is so that I know that the compiler
will deal with the BEGIN { BLOCK } before
worrying about anything else in the code.
That way I know that my objects will be sorted out foist.

As a general rule of thumb, though, once I have played
out an idea then it is going off to it's own
	Monkey.pm

file where it is a fully externalized perl module...

ciao
drieux
---

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



Re: can i do it with perl ?

2004-01-23 Thread wolf blaum
   I there,
Hi, 
  I need to write a web database application using
 perl, and i need a way that when the users logs into
 the system  i download all the information regarding
 to the user to its local computer and make all the
 transaction locally.  After that, when the user logs
 out of the system all the information and transaction
 that were made by that user are then updated to the
 database server.   Can i do it with perl ?, which
 modules ?,  thanks.

Why does it have to be a web application? 
Or rather just a client/server thing?
What Database?
I didnt find a way to do the dishes yet, anything else I ever tried works in 
perl.

Just give us some more info.
Wolf


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




porting to windows NT

2004-01-23 Thread Johnson, Shaunn
Howdy:

I want to move my perl script from Linux to Windows NT.
The Linux script connects to Oracle via the DBI modules I
have installed.  I want to do the same on NT, but I'm not
sure if the connection strings / values are the same.

In the linux script:

[snip]
use strict;
use diagnostics;
use DBI;
use POSIX 'strftime';

my $host='192.168.1.100';
my $sid='testdb';
my $username='scott';
my $password='tiger';
my $datestr=strftime '%d%m%Y',localtime;

# connection option
my $dbh = DBI-connect(dbi:Oracle:host=$host;sid=$sid, $username,
$password, { RaiseError = 1 }) or die Can not connect: $!;
[/snip]

Win:32 errors:

[errors]
D:\test\tmo_connecttest.pl
Use of uninitialized value in concatenation (.) or string at
D:/Perl/site/lib/DBI.pm line 584.
DBI connect('host=192.168.1.100;sid=testdb','scott',...) failed:  at
D:\test\tmo_connect\test.pl line 19
Can not connect:  at D:\test\tmo_connect\test.pl line 19.
[/errors]

Should this be the same? I had installed DBI 1.37 via
the ppm install DBI.ppd method.  Looking at the 'query'
option, it says that DBI is installed and 'verify' says
it's up to date.

Question:  Is there an example of how to connect to Oracle 
(version 9.2.0.1) via Win:32?  

Basically, what am I doing wrong?

Thanks in advance!

-X


Re: can i do it with perl ?

2004-01-23 Thread Daniel Staal
--As off Saturday, January 24, 2004 12:07 AM +0100, wolf blaum is 
alleged to have said:

I didnt find a way to do the dishes yet, anything else I ever tried
works in  perl.
--As for the rest, it is mine.

I'm sure you could do something with LEGO::RCX and a Mindstorms kit...
;-)
Daniel T. Staal

---
This email copyright the author.  Unless otherwise noted, you
are expressly allowed to retransmit, quote, or otherwise use
the contents for non-commercial purposes.  This copyright will
expire 5 years after the author's death, or in 30 years,
whichever is longer, unless such a period is in excess of
local copyright law.
---
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: can i do it with perl ?

2004-01-23 Thread Dan Anderson
On Fri, 2004-01-23 at 18:07, wolf blaum wrote:
I there,
 Hi, 
   I need to write a web database application using
  perl, and i need a way that when the users logs into
  the system  i download all the information regarding
  to the user to its local computer and make all the
  transaction locally.  After that, when the user logs
  out of the system all the information and transaction
  that were made by that user are then updated to the
  database server.   Can i do it with perl ?, which
  modules ?,  thanks.
 
 Why does it have to be a web application? 
 Or rather just a client/server thing?
 What Database?
 I didnt find a way to do the dishes yet, anything else I ever tried works in 
 perl.

Give me a little bit of time with a soldering iron, some wire, and a
laptop connected to your home network and your dishwasher and that can
be rectified.  :-D

-Dan


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




Re: can i do it with perl ?

2004-01-23 Thread wolf blaum
 Give me a little bit of time with a soldering iron, some wire, and a
 laptop connected to your home network and your dishwasher and that can
 be rectified.  :-D

I new that was a gentle list!
I just dont have a dishwasher :(
But given the traffic here I happily dont get much time to use dishes at all.

Have a nice weekend, Wolf


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




From 5.6.1 to 5.8.2: how preserve installed modules?

2004-01-23 Thread mcdavis941
Hi, I'm considering upgrading from ActiveState Perl 5.6.1 to 5.8.2 (in order to use 
the latest Apache and mod_perl, although that's kind of beside the point).

Unfortunately, being a Perl beginner, I've installed CPAN modules by a variety of 
methods including:
- manually downloading the .zip from CPAN and running its make 
- manually downloading the .zip from ActiveState and running its install
- using PPM to download and install from ActiveState
- downloading just the Perl source (!!!) from single .pm files  (!!!) on CPAN and 
placing it by hand.  (Honest, that was at the very beginning of learning Perl.)

Now I'm ready to get religion and start managing all my packages the right way.  So 
my question is: what is the right way?  How do *you* go about managing all your 
downloaded modules?

Questions:

- I see that CPAN.pm is available to install packages and prerequisites.  Does it play 
well with PPM?  When you have a choice, is it preferable to use PPM or CPAN.pm?
- How can I get PPM to tell me everything that's installed?

And specific to the Perl version upgrade:

- Is there any way to say take everything added to 5.6.1, and add it again to 5.8.2? 
 (I'm not doing an inplace upgrade, if that's even possible, because I want to test 
everything with 5.8.2 before I commit to getting rid of 5.6.1.)
- How can I tell whether a module contains compiled binary code (these being modules 
likely to need downloading from scratch for 5.8.2)?  
- Can anyone say what I would break by upgrading to 5.8.2?  Are there major CPAN 
modules known to become incompatible when moving to 5.8.2?

I'm facing a look of work to get all this straight, and I'd really appreciate any 
pointers.  TIA.




__
New! Unlimited Netscape Internet Service.
Only $9.95 a month -- Sign up today at http://isp.netscape.com/register
Act now to get a personalized email address!

Netscape. Just the Net You Need.

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




Re: From 5.6.1 to 5.8.2: how preserve installed modules?

2004-01-23 Thread wolf blaum
Hi, 

i ont want to get involved in the religios questions: for the rest:

 use PPM or CPAN.pm? - How can I get PPM to tell me everything that's
 installed?

ppm query *   #gives you the list of installed modules
ppm properties Mo::Dule  #gives you a detailed discriptio of that installed 
module

 Can anyone say what I would break by upgrading to 5.8.2?  Are there major
 CPAN modules known to become incompatible when moving to 5.8.2?

Not from the top of my head.
However, if you check 
http://aspn.activestate.com/ASPN/Modules/

and look for the ppm module status, youll find a nice table telling you which 
modules work in which version of activestate perl.
There is a lot of modules that dont work with 5.8. yet (like 
Mail::POP3Client).

Good luck, Wolf




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




String concatenation qn

2004-01-23 Thread Ajey Kulkarni
hi,.
i would like to quickly append a string to a variable.
Suppose $filename has /tmp/xyz after appending i want to
get $filename as /tmp/xyz.NEW.

I'm getting a ? for a . (period).

I'm doing something like

open NEWFH,  $filename.new or die new procmailrc err;
where $filename has /tmp/xyz

Anything really silly here??

regards
-Ajey


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




Re: String concatenation qn

2004-01-23 Thread wolf blaum
For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 2004 17:52 
may have been monitored or recorded as:

 hi,.
hi
 i would like to quickly append a string to a variable.

 open NEWFH,  $filename.new or die new procmailrc err;
 where $filename has /tmp/xyz

 Anything really silly here??

Nothing I didnt do wrong at least a thousand times:

open NEWFH,  $filename..new or die new procmailrc err;

will do it.

perldoc perlop:
Gory details of parsing quoted constructs

       When presented with something that might have several dif-
       ferent interpretations, Perl uses the DWIM (that's Do
       What I Mean) principle to pick the most probable inter-
       pretation.  This strategy is so successful that Perl pro-
       grammers often do not suspect the ambivalence of what they
       write.  But from time to time, Perl's notions differ sub-
       stantially from what the author honestly meant.
-

This is one of the latter cases.

Wolf


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




Re: can i do it with perl ?

2004-01-23 Thread John McKown
On Fri, 23 Jan 2004, Joe Echavarria wrote:

 
   I there, 
 
  I need to write a web database application using
 perl, and i need a way that when the users logs into
 the system  i download all the information regarding
 to the user to its local computer and make all the
 transaction locally.  After that, when the user logs
 out of the system all the information and transaction
 that were made by that user are then updated to the
 database server.   Can i do it with perl ?, which
 modules ?,  thanks.
 

Unless this is an in house application for internal business use, I'd 
suggest against it. The main reason is that you are downloading something 
to the user's computer. They may not like that very much at all! I know 
that if a web site wanted to put some application on my machine, I'd tell 
them to take a walk. If the visitors are on a company PC, they might not 
even be able to install your application on their system. I know that our 
PC people do _not_ allow any unauthorized software to be installed by the 
user. In fact, any software going onto a PC owned by our company _must_ be 
tested and approved by our Integration Lab. The end-users do not have 
the authority to do any sort of installation.

Also, if your software is written in Perl, you would be forcing the users 
of it to have Perl installed. This may or may not be true.

And what DB are you considering? That would need to be installed as well. 
Along with the Perl bindings. Unless it was integrated with Perl.

Now, suppose we get by all my objections. How would you upload the 
changed data? What if another person had changed the same datum? How do 
you guarantee the reliability of your data? What if the user's computer 
dies (blue screens)? What if the user simply does not log off of your 
application?

I think this is going to be very difficult. Good luck to you!

--
Maranatha!
John McKown


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




Re: can i do it with perl ?

2004-01-23 Thread John McKown
On Fri, 23 Jan 2004, Dan Anderson wrote:

 
 Give me a little bit of time with a soldering iron, some wire, and a
 laptop connected to your home network and your dishwasher and that can
 be rectified.  :-D
 
 -Dan

I don't think that the lady who comes in and does my dishes is going to 
let you anywhere near her with a soldering iron in your hand! grin

--
Maranatha!
John McKown


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




interfacing with Python using Perl

2004-01-23 Thread Andrew Gaffney
I don't know Python and I really have no desire to learn it, but I do have a decent amount 
of experience with Perl. Is there a module(s) that will let Perl interface with existing 
Python code/modules? Specifically, I want to write a Perl program to use Gentoo Linux's 
Portage API which is written all in Python.

--
Andrew Gaffney
System Administrator
Skyline Aeronautics, LLC.
776 North Bell Avenue
Chesterfield, MO 63005
636-357-1548
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response



Re: [meta] Please delete boilerplate! (was Re: Covert Date to week number)

2004-01-23 Thread John McKown
On Fri, 23 Jan 2004, Levon Barker wrote:

 Except that John's boss is on the list too!
 

No, my boss is not UNIX or even Windows literate. He is a BOSS, not a 
GRUNT. He may, from years past, remember some COBOL (remember that?). If I 
told him that I was on a Perl list, he would think that I was talking 
about the things that come out of oysters.

--
Maranatha!
John McKown


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




Re: String concatenation qn

2004-01-23 Thread Wiggins d'Anconia
wolf blaum wrote:
For Quality purpouses, Ajey Kulkarni 's mail on Saturday 24 January 2004 17:52 
may have been monitored or recorded as:


hi,.
hi

i would like to quickly append a string to a variable.


open NEWFH,  $filename.new or die new procmailrc err;
where $filename has /tmp/xyz
Anything really silly here??


Nothing I didnt do wrong at least a thousand times:

open NEWFH,  $filename..new or die new procmailrc err;

will do it.

perldoc perlop:
Gory details of parsing quoted constructs
   When presented with something that might have several dif-
   ferent interpretations, Perl uses the DWIM (that's Do
   What I Mean) principle to pick the most probable inter-
   pretation.  This strategy is so successful that Perl pro-
   grammers often do not suspect the ambivalence of what they
   write.  But from time to time, Perl's notions differ sub-
   stantially from what the author honestly meant.
-
This is one of the latter cases.

Wolf


Not sure I see why adding a concatenation helped?  The OP's code works 
fine in my 5.8.0 RH 9.0 install and the dot isn't significant within the 
double quotes since it isn't a property or namespace token separator 
like in other languages.   Is this version dependent, or maybe UTF-8 
related?

http://danconia.org

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



Re: interfacing with Python using Perl

2004-01-23 Thread Jeff 'japhy' Pinyan
On Jan 23, Andrew Gaffney said:

I don't know Python and I really have no desire to learn it, but I do
have a decent amount of experience with Perl. Is there a module(s) that
will let Perl interface with existing Python code/modules? Specifically,
I want to write a Perl program to use Gentoo Linux's Portage API which is
written all in Python.

I believe you can do just that with Inline::Python, on CPAN.

  http://search.cpan.org/author/NEILW/Inline-Python-0.20/Python.pod

It's from 2001, though... just so you know...

-- 
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]
http://learn.perl.org/ http://learn.perl.org/first-response




Re: Need help with a regex

2004-01-23 Thread R. Joseph Newton
[EMAIL PROTECTED] wrote:

 Thanks Jeff.  I hope to try this out later today.  I thought I had the
 solution earlier this morning, but I ran into a problem.  I hope this will
 solve it !  Thanks again.

 apples  San Antonio  Fruit
 oranges Sacramento Fruit
 pineapples Honolulu Fruit
 lemonsCorona del Rey   Fruit
 
 Basically, I want to put the city names into an array.  The first field,
 the fruit name, is always one word with no spaces.
 
 Anyone know how to do that ?

 Well, there are many ways.  You could split the string on whitespace,
 remove the first and last elements, and join the others with spaces:

   for (@data) {
 my @fields = split;
 shift @fields;
 pop @fields;
 push @cities, @fields;  # @array = join( , @array)
   }

I'd vote for this one--almost.  It does the right thing with positions,
presuming that Stuart can count on the fruit type and class always being
contained in a single token.  The one thing I would do is to give the parts
meaningful names.  Unless he totally wants to discard the significant fruit
name as well as the non-informaticve class desiganation Fruit, he might as
well preserve the information that he has available:

foreach (@data) {
my @fields = split;
pop @fields;  # only use void statements to get rid of garbage
my $growing_location = {
'fruit type' = shift @fields,
 'growing location'  =  join @fields
}
push @cities, $growing_location;
}

Okay, I don't know whether these really indicate growing locations, but I am
assuming sanity here--that there is some articulable meaning to the
juxtaposition.  The identifiers in the code should communicate that meaning..
Otherwise you are throwing information away, the antithesis of the
programmer's purpose.  Besides, clearly named variables are much easier to
debug.

Joseph




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




Undefined symbol?

2004-01-23 Thread Mark Setzer
Hey there,

Wasn't sure which mailing list to send this to but maybe someone can 
point me in the right direction. When perl is invoked (presumably by 
debian's dpkg command, since that's what causes the error), I  get this 
message:

/usr/bin/perl: relocation error: 
/usr/lib/perl5/auto/Locale/gettext/gettext.so: undefined symbol: 
Perl_Gthr_key_ptr

Didn't know what to make of it or how to fix it. Thoughts?

-Mark

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