Re: help with compiling on win2000 with vs.net
lonnie percent wrote: hi all this is my first post and I need some help in compiling perl op sys win2000 pro I have vs.net 2003 I have cd'd to C:\PROGRA~1\MICROS~3.NET\VC7\BIN for nmake I another other instances of nmake in sdk\v1.1\bin but am using the above I ran vcvars23.bat PATH has c:\perl\perl-5.8.3\win32 I am compiling from the command line I execute: nmake c:\perl\perl-5.8.3\win32\Makefile cd c:\perl\perl-5.8.3\win32\ nmake -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Nested {}
On 6/29/2004 9:58 PM, David Arnold wrote: All, Suppose I have a number of lines in a latex file like this: \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can substitute to find a solution.} I'd like to scan the file and replace all of these with this format: \begin{answer} If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can substitute to find a solution. \end{answer} I'm looking for suggestions as to how to make this change with my perl script. I am puzzled by the use of nested braces and how I can be sure I've got everything between the opening and closing brace. You may want to take a look at Text::Balanced or Regexp::Common (the Regexp::Common::balanced subclass). For this type of work though, I generally prefer the more straightforward method of walking thru the file one char at a time, counting opening braces and substracting closing braces until the count reaches zero. At that point you can take the appropriate action. For this task, I really don't believe regexs offer any advantage and are probably slower (I'm sure Japhy will correct me if I'm wrong here). Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Favorite email parser?
On 6/29/2004 6:46 PM, Brian Gerard wrote: Hi all- I'm about to start a project that goes a little something like this... Right now, alerts get automatically emailed to a central address which due to the volume is largely ignored. You know the drill: Ooo! It would be great if we got notified when resource X is running low! Then we could anticipate the need for it and get ahead of the game. Repeat for resources A-Z, AA-ZZ, etc, etc and you get a mailbox that quickly becomes filled with alerts that no one reads, largely due to the fact that the reading alone would be a full time job. We can receive anywhere from a couple of hundred to a couple of thousand of these per day. Uhmm, perhaps a better solution is an organizational one. Alerts lose there efficacy when there are an overload of them. Perhaps you should reconsider what constitutes an alert. However, if you're using the term alert as a synonym for a todo then it would make sense to develop a solution like you propose. Just a thought, Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Favorite email parser?
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Brian Gerard) writes: Right now, alerts get automatically emailed to a central address which due to the volume is largely ignored. You know the drill: Ooo! It would be great if we got notified when resource X is running low! Then we could anticipate the need for it and get ahead of the game. Repeat for resources A-Z, AA-ZZ, etc, etc and you get a mailbox that quickly becomes filled with alerts that no one reads, largely due to the fact that the reading alone would be a full time job. We can receive anywhere from a couple of hundred to a couple of thousand of these per day. So I'm planning to set up the address to forward to a backline server, where my Brilliantly Written(tm) perl script will crunch said alerts. I'd like it to chop them up into little bits and insert the bits into an intelligently-structured database of some sort. I'm planning on Postgres at this point. Then there will be another script, available to the proper people via an internal website, where queries can be made against the database according to a yet-to-be-designed web interface. The main thing I want is a simplification of the alert viewing. So you might see 3245 instances of alert Y, which could be drilled down into based on various criteria, rather than the first page (out of 65) of 50 alerts all of the same type. Statistical trending and other such pie-chart-able things may show up in the future, but not for now. So my questions are these: 1) Does this sound like a reasonable approach to the problem, given the relatively low amount of detail I've provided? Yes. 2) From what I've read, Postgres beats MySQL performance-wise, which is why I chose it, but IANADBA. Any votes on a free DB to use for this? Which ever one you find easiest to set up. If performance turns out to be a problem, it's unlikely to make a difference which one you use. Judge by other criteria. Obviously, it needs to have a perl interface or CPAN module available. Regardless of which DB you like, what's your favorite module for interacting with it? DBI. And it won't make any difference what database you use. 3) Which module would you suggest for parsing email? There are a few of them out there, and I really don't have the time to try each one out until I find the one I like the best. :) Check out Email::Simple. Should be quite, er, simple. -- Peter Scott http://www.perldebugged.com/ *** NEW *** http://www.perlmedic.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Progress.....
Hi Thanx for the help Zentara. Here are a part of my code. I know that I'm doning stuff the long way so if anyone could show me a shorter way it will be helpfull. I wanted to put the sub's that I call into one but how? The progress meter have to show that it is still busy scanning the file, as soon as it is done and the file is closed, and the output have been given the meter should stop. I don't want the user to close the program before the job is done. Thanx Hi My program works thru long lists of word. How can I show the user that it is still busy and when it is done. Is there a progressmeter that I can insert into the while loop. To have a perl/tk interface for the user. Here is an example, you need to show us your code, if you want us to help you fit it into your script. #!/usr/bin/perl use strict; use warnings; use Tk; use Tk::ProgressIndicator; my $MainWindow = MainWindow-new(); my $total = 100;# this will vary my $ProgressIndicator = $MainWindow-ProgressIndicator ( '-current' = 0, '-limit' = 100, # this is fixed! '-increment' = 1, '-height' = 20, '-width' = 400 )-pack; foreach my $offset (0..$total) { $ProgressIndicator-configure ('-current' = $offset*100/$total,); $MainWindow-update; } MainLoop; toets_s.pl Description: Binary data -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Set value
Hi I have the next problem. The person push a button for set value, how do I get 'n popup windows with three values. $opt_t, $opt_v,$opt_c. It has to open a fle with that criteria, and have to create a file to save errors to with that criteria. It is for the usage that they have set. exsample of values : my $usage = Usage: $0 [OPTION}\.\.\. -v Version Version Nommer van leksikon -V Version Nuwe version nommer -t Taal Taal van leksikon -c Case Case van file waarmee werk -h Show this help and ; they then open the file as follow : open(KORREK, $opt_t.$opt_v.$opt_c.cwords.txt) or die $!: Korrek.uc.txt\n; and they send the tested result to : open(KORREK1, $opt_t.$opt_V.$opt_c.Reg vir leksikon.txt) or die $!: Korrek1.uc.txt\n; and then they write to the created file : foreach my $l (sort keys %korrek){ print KORREK1 $l\n; } I want them to set the value and test the files. The the output file shoud be written with the values and the name. Thanx -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Socket or NetServer::generic???
Hello, there I am progarmming a client server passed solution. My Question here ist which Modul I should use. I already noticed that the IO::Socket and the NetServer::Generic are both easy to use. My question is does a IO::Socket server handle multiple clients or not? Thank you, Bastian -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Checking for Senders via POP3
I want to check for specific senders (in my inbox) connecting to the Mail Server via POP3.(just checking the From : bla bla string) Not to download the inbox mails to my system. Thanks in advance
Re: Socket or NetServer::generic???
On Jun 30, 2004, at 3:49 AM, Bastian Angerstein wrote: Hello, there I am progarmming a client server passed solution. My Question here ist which Modul I should use. I already noticed that the IO::Socket and the NetServer::Generic are both easy to use. My question is does a IO::Socket server handle multiple clients or not? By itself, not really. To handle multiple clients you need to combine it with some sort of multiprocessing device: Threading, fork(), or non-blocking IO. These can be handled without a module, but it doesn't fall into the category you mentioned, easy to use. Just FYI, if you're going to be digging deep into networking, Network Programming with Perl is simply an excellent book. Good luck. James -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Favorite email parser?
::On Tuesday 29 June 2004 06:46 pm, Brian Gerard [EMAIL PROTECTED] wrote: ::Hi all- :: ::I'm about to start a project that goes a little something like this... :: ::Right now, alerts get automatically emailed to a central address which due ::to the volume is largely ignored. You know the drill: Ooo! It would be ::great if we got notified when resource X is running low! Then we could ::anticipate the need for it and get ahead of the game. Repeat for :: resources A-Z, AA-ZZ, etc, etc and you get a mailbox that quickly becomes :: filled with alerts that no one reads, largely due to the fact that the :: reading alone would be a full time job. We can receive anywhere from a :: couple of hundred to a couple of thousand of these per day. :: There's an open-source package out there called Nagios (www.nagios.org) which sounds like what your trying to accomplish. Nagios is written mostly in C (IIRC) and supports many different plugins (written in perl or C). -rak -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
questions and understanding
All, I was playing with my code and after re-reading perdoc perlre, I still do not understand the items in yellow and their need. here is my code. open(F,$ARGV[0]) || die dick face: $!\n; $i=0; print -w '; #print $i; while (F) { chomp($_); if ($i 0) { print or ; } $i++; print barcode=\$_\ ; } print \'\n; I will start from the bottom up: Why do I need or what is the significance of print \ ' \n; I really do not need the first \ ! At line print barcode it seems that do need the \ $_\ ; as when I take the \'s away I get these errors which I am not understanding: Scalar found where operator expected at parse_for_ejects.pl line 11, near barcode=$_ (Missing operator before $_?) String found where operator expected at parse_for_ejects.pl line 11, near $_ (Missing operator before ?) syntax error at parse_for_ejects.pl line 11, near barcode=$_ parse_for_ejects.pl had compilation errors. help in explaining. thanks, derek Derek B. Smith Ohiohealth IT UNIX, EDM, TSMSupport
Re: Favorite email parser?
--As of Tuesday, June 29, 2004 3:46 PM -0700, Brian Gerard is alleged to have said: snip 3) Which module would you suggest for parsing email? There are a few of them out there, and I really don't have the time to try each one out until I find the one I like the best. :) I've been just doing some research into this for a project I'm working on, and have been impressed by the Mail::Box module set. Of course, ask me in a couple weeks and my answer may change... But generally that module set looks to be able to do anything you would want to do with email. Others have covered the discussion well enough, I tend to concur with them. Mail::Box is excellent and incredibly thorough, which also means it is incredibly complex and has a pretty steep learning curve. It was by far the most robust mail handling I could find, and took me the longest to learn. It is also not the most efficient, but then that wasn't our goal. Just my $.02 on MB, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Socket or NetServer::generic???
On Jun 30, 2004, at 3:49 AM, Bastian Angerstein wrote: Hello, there I am progarmming a client server passed solution. My Question here ist which Modul I should use. I already noticed that the IO::Socket and the NetServer::Generic are both easy to use. My question is does a IO::Socket server handle multiple clients or not? By itself, not really. To handle multiple clients you need to combine it with some sort of multiprocessing device: Threading, fork(), or non-blocking IO. These can be handled without a module, but it doesn't fall into the category you mentioned, easy to use. Though it does appear that Netserver::Generic wraps much of what I figure you mean. Just FYI, if you're going to be digging deep into networking, Network Programming with Perl is simply an excellent book. Concur, and the topics covered in the book seem to be provided by the module he mentioned. Good luck. I would add you may want to check out POE, http://poe.perl.org, and I assume you aren't implementing one of the standard protocols that have already been implemented a thousand times, FTP, SMTP, HTTP, etc. You may also want to look at Proc::Daemon and Log::Log4perl. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
how to load the printer jobs number.
Hi, Anyone got a suggestion on how i can load the jobs in a printer? i use somethings like this: @jobs= `/usr/bin/lpstat -P HP2200V | cut -d- -f2 | cut -d -f1`; this show me something like this: 3259 3260 that are the number of the job for the HP2200V There are other way to do that? thank you __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Mail::POP3Client Doesn't Work on Win32 perl
I have This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) I also have the Mail::POP3Client but it doen;t connect to anywhere. Could you help me with that? john
Re: Checking for Senders via POP3
John wrote: I want to check for specific senders (in my inbox) connecting to the Mail Server via POP3.(just checking the From : bla bla string) Not to download the inbox mails to my system. This is one way: use Net::POP3; my $pop = Net::POP3-new($host) or die Couldn't connect: $!; my $cnt; unless ( defined ( $cnt = $pop-login($user, $pw) ) ) { $pop-quit; die Login error; } if ($cnt 0) { for my $num ( sort { $a = $b } keys %{ $pop-list } ) { print Msg $num - , grep /^From: /, @{ $pop-top($num) }; } } else { print No messages\n; } $pop-quit; I for one did not receive the result of your efforts so far. Maybe you forgot to paste it into the message you sent... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Checking for Senders via POP3
Your script doesn't get connect to anywhere. (netstat -a says nothing) I give the correct host , username, password and it doesn't work. Is the module broken? Net::POP3 (i use it on win32 active's distribution) - Original Message - From: Gunnar Hjalmarsson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 5:55 PM Subject: Re: Checking for Senders via POP3 John wrote: I want to check for specific senders (in my inbox) connecting to the Mail Server via POP3.(just checking the From : bla bla string) Not to download the inbox mails to my system. This is one way: use Net::POP3; my $pop = Net::POP3-new($host) or die Couldn't connect: $!; my $cnt; unless ( defined ( $cnt = $pop-login($user, $pw) ) ) { $pop-quit; die Login error; } if ($cnt 0) { for my $num ( sort { $a = $b } keys %{ $pop-list } ) { print Msg $num - , grep /^From: /, @{ $pop-top($num) }; } } else { print No messages\n; } $pop-quit; I for one did not receive the result of your efforts so far. Maybe you forgot to paste it into the message you sent... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: mapping
Please bottom post, and group reply so that everyone can help and be helped, and to prevent accidental ignoring of your post. Hello wiggins, Thanks, My requirement is i have two arrays @element and @size that i have got by splitting. Probably you should adjust the code at the 'split' time in anticipation of your future needs, the need for two arrays that are then combined is an indication of a design flaw. Post more code to have that looked over... I want to map first element of @element with first element of @size seperated with a colon . (in a loop how should i do it for all elements in arrays),i want this output in an array @mapped. for eg: file1 : 1 file2 : 2 file3 : 3 so if say print @c i should have output as follows file1 : 1 file2 : 2 file3 : 3 I am assuming the arrays are the same size... my @c; foreach my $index (0 .. $#element) { $c[$index] = $element[$index] : $size[$index]; } works? http://danconia.org snip old posts -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Favorite email parser?
-Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 3:48 PM To: Perl Beginners Subject: Re: Favorite email parser? Mail::Box is excellent and incredibly thorough, which also means it is incredibly complex and has a pretty steep learning curve. It was by far the most robust mail handling I could find, and took me the longest to learn. It is also not the most efficient, but then that wasn't our goal. I'm using with a lot success Mail::Box and I'm curious to know Which aspect of Mail::Box you found to be not effecient ? Thanks, José. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: questions and understanding
[EMAIL PROTECTED] wrote: All, I was playing with my code and after re-reading perdoc perlre, I still do not understand the items in yellow and their need. items in yellow??? here is my code. open(F,$ARGV[0]) || die dick face: $!\n; $i=0; print -w '; #print $i; while (F) { chomp($_); if ($i 0) { print or ; } $i++; print barcode=\$_\ ; } print \'\n; I will start from the bottom up: Why do I need or what is the significance of print \ ' \n; I really do not need the first \ ! You're correct. The backslash is not needed to escape single quotes within double quotes. At line print barcode it seems that do need the \ $_\ ; as when I take the \'s away I get these errors which I am not understanding: Double quotes must be quoted within double quotes. Otherwise, perl will think the string has ended. In the above example it would be translated as: print barcode= $_ ; And as the error below says, if this is your intention, their should be an operator before and after the $_ in order for it to be a valid instruction. If you want to use the double quotes in a string without the esapes, you can use a differnet quote character for your string: print qq{barcode=$_ }; Read the section Quote and Quote-like operators in `perldoc perlop` Scalar found where operator expected at parse_for_ejects.pl line 11, near barcode=$_ (Missing operator before $_?) String found where operator expected at parse_for_ejects.pl line 11, near $_ (Missing operator before ?) syntax error at parse_for_ejects.pl line 11, near barcode=$_ parse_for_ejects.pl had compilation errors. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Favorite email parser?
-Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 3:48 PM To: Perl Beginners Subject: Re: Favorite email parser? Mail::Box is excellent and incredibly thorough, which also means it is incredibly complex and has a pretty steep learning curve. It was by far the most robust mail handling I could find, and took me the longest to learn. It is also not the most efficient, but then that wasn't our goal. I'm using with a lot success Mail::Box and I'm curious to know Which aspect of Mail::Box you found to be not effecient ? Load time mostly, since it is a massive library. For our app that didn't matter much since it runs for months at a time and we have much more overhead with POE. We are also running off a pretty old version, and with all of the memory leak fixes and the C parser, it might be significantly better than when I was doing load testing (year ago). Doubt it would stack up compared to some of the other mail parsers, but then they wouldn't in feature list come even close, but that is really a hinderance of Perl in general rather than anything specific about MB. Essentially with the need for so many objects and doing everything through methods there is a fair amount of overhead even if you just want to do something trivial, but that *is* the point, it is a very good interface for doing non-trivial things. http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Checking for Senders via POP3
John wrote: Your script doesn't get connect to anywhere. It does for me. (netstat -a says nothing) Don't know what that is. I give the correct host , username, password and it doesn't work. Exactly what does doesn't work mean? What error message do you get? Is the module broken? No. Are you sure that the server you are trying to connect to has POP3 enabled? -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Favorite email parser?
-Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 6:14 PM To: NYIMI Jose (BMB); Perl Beginners Subject: RE: Favorite email parser? -Original Message- From: Wiggins d Anconia [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 3:48 PM To: Perl Beginners Subject: Re: Favorite email parser? Mail::Box is excellent and incredibly thorough, which also means it is incredibly complex and has a pretty steep learning curve. It was by far the most robust mail handling I could find, and took me the longest to learn. It is also not the most efficient, but then that wasn't our goal. I'm using with a lot success Mail::Box and I'm curious to know Which aspect of Mail::Box you found to be not effecient ? Load time mostly, since it is a massive library. For our app that didn't matter much since it runs for months at a time and we have much more overhead with POE. We are also running off a pretty old version, and with all of the memory leak fixes and the C parser, it might be significantly better than when I was doing load testing (year ago). Doubt it would stack up compared to some of the other mail parsers, but then they wouldn't in feature list come even close, but that is really a hinderance of Perl in general rather than anything specific about MB. Essentially with the need for so many objects and doing everything through methods there is a fair amount of overhead even if you just want to do something trivial, but that *is* the point, it is a very good interface for doing non-trivial things. Thanks for sharing ... José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: CGI-Perl fails to work on Solaris
Hi, My perl script which uses CGI module fails to work in Solaris giving Standard HTTP 500 Internal server error.I checked the Apache log. It says Premature end of script headers: But it works fine in HPUX and Windows. Is there any thing That has to be take care of in Solaris. Only that CGI be installed. Have you tried running the script from the command line and checking its output? Are the Perl versions, and CGI.pm versions identical? Generally the error you state is caused by either failure to execute the script at all, or something being printed before a proper header. If you try to run the script from the command line be sure to do it as the user the web server runs as, and note that the environment when logged in at a shell will be different than that of the web server's environment. Thanks in Advance. See if you can provide more info, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
recurisiveness
I have a script that recursively goes through the filesystem and changes links in html documents The problem I'm having is that it chokes on directories with spaces in there names. Does anyone have any suggestions on how to deal with this? I've tried using both glob and readdir to go through the directory. Glob doesnt error out, but it doesnt change the links in the documents and when using readdir I get this error message. Bad symbol for filehandle at ./recurse.pl line 15. Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: recurisiveness
On Wed, 30 Jun 2004 12:00:44 -0500, Joe Stuart wrote I have a script that recursively goes through the filesystem and changes links in html documents The problem I'm having is that it chokes on directories with spaces in there names. Does anyone have any suggestions on how to deal with this? I've tried using both glob and readdir to go through the directory. Glob doesnt error out, but it doesnt change the links in the documents and when using readdir I get this error message. Bad symbol for filehandle at ./recurse.pl line 15. Thanks A website with spaces in directory names? Yuck. Without seeing the code, hard to say, but try double-quoting the variable that contains the filename on this line number. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: recurisiveness
Joe Stuart wrote: I have a script that recursively goes through the filesystem and changes links in html documents The problem I'm having is that it chokes on directories with spaces in there names. Does anyone have any suggestions on how to deal with this? I noticed when answering another question that I needed to escape the space in a directory name when using it with glob. http://www.mail-archive.com/beginners%40perl.org/msg59282.html -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Checking for Senders via POP3
Hello John, Try the same script with a few modification. Good luck, Josimar code use Net::POP3; # #my $pop = Net::POP3-new($host) or die Couldn't connect: $!; #my $cnt; #unless ( defined ( $cnt = $pop-login($user, $pw) ) ) { # $pop-quit; # die Login error; #} #here is the modification--- $host = 'yourmailserver.yourdomain'; $user = '[EMAIL PROTECTED]'; $pw = 'yourpassword'; my $pop = Net::POP3-new($host, Timeout = 60) or die 'connect error'; $pop-user($user) or die 'login error'; my $cnt = $pop-pass($pw) or die 'authetication error'; #--- if ($cnt 0) { for my $num ( sort { $a = $b } keys %{ $pop-list } ) { print Msg $num - , grep /^From: /, @{ $pop-top($num) }; } } else { print No messages\n; } $pop-quit; /code - Original Message - From: John [EMAIL PROTECTED] To: Perl Beginners [EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 12:13 PM Subject: Re: Checking for Senders via POP3 Your script doesn't get connect to anywhere. (netstat -a says nothing) I give the correct host , username, password and it doesn't work. Is the module broken? Net::POP3 (i use it on win32 active's distribution) - Original Message - From: Gunnar Hjalmarsson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 5:55 PM Subject: Re: Checking for Senders via POP3 John wrote: I want to check for specific senders (in my inbox) connecting to the Mail Server via POP3.(just checking the From : bla bla string) Not to download the inbox mails to my system. This is one way: use Net::POP3; my $pop = Net::POP3-new($host) or die Couldn't connect: $!; my $cnt; unless ( defined ( $cnt = $pop-login($user, $pw) ) ) { $pop-quit; die Login error; } if ($cnt 0) { for my $num ( sort { $a = $b } keys %{ $pop-list } ) { print Msg $num - , grep /^From: /, @{ $pop-top($num) }; } } else { print No messages\n; } $pop-quit; I for one did not receive the result of your efforts so far. Maybe you forgot to paste it into the message you sent... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response - Original Message - From: John [EMAIL PROTECTED] To: Perl Beginners [EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 12:13 PM Subject: Re: Checking for Senders via POP3 Your script doesn't get connect to anywhere. (netstat -a says nothing) I give the correct host , username, password and it doesn't work. Is the module broken? Net::POP3 (i use it on win32 active's distribution) - Original Message - From: Gunnar Hjalmarsson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 5:55 PM Subject: Re: Checking for Senders via POP3 John wrote: I want to check for specific senders (in my inbox) connecting to the Mail Server via POP3.(just checking the From : bla bla string) Not to download the inbox mails to my system. This is one way: use Net::POP3; my $pop = Net::POP3-new($host) or die Couldn't connect: $!; my $cnt; unless ( defined ( $cnt = $pop-login($user, $pw) ) ) { $pop-quit; die Login error; } if ($cnt 0) { for my $num ( sort { $a = $b } keys %{ $pop-list } ) { print Msg $num - , grep /^From: /, @{ $pop-top($num) }; } } else { print No messages\n; } $pop-quit; I for one did not receive the result of your efforts so far. Maybe you forgot to paste it into the message you sent... -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: recurisiveness
Joe Stuart wrote: I have a script that recursively goes through the filesystem and changes links in html documents The problem I'm having is that it chokes on directories with spaces in there names. Does anyone have any suggestions on how to deal with this? I've tried using both glob and readdir to go through the directory. Glob doesnt error out, but it doesnt change the links in the documents and when using readdir I get this error message. Bad symbol for filehandle at ./recurse.pl line 15. Here is some code I've posted before. I think it works with spaces. #!/usr/bin/perl use strict; use warnings; use File::Spec; scan_dir('.'); my @dirstack; sub scan_dir { my $dir = shift; return unless -d $dir; my @subdirs; opendir DIR, $dir or die Can't open directory ($dir): $!\n; while (my $file = readdir DIR) { next if $file eq File::Spec-curdir() or $file eq File::Spec-updir(); my $path = File::Spec-catfile($dir, $file); if (-d $path) { push @subdirs, $file; next; } else { # = do something here = # print $path\n; } } closedir DIR; foreach my $subdir (@subdirs) { push @dirstack, $subdir; scan_dir(File::Spec-catdir($dir, $subdir)); pop @dirstack; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Using Perl on a UNIX box where you have no ADMIN rights....
I want to use perl thats installed on a server here at work. I want to install modules that will enhance my scripts, avoiding having to do calls to the shell for things that perl already has in place. How can i do this? I know that its more of a unix question, but I hope that there is something that can be done. Thanks. JC
Re: recurisiveness
Thanks that worked great [EMAIL PROTECTED] 06/30/04 12:22PM Joe Stuart wrote: I have a script that recursively goes through the filesystem and changes links in html documents The problem I'm having is that it chokes on directories with spaces in there names. Does anyone have any suggestions on how to deal with this? I've tried using both glob and readdir to go through the directory. Glob doesnt error out, but it doesnt change the links in the documents and when using readdir I get this error message. Bad symbol for filehandle at ./recurse.pl line 15. Here is some code I've posted before. I think it works with spaces. #!/usr/bin/perl use strict; use warnings; use File::Spec; scan_dir('.'); my @dirstack; sub scan_dir { my $dir = shift; return unless -d $dir; my @subdirs; opendir DIR, $dir or die Can't open directory ($dir): $!\n; while (my $file = readdir DIR) { next if $file eq File::Spec-curdir() or $file eq File::Spec-updir(); my $path = File::Spec-catfile($dir, $file); if (-d $path) { push @subdirs, $file; next; } else { # = do something here = # print $path\n; } } closedir DIR; foreach my $subdir (@subdirs) { push @dirstack, $subdir; scan_dir(File::Spec-catdir($dir, $subdir)); pop @dirstack; } } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
PERL Error when running MIME::Lite
Cannot locate MIME/Lite.pm in @INC. @INC contains: /usr/local/perl156/lib/5.6.1/PA-RISC2... Any one know about this? Thanks, JC
Re: PERL Error when running MIME::Lite
jason corbett wrote: Cannot locate MIME/Lite.pm in @INC. @INC contains: /usr/local/perl156/lib/5.6.1/PA-RISC2... Any one know about this? You need to install the MIME::Lite module. -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: PERL Error when running MIME::Lite
jason corbett wrote: How can I install it when I don't have root rights to place it in the bin? First, please reply to the list. Second, either get the person who does have root access to install the module or install it locally in your home dir and add it to your @INC (someone else can tell you how to do that). -- Andrew Gaffney Network Administrator Skyline Aeronautics, LLC. 636-357-1548 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
function that returns a HASH.
Hi all, I'm trying to use the Net::CUPS::Printer::cupsGetJobs() function. In theory this function returns the jobs a cups printer got printed or to be printed. I'm using this like: _BEGIN_ use Net::CUPS::Printer; my %jobs = cupsGetJobs('HP4100V',0,0); foreach $key (keys %jobs){ print $jobs{$key}; } _END_ and the function always returns somethings like this: HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8) How can i get this results in an human redable mode? Thank's __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Nested {}
Japhy, Thanks. These suggestions worked great! At 01:18 AM 6/30/04 -0400, you wrote: On Jun 29, David Arnold said: \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can substitute to find a solution.} I'd like to scan the file and replace all of these with this format: \begin{answer} If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can substitute to find a solution. \end{answer} To match nested things, you probably want to use Regexp::Common, which allows you to do that very easily: use Regexp::Common; $text =~ s \\ backans { ( $RE{balanced}{-parens='{}'} ) } \\begin{answer}\n$1\n\\end{answer}xg; The /x modifier is so that I can have extra whitespace, and the /g modifier means do it globally. The %RE hash is quite magical -- see the Regexp::Common docs for an explanation. The module isn't standard, though, so you'd have to download it from CPAN yourself. If you want a stand-alone solution, you can have one if you make use of some of Perl's special regex constructs: my $rx; # must be declared first... $rx = qr[ (?: (? [^{}\\]+ | \\. ) | { (??{ $rx }) } )* ]xs; $text =~ s/\\backans{($rx)}/\\begin{answer}\n$1\n\\end{answer}/g; Its primary trick is the (??{ ... }) assertion, which evaluates its contents as PART of the regex to match. Since its contents are $rx itself, it basically creates an automatically deeply-enough nested regex for you on the fly. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: function that returns a HASH.
On Wed, 30 Jun 2004 11:44:53 -0700 (PDT), Rod Za wrote: and the function always returns somethings like this: HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8) How can i get this results in an human redable mode? Hello Rod, to see what's going on in structured data types I strongly recommend the use of DATA::DUMPER. Just include the module into your source code and when you print the $jobs you just change your line to the following: print Dumper( $jobs{$key} ); The statement will print back the data structure with it's keys, instead of just giving you the data type and it's position in memory. Once you know which data key you want to access you can try the following: print $jobs{$key}-{$data_key}; Hope this helps. /oliver/ -- If you believe everything you read, you better not read. -Japanese Proverb -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: function that returns a HASH.
Oliver, this is wanderful! :) Thank you very much! --- Oliver Schnarchendorf [EMAIL PROTECTED] wrote: to see what's going on in structured data types I strongly recommend the use of DATA::DUMPER. Just include the module into your source code and when you print the $jobs you just change your line to the following: print Dumper( $jobs{$key} ); The statement will print back the data structure with it's keys, instead of just giving you the data type and it's position in memory. Once you know which data key you want to access you can try the following: print $jobs{$key}-{$data_key}; Hope this helps. /oliver/ -- If you believe everything you read, you better not read. -Japanese Proverb -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Searching ahead in a file
All, I have a file that is filled with exercises that was written in a brand of lamstex that I need to convert to latex. Exercises begin like this: \ex If $f(x)=x^2$, blah ... That is, I can count on each exercise beginning with the \ex macro. Now there are at times instructions for groups of exercises. They look like this: \begin{instructions} Blah, blah, blah, ... \end{instructions} As I begin reading in lines from the file, I just print them until I hit a line that has an opening \ex in it. At that point I want to accumulate lines in one long string until I hit either \begin{instructions} or another \ex. $line.=IN #unless the current line coming in from IN is the start #of a new \ex or a \begin{instructions} The difficulty is now I've read one line too many. I'd like to put this last line back for the next round of reading while I process the accumulated exercise lines. Is there a standard way of handling this difficulty? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
use, require or none of the above?
I have read the docs but I'm still not quite clear on the difference between use and require and if either is even needed. I just moved some code from one module to another. The orignal module has use Net::SMTP in it, but the module I moved the code to does not (it does use the first module though). I forgot to put the use line in the second module, but the code still works (I fully qualify it like my ${smtp} = new Net::SMTP( ${params{'server'}} );. Does that mean I don't need the use statements anywhere if I fully qualify? or does it work only because the second module uses the first module that uses Net::SMTP? I would like to avoid use statements if possible since they can result in compiler warnings about circular references and it seems to parse the library even when it doesn't need to, which seems like a performance concern. Any light anyone could shed on all this would be greatly appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: function that returns a HASH.
ok, i got the response: and the function always returns somethings like this: HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8) It's returning a reference to a hash. You can grab that reference into a scalar: my $hash_ref = function(); And then access it by de-referencing the reference: foreach my $key( keys %$hash_ref ) { print $hash_var-{$key}; } Or you can de-reference the hash ref when you call function: my %hash_var = %{ function() }; and access the values of %hash_var as you've written above. You may like to 'perldoc -f values' to see how to simplify both loops to something like this: foreach my $val ( values %$hash_ref ) { print $val; } perlreftut and perlref, both available via perldoc, explain references in more detail. I'd suggest starting with perlreftut; you can skip straight to the section labeled 'Syntax' if the history of references in perl isn't interesting to you. at london.pm.org --- Oliver Schnarchendorf [EMAIL PROTECTED] wrote: On Wed, 30 Jun 2004 11:44:53 -0700 (PDT), Rod Za wrote: and the function always returns somethings like this: HASH(0x81b99c4)HASH(0x81b988c)HASH(0x814fcf4)HASH(0x81b9c34)HASH(0x81b9afc)HASH(0x81a54f8) How can i get this results in an human redable mode? Hello Rod, to see what's going on in structured data types I strongly recommend the use of DATA::DUMPER. Just include the module into your source code and when you print the $jobs you just change your line to the following: print Dumper( $jobs{$key} ); The statement will print back the data structure with it's keys, instead of just giving you the data type and it's position in memory. Once you know which data key you want to access you can try the following: print $jobs{$key}-{$data_key}; Hope this helps. /oliver/ -- If you believe everything you read, you better not read. -Japanese Proverb -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response __ Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers! http://promotions.yahoo.com/new_mail -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Searching ahead in a file
On Jun 30, David Arnold said: As I begin reading in lines from the file, I just print them until I hit a line that has an opening \ex in it. At that point I want to accumulate lines in one long string until I hit either \begin{instructions} or another \ex. $line.=IN #unless the current line coming in from IN is the start #of a new \ex or a \begin{instructions} The difficulty is now I've read one line too many. I'd like to put this last line back for the next round of reading while I process the accumulated exercise lines. I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } This uses the seek() function to go to a position in the file. The last argument, 1, means we're moving relative to where we are now. The middle argument, -length, is the number of bytes to move. So if the line is 20 characters long, we're going 20 characters back from where we are now, essentially to the start of the line. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Searching ahead in a file
If the file is relatively small, why not read it into an array, then just manipulate the array index? Something like: my @{lines} = IN; close( IN ); my ${ln} = 0; while( ${ln} = $#lines + 1 ) { # check ${lines[${ln}]} and manipulate ${ln} accordingly. } I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } On Wed, 30 Jun 2004 16:32:00 -0400 (EDT), Jeff 'japhy' Pinyan wrote On Jun 30, David Arnold said: As I begin reading in lines from the file, I just print them until I hit a line that has an opening \ex in it. At that point I want to accumulate lines in one long string until I hit either \begin{instructions} or another \ex. $line.=IN #unless the current line coming in from IN is the start #of a new \ex or a \begin{instructions} The difficulty is now I've read one line too many. I'd like to put this last line back for the next round of reading while I process the accumulated exercise lines. I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } This uses the seek() function to go to a position in the file. The last argument, 1, means we're moving relative to where we are now. The middle argument, -length, is the number of bytes to move. So if the line is 20 characters long, we're going 20 characters back from where we are now, essentially to the start of the line. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Net::SMTP error handling
Unless otherwise stated all methods return either a *true* or *false* value, with *true* meaning that the operation was a success. So sayeth the perldocs, but where is information about the error? With docs like this do you assume it's ${!}, or could it be that other thing (I think I saw something like $^E on this list - what is that?), or some package variable? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Searching ahead in a file
Sorry, while( ${ln} = $#lines ) That $# starting with -1 thing really gets to me. On Wed, 30 Jun 2004 16:38:45 -0400, perl.org wrote If the file is relatively small, why not read it into an array, then just manipulate the array index? Something like: my @{lines} = IN; close( IN ); my ${ln} = 0; while( ${ln} = $#lines + 1 ) { # check ${lines[${ln}]} and manipulate ${ln} accordingly. } I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } On Wed, 30 Jun 2004 16:32:00 -0400 (EDT), Jeff 'japhy' Pinyan wrote On Jun 30, David Arnold said: As I begin reading in lines from the file, I just print them until I hit a line that has an opening \ex in it. At that point I want to accumulate lines in one long string until I hit either \begin{instructions} or another \ex. $line.=IN #unless the current line coming in from IN is the start #of a new \ex or a \begin{instructions} The difficulty is now I've read one line too many. I'd like to put this last line back for the next round of reading while I process the accumulated exercise lines. I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } This uses the seek() function to go to a position in the file. The last argument, 1, means we're moving relative to where we are now. The middle argument, -length, is the number of bytes to move. So if the line is 20 characters long, we're going 20 characters back from where we are now, essentially to the start of the line. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
pattern matching binary or garbage characters in string
I have a log file with thousands of lines, some of those lines come in with garbage / binary data in them. The lines with that happening are junk and of no use to me I want to pattern match for the junk and simply do nothing with that line, all other lines get divided into 2 different output files. The code that I have below will separate the lines into output files but does not take into account the garbage. # Split the lines into the appropriate files. while (LOGFILE) { if ( (/JUNIPER/)||(/REDBACK/) ){ print DSL $_ ; } else { print DIALUP $_ ; } } I have included one good line and one garbage line in this post, be aware though that outlook and other mail clients will convert the control characters in the garbage to single characters so the garbage lines below is not 100% accurate but you should get the jist. Good line: 06/16/2004,00:11:02,CVX_GUAYNABO_OLD,Stop,[EMAIL PROTECTED],200,username,10.xx.x4.1,1218,2,66.x3.x4.x7,7879592525,7877901623,C4536D6E:0005319,,0, Garbage line: 06/16/2004,00:11:02,ARECIBO2,Stop,Unknown,Unknown,T e2y8dM(Q99zq/k8a,^808185?9bcX*A83W8d2859I$ES_2A0cR+#T!k88nW8ae9393[92hed8380vC90,10.xx.x0.1,3145,7,,7879592000,7878781076,C390F9EB:00182BC,,0, Chris Hood Investigator Verizon Global Security Operations Center Email: mailto:[EMAIL PROTECTED] [EMAIL PROTECTED] Desk: 972.399.5900 Verizon Proprietary NOTICE - This message and any attached files may contain information that is confidential and/or subject of legal privilege intended only for the use by the intended recipient. If you are not the intended recipient or the person responsible for delivering the message to the intended recipient, be advised that you have received this message in error and that any dissemination, copying or use of this message or attachment is strictly forbidden, as is the disclosure of the information therein. If you have received this message in error please notify the sender immediately and delete the message.
Re: Searching ahead in a file
Japhy et al, This worked perfectly for what I want to do. Thanks to all of you, I am learning at a greater rate than by working alone. Many thanks. At 04:32 PM 6/30/04 -0400, Jeff 'japhy' Pinyan wrote: On Jun 30, David Arnold said: As I begin reading in lines from the file, I just print them until I hit a line that has an opening \ex in it. At that point I want to accumulate lines in one long string until I hit either \begin{instructions} or another \ex. $line.=IN #unless the current line coming in from IN is the start #of a new \ex or a \begin{instructions} The difficulty is now I've read one line too many. I'd like to put this last line back for the next round of reading while I process the accumulated exercise lines. I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } This uses the seek() function to go to a position in the file. The last argument, 1, means we're moving relative to where we are now. The middle argument, -length, is the number of bytes to move. So if the line is 20 characters long, we're going 20 characters back from where we are now, essentially to the start of the line. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Mail::POP3Client Doesn't Work on Win32 perl
Hello, John! That's very strange, I use this and this works fine (and at Uniz web-server too). How did you install this module and how do you use this? I have This is perl, v5.6.1 built for MSWin32-x86-multi-thread (with 1 registered patch, see perl -V for more detail) I also have the Mail::POP3Client but it doen;t connect to anywhere. Could you help me with that? john -- - Nicolay A. Vasiliev http://www.spamliquidator.com - Real spam fighter http://www.soft411.com - Excellent soft archive -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pattern matching binary or garbage characters in string
Christopher L Hood wrote: I have a log file with thousands of lines, some of those lines come in with garbage / binary data in them. The lines with that happening are junk and of no use to me I want to pattern match for the junk and simply do nothing with that line, all other lines get divided into 2 different output files. State your definition of garbage in a regex and make something like this the first line in the while loop: next if /[^\w\s,.:@\/-]/; -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Searching ahead in a file
what about if I wanted to move to the 10th element or 10th scaler as opposed to bytes or characters? I want to go to scaler 10 then \n then 3 more lines of 10 or less. If there were exactly 40 lines then obviously 4 lines of 10, but less than 40 first line = 10 and so on just as long each line does not exceed 10. like so: dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dsxxd edsxx edxxs eedx edsa edcsa dsxxd edsxx edxxs eedx edsa edcsa ecdsd edsd eddds edsad dedd defde ddefde wefwerf edewfew thanks, Derek B. Smith OhioHealth IT UNIX / TSM / EDM Teams David Arnold [EMAIL PROTECTED] 06/30/2004 05:52 PM To: [EMAIL PROTECTED] cc: [EMAIL PROTECTED] Subject:Re: Searching ahead in a file Japhy et al, This worked perfectly for what I want to do. Thanks to all of you, I am learning at a greater rate than by working alone. Many thanks. At 04:32 PM 6/30/04 -0400, Jeff 'japhy' Pinyan wrote: On Jun 30, David Arnold said: As I begin reading in lines from the file, I just print them until I hit a line that has an opening \ex in it. At that point I want to accumulate lines in one long string until I hit either \begin{instructions} or another \ex. $line.=IN #unless the current line coming in from IN is the start #of a new \ex or a \begin{instructions} The difficulty is now I've read one line too many. I'd like to put this last line back for the next round of reading while I process the accumulated exercise lines. I would suggest the following approach: # some bigger loop while (...) { my $line = ; while (IN) { if (/\\ex|\\begin{instructions}/) { seek IN, -length, 1; last; } $line .= $_; } } This uses the seek() function to go to a position in the file. The last argument, 1, means we're moving relative to where we are now. The middle argument, -length, is the number of bytes to move. So if the line is 20 characters long, we're going 20 characters back from where we are now, essentially to the start of the line. -- Jeff japhy Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ CPAN ID: PINYAN[Need a programmer? If you like my work, let me know.] stu what does y/// stand for? tenderpuss why, yansliterate of course. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Searching ahead in a file
On 6/30/2004 4:38 PM, perl.org wrote: If the file is relatively small, why not read it into an array, then just manipulate the array index? Something like: my @{lines} = IN; Small pet peeve: slurping entire files is a bad habbit in general. Once your program allocates memory, it can never be freed even if you undefine every variable in your script. Use only what you need: no more, no less. Some tasks do require being able to see the entire file at once; these are rare and are probably the only exception. Even small files are better handled one piece at a time. Buffering input is generally the most efficient way of handling the peek ahead problem. It saves you from having to seek back and forth in the file which is relatively expensive. Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pattern matching binary or garbage characters in string
On 6/30/2004 5:20 PM, [EMAIL PROTECTED] wrote: I have a log file with thousands of lines, some of those lines come in with garbage / binary data in them. The lines with that happening are junk and of no use to me I want to pattern match for the junk and simply do nothing with that line, all other lines get divided into 2 different output files. The code that I have below will separate the lines into output files but does not take into account the garbage. # Split the lines into the appropriate files. while (LOGFILE) { if ( (/JUNIPER/)||(/REDBACK/) ){ print DSL $_ ; } else { print DIALUP $_ ; } } I have included one good line and one garbage line in this post, be aware though that outlook and other mail clients will convert the control characters in the garbage to single characters so the garbage lines below is not 100% accurate but you should get the jist. try either: /[:print:]/ print junk; # or # use utf8; /\p{IsPrint}/ print junk; see `perldoc perlre` for info on POSIX Unicode character classes. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: pattern matching binary or garbage characters in string
On Wednesday 30 June 2004 15:07, Randy W. Sims wrote: try either: /[:print:]/ print junk; So you are saying that the characters ':', 'p', 'r', 'i', 'n' and 't' are junk? You probably meant to use the character class [^[:print:]] or [[:^print:]] instead. :-) John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: help with compiling on win2000 with vs.net
thanks - I got a little further but still no cigar. now I get perlglob.c(6) : fatal error C1083: Cannot open include file: 'stdio.h': No such file or directory NMAKE : fatal error U1077: 'cl' : return code '0x2' Stop. I have C:\PROGRA~1\MICROS~3.NET\VC7\include in my path I have USE_PERLIO = define the other places on my system stdio.h exists ar C:\PROGRA~1\MICROS~3.NET\VC7\crt\src c:\perl\perl-5.8.3\mint TIA Lonnie -Original Message- From: Randy W. Sims [mailto:[EMAIL PROTECTED] Sent: Wednesday, June 30, 2004 12:46 AM To: lonnie percent Cc: [EMAIL PROTECTED] Subject: Re: help with compiling on win2000 with vs.net lonnie percent wrote: hi all this is my first post and I need some help in compiling perl op sys win2000 pro I have vs.net 2003 I have cd'd to C:\PROGRA~1\MICROS~3.NET\VC7\BIN for nmake I another other instances of nmake in sdk\v1.1\bin but am using the above I ran vcvars23.bat PATH has c:\perl\perl-5.8.3\win32 I am compiling from the command line I execute: nmake c:\perl\perl-5.8.3\win32\Makefile cd c:\perl\perl-5.8.3\win32\ nmake -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response