The number of elements in an array

2003-01-16 Thread Robert Monical
Hello,

I'm away from my Perl book and hope one of you will help me.

Would somebody please remind me how to make this line work

for ($x=0;$x<$#{@amen};$x++){

right now, the loop only executes once.

TIA


Robert Monical
[EMAIL PROTECTED] (mailing list stuff)
[EMAIL PROTECTED] (everything else)
www.restek.com


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




Re: The number of elements in an array

2003-01-16 Thread Victor Tsang
for ($x=0; $x < scalar(@amen); $x++)


Tor.

Robert Monical wrote:
> 
> Hello,
> 
> I'm away from my Perl book and hope one of you will help me.
> 
> Would somebody please remind me how to make this line work
> 
>  for ($x=0;$x<$#{@amen};$x++){
> 
> right now, the loop only executes once.
> 
> TIA
> 
> Robert Monical
> [EMAIL PROTECTED] (mailing list stuff)
> [EMAIL PROTECTED] (everything else)
> www.restek.com
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]

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




Re: The number of elements in an array

2003-01-16 Thread John W. Krahn
Robert Monical wrote:
> 
> Hello,

Hello,

> I'm away from my Perl book and hope one of you will help me.
> 
> Would somebody please remind me how to make this line work
> 
>  for ($x=0;$x<$#{@amen};$x++){
> 
> right now, the loop only executes once.

An array in scalar context return the number of elements in the array so
you probably want:

  for ( my $x = 0; $x < @amen; $x++ ) {

Or the more Perlish way:

  for my $x ( 0 .. $#amen ) {



John
-- 
use Perl;
program
fulfillment

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




JavaScript/Perl Genius Sought

2003-01-16 Thread Maurice O'Prey
All

I have to admit defeat on this one and will gladly acknowledge anyone who
solves it as a genius! The Perl script below is part of an application which
can be tested at

http://www.demo.wizz400.com/scripts/cgi-bin/wizz400/wizz400sop.pl

You can login with a user ID of Wizz400 and a password of Wizz400

Type 'br' in the search field and select customer British Gas. Type a
customer order number and press ENTER. Select Maxim Trade and then click OK.

Right heres the problem. I have tried to map function keys (yes those old
fashioned things) to the buttons (because the user doesn't want to have to
reach for the mouse) and in the main these work. However when you type an
order quantity and press F6 the order lines are duplicated, I believe the
page is being submitted twice. Clicking on 'Add to order' works fine.

This is just a demo application (and my Perl is not brilliant) so you can do
no damage, though please don't hack it. Note it may only be available
between 09:00 and 18:00 hours GMT.

Also note I have no idea what will happen when lots of people (all using the
same user ID) access the system. It will probably melt the server and
produce some very odd results (please let me know if you encounter these).

Many thanks, I just need to solve the F6 problem. Sorry the post is such a
size.

Regards

Maurice

<-- source for script follows



#  Wizz_sop-030.plCustomer Order Entry
#


sub wizz_sop_030 {

  # parameters passed to this subroutine
  $ORUSR = "$_[0]"; # user id
  $OCLID = "$_[1]"; # prefered customer language
  $ORCTL = "$_[2]"; # catalogue
  $ORCUS = "$_[3]"; # customer number
  $ORCNM = "$_[4]"; # customer name
  $OCUSR = "$_[5]"; # customer user name
  $ORSNO = "$_[6]"; # ship to number
  $ORSNM = "$_[7]"; # ship to name
  $ORBRD = "$_[8]"; # selected brand
  $ORFDS = "$_[9]"; # finish discription
  $ORCOL = "$_[10]"; # colour
  $ORFNS = "$_[11]"; # finish


  # set browser title
  print "";
  print "$browser_title_030";

   # javascript routines
print "";
# javascript arrays
print "var cells = new Array();";
print "var aline = new Array();";
print "var acol  = new Array();";
print "var firstline = 0;";
print "var lastline  = 0;";
print "var maxcell  = 0;";
print "var found = \"no\";";
print "var lr_arrow = \"$function_left_rigth\";";

print "function focus_cells() {";
 print '   cells = "value[0]";';
 print "   last = document.wizz_sop_030.elements.length - 1;";
 print "   found = false;";
 print "   for (i=0; i acol[i]) { i++; }";
 print " if (nline != aline[i]) { i--; } ";
 print " return i;";
 print "  }";
 print "   } ";
 print "   if (direction == 2  &&  cline > firstline) {";
 print "  while (cline == aline[i]) { i--; }";
 print "  savi = i;";
 print "  nline = aline[i];";
 print "  while (ccol != acol[i]  &&  i > 1) { i--; }";
 print "  if (ccol == acol[i]) {";
 print " return i; }";
 print "  else {";
 print " i = savi;";
 print " while (nline == aline[i] && ccol < acol[i]) { i--; }";
 print " if (nline != aline[i]) { i++; } ";
 print " return i;";
 print "  }";
 print "   } ";
 print "   return index;";
print "}";

# javascript for shortcut buttons
print "function sho

Re: JavaScript/Perl Genius Sought

2003-01-16 Thread Rob Dixon
Maurice O'Prey wrote:
> All
>
> I have to admit defeat on this one and will gladly acknowledge anyone
> who solves it as a genius!

Maurice

This isn't really a beginners Perl question, so don't be surprised if
you get an objector or two. However, unrelated to your problem is the
suggestion that you should use 'here documents' as the basis for
outputting the chunks of JavaScript.

print <
$browser_title_030
END

The string 'END' can be any text you like, but must be flush with the
left margin.

At least this will get rid of all those print stetements and quotation
marks and make your JavaScript more readable (and fixable!).

HTH,

Rob




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




Re: JavaScript/Perl Genius Sought

2003-01-16 Thread Rob Dixon
Maurice O'Prey wrote:
> All
>
> I have to admit defeat on this one and will gladly acknowledge anyone
> who solves it as a genius!

Maurice,

OK, here's what I think is happening. You have a  tag (curiously
inside your ) with an onkeydown attibute of shortcut(). You also
have several  tagswith onkeydown attributes of move_cursor($i).
move_cursor() calls shortcut(), so pressing a key in an input field will
execute both the  and  onkeydown actions. shortcut() will
be called twice, and the add_to_order button will be clicked twice by
JavaScript.

My apologies to others for all this nasty HTML and JavaScript stuff in a
Perl group.

Oh, and use 'here documents' like I said. And fix that  tag!

Rob





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




Network Administration and Perl

2003-01-16 Thread squiggle
I use it on a MS network to log logins, report on how much space people are using for 
their home directories and condense the information from 14 servers' daily backup logs 
onto a single html page.


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




floating-point number on the right side with sprintf

2003-01-16 Thread Konrad Foerstner
Hi,

I have a problem with formating my output. I use sprintf to format a
floating-point number. My output with "%.4f" looks like this:

111.5611  
21.4870  
10.7046  
8.8443  
8.6823  

but I would like to see it that way:

111.5611  
 21.4870  
 10.7046  
  8.8443  
  8.6823

So, a kind of combination of "%.4f" and "%-8s" is needed. How can I do this?

Thanks

Konrad



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




Re: Network Administration and Perl

2003-01-16 Thread Bob X

"Paul Kraus" <[EMAIL PROTECTED]> wrote in message
005f01c2bc9f$8cff78d0$64fea8c0@pkrausxp">news:005f01c2bc9f$8cff78d0$64fea8c0@pkrausxp...
> What are some of the ways you guys use Perl for network administration?
>
1. I search an FTP site daily for updated files that I then download and use
to creat other files.

2. I use it to parse large (+30MB) log files for instances of certain words
that are then split out into smaller files.

3. Perl + SQLite makes a great way for me to process info



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




Help for telnet using perl

2003-01-16 Thread shirish doshi
Hi,
   I am a novice in Perl and I want to implement
telnet in perl. If you have any tutorials or source
code available with you , please forward me.
Thanking you in advance,
Regards,
Shirish

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




question on nested if

2003-01-16 Thread Seamus Carr
I'm trying to count first occurrence of a pattern in a block of lines 
which have the same number in first field.  I was using if statements to 
test the conditions.  The problem is that it reads the pattern of every 
line, not skipping rest of the block if the pattern has been matched. 
Putting the block of related lines into an array is impractical due to 
the length of the lines in the file.  I tried nesting an if conditional, 
but it didn't make any difference in skipping the lines in the block.

#!/usr/local/bin/perl -w
use strict;
my $count;
my $control;
$count=0;
while (my $lfile = glob"ZKL*.ARC"){
$lfile =~ /^ZKL(\d+).ARC/;
  open(LFILE, "<$lfile");
   while () {
my $control = substr($_,0,4);
 if ($control < 9000){
   if (m/PATTERN/){
++$count;
  if ($control != substr($_,0,4)){
my $control = substr($_,0,4);
}else{
  next;
 }
  }
   }
 }
   }
}
print "$count\n";

small snippet of file1
230 11  025101219ZZ1735L >all lines continue until 250
1230 11  111601220ALM>characters
1230 11  281201221J K>
1232 11  01221J K>
1232 11  11222J K>



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



Database Issues

2003-01-16 Thread Caroline Warnock
Hi,

I have written a perl program that is supposed to search for a set of
customer details on our database and return them 1 after the other.
The problem is that it is returning the customers as well as cdetail
id, type, checksum. The problem is that is returning the checksum the
same amount of times as the number of the account (ie) account number
2 returns the cdetail, type, checksum line twice - account
number 3 returns the cdetail, type, checksum line 3 times,
and so on.
I don't mind it looking for the cdetail, type, checksum line once but
why is it doing it like this.
I am very new to Perl and have used part of another script to make
this so please excuse my ignorance.
Please see attached mcp6.pl which is my script and test6.xml which
displays the results.

Thanks in advance
McP


mcp6.pl
Description: Perl program




























































































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


IP address

2003-01-16 Thread Muhikanta Nath
Dear Sir,

I am not able to understand about IP/Subnet
Calculation as I amnot understand properly about IP
and Use of IP. I am trying to understand these by
reading books but not able to understand completely.
Pls. give some idea redarding this.

Rgds
Muhi
Assam

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




RE: JavaScript/Perl Genius Sought

2003-01-16 Thread Beau E. Cox
Hi -

> -Original Message-
> From: Maurice O'Prey [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 11:52 PM
> To: [EMAIL PROTECTED]
> Subject: JavaScript/Perl Genius Sought
> 
> 
> All
> 
> I have to admit defeat on this one and will gladly acknowledge anyone who
> solves it as a genius! The Perl script below is part of an 
> application which
> can be tested at
> 
> http://www.demo.wizz400.com/scripts/cgi-bin/wizz400/wizz400sop.pl
> 
> You can login with a user ID of Wizz400 and a password of Wizz400
> ...

I am applying to be a genius :) but the user/password you gave don't
work for me (yes, I observed case-sensitivity)...

Aloha => Beau;


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




RE: floating-point number on the right side with sprintf

2003-01-16 Thread Beau E. Cox
Hi -

> -Original Message-
> From: Konrad Foerstner [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 11:27 AM
> To: [EMAIL PROTECTED]
> Subject: floating-point number on the right side with sprintf
> 
> 
> Hi,
> 
> I have a problem with formating my output. I use sprintf to format a
> floating-point number. My output with "%.4f" looks like this:
> 
> 111.5611  
> 21.4870  
> 10.7046  
> 8.8443  
> 8.6823  
> 
> but I would like to see it that way:
> 
> 111.5611  
>  21.4870  
>  10.7046  
>   8.8443  
>   8.6823
> 
> So, a kind of combination of "%.4f" and "%-8s" is needed. How can 
> I do this?
> 
> Thanks
> 
> Konrad
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

"%8.4f"

Aloha => Beau;


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




RE: Help for telnet using perl

2003-01-16 Thread Beau E. Cox
Hi -

> -Original Message-
> From: shirish doshi [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, January 15, 2003 12:50 PM
> To: [EMAIL PROTECTED]
> Subject: Help for telnet using perl
> 
> 
> Hi,
>I am a novice in Perl and I want to implement
> telnet in perl. If you have any tutorials or source
> code available with you , please forward me.
> Thanking you in advance,
> Regards,
> Shirish
> 

The documentation of the CPAN module Net::Telnet

http://search.cpan.org/author/JROGERS/Net-Telnet-3.03/lib/Net/Telnet.pm

will give you a good start. You probably should use this module
in your code.

Aloha => Beau;

(Watashi no Okksan wa Nihon jin desu!)


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




Weekly list FAQ posting

2003-01-16 Thread casey
NAME
beginners-faq - FAQ for the beginners mailing list

1 -  Administriva
  1.1 - I'm not subscribed - how do I subscribe?

Send mail to <[EMAIL PROTECTED]>

You can also specify your subscription email address by sending email to
(assuming [EMAIL PROTECTED] is your email address):

<[EMAIL PROTECTED]>.

  1.2 -  How do I unsubscribe?

Now, why would you want to do that? Send mail to
<[EMAIL PROTECTED]>, and wait for a response. Once you
reply to the response, you'll be unsubscribed. If that doesn't work,
find the email address which you are subscribed from and send an email
like the following (let's assume your email is [EMAIL PROTECTED]):

<[EMAIL PROTECTED]>

  1.3 - There is too much traffic on this list. Is there a digest?

Yes. To subscribe to the digest version of this list send an email to:

<[EMAIL PROTECTED]>

To unsubscribe from the digest, send an email to:

<[EMAIL PROTECTED]>

This is a high traffic list (100+ messages per day), so please subscribe
in the way which is best for you.

  1.4 - Is there an archive on the web?

Yes, there is. It is located at:

http://archive.develooper.com/beginners%40perl.org/

  1.5 - How can I get this FAQ?

This document will be emailed to the list once a week, and will be
available online in the archives, and at http://learn.perl.org/

  1.6 - I don't see something in the FAQ, how can I make a suggestion?

Send an email to <[EMAIL PROTECTED]> with your suggestion.

  1.7 - Is there a supporting website for this list?

Yes, there is. It is located at:

http://beginners.perl.org/

  1.8 - Who owns this list?  Who do I complain to?

Casey West owns the beginners list. You can contact him at
[EMAIL PROTECTED]

  1.9 - Who currently maintains the FAQ?

Kevin Meltzer, who can be reached at the email address (for FAQ
suggestions only) in question 1.6

  1.10 - Who will maintain peace and flow on the list?

Casey West, Kevin Meltzer and Ask Bjoern Hansen currently carry large,
yet padded, clue-sticks to maintain peace and order on the list. If you
are privately emailed by one of these folks for flaming, being
off-topic, etc... please listen to what they say. If you see a message
sent to the list by one of these people saying that a thread is closed,
do not continue to post to the list on that thread! If you do, you will
not only meet face to face with a XQJ-37 nuclear powered pansexual
roto-plooker, but you may also be taken off of the list. These people
simply want to make sure the list stays topical, and above-all, useful
to Perl beginners.

  1.11 - When was this FAQ last updated?

Sept 07, 2001

2 -  Questions about the 'beginners' list.
  2.1 - What is the list for?

A list for beginning Perl programmers to ask questions in a friendly
atmosphere.

  2.2 - What is this list _not_ for?

* SPAM
* Homework
* Solicitation
* Things that aren't Perl related
* Monkeys
* Monkeys solicitating homework on non-Perl related SPAM.
  2.3 - Are there any rules?

Yes. As with most communities, there are rules. Not many, and ones that
shouldn't need to be mentioned, but they are.

* Be nice
* No flaming
* Have fun
  2.4 - What topics are allowed on this list?

Basically, if it has to do with Perl, then it is allowed. You can ask
CGI, networking, syntax, style, etc... types of questions. If your
question has nothing at all to do with Perl, it will likely be ignored.
If it has anything to do with Perl, it will likely be answered.

  2.5 - I want to help, what should I do?

Subscribe to the list! If you see a question which you can give an
idiomatic and Good answer to, answer away! If you do not know the
answer, wait for someone to answer, and learn a little.

  2.6 - Is there anything I should keep in mind while answering?

We don't want to see 'RTFM'. That isn't very helpful. Instead, guide the
beginner to the place in the FM they should R :)

Please do not quote the documentation unless you have something to add
to it. It is better to direct someone to the documentation so they
hopefully will read documentation above and beyond that which answers
their question. It also helps teach them how to use the documentation.

  2.7 - I don't want to post a question if it is in an FAQ. Where should I
look first?

Look in the FAQ! Get acquainted with the 'perldoc' utility, and use it.
It can save everyone time if you look in the Perl FAQs first, instead of
having a list of people refer you to the Perl FAQs :) You can learn
about 'perldoc' by typing:

"perldoc perldoc"

At your command prompt. You can also view documentation online at:

http://www.perldoc.com and http://www.perl.com

  2.8 Is this a high traffic list?

YES! You have been warned! If you don't want to get ~100 emails per day
from this

Re: question on nested if

2003-01-16 Thread Rob Dixon
Hi Seamus

Seamus Carr wrote:
> I'm trying to count first occurrence of a pattern in a block of lines
> which have the same number in first field.

'Count the first occurrence'? That would be '1' ;-)

> I was using if statements
> to test the conditions.  The problem is that it reads the pattern of
> every line, not skipping rest of the block if the pattern has been
> matched. Putting the block of related lines into an array is
> impractical due to the length of the lines in the file.  I tried
> nesting an if conditional, but it didn't make any difference in
> skipping the lines in the block.

You need a conditional 'last' statement to skip the remaining lines in
the current file.

>
> #!/usr/local/bin/perl -w
> use strict;
> my $count;
> my $control;
> $count=0;
> while (my $lfile = glob"ZKL*.ARC"){
> $lfile =~ /^ZKL(\d+).ARC/;
>open(LFILE, "<$lfile");
> while () {
>  my $control = substr($_,0,4);
>   if ($control < 9000){
> if (m/PATTERN/){
>  ++$count;
>if ($control != substr($_,0,4)){
>  my $control = substr($_,0,4);
>  }else{
>next;
>   }
>}
> }
>   }
> }
> }
> print "$count\n";

Hi Seamus

I got a bit lost amongst all those braces; I suspect you did too! I'm
not exactly sure what your check is supposed to be, but I think you're
counting the number of files which match /ZKL\d+\.ARC/ and which contain
at leaast one line starting with an integer less than 9000 and
containing /PATTERN/? If not, correct me.

Try this:

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

my $count;

foreach (glob "ZKL*.ARC") {

next unless /^ZKL(\d+)\.ARC/;
open LFILE, "< $_" or die "Couldn't open $_: $!";

while () {

/^(\d+)/;
if ($1 < 9000 && m/PATTERN/)
{
++$count;
last;
}
}

close LFILE;
}

print "$count\n";

__END__

HTH,

Rob




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




RE: Perl book

2003-01-16 Thread Meidling, Keith, CTR, OSD-C3I
A great starter book I used was Beginning Perl by Simon Cozens, published by
Wrox. ISBN - 1861003145. I use it as a quick reference as well.

I recommend it highly to anyone learning perl.

-Original Message-
From: Ben Siders [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, January 15, 2003 11:50 AM
To: Dan Muey
Cc: Dylan Boudreau; [EMAIL PROTECTED]
Subject: Re: Perl book


I generally like the O'Reilly Perl books, and I've had good luck with 
them.  I can't use them as my only Perl reference, though.  I don't pick 
up the condescending tone in them that you seem to have, but I 
definately agree that they're overrated.  The Perl books, in general, 
are excellent, but I've seen just as many O'Reilly books on other 
subjects that are horrible.  Like any book, it comes down to the 
author's command of the topic, and the skills of the editor.

About 20 minutes ago, I bumped into the 'eval' function in a context I'd 
never seen it used.  I flipped open Advanced Perl Programming and 
understood it all in a few minutes.  On the other hand, I also saw a use 
of 'unpack' this morning that I didn't understand, and I can't find an 
answer to it in any of my books.  It's probably in one of those books 
somewhere, but it's easier for me to ask a coworker or search on-line 
than to pore through the books.  As with any resource, you have to learn 
when it will and will not be helpful for your situation.

I've never heard of the Black Book series.  Did anybody post the publisher?

Dan Muey wrote:

>It may be 'Perl Black Book' actually, I don't have it with me right now but
I'll get the info and post it later today.
>
>There's a whole series of 'Balck Books' for different programming languages
and stuff.
>
>An excellent reference but also better learning tools because of example
situations for the more obscure and actual code examples instead of the 
>
>funtion_name obscure_arg1,obscure_arg2
>format that O'rielly seems to like.
>
>That translates into :
>"What! You don't know what this means? 
>Are you stupid, you must be if you don't know this!
>Because everybody just loves Orielly, everybody else 
>is smart and you are dumb."
>
>Ok done preaching, I'll post more detailed info when I can.
>
>Thanks for putting up with my rantings everyone. 
>I don't mean to insult any Orielly fans. They are great 
>refernces for stuff you know but bad teachers of new things.
>
>  
>
>>Thanks Dan,
>>Your assessment of the Oreilly books is pretty much in line 
>>with my own. I think they are a great reference if you 
>>already know the material and just need to looks something up 
>>but they are not the most descriptive when used as a learning tool.
>>
>>Is the book you are referring too call "The Black Book of 
>>Perl" or "Perl Black Book"?  I ask because I can't find any 
>>instance of "The Black Book of Perl" when searching 
>>chapters.ca or amazon.com.
>>
>>Is this book a good learning tool or more of a reference?
>>
>>Thanks again,
>>
>>Dylan
>>
>>-Original Message-
>>From: Dan Muey [mailto:[EMAIL PROTECTED]] 
>>Sent: January 15, 2003 12:12 PM
>>To: Dylan Boudreau; [EMAIL PROTECTED]
>>Subject: RE: Perl book
>>
>>
>>
>>I'd say go to the library then and check out some books 
>>( have them get them other libraries if they don't have them 
>>) and when you find one you jive with go buy it.
>>
>>I love 'The Black Book of Perl' and have learned most all 
>>I do from it and I to do a lot of Unix Administration.
>>
>>One reason I didn't jive real great with the O'reilly books 
>>is that the ones I 
>>Had available to me where sort of vague while being 
>>desciptive at the same time Especially with modules. 
>>
>>Example :
>>
>>Page 114 of 'Perl in a Nutshell'
>>
>>It is describing the pack function and does so quite well and 
>>informative like. But if I'd never used pack before I'd have 
>>no idea what it is for. How am I supposed to understand what  
>>'taking a list of values and packing it in a binary 
>>structure' is supposed to mean if I've never come across it before. 
>>
>>There are no examples of situations you might use this or 
>>samples of usage beside at the top
>>
>>It has
>>Pack template, list
>>
>>Then explains what pack does and what template and list are 
>>but how do you know if you are supposed to do
>>
>>pack($template, @list);
>>Or exactly like they have it
>>pack $template, $list;
>>Or both or can I do 
>>Pack abBA, list
>>
>>Or only one character where template is?
>>
>>And I can see that for template I might use any number of 
>>things a,A,b,B, etc and I can even see what they mean a - An 
>>ASCCI string, will be null padded.
>>
>>That's a great reminder if you've used this before and 
>>understand what 'An ASCCI string, will be null padded' means. 
>>What is list, an array or a string? What can it be, a file, 
>>input, what good would you get from using pack?
>>
>>Why not thrown in : 
>>You may want to use pack if you are .
>>
>>And have at least one example
>>$value = "Example Of actual data you might

Apache & WINNT : Thank you note...

2003-01-16 Thread Ben Crane
Hi,

I just wanted to say a HUGE thank you to:

David Kirol
Bob Showalter
Dan Muey

for their combined help in getting perl to work on my
apache server...it was a combination of sorting out
the httpd file and changing the perl path from
#!usr/local/bin/perl to #!c:/perl/bin/perl.exe
(something I didn't know I had to do!) :)

Once again a big thank you!!!

Ben Crane

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




Performance of Net::SNMP

2003-01-16 Thread Wim
Hi all!

I'm some writing scripts using the module Net::SNMP.
Is this module a performant one, or are there faster ones available?
I tried the SNMP module that uses Net_SNMP, but the last version is from 
2000 and I could get it installed...


Thanx!

Wim



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



Re: Escaping Ampersands in XML

2003-01-16 Thread Jenda Krynicky
From: Ben Siders <[EMAIL PROTECTED]>
> I've got a real easy one here (in theory).  I have some XML files that
> were generated by a program, but generated imperfectly.  There's some
> naked ampersands that need to be converted to &.  I need a regexp
> that will detect them and change them.  Sounds easy enough.
> 
> The pattern I want to match is an ampersand that is NOT immediately
> followed by a few characters and then a semicolon.  Any ideas?
> 
> This is the best I've come up with so far.  It should match an
> ampersand whose following characters, up to five, are not semicolons. 
> I don't feel that this is a great solution.  I'm hoping the community
> can think of a better one.
> 
> $line =~ s/\&[^;]{,5}/\&/g;
> 
> I'm hoping that'll match something like:  "Blah data &",
> but NOT match "Blah &".
> 
> I'm not sure if I'm on the right track here.  I also can't match other
> escaped characters such as: "Copyright © 2003".

For something similar I use this (I have it inside a module):

use HTML::Entities;
sub PolishHTML {
my $str = shift;
if ($AllowXHTML) {
$str =~ 
s{(.*?)(&\w+;|&#\d+;|<\w[\w\d]*(?:\s+\w[\w\d]*(?:\s*=\s*(?:[^" 
'><\s]+|(?:'[^']*')+|(?:"[^"]*")+))?)*\s*/?>||$)}
 {HTML::Entities::encode($1, '^\r\n\t !\#\$%\"\'-;=?-
~').$2}gem;
} else {
$str =~ 
s{(.*?)(&\w+;|&#\d+;|<\w[\w\d]*(?:\s+\w[\w\d]*(?:\s*=\s*(?:[^" 
'><\s]+|(?:'[^']*')+|(?:"[^"]*")+))?)*\s*>||$)}
 {HTML::Entities::encode($1, '^\r\n\t !\#\$%\"\'-;=?-
~').$2}gem;
}
return $str;
}

It escapes the &, < and > that doesn't seem to belong to HTML 
entities or tags.
If you would use this over the XML you would want to set the 
$AllowXHTML (or just use the first branch).


If all you want is to process the ampersand you may want something 
like this:

$line =~ s/&(?!\w+;|#\d+;)/&/g;


Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Network Administration and Perl

2003-01-16 Thread Jenda Krynicky
I'm not a network admin now. Currently I use Perl for things like:

Preprocessing and archiving log files, searching for errors and 
unexpected messages them and mailing the result to me for review.

Indexing the files on the production, QA and development servers and 
generating ZIPs with the files that need to be updated.

And of course lots of development related tools like generating 
multilanguage pages, automatic uploading of translations, code 
generation and such. And for some parts of the system we develop.


When I was an admin I had scripts for:

Creation of users (in WinNT, Unix and MSSQL, creation of directories, 
setting up permissions, copying initial content and so forth)

Automatic download and update of data in some programs.

Copying data between those programs databases and our own Oracle.

And a lot small tools like for example one that changed the page size 
in all Word documents from US Letter to A4 (you would not believe how 
hard is it to explain the users we really do NOT have US Letter 
printers. ;-)

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: question on nested if

2003-01-16 Thread John W. Krahn
Seamus Carr wrote:
> 
> I'm trying to count first occurrence of a pattern in a block of lines
> which have the same number in first field.  I was using if statements to
> test the conditions.  The problem is that it reads the pattern of every
> line, not skipping rest of the block if the pattern has been matched.
> Putting the block of related lines into an array is impractical due to
> the length of the lines in the file.  I tried nesting an if conditional,
> but it didn't make any difference in skipping the lines in the block.
> 
> #!/usr/local/bin/perl -w
> use strict;
> my $count;
> my $control;
> $count=0;
> while (my $lfile = glob"ZKL*.ARC"){
> $lfile =~ /^ZKL(\d+).ARC/;
>open(LFILE, "<$lfile");
> while () {
>  my $control = substr($_,0,4);
>   if ($control < 9000){
> if (m/PATTERN/){
>  ++$count;
>if ($control != substr($_,0,4)){
>  my $control = substr($_,0,4);
>  }else{
>next;
>   }
>}
> }
>   }
> }
> }
> print "$count\n";
> 
> small snippet of file1
> 230 11  025101219ZZ1735L >all lines continue until 250
> 1230 11  111601220ALM>characters
> 1230 11  281201221J K>
> 1232 11  01221J K>
> 1232 11  11222J K>

It looks like you are trying to count the number of lines that contain
PATTERN from the beginning of the file to the first line that starts
with 9000.  If so then this will do what you want:

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

my $count;
@ARGV = glob 'ZKL*.ARC';

while ( <> ) {
close ARGV if /^9000/;
$count++ if /PATTERN/;
}

print "$count\n";

__END__



John
-- 
use Perl;
program
fulfillment

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




Script works on one machine not the other?

2003-01-16 Thread Samuelsson, David
I have happily been having a script running to add users into groups.
Suddenly one of the scripts on 1 machine stopped working, while the
other machine, setup like the first machine works, it's the same script
in both, whats altered is the machine name. I even copyed the script
from the machine that works, altered tha few values, and still it gave
me the same error! I am wondering is this machin dependant, or is there
something weird here..

Its kinda big so bare with me..as you can see it's the same routine over
and over again. It works on one machine not the other. And its W2K..i
get this error from the script:

Can't populate local group list: Overlapped I/O operation is in progress

Here is the script..
use strict;
use Win32API::Net;
my
(@users,$user,@lusers,@l,$w,@diffusers,@user,@susers,@slusers,@sdiffuser
s,$suser,@suser,%hash,$fullname,@musers,@mdiffusers);

my $group = "SG-SEKI-SECURITY-SERVER-C-G";
my $dserver = "SEKIDCC01";
my $lserver = "SEKIMSW07";
my $lgroup = "UNLOCK_ACCESS1";
my $sgroup = "SG-SEKI-SECURITY-SERVER2-C-G";
my $lgroup2 = "UNLOCK_ACCESS2";
my $logfile = "c:\\temp\\sec-server.log";
my $mgroup = "SG-GBMC-SECURITY-SERVER-C-G";
my $mailadress = "removed";
if (-e $logfile)
{
unlink $logfile or die "cant delete old $logfile\n";
}
Win32API::Net::GroupGetUsers($dserver, $group, \@users) or die "Can't
get global group list: $^E\n";
Win32API::Net::LocalGroupGetMembers($lserver, $lgroup, \@lusers) or die
"Can't get local group list: $^E\n";
#UserGetInfo(server, user, level, hash)
{
my (%h1, %h2);
@h1{@users} = ();
@h2{@lusers} = ();
for my $key (keys %h1) {
push @diffusers => $key unless exists $h2{$key};
}
}
print "These users differ between groups: @diffusers\n";
foreach $user(@diffusers){
Win32API::Net::UserGetInfo($dserver, $user, 11, \%hash);
$user = "corpusers\\$user\n";
push (@user,$user);
chomp @user;
print "Adding @user to $lserver $lgroup\n";
Win32API::Net::LocalGroupAddMembers($lserver, $lgroup, \@user) or
die "Can't populate local group list: $^E\n";
if (@diffusers)
{
open LOG, ">>$logfile" or die "cant open $logfile\n";
chomp $user;
print LOG "KISTA $user ($hash{fullName}) Added to Security
Server SEKIMSW07 local group UNLOCK_ACCESS1\n";
}
   @user =(); 
}

Win32API::Net::GroupGetUsers($dserver, $sgroup, \@susers) or die "Can't
get global group list: $^E\n";
Win32API::Net::LocalGroupGetMembers($lserver, $lgroup2, \@slusers) or
die "Can't get local group list: $^E\n";
{
my (%h1, %h2);
@h1{@susers} = ();
@h2{@slusers} = ();
for my $key (keys %h1) {
push @sdiffusers => $key unless exists $h2{$key};
}
}
print "These users differ between groups: @sdiffusers\n";

foreach $suser(@sdiffusers){
Win32API::Net::UserGetInfo($dserver, $suser, 11, \%hash);
$suser = "corpusers\\$suser\n";
push (@suser,$suser);
chomp @suser;
print "Adding @suser to $lserver $lgroup2\n";
Win32API::Net::LocalGroupAddMembers($lserver, $lgroup2, \@suser) or
die "Can't populate local group list: $^E\n";
if (@sdiffusers)
{
open LOG, ">>$logfile" or die "cant open $logfile\n";
chomp $suser;
print LOG "KISTA $suser ($hash{fullName}) Added to Security
Server SEKIMSW07 local group UNLOCK_ACCESS2\n";
}
   @suser =(); 
}

Win32API::Net::GroupGetUsers($dserver, $mgroup, \@musers) or die "Can't
get global group list: $^E\n";
Win32API::Net::LocalGroupGetMembers($lserver, $lgroup, \@lusers) or die
"Can't get local group list: $^E\n";
#UserGetInfo(server, user, level, hash)
{
my (%h1, %h2);
@h1{@musers} = ();
@h2{@lusers} = ();
for my $key (keys %h1) {
push @mdiffusers => $key unless exists $h2{$key};
}
}
print "These users differ between groups: @mdiffusers\n";
foreach $user(@mdiffusers){
Win32API::Net::UserGetInfo($dserver, $user, 11, \%hash);
$user = "corpusers\\$user\n";
push (@user,$user);
chomp @user;
print "Adding @user to $lserver $lgroup\n";
Win32API::Net::LocalGroupAddMembers($lserver, $lgroup, \@user) or
die "Can't populate local group list: $^E\n";
if (@diffusers)
{
open LOG, ">>$logfile" or die "cant open $logfile\n";
chomp $user;
print LOG "MANCHESTER $user ($hash{fullName}) Added to Security
Server SEKIMSW07 local group UNLOCK_ACCESS1\n";
}
   @user =(); 
}
close LOG;
if (-e $logfile){
print "sending mail notification..\n";
`blat $logfile -t $mailadress -s \"Users added to Security Server\"`
or die "cannot send mail\n";
}









Spreadsheet::WriteExcel - Unix New line

2003-01-16 Thread Paul Kraus
I wrote a script that generates an excel file. I tested it on a windows
xp pro machine and everything was ok. When I put the script on the UNIX
server and run it I get blocks on my excel sheet where new lines
occurred. How can I have the UNIX Perl write out Microsoft new line
characters so that the excel sheet looks normal?

Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.com


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


Re: Escaping Ampersands in XML

2003-01-16 Thread Ben Siders
Whew!  That's the same one I finally came up with.  Glad to see I was on 
the right track.  The original solution didn't work at all.

Toby Stuart wrote:

 

-Original Message-
From: Ben Siders [mailto:[EMAIL PROTECTED]]
Sent: Thursday, January 16, 2003 7:38 AM
To: Perl
Subject: Escaping Ampersands in XML


I've got a real easy one here (in theory).  I have some XML 
files that 
were generated by a program, but generated imperfectly.  There's some 
naked ampersands that need to be converted to &.  I need a regexp 
that will detect them and change them.  Sounds easy enough.

The pattern I want to match is an ampersand that is NOT immediately 
followed by a few characters and then a semicolon.  Any ideas?

This is the best I've come up with so far.  It should match 
an ampersand 
whose following characters, up to five, are not semicolons.  I don't 
feel that this is a great solution.  I'm hoping the community 
can think 
of a better one.

$line =~ s/\&[^;]{,5}/\&/g;
   


Try this one:

 s/&(?!\w+;)/&/g



 

I'm hoping that'll match something like:  "Blah data 
&", but 
NOT match "Blah &".

I'm not sure if I'm on the right track here.  I also can't 
match other 
escaped characters such as: "Copyright © 2003".



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

   



 




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




baffling script behavior- root loses files

2003-01-16 Thread zentara
Hi,
I'm just stumped by this one. It all started when I was trying to work
out a backup method of backing up all subdirs of /home/user as
individual tarballs. So I wanted to copy everything from the user's
top level directory to a temporary backup directory. This included
all hidden file, hidden directories, and plain files in /home/user.

Well, I did some testing as myself, and all seemed to be going well,
then I moved the script to /, and see what happens when root
ran it. Things went wrong, root runs the same file from /, and it
misses plain files like /home/user/sig.

I made a little test case to demonstrate the problem.
The following script is run by root in /home/user:
/home/zentara/backup-homex
---
#!/usr/bin/perl -w

@users=('/home/zentara');

#put all user-root hidden files and hidden dirs into 1 temp dir
#this makes it easier to backup second level subdirs
foreach $homedir(@users){
opendir DIR, $homedir or warn "Cannot readdir $homedir:$!\n";
@files = grep !/^\.\.?$/, readdir DIR;
foreach (@files){push @movem,$_ if -f}
foreach (@files){push @movem,$_ if ($_ =~ m!^[.]!)}
print "@movem\n";
print "##\n";
}
exit;


When the above script is run as user or as root in /home/zentara
the output is good:

x z z1 zz sig sig1 sig2 sigs wxyz .Xmodmap sig.perl .bashrc .fvwm2rc
.bash_history backup-homex .Xdefaults .Xauthority .profile .Xresources
dontfeedtrolls .xinitrc wxyz-root .kc .le .mc .qt .ddd .kde .pan .pfm
.ssh .netscape .designer .babygimp .gftp .gimv .fvwm .java .kde2 .sane
.skel .ssh2 .vifm .wine .xmms .Xmodmap .tkalbum .bashrc .gnome2_private
.tkphone .dosemu .mozilla .gconfd .gnome2 .gphoto .gqview .glabels
.gkrellm .fvwm2rc .acrobat .gnucash .gimp-1.2 .pgaccess .regexp
.ptknotes .nautilus .bash_history .mhwaveedit .glameswap .autozen
.kalyptus .antiword .Xdefaults .gnome-desktop .Xauthority .profile
.jpi_cache .gnome_private .Xresources .xinitrc .pornview .adobe .cedit
.dillo .gconf .foxrc .gnome .gnupg .gtklp .links .tkfax .sweep
.cddbslave .roadmap .rolodex .sylpheed .TinyCA .emacs.d .wine.bak
##

-
when the above script is run by root from /, the output misses some
plain files, notably sig, but many are missing, seemingly random:

wxyz backup-homex .kc .le .mc .qt .ddd .kde .pan .pfm .ssh .netscape
.designer .babygimp .gftp .gimv .fvwm .java .kde2 .sane .skel .ssh2
.vifm .wine .xmms .Xmodmap .tkalbum .bashrc .gnome2_private .tkphone
.dosemu .mozilla .gconfd .gnome2 .gphoto .gqview .glabels .gkrellm
.fvwm2rc .acrobat .gnucash .gimp-1.2 .pgaccess .regexp .ptknotes
.nautilus .bash_history .mhwaveedit .glameswap .autozen .kalyptus
.antiword .Xdefaults .gnome-desktop .Xauthority .profile .jpi_cache
.gnome_private .Xresources .xinitrc .pornview .adobe .cedit .dillo
.gconf .foxrc .gnome .gnupg .gtklp .links .tkfax .sweep .cddbslave
.roadmap .rolodex .sylpheed .TinyCA .emacs.d .wine.bak
##


Can someone shed some light on why this happens? It has
something to do with running it from /.

Thanks.



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




Request for a CPAN Module

2003-01-16 Thread Ben Siders
Are there any CPAN modules that can analyze XML or HTML and report any 
cases of unclosed tags?  For example:


   Hello, world
   Me
   Hey, is thing thing on?


In the above, I'd like to find a method of detecting that the bold tag 
is missing a  closer.



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



RE: Spreadsheet::WriteExcel - Unix New line

2003-01-16 Thread Dan Muey
I think unix uses \n and winders uses \n\r so you may need to use \n\r or \r instead 
of \n

Or someother  line ending \f or??

Dan

> -Original Message-
> From: Paul Kraus [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 16, 2003 7:45 AM
> To: Perl
> Subject: Spreadsheet::WriteExcel - Unix New line
> 
> 
> I wrote a script that generates an excel file. I tested it on 
> a windows xp pro machine and everything was ok. When I put 
> the script on the UNIX server and run it I get blocks on my 
> excel sheet where new lines occurred. How can I have the UNIX 
> Perl write out Microsoft new line characters so that the 
> excel sheet looks normal?
> 
> Paul Kraus
> Network Administrator
> PEL Supply Company
> 216.267.5775 Voice
> 216-267-6176 Fax
> www.pelsupply.com
> 
> 

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




RE: JavaScript/Perl Genius Sought

2003-01-16 Thread Dan Muey

> > All
> > 
> > I have to admit defeat on this one and will gladly 
> acknowledge anyone 
> > who solves it as a genius! The Perl script below is part of an 
> > application which can be tested at
> > 
> > http://www.demo.wizz400.com/scripts/cgi-bin/wizz400/wizz400sop.pl
> > 
> > You can login with a user ID of Wizz400 and a password of 
> Wizz400 ...

I also am applying for genius, looks good on resume! 
Actually it's wizz400 and wizz400 lowercase 'W'
I logged in fine but am not quite sure what the problem is.
Could you elaborate what your'e trying to figure out? 
May be I missed an earlier post about it.

> 
> I am applying to be a genius :) but the user/password you 
> gave don't work for me (yes, I observed case-sensitivity)...
> 
> Aloha => Beau;
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: Database Issues

2003-01-16 Thread Dan Muey

> Hi,
Howdy
> 
> I have written a perl program that is supposed to search for 
> a set of customer details on our database and return them 1 
> after the other. The problem is that it is returning the 
> customers as well as cdetail id, type, checksum. The problem 
> is that is returning the checksum the same amount of times as 
> the number of the account (ie) account number 2 
> returns the cdetail, type, checksum line twice - account 
> number 3 returns the cdetail, type, checksum line 3 
> times, and so on. I don't mind it looking for the cdetail, 
> type, checksum line once but why is it doing it like this. I

If by 'this' you mean returning the checksum line more than once 
it's because you tell it to do that inside a loop. So it will do it 
Everytime the loop runs.

> am very new to Perl and have used part of another script to 
> make this so please excuse my ignorance. Please see attached 
> mcp6.pl which is my script and test6.xml which displays the results.
> 
> Thanks in advance
> McP
> 

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




RE: JavaScript/Perl Genius Sought

2003-01-16 Thread Maurice O'Prey
Dan et all

>I also am applying for genius, looks good on resume!
>Actually it's wizz400 and wizz400 lowercase 'W'
>I logged in fine but am not quite sure what the problem is.
>Could you elaborate what your'e trying to figure out?
>May be I missed an earlier post about it


The problem has been resolved now, it would seem that Rob Dixon is the
Genius (the fastest one at least).

Have a poke around if you want to, but as I say it now works.

Thanks to all for their help.

Regards

Maurice




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




RE: JavaScript/Perl Genius Sought

2003-01-16 Thread Dan Muey
> Dan et all
> 
> >I also am applying for genius, looks good on resume!
> >Actually it's wizz400 and wizz400 lowercase 'W'
> >I logged in fine but am not quite sure what the problem is. 
> Could you 
> >elaborate what your'e trying to figure out? May be I missed 
> an earlier 
> >post about it
> 
> 
> The problem has been resolved now, it would seem that Rob 
> Dixon is the Genius (the fastest one at least).

Darn it Rob, I wanted to be genius! :) Cool glad it worked out. 
I eventually found the original post, so glad all is well.

> 
> Have a poke around if you want to, but as I say it now works.
> 
> Thanks to all for their help.
> 
> Regards
> 
> Maurice
> 
> 
> 
> 

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




Re: The number of elements in an array

2003-01-16 Thread Robert Monical
At 01:12 AM 1/16/2003 -0800, you wrote:

Robert Monical wrote:
>
> Hello,

Hello,

> I'm away from my Perl book and hope one of you will help me.
>
> Would somebody please remind me how to make this line work
>
>  for ($x=0;$x<$#{@amen};$x++){
>
> right now, the loop only executes once.

An array in scalar context return the number of elements in the array so
you probably want:

  for ( my $x = 0; $x < @amen; $x++ ) {

Or the more Perlish way:

  for my $x ( 0 .. $#amen ) {

Thanks, both constructs worked perfectly.
My instinct was to try

for my $x ( 0 .. $#amen -1) {

for the second construct. As seems to be
typical with Perl, my instinct was wrong


Robert Monical
[EMAIL PROTECTED] (mailing list stuff)
[EMAIL PROTECTED] (everything else)
www.restek.com


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




Re: JavaScript/Perl Genius Sought

2003-01-16 Thread Rob Dixon
Dan Muey wrote:
>> Dan et all
>>
>>> I also am applying for genius, looks good on resume!
>>> Actually it's wizz400 and wizz400 lowercase 'W'
>>> I logged in fine but am not quite sure what the problem is. Could
>>> you elaborate what your'e trying to figure out? May be I missed an
>>> earlier post about it
>>
>>
>> The problem has been resolved now, it would seem that Rob
>> Dixon is the Genius (the fastest one at least).
>
> Darn it Rob, I wanted to be genius! :) Cool glad it worked out.
> I eventually found the original post, so glad all is well.
>

Beau gets the hat tomorrow. It's yours on Monday. :-)

Rob




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




DBI->prepare problem w/ trace

2003-01-16 Thread Dan Muey
Howdy group,

I've also posted this message with the dbi mailing list but so far nothing from them...

I have a script that does several queries and I have trouble with one :

I can't seem to get a particular query to prepare().

$queryqq = "SELECT * FROM $root_table WHERE ID=\'$Root_ID_DB\'";   
Print 1;
print $queryqq; 
DBI->trace(2,"trace.txt");
($tmp = $queryqq) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", ord $1/ge;print "DEBUG : 
NON PRINT ACHAR -$tmp-  \n"; 
# Shows us any unprintable character
my $sthqq = $dbhqq->prepare($queryqq)  or die $dbhqq->errstr; 
print 2;


outputs ::  
1SELECT * FROM root WHERE ID='5'DEBUG : NON PRINT ACHAR -SELECT * FROM root WHERE 
ID='5'- No unprintable charcters 

( I had that happen before, I couldn't see it but to mysql 
it was a period which made the query bad ) Never gets to 'print 2' I can run the 
generated query 

mysql>SELECT * FROM root WHERE ID='5';
in the mysql shell and get the right record back
Couldn't make to much sense from trace()

I can't run this script with -w currently and I have many other queries that go 
through fine with the same set up. Can't seem to see what's happening. The mysql user 
has all but grant privileges on this database and table.

trace.txt ::

DBI 1.21-nothread dispatch trace level set to 2
Note: perl is running without the recommended perl -w option
-> DESTROY for DBD::mysql::st (DBI::st=HASH(0x82315ec)~INNER)
<- DESTROY= undef
-> DESTROY for DBD::mysql::st (DBI::st=HASH(0x82317cc)~INNER)
<- DESTROY= undef
-- DBI::END
-> disconnect_all for DBD::mysql::dr (DBI::dr=HASH(0x80eb5d4)~0x822a8cc)
<- disconnect_all= '' at DBI.pm line 533
-> DESTROY for DBD::mysql::st (DBI::st=HASH(0x805b360)~INNER)
<- DESTROY= undef during global destruction
-> DESTROY for DBD::mysql::st (DBI::st=HASH(0x82315b0)~INNER)
<- DESTROY= undef during global destruction
-> DESTROY for DBD::mysql::db (DBI::db=HASH(0x822a9bc)~INNER)
imp_dbh->svsock: 8228644
<- DESTROY= undef during global destruction
-> DESTROY in DBD::_::common for DBD::mysql::dr (DBI::dr=HASH(0x822a8cc)~INNER)
<- DESTROY= undef during global destruction
DBI 1.21-nothread dispatch trace level set to 1
Note: perl is running without the recommended perl -w option
<- DESTROY= undef
<- DESTROY= undef
<- disconnect_all= '' at DBI.pm line 533
<- DESTROY= undef during global destruction
<- DESTROY= undef during global destruction
<- DESTROY= undef during global destruction
<- DESTROY= undef during global destruction

Any assistance is very appreciated!!Thanks!

I don't use the $dbhqq and $sthqq or $queryqq anywhere else in the script!
The only other factor is that I can get this to work ok if I comment 
out an eval earlier in the script.
But even with the eval every other query goes through just fine.

Dan

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




Hashes and memory consumption

2003-01-16 Thread Schoenwaelder Oliver
Hi list members,

I have some problems with a script using hashes.
I use hashes for years but never had this kind of problem before...
I have a ascii file with 6.5 MB of data. This file is tokenized by Parse:Lex
module.
The tokens are then stored in a two level hash:
$TokenHash{$TokenType}->{$TokenID}=$TokenValue.
The file contains 536,332 tokens which will lead to 79 keys for %TokenHash.
I'm evaluating the hash with two loops, one for each level.
Due to that I need to move back and forth through the _sorted_ hash while
being in the loop I can't use the built-in procedures like "foreach $key1
(keys %TokenHash)...". So I decided to use Tie::LLHash.
Now I'm amazed by the memory consumption. The script uses up to 300MB for
processing this small file which will lead to a 3.5 MB file at the end. I
developed and tested my script with a 2K subset of the original file and
therefore I haven't encountered the problem during tests.
A simple "if (not exists $TokenHash{$TokenType}->{$TokenID}) {}" uses 110MB
of memory. I encountered this when storing the elements into the hash was
commented out. Just tokenization of the file uses 4M of memory. So in my
opinion it's hash/hash operations related.
In production the files to be processed will be up to several 100MB of size,
so memory usage is really an issue for me.
I also tried with "simple/built-in" hashes just to be sure that the module
isn't the problem. But I got the same strange results. And I tried to use
multi-dimension arrays, but they also use up to 50MB of memory.

Anything I need to consider? Anybody with the same experience?

Perl: 5.6.1
Tie::LLHash: 1.002
Parse::Lex: 2.15

Best regards,

Oliver



Where is the new line coming from.

2003-01-16 Thread Paul Kraus
I am reading in a text file that has input similar to this.
date|data|data|data\n

I then read the file in and using a while loop I chomp off the new line.
while (){
chomp;
@line=split /\|/,$_;
$line[2]=~s/ //g;
print "$_" foreach (@line);
last;
$count++;
last if ($count == 7);
}

Here is the mystery. the output has a newline at the end of it.
It should print 
"data data data data" and then my next prompt should be right here.
instead it prints 
"data data data data
"and my prompt is here.

If I remove the initial chomp then I get a double space at the end.

No matter what I print the last element gets a new line ?

Example if I
print "$line[0] $line[1]";
then right at the end of the print statement is a new line and the
output is identical to what I previously described.
the last elements always inherits a new line. It driving me crazy!!!
thanks in advance :)


Paul Kraus
Network Administrator
PEL Supply Company
216.267.5775 Voice
216-267-6176 Fax
www.pelsupply.com


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




RE: Request for a CPAN Module

2003-01-16 Thread Beau E. Cox
Hi -

> -Original Message-
> From: Ben Siders [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 16, 2003 4:38 AM
> To: Perl
> Subject: Request for a CPAN Module
> 
> 
> Are there any CPAN modules that can analyze XML or HTML and report any 
> cases of unclosed tags?  For example:
> 
> 
> Hello, world
> Me
> Hey, is thing thing on?
> 
> 
> In the above, I'd like to find a method of detecting that the bold tag 
> is missing a  closer.
> 

For HTML I use HTML::Lint from CPAN; look there
for a corresponding XML module.

Aloha => Beau.



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




Re: Escaping Ampersands in XML

2003-01-16 Thread Jenda Krynicky
> Toby Stuart wrote:
> >Try this one:
> >
> >  s/&(?!\w+;)/&/g

Problem is that this will break things like
@

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Catching unknown socket (or unknown handle / filehandle)

2003-01-16 Thread Admin-Stress
Hi,

In this example, to 'catch' if the socket could not be created, by using -> or die 
"";

#!/usr/bin/perl -w
use IO::Socket;
$remote = IO::Socket::INET->new(
Proto=> "tcp",
PeerAddr => "localhost",
PeerPort => "daytime(13)",
)
  or die "cannot connect to daytime port at localhost";

How can I use 'if' statement?
So I can handle the exception better.

$remote = IO::Socket::INET->new(
Proto=> "tcp",
PeerAddr => "localhost",
PeerPort => "daytime(13)",
);

if (...) {
   cleanup();
   print "socket error";
   exit(0);
}

I dont know how to check if a handle has not ben created. Anyone can explain to me?

Thanks,
pot

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




httpd and SVG?

2003-01-16 Thread Ben Crane
Hi list,

Whenever I load an SVG document into my apache browser
it prints the contents of the XML. I'm presuming that
apache doesn't come equiped to deal with SVG?

Do I need a special module to install? Or can I modify
the httpd file to deal with SVG types (in a sense,
switch it on?)
e.g.: AddType application/x-httpd-svg .svg -> but if
this needs a special module which may not be present I
suppose it's useless? 

Ben 


__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




RE: Where is the new line coming from.

2003-01-16 Thread Dan Muey
> I am reading in a text file that has input similar to this.
> date|data|data|data\n
> 
> I then read the file in and using a while loop I chomp off 
> the new line. while (){
> chomp;
> @line=split /\|/,$_;
> $line[2]=~s/ //g;

Do you mean $line[3] since that is the last one in the array in the example above?
date1|data2|data3|data4\n would become
0 data1
1 data2
2 data3
3 data4\n
If so remove any newlines and space also :
$line[3] =~ s/\n|\r| //g;
Or use '\s' instead of ' ' for the space.

Dan
> print "$_" foreach (@line);
> last;
> $count++;
> last if ($count == 7);
> }
> 
> Here is the mystery. the output has a newline at the end of 
> it. It should print 
> "data data data data" and then my next prompt should be right 
> here. instead it prints 
> "data data data data
> "and my prompt is here.
> 
> If I remove the initial chomp then I get a double space at the end.
> 
> No matter what I print the last element gets a new line ?
> 
> Example if I
>   print "$line[0] $line[1]";
> then right at the end of the print statement is a new line 
> and the output is identical to what I previously described. 
> the last elements always inherits a new line. It driving me 
> crazy!!! thanks in advance :)
>   
> 
> Paul Kraus
> Network Administrator
> PEL Supply Company
> 216.267.5775 Voice
> 216-267-6176 Fax
> www.pelsupply.com
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: Escaping Ampersands in XML

2003-01-16 Thread Rob Dixon
Jenda Krynicky wrote:
>> Toby Stuart wrote:
>>> Try this one:
>>>
>>>  s/&(?!\w+;)/&/g
>
> Problem is that this will break things like
> @
>

Why not just:

s/&(?!amp;)/&/g

i.e. change every ampersand that isn't followed by 'amp;' into &

Rob





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




RE: Where is the new line coming from.

2003-01-16 Thread Paul Kraus
any of the array elements when printed act as if they have a new line.
So it would be the last array element printed. In the case it could be 3
but it could also be 2 or 4.

> -Original Message-
> From: Dan Muey [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 16, 2003 10:49 AM
> To: Paul Kraus; Perl
> Subject: RE: Where is the new line coming from.
> 
> 
> > I am reading in a text file that has input similar to this.
> > date|data|data|data\n
> > 
> > I then read the file in and using a while loop I chomp off
> > the new line. while (){
> > chomp;
> > @line=split /\|/,$_;
> > $line[2]=~s/ //g;
> 
> Do you mean $line[3] since that is the last one in the array 
> in the example above?
> date1|data2|data3|data4\n would become
> 0 data1
> 1 data2
> 2 data3
> 3 data4\n
> If so remove any newlines and space also :
> $line[3] =~ s/\n|\r| //g;
> Or use '\s' instead of ' ' for the space.
> 
> Dan
> > print "$_" foreach (@line);
> > last;
> > $count++;
> > last if ($count == 7);
> > }
> > 
> > Here is the mystery. the output has a newline at the end of
> > it. It should print 
> > "data data data data" and then my next prompt should be right 
> > here. instead it prints 
> > "data data data data
> > "and my prompt is here.
> > 
> > If I remove the initial chomp then I get a double space at the end.
> > 
> > No matter what I print the last element gets a new line ?
> > 
> > Example if I
> > print "$line[0] $line[1]";
> > then right at the end of the print statement is a new line
> > and the output is identical to what I previously described. 
> > the last elements always inherits a new line. It driving me 
> > crazy!!! thanks in advance :)
> > 
> > 
> > Paul Kraus
> > Network Administrator
> > PEL Supply Company
> > 216.267.5775 Voice
> > 216-267-6176 Fax
> > www.pelsupply.com
> > 
> > 
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> > 
> > 
> 


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




Variable source for an array assignment

2003-01-16 Thread Robert Monical
Hello
I'm maintaining a 4 year old mod_perl Web application.

Several months ago, this list helped me to get the following working

I spent a couple of hours last night trying to figure out if
there is a way to do this in a single statement.

$val->{'Ammenities' } is set upstream and is a scalar
if a single item is selected, an array if more than one
is selected.

To re-iterate, this code works. I just want to understand
if there is a better way.

if (ref($val->{'Ammenities'}) eq "ARRAY"){
for ( $keys = 0;$keys<=$#{$val->{Ammenities}};$keys++)  {
   $amen[$keys] = $val->{Ammenities}[$keys];
   }# end for
  } else {
$amen[0] = $val->{Ammenities};
  }# end if

Then we stick @amen in the database

TIA

Robert Monical
[EMAIL PROTECTED] (mailing list stuff)
[EMAIL PROTECTED] (everything else)
www.restek.com


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




RE: Where is the new line coming from.

2003-01-16 Thread Dan Muey
> any of the array elements when printed act as if they have a 
> new line. So it would be the last array element printed. In 
> the case it could be 3 but it could also be 2 or 4.

Then do a froeach loop on each item in the array replacing \n's and \r's and 
spaces( if you want to kill space that is )

That way you can put newlines of whatever kind wherever you want.

> 
> > -Original Message-
> > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 16, 2003 10:49 AM
> > To: Paul Kraus; Perl
> > Subject: RE: Where is the new line coming from.
> > 
> > 
> > > I am reading in a text file that has input similar to this.
> > > date|data|data|data\n
> > > 
> > > I then read the file in and using a while loop I chomp 
> off the new 
> > > line. while (){
> > > chomp;
> > > @line=split /\|/,$_;
> > > $line[2]=~s/ //g;
> > 
> > Do you mean $line[3] since that is the last one in the array
> > in the example above?
> > date1|data2|data3|data4\n would become
> > 0 data1
> > 1 data2
> > 2 data3
> > 3 data4\n
> > If so remove any newlines and space also :
> > $line[3] =~ s/\n|\r| //g;
> > Or use '\s' instead of ' ' for the space.
> > 
> > Dan
> > > print "$_" foreach (@line);
> > > last;
> > > $count++;
> > > last if ($count == 7);
> > > }
> > > 
> > > Here is the mystery. the output has a newline at the end 
> of it. It 
> > > should print "data data data data" and then my next 
> prompt should be 
> > > right here. instead it prints
> > > "data data data data
> > > "and my prompt is here.
> > > 
> > > If I remove the initial chomp then I get a double space 
> at the end.
> > > 
> > > No matter what I print the last element gets a new line ?
> > > 
> > > Example if I
> > >   print "$line[0] $line[1]";
> > > then right at the end of the print statement is a new 
> line and the 
> > > output is identical to what I previously described. the last 
> > > elements always inherits a new line. It driving me 
> crazy!!! thanks 
> > > in advance :)
> > >   
> > > 
> > > Paul Kraus
> > > Network Administrator
> > > PEL Supply Company
> > > 216.267.5775 Voice
> > > 216-267-6176 Fax
> > > www.pelsupply.com
> > > 
> > > 
> > > --
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > > 
> > > 
> > 
> 
> 

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




RE: Catching unknown socket (or unknown handle / filehandle)

2003-01-16 Thread Beau E. Cox
Hi -

> -Original Message-
> From: Admin-Stress [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 16, 2003 5:49 AM
> To: perl
> Subject: Catching unknown socket (or unknown handle / filehandle)
> 
> 
> Hi,
> 
> In this example, to 'catch' if the socket could not be created, 
> by using -> or die "";
> 
> #!/usr/bin/perl -w
> use IO::Socket;
> $remote = IO::Socket::INET->new(
>   Proto=> "tcp",
>   PeerAddr => "localhost",
>   PeerPort => "daytime(13)",
>   )
> or die "cannot connect to daytime port at localhost";
> 
> How can I use 'if' statement?
> So I can handle the exception better.
> 
> $remote = IO::Socket::INET->new(
>   Proto=> "tcp",
>   PeerAddr => "localhost",
>   PeerPort => "daytime(13)",
>   );
> 
> if (...) {
>cleanup();
>print "socket error";
>exit(0);
> }
> 
> I dont know how to check if a handle has not ben created. Anyone 
> can explain to me?
> 
> Thanks,
> pot
> 

Two ways:

'do' statement -

 $remote = IO::Socket::INET->new(
...
)
  or do {..whatever..};

'eval' (block) statement -

 eval {
 $remote = IO::Socket::INET->new(
...
);
 };
 if (!@) {..failed..do whatever..}

Aloha => Beau;



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




RE: Where is the new line coming from.

2003-01-16 Thread Paul Kraus
come to think of it. This "newline" I am getting must be a result of
windows just dropping my prompt to the next line. So I assumed it was
there...
Stupid me. I am used to Linux which does not do this in the shell.

Ok then this brings me full circle.
When I run this program on UNIX it makes an excel spread sheet that has
little square strange characters at the end of every row in the last
cell.
I assumed they where new lines but I have ruled this out as I am not
printing any new lines. Any idea on how to fix this? It works in windows
but not on my sco box.

#!/usr/bin/perl

open IPO,('ipo.txt');
$count=2;
$lineref=['PEL Supply Company - IPO Price List',
  ['Item Code','Description','List','Vendor']];
$addline = sub {$worksheet->write_row($count,0,$lineref)};

#setup excel spread sheet
use Spreadsheet::WriteExcel;
my $workbook = Spreadsheet::WriteExcel->new("ipo.xls");
$worksheet   = $workbook->addworksheet();
$format1  = $workbook->addformat();
$format2  = $workbook->addformat();
$format3  = $workbook->addformat();
$format4  = $workbook->addformat();

#Format 1 (Header Row: Bold, BG Yellow, Bottom Border)
$format1->set_bold();
$format1->set_bg_color('yellow');
$format1->set_bottom();

#Format 2 (List Column Right justified set to currency)
$format2->set_align('right');
$format2->set_num_format(8);

#Format 3 (List Column Header - Bold, Yel BG, Bottom Border, Right
Justified)
$format3->set_bold();
$format3->set_bg_color('yellow');
$format3->set_bottom();
$format3->set_align('right');

#Format 4
$format4->set_bold();
$format4->set_bg_color('yellow');
$format4->set_merge();


#Format Columns
$worksheet->set_column(0,0, 25);
$worksheet->set_column(1,1, 44);
$worksheet->set_column(2,2, 10,$format2);
$worksheet->set_column(3,3, 15);
$worksheet->freeze_panes(2,0);

#Write Header Row
$worksheet->write(0,0,$lineref->[0],$format4);
$worksheet->write_blank(0,1,$format4);
$worksheet->write_blank(0,2,$format4);
$worksheet->write_blank(0,3,$format4);

$worksheet->write(1,0,$lineref->[1]->[0],$format1);# Item Code
$worksheet->write(1,1,$lineref->[1]->[1],$format1);# Item
Description
$worksheet->write(1,2,$lineref->[1]->[2],$format3);# Item List
$worksheet->write(1,3,$lineref->[1]->[3],$format1);# Vendor Code

$lineref = \@line;

while (){
chomp;
@line=split /\|/,$_;
$line[2]=~s/ //g;
&$addline;
$count++;
}


> -Original Message-
> From: Dan Muey [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, January 16, 2003 10:49 AM
> To: Paul Kraus; Perl
> Subject: RE: Where is the new line coming from.
>
>
> > I am reading in a text file that has input similar to this.
> > date|data|data|data\n
> >
> > I then read the file in and using a while loop I chomp off
> > the new line. while (){
> > chomp;
> > @line=split /\|/,$_;
> > $line[2]=~s/ //g;
>
> Do you mean $line[3] since that is the last one in the array
> in the example above?
> date1|data2|data3|data4\n would become
> 0 data1
> 1 data2
> 2 data3
> 3 data4\n
> If so remove any newlines and space also :
> $line[3] =~ s/\n|\r| //g;
> Or use '\s' instead of ' ' for the space.
>
> Dan
> > print "$_" foreach (@line);
> > last;
> > $count++;
> > last if ($count == 7);
> > }
> >
> > Here is the mystery. the output has a newline at the end of
> > it. It should print
> > "data data data data" and then my next prompt should be right
> > here. instead it prints
> > "data data data data
> > "and my prompt is here.
> >
> > If I remove the initial chomp then I get a double space at the end.
> >
> > No matter what I print the last element gets a new line ?
> >
> > Example if I
> > print "$line[0] $line[1]";
> > then right at the end of the print statement is a new line
> > and the output is identical to what I previously described.
> > the last elements always inherits a new line. It driving me
> > crazy!!! thanks in advance :)
> >
> >
> > Paul Kraus
> > Network Administrator
> > PEL Supply Company
> > 216.267.5775 Voice
> > 216-267-6176 Fax
> > www.pelsupply.com
> >
> >
> > --
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
> >
> 


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




RE: httpd and SVG?

2003-01-16 Thread Dan Muey

> Hi list,
> 
> Whenever I load an SVG document into my apache browser
> it prints the contents of the XML. I'm presuming that
> apache doesn't come equiped to deal with SVG?

Is you path to perl /usr/bin/perl ?
What? That has nothing to do with your question? Huh that's odd.

You really need to go to an apache list for that as it's 
not really related to perl at all just as mu sarcastic question isn't
Related to your problem at all. :)

> 
> Do I need a special module to install? Or can I modify
> the httpd file to deal with SVG types (in a sense,
> switch it on?)

I'm sure you'll at least need the AddType but wouldn't be surprised if you needed a 
module too. 
Go to apache.org and look there for documention and apche lists.

> e.g.: AddType application/x-httpd-svg .svg -> but if
> this needs a special module which may not be present I
> suppose it's useless? 
> 
> Ben 
> 
> 
> __
> Do you Yahoo!?
> Yahoo! Mail Plus - Powerful. Affordable. Sign up now. 
http://mailplus.yahoo.com

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


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




RE: Where is the new line coming from.

2003-01-16 Thread Paul Kraus
attached is a copy of the excel file if it helps.

> -Original Message-
> From: Paul Kraus [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 16, 2003 11:03 AM
> To: 'Dan Muey'; 'Perl'
> Subject: RE: Where is the new line coming from.
> 
> 
> come to think of it. This "newline" I am getting must be a 
> result of windows just dropping my prompt to the next line. 
> So I assumed it was there... Stupid me. I am used to Linux 
> which does not do this in the shell.
> 
> Ok then this brings me full circle.
> When I run this program on UNIX it makes an excel spread 
> sheet that has little square strange characters at the end of 
> every row in the last cell. I assumed they where new lines 
> but I have ruled this out as I am not printing any new lines. 
> Any idea on how to fix this? It works in windows but not on 
> my sco box.
> 
> #!/usr/bin/perl
> 
> open IPO,('ipo.txt');
> $count=2;
> $lineref=['PEL Supply Company - IPO Price List',
> ['Item Code','Description','List','Vendor']];
> $addline = sub {$worksheet->write_row($count,0,$lineref)};
> 
> #setup excel spread sheet
> use Spreadsheet::WriteExcel;
> my $workbook = Spreadsheet::WriteExcel->new("ipo.xls");
> $worksheet   = $workbook->addworksheet();
> $format1  = $workbook->addformat();
> $format2  = $workbook->addformat();
> $format3  = $workbook->addformat();
> $format4  = $workbook->addformat();
> 
> #Format 1 (Header Row: Bold, BG Yellow, Bottom Border) 
> $format1->set_bold(); $format1->set_bg_color('yellow'); 
> $format1->set_bottom();
> 
> #Format 2 (List Column Right justified set to currency) 
> $format2->set_align('right'); $format2->set_num_format(8);
> 
> #Format 3 (List Column Header - Bold, Yel BG, Bottom Border, 
> Right Justified) $format3->set_bold(); 
> $format3->set_bg_color('yellow'); $format3->set_bottom(); 
> $format3->set_align('right');
> 
> #Format 4
> $format4->set_bold();
> $format4->set_bg_color('yellow');
> $format4->set_merge();
> 
> 
> #Format Columns
> $worksheet->set_column(0,0, 25);
> $worksheet->set_column(1,1, 44);
> $worksheet->set_column(2,2, 10,$format2); 
> $worksheet->set_column(3,3, 15); $worksheet->freeze_panes(2,0);
> 
> #Write Header Row $worksheet->write(0,0,$lineref->[0],$format4);
> $worksheet->write_blank(0,1,$format4);
> $worksheet->write_blank(0,2,$format4);
> $worksheet->write_blank(0,3,$format4);
> 
> $worksheet->write(1,0,$lineref->[1]->[0],$format1);# Item Code
> $worksheet->write(1,1,$lineref->[1]->[1],$format1);# Item 
> Description
> $worksheet->write(1,2,$lineref->[1]->[2],$format3);# Item List
> $worksheet->write(1,3,$lineref->[1]->[3],$format1);# Vendor Code
> 
> $lineref = \@line;
> 
> while (){
> chomp;
> @line=split /\|/,$_;
> $line[2]=~s/ //g;
> &$addline;
> $count++;
> }
> 
> 
> > -Original Message-
> > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 16, 2003 10:49 AM
> > To: Paul Kraus; Perl
> > Subject: RE: Where is the new line coming from.
> >
> >
> > > I am reading in a text file that has input similar to this.
> > > date|data|data|data\n
> > >
> > > I then read the file in and using a while loop I chomp 
> off the new 
> > > line. while (){
> > > chomp;
> > > @line=split /\|/,$_;
> > > $line[2]=~s/ //g;
> >
> > Do you mean $line[3] since that is the last one in the array in the 
> > example above?
> > date1|data2|data3|data4\n would become
> > 0 data1
> > 1 data2
> > 2 data3
> > 3 data4\n
> > If so remove any newlines and space also :
> > $line[3] =~ s/\n|\r| //g;
> > Or use '\s' instead of ' ' for the space.
> >
> > Dan
> > > print "$_" foreach (@line);
> > > last;
> > > $count++;
> > > last if ($count == 7);
> > > }
> > >
> > > Here is the mystery. the output has a newline at the end 
> of it. It 
> > > should print "data data data data" and then my next 
> prompt should be 
> > > right here. instead it prints
> > > "data data data data
> > > "and my prompt is here.
> > >
> > > If I remove the initial chomp then I get a double space 
> at the end.
> > >
> > > No matter what I print the last element gets a new line ?
> > >
> > > Example if I
> > > print "$line[0] $line[1]";
> > > then right at the end of the print statement is a new 
> line and the 
> > > output is identical to what I previously described. the last 
> > > elements always inherits a new line. It driving me 
> crazy!!! thanks 
> > > in advance :)
> > >
> > >
> > > Paul Kraus
> > > Network Administrator
> > > PEL Supply Company
> > > 216.267.5775 Voice
> > > 216-267-6176 Fax
> > > www.pelsupply.com
> > >
> > >
> > > --
> > > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > > For additional commands, e-mail: [EMAIL PROTECTED]
> > >
> > >
> > 
> 



ipo.xls
Description: MS-Excel spreadsheet
-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


RE: DBI->prepare problem w/ trace

2003-01-16 Thread Dan Muey
Just FYI
Here's the entire code surrounding it from db connection to disconnect :

my $dbhqq = DBI->connect("DBI:mysql:$db_use:$db_host","$db_user","$db_pass");

  $queryqq = "SELECT * FROM $root_table WHERE ID=\'$Root_ID_DB\'";

print $queryqq;
#DBI->trace(1,"trace.txt");
($tmp = $queryqq) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", ord $1/ge;print "DEBUG : 
NON PRINT ACHAR -$tmp-  \n";
my $sthqq = $dbhqq->prepare($queryqq) || print $dbhqq->errstr;
  
print 2;
$sthqq->execute or die "Can not execute $queryqq :" . $dbhqq->errstr . "\n";
print 3;
my $row;
@tmp_row_a = $sthqq->fetchrow_array;

  foreach $x(@disp_nums_2) {
$rel_table_label .= " $tmp_row_a[$x]";
}
  $sthqq->finish; 
  $dbhqq->disconnect;

Again, $dbhqq, $sthqq, $qyeryqq are not used anywhere else in the script.
The eval mentioned below only evals a print statement to make sure it's correct and 
doesn't kill everythign if it is bad
And the print statement gets printed just dandy. It does some other stuff it has to do 
the get s to the code above and dies.

Thanks
> Howdy group,
> 
> I've also posted this message with the dbi mailing list but 
> so far nothing from them...
> 
> I have a script that does several queries and I have trouble 
> with one :
> 
> I can't seem to get a particular query to prepare().
> 
> $queryqq = "SELECT * FROM $root_table WHERE ID=\'$Root_ID_DB\'";   
> Print 1;
> print $queryqq; 
> DBI->trace(2,"trace.txt");
> ($tmp = $queryqq) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", 
> ord $1/ge;print "DEBUG : NON PRINT ACHAR -$tmp-  \n"; 
> # Shows us any unprintable character
> my $sthqq = $dbhqq->prepare($queryqq)  or die $dbhqq->errstr; 
> print 2;
> 
> 
> outputs ::  
> 1SELECT * FROM root WHERE ID='5'DEBUG : NON PRINT ACHAR 
> -SELECT * FROM root WHERE ID='5'- No unprintable charcters 
> 
> ( I had that happen before, I couldn't see it but to mysql 
> it was a period which made the query bad ) Never gets to 
> 'print 2' I can run the generated query 
> 
> mysql>SELECT * FROM root WHERE ID='5';
> in the mysql shell and get the right record back
> Couldn't make to much sense from trace()
> 
> I can't run this script with -w currently and I have many 
> other queries that go through fine with the same set up. 
> Can't seem to see what's happening. The mysql user has all 
> but grant privileges on this database and table.
> 
> trace.txt ::
> 
> DBI 1.21-nothread dispatch trace level set to 2
> Note: perl is running without the recommended perl -w option
> -> DESTROY for DBD::mysql::st (DBI::st=HASH(0x82315ec)~INNER)
> <- DESTROY= undef
> -> DESTROY for DBD::mysql::st (DBI::st=HASH(0x82317cc)~INNER)
> <- DESTROY= undef
> -- DBI::END
> -> disconnect_all for DBD::mysql::dr 
> (DBI::dr=HASH(0x80eb5d4)~0x822a8cc)
> <- disconnect_all= '' at DBI.pm line 533
> -> DESTROY for DBD::mysql::st (DBI::st=HASH(0x805b360)~INNER)
> <- DESTROY= undef during global destruction
> -> DESTROY for DBD::mysql::st (DBI::st=HASH(0x82315b0)~INNER)
> <- DESTROY= undef during global destruction
> -> DESTROY for DBD::mysql::db (DBI::db=HASH(0x822a9bc)~INNER)
> imp_dbh->svsock: 8228644
> <- DESTROY= undef during global destruction
> -> DESTROY in DBD::_::common for DBD::mysql::dr 
> (DBI::dr=HASH(0x822a8cc)~INNER)
> <- DESTROY= undef during global destruction
> DBI 1.21-nothread dispatch trace level set to 1
> Note: perl is running without the recommended perl -w option
> <- DESTROY= undef
> <- DESTROY= undef
> <- disconnect_all= '' at DBI.pm line 533
> <- DESTROY= undef during global destruction
> <- DESTROY= undef during global destruction
> <- DESTROY= undef during global destruction
> <- DESTROY= undef during global destruction
> 
> Any assistance is very appreciated!!Thanks!
> 
> I don't use the $dbhqq and $sthqq or $queryqq anywhere else 
> in the script! The only other factor is that I can get this 
> to work ok if I comment 
> out an eval earlier in the script.
> But even with the eval every other query goes through just fine.
> 
> Dan
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




Re: Where is the new line coming from.

2003-01-16 Thread Rob Dixon
Paul Kraus wrote:
> attached is a copy of the excel file if it helps.

Paul

You have CRLF at the end of the line. chomp will only remove the LF. Try

s/[[:cntrl:]]$//g;

instead of chomp.

HTH,

Rob




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




searching the database with a sub, getting an error message

2003-01-16 Thread Le Blanc, Kerry (Kerry)
Greetings,
  I have a quick question. In the code below I get an error message that says 'Global 
symbol "@fields" requires explicit package name'
The line that causes the error is highlighted in red. Obviously it has to do with how 
I declared the variable in my subroutine. I tried moving curly brackets and I tried 
other ways of declaring. Could someone please tell me the correct way to do this. The 
perldoc's are still somewhat cryptic to me.
I thought that moving the close(FILE) would help, but it did not.
 

#this is the subroutine to search the file
sub search{
open(FILE, ') {
chomp;  # remove newline
my @fields = split(/\|/, $_);
 
# test whether the search string matches part number
 if ($fields[0] =~ /$PartNumber/ ) {
print "$PartNumber Rev. $Revision has a First Article Report\nWould 
you like to view it?";
 }
 
 
 
 }}
 

my $answer = ;
 
chomp($answer);
 
# If the answer is yes then fill the form with the information
 
if ($answer eq "yes") {
   print "\n\n\none second please..\n";
   print "retrieving file\n";
   print "$fields[0]: $fields[1]: $fields[2]: $fields[3]\n";
 
} 
# If the answer is no then die
   else {
print "ok, well have a nice day.\n";
   }
 
close(FILE);


Kerry LeBlanc 
Materials Auditor 
Process Owner 
75 Perseverence Way 
Hyannis, MA. 02601 
1-508-862-3082 
http://www.vsf.cape.com/~bismark   

 



Re: Escaping Ampersands in XML

2003-01-16 Thread Ben Siders
Because of ©

I don't want that to get changed.  In the end, something like:

s/&(?!\w+|[#\d]+;/&/g

Works.  That might not be quite right, but I think you know what I'm 
getting at.

Rob Dixon wrote:

Jenda Krynicky wrote:
 

Toby Stuart wrote:
 

Try this one:

s/&(?!\w+;)/&/g
   

Problem is that this will break things like
@

   


Why not just:

   s/&(?!amp;)/&/g

i.e. change every ampersand that isn't followed by 'amp;' into &

Rob





 




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




RE: Where is the new line coming from.

2003-01-16 Thread Dan Muey
> attached is a copy of the excel file if it helps.

I see it now. 
It's probably some odd unprintable character.
You could try somehting like this that will change unprintable 
characters to their viewable equivalent 
( ascii, hex?? I can't remember.) 
But I got his form someone a while ago.

($tmp = $line) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", ord $1/ge;
print "DEBUG : NON PRINT ACHAR -$tmp-  \n"; 

So if you run this and get soemthing like :
DEBUG : NON PRINT ACHAR -my sting %n20- then you can look up and see 
what the regex equivalent of %n20 is and kill it all the way to the bank. 

Try that and see.

Dan

> 
> > -Original Message-
> > From: Paul Kraus [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 16, 2003 11:03 AM
> > To: 'Dan Muey'; 'Perl'
> > Subject: RE: Where is the new line coming from.
> > 
> > 
> > come to think of it. This "newline" I am getting must be a
> > result of windows just dropping my prompt to the next line. 
> > So I assumed it was there... Stupid me. I am used to Linux 
> > which does not do this in the shell.
> > 
> > Ok then this brings me full circle.
> > When I run this program on UNIX it makes an excel spread
> > sheet that has little square strange characters at the end of 
> > every row in the last cell. I assumed they where new lines 
> > but I have ruled this out as I am not printing any new lines. 
> > Any idea on how to fix this? It works in windows but not on 
> > my sco box.
> > 
> > #!/usr/bin/perl
> > 
> > open IPO,('ipo.txt');
> > $count=2;
> > $lineref=['PEL Supply Company - IPO Price List',
> >   ['Item Code','Description','List','Vendor']];
> > $addline = sub {$worksheet->write_row($count,0,$lineref)};
> > 
> > #setup excel spread sheet
> > use Spreadsheet::WriteExcel;
> > my $workbook = Spreadsheet::WriteExcel->new("ipo.xls");
> > $worksheet   = $workbook->addworksheet();
> > $format1  = $workbook->addformat();
> > $format2  = $workbook->addformat();
> > $format3  = $workbook->addformat();
> > $format4  = $workbook->addformat();
> > 
> > #Format 1 (Header Row: Bold, BG Yellow, Bottom Border)
> > $format1->set_bold(); $format1->set_bg_color('yellow'); 
> > $format1->set_bottom();
> > 
> > #Format 2 (List Column Right justified set to currency)
> > $format2->set_align('right'); $format2->set_num_format(8);
> > 
> > #Format 3 (List Column Header - Bold, Yel BG, Bottom Border,
> > Right Justified) $format3->set_bold(); 
> > $format3->set_bg_color('yellow'); $format3->set_bottom(); 
> > $format3->set_align('right');
> > 
> > #Format 4
> > $format4->set_bold();
> > $format4->set_bg_color('yellow');
> > $format4->set_merge();
> > 
> > 
> > #Format Columns
> > $worksheet->set_column(0,0, 25);
> > $worksheet->set_column(1,1, 44);
> > $worksheet->set_column(2,2, 10,$format2);
> > $worksheet->set_column(3,3, 15); $worksheet->freeze_panes(2,0);
> > 
> > #Write Header Row $worksheet->write(0,0,$lineref->[0],$format4);
> > $worksheet->write_blank(0,1,$format4);
> > $worksheet->write_blank(0,2,$format4);
> > $worksheet->write_blank(0,3,$format4);
> > 
> > $worksheet->write(1,0,$lineref->[1]->[0],$format1);# Item Code
> > $worksheet->write(1,1,$lineref->[1]->[1],$format1);# Item 
> > Description
> > $worksheet->write(1,2,$lineref->[1]->[2],$format3);# Item List
> > $worksheet->write(1,3,$lineref->[1]->[3],$format1);# Vendor Code
> > 
> > $lineref = \@line;
> > 
> > while (){
> > chomp;
> > @line=split /\|/,$_;
> > $line[2]=~s/ //g;
> > &$addline;
> > $count++;
> > }
> > 
> > 
> > > -Original Message-
> > > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, January 16, 2003 10:49 AM
> > > To: Paul Kraus; Perl
> > > Subject: RE: Where is the new line coming from.
> > >
> > >
> > > > I am reading in a text file that has input similar to this.
> > > > date|data|data|data\n
> > > >
> > > > I then read the file in and using a while loop I chomp
> > off the new
> > > > line. while (){
> > > > chomp;
> > > > @line=split /\|/,$_;
> > > > $line[2]=~s/ //g;
> > >
> > > Do you mean $line[3] since that is the last one in the 
> array in the
> > > example above?
> > > date1|data2|data3|data4\n would become
> > > 0 data1
> > > 1 data2
> > > 2 data3
> > > 3 data4\n
> > > If so remove any newlines and space also :
> > > $line[3] =~ s/\n|\r| //g;
> > > Or use '\s' instead of ' ' for the space.
> > >
> > > Dan
> > > > print "$_" foreach (@line);
> > > > last;
> > > > $count++;
> > > > last if ($count == 7);
> > > > }
> > > >
> > > > Here is the mystery. the output has a newline at the end
> > of it. It
> > > > should print "data data data data" and then my next
> > prompt should be
> > > > right here. instead it prints
> > > > "data data data data
> > > > "and my prompt is here.
> > > >
> > > > If I remove the initial chomp then I get a double space
> > at the end.
> > > >
> > > > No matter what I print the last element gets a new line ?
> > > >
> > > > Example if I
> > > > prin

RE: Catching unknown socket (or unknown handle / filehandle)

2003-01-16 Thread Bob Showalter
Admin-Stress wrote:
> Hi,
> 
> In this example, to 'catch' if the socket could not be
> created, by using -> or die "";
> 
> #!/usr/bin/perl -w
> use IO::Socket;
> $remote = IO::Socket::INET->new(
>   Proto=> "tcp",
>   PeerAddr => "localhost",
>   PeerPort => "daytime(13)",
>   )
> or die "cannot connect to daytime port at localhost";
> 
> How can I use 'if' statement?
> So I can handle the exception better.
> 
> $remote = IO::Socket::INET->new(
>   Proto=> "tcp",
>   PeerAddr => "localhost",
>   PeerPort => "daytime(13)",
>   );
> 
> if (...) {
>cleanup();
>print "socket error";
>exit(0);
> }

IO::Socket::INET->new returns undef on error (and sets $@ with an error
message), althout this isn't terribly well documented.

So you can say:

   if (!$sock) {
   ...

or 

   unless ($sock) {
   ...

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




Re: Variable source for an array assignment

2003-01-16 Thread Rob Dixon
Robert Monical wrote:
> Hello
> I'm maintaining a 4 year old mod_perl Web application.
>
> Several months ago, this list helped me to get the following working
>
> I spent a couple of hours last night trying to figure out if
> there is a way to do this in a single statement.
>
> $val->{'Ammenities' } is set upstream and is a scalar
> if a single item is selected, an array if more than one
> is selected.
>
> To re-iterate, this code works. I just want to understand
> if there is a better way.
>
> if (ref($val->{'Ammenities'}) eq "ARRAY"){
>  for ( $keys = 0;$keys<=$#{$val->{Ammenities}};$keys++)  {
> $amen[$keys] = $val->{Ammenities}[$keys];
> }# end for
>} else {
>  $amen[0] = $val->{Ammenities};
>}# end if
>
> Then we stick @amen in the database

Hi Robert

Try:

for ( $val->{'Ammenities'} ) {
@amen = (ref) ? @$_ : ($_);
}

HTH,

Rob




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




multi-dimensional array foreach loop...

2003-01-16 Thread Liss, Mike
Ok,
 
I think I am beginning to see the light...
but I am still in the dark on this one...
 
How would I iterate over these arrays?
 
$MyArray[0][0][0] = "A 1";
$MyArray[0][1][0] = "comment 1";
 
$MyArray[0][0][1] = "A 2";
$MyArray[0][1][1] = "Comment 2";
 
$MyArray[1][0][0] = "B 1";
$MyArray[1][1][0] = "comment 1";
 
$MyArray[1][0][1] = "B 2";
$MyArray[1][1][1] = "Comment 2";
 
 
for example I could do this:
 
for( $i=0; $i<$n; $i++ )
{
for( $j=0; $j<$m; $j++ )
{
for( $k=0; $k<$p; $k++ )
{
print " $MyArray[ $i ][ $j ][ $p ] \n" ;
}
}
}
 
But the problem with that is I don't know what n, m, and p are going to
be...
 
 
Thanks
Mike



RE: Where is the new line coming from.

2003-01-16 Thread Paul Kraus
Interesting When I run the script on my windows box (5.6.1) I get
this output
DEBUG : NON PRINT ACHAR -011747- 
DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  -
DEBUG : NON PRINT ACHAR -139.45- 

Same script same source file run on sco openserver 5 (5.6.0) I get this
output
DEBUG : NON PRINT ACHAR -011747- 
DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  -
DEBUG : NON PRINT ACHAR -139.45- 
DEBUG : NON PRINT ACHAR -\xd20-

any ideas on where this came from?


> -Original Message-
> From: Dan Muey [mailto:[EMAIL PROTECTED]] 
> Sent: Thursday, January 16, 2003 11:22 AM
> To: Paul Kraus; Perl
> Subject: RE: Where is the new line coming from.
> 
> 
> > attached is a copy of the excel file if it helps.
> 
> I see it now. 
> It's probably some odd unprintable character.
> You could try somehting like this that will change unprintable 
> characters to their viewable equivalent 
> ( ascii, hex?? I can't remember.) 
> But I got his form someone a while ago.
> 
> ($tmp = $line) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", ord $1/ge;
> print "DEBUG : NON PRINT ACHAR -$tmp-  \n"; 
> 
> So if you run this and get soemthing like :
> DEBUG : NON PRINT ACHAR -my sting %n20- then you can look up and see 
> what the regex equivalent of %n20 is and kill it all the way 
> to the bank. 
> 
> Try that and see.
> 
> Dan
> 
> > 
> > > -Original Message-
> > > From: Paul Kraus [mailto:[EMAIL PROTECTED]]
> > > Sent: Thursday, January 16, 2003 11:03 AM
> > > To: 'Dan Muey'; 'Perl'
> > > Subject: RE: Where is the new line coming from.
> > > 
> > > 
> > > come to think of it. This "newline" I am getting must be a
> > > result of windows just dropping my prompt to the next line. 
> > > So I assumed it was there... Stupid me. I am used to Linux 
> > > which does not do this in the shell.
> > > 
> > > Ok then this brings me full circle.
> > > When I run this program on UNIX it makes an excel spread
> > > sheet that has little square strange characters at the end of 
> > > every row in the last cell. I assumed they where new lines 
> > > but I have ruled this out as I am not printing any new lines. 
> > > Any idea on how to fix this? It works in windows but not on 
> > > my sco box.
> > > 
> > > #!/usr/bin/perl
> > > 
> > > open IPO,('ipo.txt');
> > > $count=2;
> > > $lineref=['PEL Supply Company - IPO Price List',
> > > ['Item Code','Description','List','Vendor']];
> > > $addline = sub {$worksheet->write_row($count,0,$lineref)};
> > > 
> > > #setup excel spread sheet
> > > use Spreadsheet::WriteExcel;
> > > my $workbook = Spreadsheet::WriteExcel->new("ipo.xls");
> > > $worksheet   = $workbook->addworksheet();
> > > $format1  = $workbook->addformat();
> > > $format2  = $workbook->addformat();
> > > $format3  = $workbook->addformat();
> > > $format4  = $workbook->addformat();
> > > 
> > > #Format 1 (Header Row: Bold, BG Yellow, Bottom Border)
> > > $format1->set_bold(); $format1->set_bg_color('yellow'); 
> > > $format1->set_bottom();
> > > 
> > > #Format 2 (List Column Right justified set to currency)
> > > $format2->set_align('right'); $format2->set_num_format(8);
> > > 
> > > #Format 3 (List Column Header - Bold, Yel BG, Bottom Border,
> > > Right Justified) $format3->set_bold(); 
> > > $format3->set_bg_color('yellow'); $format3->set_bottom(); 
> > > $format3->set_align('right');
> > > 
> > > #Format 4
> > > $format4->set_bold();
> > > $format4->set_bg_color('yellow');
> > > $format4->set_merge();
> > > 
> > > 
> > > #Format Columns
> > > $worksheet->set_column(0,0, 25);
> > > $worksheet->set_column(1,1, 44);
> > > $worksheet->set_column(2,2, 10,$format2);
> > > $worksheet->set_column(3,3, 15); $worksheet->freeze_panes(2,0);
> > > 
> > > #Write Header Row $worksheet->write(0,0,$lineref->[0],$format4);
> > > $worksheet->write_blank(0,1,$format4);
> > > $worksheet->write_blank(0,2,$format4);
> > > $worksheet->write_blank(0,3,$format4);
> > > 
> > > $worksheet->write(1,0,$lineref->[1]->[0],$format1);# Item Code
> > > $worksheet->write(1,1,$lineref->[1]->[1],$format1);# Item 
> > > Description
> > > $worksheet->write(1,2,$lineref->[1]->[2],$format3);# Item List
> > > $worksheet->write(1,3,$lineref->[1]->[3],$format1);# 
> Vendor Code
> > > 
> > > $lineref = \@line;
> > > 
> > > while (){
> > > chomp;
> > > @line=split /\|/,$_;
> > > $line[2]=~s/ //g;
> > > &$addline;
> > > $count++;
> > > }
> > > 
> > > 
> > > > -Original Message-
> > > > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, January 16, 2003 10:49 AM
> > > > To: Paul Kraus; Perl
> > > > Subject: RE: Where is the new line coming from.
> > > >
> > > >
> > > > > I am reading in a text file that has input similar to this.
> > > > > date|data|data|data\n
> > > > >
> > > > > I then read the file in and using a while loop I chomp
> > > off the new
> > > > > line. while ()

RE: Where is the new line coming from.

2003-01-16 Thread Dan Muey
> Interesting When I run the script on my windows box 
> (5.6.1) I get this output
> DEBUG : NON PRINT ACHAR -011747- 
> DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  -
> DEBUG : NON PRINT ACHAR -139.45- 
> 
> Same script same source file run on sco openserver 5 (5.6.0) 
> I get this output
> DEBUG : NON PRINT ACHAR -011747- 
> DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  -
> DEBUG : NON PRINT ACHAR -139.45- 
> DEBUG : NON PRINT ACHAR -\xd20-
> 
> any ideas on where this came from?

I don't have any idea where it's from. 
I'd say if you could delete that entry from the array or
Find out what the regex equivalent is and delete it from 
each line or transform the actual $line into the '\xd20' version,
Delete any xd* and don't use the line is it's empty after that.


> 
> 
> > -Original Message-
> > From: Dan Muey [mailto:[EMAIL PROTECTED]]
> > Sent: Thursday, January 16, 2003 11:22 AM
> > To: Paul Kraus; Perl
> > Subject: RE: Where is the new line coming from.
> > 
> > 
> > > attached is a copy of the excel file if it helps.
> > 
> > I see it now.
> > It's probably some odd unprintable character.
> > You could try somehting like this that will change unprintable 
> > characters to their viewable equivalent 
> > ( ascii, hex?? I can't remember.) 
> > But I got his form someone a while ago.
> > 
> > ($tmp = $line) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", 
> ord $1/ge; 
> > print "DEBUG : NON PRINT ACHAR -$tmp-  \n";
> > 
> > So if you run this and get soemthing like :
> > DEBUG : NON PRINT ACHAR -my sting %n20- then you can look up and see
> > what the regex equivalent of %n20 is and kill it all the way 
> > to the bank. 
> > 
> > Try that and see.
> > 
> > Dan
> > 
> > > 
> > > > -Original Message-
> > > > From: Paul Kraus [mailto:[EMAIL PROTECTED]]
> > > > Sent: Thursday, January 16, 2003 11:03 AM
> > > > To: 'Dan Muey'; 'Perl'
> > > > Subject: RE: Where is the new line coming from.
> > > > 
> > > > 
> > > > come to think of it. This "newline" I am getting must 
> be a result 
> > > > of windows just dropping my prompt to the next line. So 
> I assumed 
> > > > it was there... Stupid me. I am used to Linux which does not do 
> > > > this in the shell.
> > > > 
> > > > Ok then this brings me full circle.
> > > > When I run this program on UNIX it makes an excel spread sheet 
> > > > that has little square strange characters at the end of 
> every row 
> > > > in the last cell. I assumed they where new lines but I 
> have ruled 
> > > > this out as I am not printing any new lines. Any idea on how to 
> > > > fix this? It works in windows but not on my sco box.
> > > > 
> > > > #!/usr/bin/perl
> > > > 
> > > > open IPO,('ipo.txt');
> > > > $count=2;
> > > > $lineref=['PEL Supply Company - IPO Price List',
> > > >   ['Item Code','Description','List','Vendor']];
> > > > $addline = sub {$worksheet->write_row($count,0,$lineref)};
> > > > 
> > > > #setup excel spread sheet
> > > > use Spreadsheet::WriteExcel;
> > > > my $workbook = Spreadsheet::WriteExcel->new("ipo.xls");
> > > > $worksheet   = $workbook->addworksheet();
> > > > $format1  = $workbook->addformat();
> > > > $format2  = $workbook->addformat();
> > > > $format3  = $workbook->addformat();
> > > > $format4  = $workbook->addformat();
> > > > 
> > > > #Format 1 (Header Row: Bold, BG Yellow, Bottom Border) 
> > > > $format1->set_bold(); $format1->set_bg_color('yellow'); 
> > > > $format1->set_bottom();
> > > > 
> > > > #Format 2 (List Column Right justified set to currency) 
> > > > $format2->set_align('right'); $format2->set_num_format(8);
> > > > 
> > > > #Format 3 (List Column Header - Bold, Yel BG, Bottom 
> Border, Right 
> > > > Justified) $format3->set_bold(); 
> $format3->set_bg_color('yellow'); 
> > > > $format3->set_bottom(); $format3->set_align('right');
> > > > 
> > > > #Format 4
> > > > $format4->set_bold();
> > > > $format4->set_bg_color('yellow');
> > > > $format4->set_merge();
> > > > 
> > > > 
> > > > #Format Columns
> > > > $worksheet->set_column(0,0, 25); 
> $worksheet->set_column(1,1, 44);
> > > > $worksheet->set_column(2,2, 10,$format2);
> > > > $worksheet->set_column(3,3, 15); $worksheet->freeze_panes(2,0);
> > > > 
> > > > #Write Header Row $worksheet->write(0,0,$lineref->[0],$format4);
> > > > $worksheet->write_blank(0,1,$format4);
> > > > $worksheet->write_blank(0,2,$format4);
> > > > $worksheet->write_blank(0,3,$format4);
> > > > 
> > > > $worksheet->write(1,0,$lineref->[1]->[0],$format1);
> # Item Code
> > > > $worksheet->write(1,1,$lineref->[1]->[1],$format1);# Item 
> > > > Description
> > > > $worksheet->write(1,2,$lineref->[1]->[2],$format3);
> # Item List
> > > > $worksheet->write(1,3,$lineref->[1]->[3],$format1);# 
> > Vendor Code
> > > > 
> > > > $lineref = \@line;
> > > > 
> > > > while (){
> > > > chomp;
> > > > @line=split /\|/,$_

Re: Where is the new line coming from.

2003-01-16 Thread Rob Dixon
Paul Kraus wrote:
> Interesting When I run the script on my windows box (5.6.1) I get
> this output
> DEBUG : NON PRINT ACHAR -011747-
> DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  -
> DEBUG : NON PRINT ACHAR -139.45-
>
> Same script same source file run on sco openserver 5 (5.6.0) I get
> this output
> DEBUG : NON PRINT ACHAR -011747-
> DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  -
> DEBUG : NON PRINT ACHAR -139.45-
> DEBUG : NON PRINT ACHAR -\xd20-

This is what I said - '\x0D', a carriage return. The '20' is because of
a mistake in your Perl, see below.

[snip]
>>
>> ($tmp = $line) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", ord $1/ge;
>> print "DEBUG : NON PRINT ACHAR -$tmp-  \n";

That substitute should be:

s/([^\x20-\x7E])/'\x' . sprintf "%02x", ord $1/ge;

(Note the sprintf() format)

Cheers,

Rob






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




RE: DBI->prepare problem w/ trace

2003-01-16 Thread Dan Muey
Nevermind. I figured it out. It seems that in the routine that 
contained the eval changed the value of $db_use to $db_user 
due to my bad typing. Which made it seem like the eval was 
the problem when it wasn't.
So it couldn't prepare the statement because that table didn't 
exist in the database $db_user ( which doesn't exist ) while it 
did exist in the database $db_use.

Welp I guess that genius statis will have to wait even longer.

Thanks for being my sounding board. Sometimes you can work problems out just by
talking to someone about them. I guess that makes all of you perl pychologosts!

Dan


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




RE: Where is the new line coming from.

2003-01-16 Thread Dan Muey
> Paul Kraus wrote:
> > Interesting When I run the script on my windows box 
> (5.6.1) I get 
> > this output
> > DEBUG : NON PRINT ACHAR -011747-
> > DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  
> - DEBUG : 
> > NON PRINT ACHAR -139.45-
> >
> > Same script same source file run on sco openserver 5 (5.6.0) I get 
> > this output
> > DEBUG : NON PRINT ACHAR -011747-
> > DEBUG : NON PRINT ACHAR -Eco-Liner w/Att A=30-35 B=23-29cm  
> - DEBUG : 
> > NON PRINT ACHAR -139.45- DEBUG : NON PRINT ACHAR -\xd20-
> 
> This is what I said - '\x0D', a carriage return. The '20' is 
> because of a mistake in your Perl, see below.

You know what you're right. I remember the guy I got that from sending me a correction 
later for the same reason.
It's been too long, sorry for the mix up. Thanks for the correction. I'll correct my 
notes.
Dang Rob gets genius again! I just can't win today! :)

> 
> [snip]
> >>
> >> ($tmp = $line) =~ s/([^\x20-\x7E])/'\x' . sprintf "%x20", 
> ord $1/ge; 
> >> print "DEBUG : NON PRINT ACHAR -$tmp-  \n";
> 
> That substitute should be:
> 
> s/([^\x20-\x7E])/'\x' . sprintf "%02x", ord $1/ge;
> 
> (Note the sprintf() format)
> 
> Cheers,
> 
> Rob
> 
> 
> 
> 
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

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




RE: multi-dimensional array foreach loop...

2003-01-16 Thread Liss, Mike
Sorry,

I should have said... "How would I iterate over these arrays using foreach"

-Original Message-
From: Liss, Mike [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 16, 2003 8:33 AM
To: [EMAIL PROTECTED]
Subject: multi-dimensional array foreach loop...


Ok,
 
I think I am beginning to see the light...
but I am still in the dark on this one...
 
How would I iterate over these arrays?
 
$MyArray[0][0][0] = "A 1";
$MyArray[0][1][0] = "comment 1";
 
$MyArray[0][0][1] = "A 2";
$MyArray[0][1][1] = "Comment 2";
 
$MyArray[1][0][0] = "B 1";
$MyArray[1][1][0] = "comment 1";
 
$MyArray[1][0][1] = "B 2";
$MyArray[1][1][1] = "Comment 2";
 
 
for example I could do this:
 
for( $i=0; $i<$n; $i++ )
{
for( $j=0; $j<$m; $j++ )
{
for( $k=0; $k<$p; $k++ )
{
print " $MyArray[ $i ][ $j ][ $p ] \n" ;
}
}
}
 
But the problem with that is I don't know what n, m, and p are going to
be...
 
 
Thanks
Mike



Re: multi-dimensional array foreach loop...

2003-01-16 Thread Rob Dixon
Mike Liss wrote:
> Ok,
>
> I think I am beginning to see the light...
> but I am still in the dark on this one...
>
> How would I iterate over these arrays?
>
> $MyArray[0][0][0] = "A 1";
> $MyArray[0][1][0] = "comment 1";
>
> $MyArray[0][0][1] = "A 2";
> $MyArray[0][1][1] = "Comment 2";
>
> $MyArray[1][0][0] = "B 1";
> $MyArray[1][1][0] = "comment 1";
>
> $MyArray[1][0][1] = "B 2";
> $MyArray[1][1][1] = "Comment 2";
>
>
> for example I could do this:
>
> for( $i=0; $i<$n; $i++ )
> {
> for( $j=0; $j<$m; $j++ )
> {
> for( $k=0; $k<$p; $k++ )
> {
> print " $MyArray[ $i ][ $j ][ $p ] \n" ;

You mean:

   print " $MyArray[ $i ][ $j ][ $k ] \n" ;

> }
> }
> }
>
> But the problem with that is I don't know what n, m, and p are going
> to be...

The sensible way to dump the entire 3D array is:

foreach (@MyArray) {
foreach (@$_) {
foreach (@$_) {
print "$_\n";
}
}
}

output

A 1
A 2
comment 1
Comment 2
B 1
B 2
comment 1
Comment 2

But that isn't the order your code assigned them, which increments the
2nd index followed by the 3rd followed by the first. Here they are
printed in the order 3, 2, 1 as you'd expect.

Cheers,

Rob





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




searching the database with a sub, getting an error message

2003-01-16 Thread Le Blanc, Kerry (Kerry)
Ok the highlights do not seem to have made it, I marked the line that is getting the 
error message.
 
Thanks
 

#this is the subroutine to search the file
sub search{
open(FILE, ') {
chomp;  # remove newline
my @fields = split(/\|/, $_);
 
# test whether the search string matches part number
 if ($fields[0] =~ /$PartNumber/ ) {
print "$PartNumber Rev. $Revision has a First Article Report\nWould 
you like to view it?";
 }
 
 
 
 }}
 

my $answer = ;
 
chomp($answer);
 
# If the answer is yes then fill the form with the information
 
if ($answer eq "yes") {
   print "\n\n\none second please..\n";
   print "retrieving file\n";
   print "$fields[0]: $fields[1]: $fields[2]: $fields[3]\n";<--This is the line that 
gets the error message
 
} 
# If the answer is no then die
   else {
print "ok, well have a nice day.\n";
   }
 
close(FILE);


Kerry LeBlanc 
Materials Auditor 
Process Owner 
75 Perseverence Way 
Hyannis, MA. 02601 
1-508-862-3082 
http://www.vsf.cape.com/~bismark   

 



Re: Request for a CPAN Module

2003-01-16 Thread Tim Musson
Hey Ben, 

My MUA believes you used Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.2.1) 
Gecko/20021223
to write the following on Thursday, January 16, 2003 at 9:37:34 AM.

BS> Are there any CPAN modules that can analyze XML or HTML and report
BS> any cases of unclosed tags? For example:

I use http://tidy.sf.net for checking/fixing, but don't know if it
does xml.

-- 
Tim Musson
Flying with The Bat! eMail v1.62 Christmas Edition
Windows 2000 5.0.2195 (Service Pack 2)
MS Windows -- From the people who brought you EDLIN! 


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




Re: searching the database with a sub, getting an error message

2003-01-16 Thread Rob Dixon
Le Blanc wrote:
> Greetings,
>   I have a quick question. In the code below I get an error message
> that says 'Global symbol "@fields" requires explicit package name'
> The line that causes the error is highlighted in red. Obviously it
> has to do with how I declared the variable in my subroutine. I tried
> moving curly brackets and I tried other ways of declaring. Could
> someone please tell me the correct way to do this. The perldoc's are
> still somewhat cryptic to me. I thought that moving the close(FILE)
> would help, but it did not.
>
>
> #this is the subroutine to search the file
> sub search{
> open(FILE, ' correct to open a file for read only?

Yes, fine.

>

Put 'my @fields'  here.

>  while () {
> chomp;  # remove newline
> my @fields = split(/\|/, $_);
>

@fields = split '|';

> # test whether the search string matches part number
>  if ($fields[0] =~ /$PartNumber/ ) {

if ($fields[0] eq $PartNumber) {

> print "$PartNumber Rev. $Revision has a First Article
>  Report\nWould you like to view it?"; }
>
>
>
>  }}

Your while statement finishes here, and so your original @fields
vanishes.

The second closing brace terminates the subroutine!!

(Assuming the second brace is removed) Your code below would be executed
whether or not the part number was found. Since you can close the file
any time after a matching record is found, I suggest you need something
like:

my $found = 0;

while () {
:
if (match) {
$found = 1;
close FILE;
}
}

if ($found)
{
:
}

>
>
> my $answer = ;
>
> chomp($answer);
>
> # If the answer is yes then fill the form with the information
>
> if ($answer eq "yes") {
>print "\n\n\none second please..\n";
>print "retrieving file\n";
>print "$fields[0]: $fields[1]: $fields[2]: $fields[3]\n";
>
> }
> # If the answer is no then die
>else {
> print "ok, well have a nice day.\n";
>}
>
> close(FILE);

Could be closed earlier - see above.

HTH,

Rob




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




Re: Help for telnet using perl

2003-01-16 Thread Paul Corr
At 2:49 PM -0800 1/15/03, shirish doshi wrote:

Hi,
   I am a novice in Perl and I want to implement
telnet in perl. If you have any tutorials or source
code available with you , please forward me.
Thanking you in advance,
Regards,
Shirish


Shirish,

Perl has the Net::Telnet module:

http://search.cpan.org/author/JROGERS/Net-Telnet-3.03/

Below, I'll include an example I created following the module's 
example in its manpage. This example doesn't require a username and 
password. Most of the information you need will be in the manpage. 
Once you install the module, use 'perldoc Net::Telnet' to read it.

Paul

#!/usr/bin/perl

# get_weather.pl
#
# This script connects to the Weather Underground site and
# retrieves a brief weather report for the designated city.
# [Based on example in Net::Telnet POD. Added config section and
# line ending substitution statement before output. -- PJC]

use strict;

use Net::Telnet;

# # # Begin Config # # #
my $url = "rainmaker.wunderground.com";
my $city_code = "PHL"; # Philadelphia, PA, USA
# # #  End Config  # # #

my($forecast, $t);

use Net::Telnet ();
$t = new Net::Telnet;
$t->open($url);

## Wait for first prompt and "hit return".
$t->waitfor('/continue:.*$/');
$t->print("");

## Wait for second prompt and respond with city code.
$t->waitfor('/city code.*$/');
$t->print($city_code);

## Read and print the first page of forecast.
($forecast) = $t->waitfor('/[ \t]+press return to continue/i');

# replace orig. line ending with Mac EOL char.
$forecast =~ s/\015?\012/\015/g; # DOS/UNIX to Mac [PJC]

print $forecast;

exit;


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



Re: baffling script behavior- root loses files

2003-01-16 Thread david
Zentara wrote:
 
---
> #!/usr/bin/perl -w
> 
> @users=('/home/zentara');
> 
> #put all user-root hidden files and hidden dirs into 1 temp dir
> #this makes it easier to backup second level subdirs
> foreach $homedir(@users){
> opendir DIR, $homedir or warn "Cannot readdir $homedir:$!\n";
> @files = grep !/^\.\.?$/, readdir DIR;
> foreach (@files){push @movem,$_ if -f}
> foreach (@files){push @movem,$_ if ($_ =~ m!^[.]!)}
> print "@movem\n";
> print "##\n";
> }
> exit;
>  
-
> Can someone shed some light on why this happens? It has
> something to do with running it from /.
> 

yes because readdir(DIR) only returns a relative path. you need to know 
where you are! example:

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

opendir(DIR,'.') || die $!;
print join("\n",grep /\.pl$/, readdir(DIR)),"\n";
closedir(DIR);

__END__

when i run the above in my perl directory, it prints the following:

tmp.pl

when i run the above in /, it prints nothing because under /, i don't have 
any script that ends with .pl

now going back to looking at your:

> foreach (@files){push @movem,$_ if -f}

when you run it in /, your if statment is trying to do:

foreach (@files){ push @movem,$_ if(-f /$_)}

because you are under /. the test will mostly like fail.

when you run it in /home/zentara, your if statement is trying to do:

foreach (@files){ push @movem,$_ if(-f /home/zentara/$_)}

so it work.

david

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




Re: Request for a CPAN Module

2003-01-16 Thread david
Ben Siders wrote:

> Are there any CPAN modules that can analyze XML or HTML and report any
> cases of unclosed tags?  For example:
> 
> 
> Hello, world
> Me
> Hey, is thing thing on?
> 
> 
> In the above, I'd like to find a method of detecting that the bold tag
> is missing a  closer.

try:

#!/usr/bin/perl -w
use strict;
use XML::Parser;

open(XML,'foo.xml') || die $!;

my $xml = XML::Parser->new;

eval{
$xml->parse(*XML);
};

print "ERROR: $@" if($@);

close(XML);

__END__

if any tag in foo.xml is mismatched(missing, typo, etc), you will get 
somethinglike:

ERROR:
mismatched tag at line 10, column 2, byte 165 at 
/usr/lib/perl5/vendor_perl/5.8.0/i386-linux-thread-multi/XML/Parser.pm line 
185

david

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




Web Applications.

2003-01-16 Thread Joe Echavarria

  Hi there,

How can i execute a perl/cgi application with its
own web server ?, I want the user to be able to
execute my  web/based application in his/her local
windows pc without a webserver installed locally?
Let say http://myapplication:port/, something like
that.
   What module can i use ?, any example ?
Thanks.

__
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

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




Re: Hashes and memory consumption

2003-01-16 Thread david
Schoenwaelder Oliver wrote:

> Hi list members,
> 
> I have some problems with a script using hashes.
> I use hashes for years but never had this kind of problem before...
> I have a ascii file with 6.5 MB of data. This file is tokenized by
> Parse:Lex module.

i never use this module before so i don't know how efficient it will be and 
what algr. it uses.

> The tokens are then stored in a two level hash:
> $TokenHash{$TokenType}->{$TokenID}=$TokenValue.

not that much of a problem in Perl. hash algr. in Perl is pretty efficient 
in terms of speed and storage. yes, hash is a little waste of memory (apply 
to most other languages) but it's not that expensive as you might think of.

> The file contains 536,332 tokens which will lead to 79 keys for
> %TokenHash. I'm evaluating the hash with two loops, one for each level.
> Due to that I need to move back and forth through the _sorted_ hash while
> being in the loop I can't use the built-in procedures like "foreach $key1
> (keys %TokenHash)...". So I decided to use Tie::LLHash.

never use Tie::LLHash either. did you contact the author of this module?

> Now I'm amazed by the memory consumption. The script uses up to 300MB for

could be a combination of your parsing module and Tie::LLHash that cause 
this. by the way, what platform are you using?

> processing this small file which will lead to a 3.5 MB file at the end. I
> developed and tested my script with a 2K subset of the original file and
> therefore I haven't encountered the problem during tests.
> A simple "if (not exists $TokenHash{$TokenType}->{$TokenID}) {}" uses
> 110MB of memory. I encountered this when storing the elements into the
> hash was commented out. Just tokenization of the file uses 4M of memory.
> So in my opinion it's hash/hash operations related.
> In production the files to be processed will be up to several 100MB of
> size, so memory usage is really an issue for me.
> I also tried with "simple/built-in" hashes just to be sure that the module
> isn't the problem. But I got the same strange results. And I tried to use
> multi-dimension arrays, but they also use up to 50MB of memory.
> 
> Anything I need to consider? Anybody with the same experience?

i regularly parse log files up to > 50G with pretty bad nested deep down 
hash/ref but never encounter the problem you are referring to. for a 6.5M 
of text file to consum over 300M of memory is unbelieveable. if the problem 
comes down to the modules you are using, they would be useless and many 
users would have complain about them.

david

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




RE: multi-dimensional array foreach loop...

2003-01-16 Thread david
Mike Liss wrote:

> Sorry,
> 
> I should have said... "How would I iterate over these arrays using
> foreach"
> Mike

using foreach? have you try this yet?

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

my @array = ([[1..5],[2..6],[7..10]],[[11..15],[16..20],[21..25]]);

foreach(my $i = 0; $i < @array; $i++){
foreach(my $j = 0; $j < @{$array[$i]}; $j++){
foreach(my $k = 0; $k < @{$array[$i][$j]}; $k++){
print "$array[$i][$j][$k]\n";
}
}
}

__END__

david

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




trouble when calling a shell script for setting an env var

2003-01-16 Thread Konrad Foerstner
He folks!

Todays problem:

I need to get a value from an environment variable VALUE. This value is
set by an shell script which location is stored in anonther environment
variable called SCRIPT. So I first call the shell script by

`. \$SCRIPT`;

and extract then the value of VALUE by

my $value = $ENV(VALUE);

But something does not work, so $value is empty. As the shell script
produces also an echo output I catch it by using

my @output = `. \$SCRIPT`;

I get this output correctly, but VALUE is still empty! I also tried also 

system(\$SCRIPT`); 

and 

`. /place/of/my/shellscript.sh`;

Both don't have the wished effect.

When I call the shell script in the shell and the start my perl script
VALUE is set and available for my perl script.

What is wrong?

Konrad

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




Re: trouble when calling a shell script for setting an env var

2003-01-16 Thread Paul Johnson
On Thu, Jan 16, 2003 at 08:58:22PM +0100, Konrad Foerstner wrote:

> I need to get a value from an environment variable VALUE. This value is
> set by an shell script which location is stored in anonther environment
> variable called SCRIPT. So I first call the shell script by
> 
> `. \$SCRIPT`;
> 
> and extract then the value of VALUE by
> 
> my $value = $ENV(VALUE);
> 
> But something does not work, so $value is empty. As the shell script
> produces also an echo output I catch it by using
> 
> my @output = `. \$SCRIPT`;
> 
> I get this output correctly, but VALUE is still empty! I also tried also 
> 
> system(\$SCRIPT`); 
> 
> and 
> 
> `. /place/of/my/shellscript.sh`;
> 
> Both don't have the wished effect.
> 
> When I call the shell script in the shell and the start my perl script
> VALUE is set and available for my perl script.
> 
> What is wrong?

Unfortunately, your understanding of processes.  A child process cannot
alter the environment of its parent.

Take a look at Shell::Source on CPAN.

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

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




Re: trouble when calling a shell script for setting an env var

2003-01-16 Thread Konrad Foerstner

> > I need to get a value from an environment variable VALUE. This value is
> > set by an shell script which location is stored in anonther environment
> > variable called SCRIPT. So I first call the shell script by
> > 
> > `. \$SCRIPT`;
> > 
> > and extract then the value of VALUE by
> > 
> > my $value = $ENV(VALUE);
> > 
> > But something does not work, so $value is empty. As the shell script
> > produces also an echo output I catch it by using
> > 
> > my @output = `. \$SCRIPT`;
> > 
> > I get this output correctly, but VALUE is still empty! I also tried also 
> > 
> > system(\$SCRIPT`); 
> > 
> > and 
> > 
> > `. /place/of/my/shellscript.sh`;
> > 
> > Both don't have the wished effect.
> > 
> > When I call the shell script in the shell and the start my perl script
> > VALUE is set and available for my perl script.
> > 
> > What is wrong?
> 
> Unfortunately, your understanding of processes.  A child process cannot
> alter the environment of its parent.
> 
> Take a look at Shell::Source on CPAN.

Ah, okay! Thanks a lot!
Konrad

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




Re: Help for telnet using perl

2003-01-16 Thread Mark Goland
Very CutE !!!

Mark
- Original Message - 
From: "Paul Corr" <[EMAIL PROTECTED]>
To: "shirish doshi" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, January 16, 2003 12:10 PM
Subject: Re: Help for telnet using perl


> At 2:49 PM -0800 1/15/03, shirish doshi wrote:
> >Hi,
> >I am a novice in Perl and I want to implement
> >telnet in perl. If you have any tutorials or source
> >code available with you , please forward me.
> >Thanking you in advance,
> >Regards,
> >Shirish
> 
> Shirish,
> 
> Perl has the Net::Telnet module:
> 
> http://search.cpan.org/author/JROGERS/Net-Telnet-3.03/
> 
> Below, I'll include an example I created following the module's 
> example in its manpage. This example doesn't require a username and 
> password. Most of the information you need will be in the manpage. 
> Once you install the module, use 'perldoc Net::Telnet' to read it.
> 
> Paul
> 
> #!/usr/bin/perl
> 
> # get_weather.pl
> #
> # This script connects to the Weather Underground site and
> # retrieves a brief weather report for the designated city.
> # [Based on example in Net::Telnet POD. Added config section and
> # line ending substitution statement before output. -- PJC]
> 
> use strict;
> 
> use Net::Telnet;
> 
> # # # Begin Config # # #
> my $url = "rainmaker.wunderground.com";
> my $city_code = "PHL"; # Philadelphia, PA, USA
> # # #  End Config  # # #
> 
> my($forecast, $t);
> 
> use Net::Telnet ();
> $t = new Net::Telnet;
> $t->open($url);
> 
> ## Wait for first prompt and "hit return".
> $t->waitfor('/continue:.*$/');
> $t->print("");
> 
> ## Wait for second prompt and respond with city code.
> $t->waitfor('/city code.*$/');
> $t->print($city_code);
> 
> ## Read and print the first page of forecast.
> ($forecast) = $t->waitfor('/[ \t]+press return to continue/i');
> 
> # replace orig. line ending with Mac EOL char.
> $forecast =~ s/\015?\012/\015/g; # DOS/UNIX to Mac [PJC]
> 
> print $forecast;
> 
> exit;
> 
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

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




Re: baffling script behavior- root loses files

2003-01-16 Thread Jenda Krynicky
From: zentara <[EMAIL PROTECTED]>
> I made a little test case to demonstrate the problem.
> The following script is run by root in /home/user:
> /home/zentara/backup-homex
> 
--
> - #!/usr/bin/perl -w
> 
> @users=('/home/zentara');
> 
> #put all user-root hidden files and hidden dirs into 1 temp dir
> #this makes it easier to backup second level subdirs
> foreach $homedir(@users){
> opendir DIR, $homedir or warn "Cannot readdir $homedir:$!\n";
> @files = grep !/^\.\.?$/, readdir DIR;
> foreach (@files){push @movem,$_ if -f}
> foreach (@files){push @movem,$_ if ($_ =~ m!^[.]!)}
> print "@movem\n";
> print "##\n";
> }
> exit;
> 
--
> --
> 
> When the above script is run as user or as root in /home/zentara
> the output is good:
> 
> when the above script is run by
> root from /, the output misses some plain files, notably sig, but 
many
> are missing, seemingly random:

Ahh the usual mistake.

The readdir() returns just the file and subdirectory names, not 
complete paths.

Therefore if you opendir() some other directory than '.' you have to 
prepend that directory to the filenames before you do the tests.
Otherwise you are looking at the files in the current directory.

Try
foreach (@files){push @movem,$_ if -f "$homedir/$_"}

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Hashes and memory consumption

2003-01-16 Thread Jenda Krynicky
From: Schoenwaelder Oliver <[EMAIL PROTECTED]>
> I have some problems with a script using hashes.
> I use hashes for years but never had this kind of problem before... 
I
> have a ascii file with 6.5 MB of data. This file is tokenized by
> Parse:Lex module. The tokens are then stored in a two level hash:
> $TokenHash{$TokenType}->{$TokenID}=$TokenValue. The file contains
> 536,332 tokens which will lead to 79 keys for %TokenHash. I'm
> evaluating the hash with two loops, one for each level. Due to that 
I
> need to move back and forth through the _sorted_ hash while being 
in
> the loop I can't use the built-in procedures like "foreach $key1 
(keys
> %TokenHash)...". So I decided to use Tie::LLHash. Now I'm amazed by
> the memory consumption. The script uses up to 300MB for processing
> this small file which will lead to a 3.5 MB file at the end. 


You may want to try Tie::IxHash instead.

But I think it would be best to store it as

$TokenHash{$TokenType,$TokenID}=$TokenValue. 

and tie the %TokenHash to DB_File in the  DB_BTREE format.
This will allow you to move back and forth and it should reduce the 
memory consumtion of your script considerably. (by storing the data 
on disk).

Let me know if you need more details :-)

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




RE: Spreadsheet::WriteExcel - Unix New line

2003-01-16 Thread Jenda Krynicky
From: "Dan Muey" <[EMAIL PROTECTED]>

> I think unix uses \n and winders uses \n\r so you may need to use 
\n\r
> or \r instead of \n

It should be \r\n (also read CRLF).
And Macs (the old ones) used \r.

> From: Paul Kraus [mailto:[EMAIL PROTECTED]] 
> 
> I wrote a script that generates an excel file. I tested it on 
> a windows xp pro machine and everything was ok. When I put 
> the script on the UNIX server and run it I get blocks on my 
> excel sheet where new lines occurred. How can I have the UNIX 
> Perl write out Microsoft new line characters so that the 
> excel sheet looks normal?

You need to use \r\n instead of \n in the strings you put into the 
sheet. Or run them through something like

$string =~ s/(?:\x0D\x0A?|\x0A)/\x0D\x0A/sg;
# this turns the end of lines in any of the three formats to \r\n
 
Though IMHO the module should take care of this itself.

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Splitting a variable

2003-01-16 Thread Scott, Joshua
I've got a CSV file which I need to process.  The format is as follows.

"Smith, John J",1/1/2002,1/15/2002,"Orlando, FL",Florida
"Doe, John L",1/1/2002,1/15/2002,Los Angeles, California

I've tried splitting it using:  @row = split(",",$data);

The problem is with the fields that contain the commas between the quotes.
It's splitting the fields at each of these fields as well and I'd like to
know how to avoid that.  

Any help is greatly appreciated!

Joshua Scott
Security Systems Analyst, CISSP
626-568-7024


==
NOTICE - This communication may contain confidential and privileged 
information that is for the sole use of the intended recipient. Any viewing,
copying or distribution of, or reliance on this message by unintended
recipients is strictly prohibited. If you have received this message in
error, please notify us immediately by replying to the message and deleting
it from your computer.

==



determining location of character in array....

2003-01-16 Thread Liss, Mike
Hello,
 
Is there an easy way to get the location of a specific instance of a
character 
in an array?
 
for example:
 
$MyArray = "This is the test";
 
I would like to know the index of the first occurence of the letter "h" ( 1
)
 
Thanks
Mike



write to file

2003-01-16 Thread thomas . browner
How can I write to a file in perl. 

Thomas

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



RE: determining location of character in array....

2003-01-16 Thread Mark Anderson

> Is there an easy way to get the location of a specific instance of a
> character in an array?
>
> for example:
>
>$MyArray = "This is the test";
>
> I would like to know the index of the first occurence of the letter "h"
( 1

perldoc -f index

index $MyArray,'h';


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




Re: Local Apache Server and CGI?

2003-01-16 Thread R. Joseph Newton
" ... apache isn't seeing
*.cgi as a script and is dumping it as a txt file onto
the browser..."

Hi Ben,

Have you configured Apache for the .pl and .cgi extensions?  On IIS, I had to 
explicitly set the server to run these two extensions as perl.  I haven't worked with 
Apache, so I don't know what the configuration interface looks like, but there 
probably is at least some setup requied.

Joseph


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




Re: Splitting a variable

2003-01-16 Thread Konrad Foerstner
On Thu, 16 Jan 2003 15:12:05 -0800
"Scott, Joshua" <[EMAIL PROTECTED]> wrote:

> I've got a CSV file which I need to process.  The format is as follows.
> 
> "Smith, John J",1/1/2002,1/15/2002,"Orlando, FL",Florida
> "Doe, John L",1/1/2002,1/15/2002,Los Angeles, California
> 
> I've tried splitting it using:  @row = split(",",$data);
> 
> The problem is with the fields that contain the commas between the quotes.
> It's splitting the fields at each of these fields as well and I'd like to
> know how to avoid that.  
> 
> Any help is greatly appreciated!

What's about regular expression? If all you lines look like this you could
use them. Are you familiar with them?

Konrad

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




Re: determining location of character in array....

2003-01-16 Thread Paul Johnson
On Thu, Jan 16, 2003 at 03:21:13PM -0800, Liss, Mike wrote:

> Is there an easy way to get the location of a specific instance of a
> character in an array?
>  
> for example:
>  
> $MyArray = "This is the test";
>  
> I would like to know the index of the first occurence of the letter "h" ( 1
> )

Surprisingly, the function you want is called C.  :-)

my $i = index $MyArray, "h";

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

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




RE: write to file

2003-01-16 Thread Dan Muey
> How can I write to a file in perl. 

perldoc -f open

open(FILEHANDLE, ">$path_to_file") or die $@;

print FILEHANDLE $newfilecontents;

close(FILEHANDLE);

> writes over
>> appends

< reads
open...
@lines_in)file = ;
close...


Dan

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

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




RE: Splitting a variable

2003-01-16 Thread Scott, Joshua
I figured regular expressions where the solution but I'm just starting to
learn how to use regular expressions.  

Also, only the first field always has a comma between the quotes.  The other
fields are not consistent.  

Joshua Scott
Security Systems Analyst, CISSP
626-568-7024


-Original Message-
From: Konrad Foerstner [mailto:[EMAIL PROTECTED]] 
Sent: Thursday, January 16, 2003 3:29 PM
To: Scott, Joshua
Cc: [EMAIL PROTECTED]
Subject: Re: Splitting a variable


On Thu, 16 Jan 2003 15:12:05 -0800
"Scott, Joshua" <[EMAIL PROTECTED]> wrote:

> I've got a CSV file which I need to process.  The format is as 
> follows.
> 
> "Smith, John J",1/1/2002,1/15/2002,"Orlando, FL",Florida "Doe, John 
> L",1/1/2002,1/15/2002,Los Angeles, California
> 
> I've tried splitting it using:  @row = split(",",$data);
> 
> The problem is with the fields that contain the commas between the 
> quotes. It's splitting the fields at each of these fields as well and 
> I'd like to know how to avoid that.
> 
> Any help is greatly appreciated!

What's about regular expression? If all you lines look like this you could
use them. Are you familiar with them?

Konrad


==
NOTICE - This communication may contain confidential and privileged 
information that is for the sole use of the intended recipient. Any viewing,
copying or distribution of, or reliance on this message by unintended
recipients is strictly prohibited. If you have received this message in
error, please notify us immediately by replying to the message and deleting
it from your computer.

==


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




Re: Splitting a variable

2003-01-16 Thread simran
Try using the Text::CSV module... 

On Fri, 2003-01-17 at 10:12, Scott, Joshua wrote:
> I've got a CSV file which I need to process.  The format is as follows.
> 
> "Smith, John J",1/1/2002,1/15/2002,"Orlando, FL",Florida
> "Doe, John L",1/1/2002,1/15/2002,Los Angeles, California
> 
> I've tried splitting it using:  @row = split(",",$data);
> 
> The problem is with the fields that contain the commas between the quotes.
> It's splitting the fields at each of these fields as well and I'd like to
> know how to avoid that.  
> 
> Any help is greatly appreciated!
> 
> Joshua Scott
> Security Systems Analyst, CISSP
> 626-568-7024
> 
> 
> ==
> NOTICE - This communication may contain confidential and privileged 
> information that is for the sole use of the intended recipient. Any viewing,
> copying or distribution of, or reliance on this message by unintended
> recipients is strictly prohibited. If you have received this message in
> error, please notify us immediately by replying to the message and deleting
> it from your computer.
> 
> ==


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




Re: determining location of character in array....

2003-01-16 Thread Jenda Krynicky
From: "Liss, Mike" <[EMAIL PROTECTED]>
> Is there an easy way to get the location of a specific instance of a
> character in an array?
> 
> for example:
> 
> $MyArray = "This is the test";
> 
> I would like to know the index of the first occurence of the letter
> "h" ( 1 )

index $MyArray, 'h'

And it's not an array. It's a scalar, a string.

Jenda
= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: Splitting a variable

2003-01-16 Thread Jenda Krynicky
From: "Scott, Joshua" <[EMAIL PROTECTED]>
> I've got a CSV file which I need to process.  The format is as
> follows.
> 
> "Smith, John J",1/1/2002,1/15/2002,"Orlando, FL",Florida
> "Doe, John L",1/1/2002,1/15/2002,Los Angeles, California
> 
> I've tried splitting it using:  @row = split(",",$data);
> 
> The problem is with the fields that contain the commas between the
> quotes. It's splitting the fields at each of these fields as well and
> I'd like to know how to avoid that.  

use Text::CVS_XS;

Jenda

= [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =
When it comes to wine, women and song, wizards are allowed 
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery


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




Re: write to file

2003-01-16 Thread simran
open(OUT, "> test.txt") || die;
print OUT "This is a test...\n";
print OUT "More text...\n";
close(OUT);

On Fri, 2003-01-17 at 08:26, [EMAIL PROTECTED] wrote:
> How can I write to a file in perl. 
> 
> Thomas


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




RE: Splitting a variable

2003-01-16 Thread Toby Stuart


> -Original Message-
> From: Scott, Joshua [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 17, 2003 10:12 AM
> To: [EMAIL PROTECTED]
> Subject: Splitting a variable
> 
> 
> I've got a CSV file which I need to process.  The format is 
> as follows.
> 
> "Smith, John J",1/1/2002,1/15/2002,"Orlando, FL",Florida
> "Doe, John L",1/1/2002,1/15/2002,Los Angeles, California
> 
> I've tried splitting it using:  @row = split(",",$data);
> 
> The problem is with the fields that contain the commas 
> between the quotes.
> It's splitting the fields at each of these fields as well and 
> I'd like to
> know how to avoid that.  
> 
> Any help is greatly appreciated!
> 

Get the Text::CSV_XS module

http://search.cpan.org/author/JWIED/Text-CSV_XS-0.23/CSV_XS.pm

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




RE: determining location of character in array....

2003-01-16 Thread Toby Stuart


> -Original Message-
> From: Liss, Mike [mailto:[EMAIL PROTECTED]]
> Sent: Friday, January 17, 2003 10:21 AM
> To: [EMAIL PROTECTED]
> Subject: determining location of character in array
> 
> 
> Hello,
>  
> Is there an easy way to get the location of a specific instance of a
> character 
> in an array?
>  
> for example:
>  
> $MyArray = "This is the test";
>  
> I would like to know the index of the first occurence of the 
> letter "h" ( 1
> )
>  

perldoc -f index


use strict;

my $s = 'This is a test';
my $i = index($s,'h');

print $i;


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




Re: Checking to see if input has valid data.

2003-01-16 Thread R. Joseph Newton
if ($TestEMail =~ /\w+@\w+\.\w{2,3}/) {print "$TestEMail\n";}

Joseph




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




Re: Script that runs on my Win98 box and the Unix server

2003-01-16 Thread R. Joseph Newton
"...Is there any way I can have two different paths to the Perl executable,
and let my script decide which to use?"  Rob

Hi Rob,

You shouldn't need to, probably.  At least on Win 2K, ActiveState Perl ignores the 
comment line completely.  If you have it properly installed, the paths should alredy 
be set, and *.pl should be r3egistered for the Perl executable.  If not, you should 
re-install with the latest version.  You will have to configure for perl CGIs in IIS, 
if you are using the native web services.

Joseph


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




  1   2   >