Re: How to email my results to a group of people....
If you do want to use perl, you can use dozens of perl modules. Learn MIME::Parser that will help you in lot of projects. But to be frank , just for sending attachments you dont need to write a perl script ( Though it is fairly simple ) . Just use mutt mutt -a attachment.file -f fromid -s SUBJECT toid content.file HTH ram On Tue, 2004-06-29 at 04:10, jason corbett wrote: I have a script that is automated every morning. I want to send this out to the team without logging onto the network and emailing the file from a shell script that i also wrote like this: `mailx -s Email Header [EMAIL PROTECTED] filename.txt`; so, I hear PEAL has emailing (in attachment format) capabilities? I down-loaded the module MIME::Lite, but I am not sure how to get this going. Can anyone help? Or is there a better (or other) way? Regards, JC -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: matching only digits
Guruguhan N wrote: Hi All, Hello, I wanted to check whether the user input is only a number and does contain any alphabet/s anywhere i.e. starting, end or in-between. Can somebody tell me how to do this? That is a Frequently Asked Question and can be found in the standard perl documentation (perlfaq4) by running this on the command line: perldoc -q How do I determine whether a scalar is a number/whole/integer/float 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: string seperated by multiple spaces
Michelle Rogers wrote: The point is...if you're wanting to help beginnersbe nicedon't jump down their throatsI'd prefer not to have that type of help. Use Charles K. Clarkson, as an example. He said the exact same thing, but said it in a way that it should be said to beginners. I guess I'm taking it upon myself to say this because I don't intend to stay in this group (and may have decided not to this morning, after that message, if I hadn't already decided that)...I've decided to use euphoria instead of perl for what i'm doing. And, i guess i'm thinking that someone needs to protect the young and innocent. That person that you just jumped down their throat may have been the person who was going to code the greatest software the world has ever seen.but the way that was handled...they may give up and never try again. Golden Rule: Do to others, as you would want them to do to you. And while you might argue that you would want people to point out things to correct, if it were you, I'd daresay that you also would want them to do it nicely. Ah yes, good advice. I try to set a good example by not TOP POSTING but some people just don't GET IT (whatever IT is.) Most times it is very hard to teach people over a text only medium especially when you are trying to teach people who don't know what they don't know. :-) 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: recursive grep for Windows
Perl.Org wrote: Can anyone share a script that recurses a filesystem for files containing one or more patterns? Seems like it would be easy to write but if it's already out there... This will probably work: #!/usr/bin/perl use warnings; use strict; use File::Find; my $dir = shift || '.'; $/ = \2_048; # set buffer size to 2,048 bytes, YMMV find( sub { local @ARGV = $File::Find::name; my $last = ''; while ( ) { $_ = $last . $_; if ( /pattern1/ or /pattern2/ or /pattern3/ ) { print $ARGV\n; close ARGV; return; } $last = $_; } }, $dir ); __END__ 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: newline to br
Papo Napolitano wrote: I have a textarea on a webpage that gets stored in a database. I'd like to convert the newline to an HTML br before it gets stored so when I display it, the line breaks as it was typed. I've been looking around but haven't found an example. $text =~ s/\r\n/br/g; doesn't work. --charlie $text =~ s/\r\n/br/gs; The /s option only effects the behavior of the . metacharacter which isn't used in that regular expression. 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: parsing large amounts of text
Andrew Gaffney wrote: I'm working on a custom Perl script to parse my Apache logs and report custom information. When I run the following program, it ends up eating all available RAM (the system has 1GB) and dying. My access_log is ~410MB. Am I doing something wrong? The only problems I can see is that your regular expression is inefficient and your AoA @requests may get very large. #!/usr/bin/perl use strict; use warnings; use CGI(); my $months = { Jan = 1, Feb = 2, Mar = 3, Apr = 4, May = 5, Jun = 6, Jul = 7, Aug = 8, Sep = 9, Oct = 10, Nov = 11, Dec = 12 }; my @requests; my $start = time; open LOG, /var/log/apache/access_log; You should *ALWAYS* verify that the file opened correctly. open LOG, ' /var/log/apache/access_log' or die Cannot open '/var/log/apache/access_log' $!; while(LOG) { my $line = $_; Why not just: while ( my $line = LOG ) { Why use $line at all? $line =~ /^(\d+\.\d+\.\d+\.\d+) (.+?) (.+?) \[(.+?)\] \(?:(.+?) )?(.+)(?: (.+?))?\ (\d+) (.+?) \(.+?)\ \(.+?)\$/; If you are not using $2, $3, $5, $7 and $10 why capture them? You should probably replace .+? with something more meaningful that won't backtrack. my ($ip, $date, $request, $requestcode, $bytesreturned, $browser) = ($1, $4, $6, $8, $9, $11); You shouldn't use the numererical scalars unless the regular expression succeeded or they will just contain the values from the last successful match. $request = CGI::unescape($request); push @requests, [$ip, $date, $request, $requestcode, $bytesreturned, $browser]; } I would write that while loop as: while ( LOG ) { my @fields = /^(\d+\.\d+\.\d+\.\d+) .+? .+? \[(.+?)\] (?:.+? )?(.+)(?:.+?)? (\d+) (.+?) .+? (.+?)$/ or next; $fields[ 2 ] = CGI::unescape( $fields[ 2 ] ); push @requests, [EMAIL PROTECTED]; } my $end = time; my $elapsed = $end - $start; close LOG; print $#requests total records. $elapsed seconds elapsed\n; 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: Creating images
This does exactly what I want, except I used the output code from JupiterHost.Net's suggestion, as i wanted to output straight to the browser, not to a file. The only other issue I'd have, is it possible to change the font of Custom Text to Tahoma? If so, how do it do it, and do I need any additional files? Cheers, Dan Randy W. Sims [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 6/25/2004 6:56 PM, dan wrote: Hi all, again! I'm attempting to make a web page, where all the buttons are dynamic, where dynamic I say there's 1 template button image with nothing written on it, and I want to put requests into a html page to call a script as an image to put text on top of the image, then output as 1 image. Does this make sense what I'm try to do? Is this even possible? If so, what's the best way of going about it, as I have absolutely no idea where to start on this one. I've aquired Apache::ImageMagick, but can't make head nor tail of the readme. Try the GD module. I think it does what you want. (untested) use GD; my $img = GD::Image-newFromJpeg( $file ); my $black = $img-colorAllocate( 0, 0, 0 ); $img-string( gdSmallFont, 10, 10, 'Custom Text', $black ); open( FH, 'outfile' ) or die; binmode( FH ); print FH $img-png(); close( FH ); __END__ Regards, Randy. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Assigning a variable to hash keys and values
Hello All, I currently have a hash of a hash... %HoH = ( Key1= { Apple = Green, Banna = Yellow, }, Key2= { Carrot= Orange, Tomoatoe = Red, }, ); How can I assign Key2 to a variable? Regards, Dan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Assigning a variable to hash keys and values
On Tue, 2004-06-29 at 12:19, Daniel Falkenberg wrote: Hello All, I currently have a hash of a hash... %HoH = ( Key1= { Apple = Green, Banna = Yellow, }, Key2= { Carrot= Orange, Tomoatoe = Red, }, ); How can I assign Key2 to a variable? I think you mean the value of Key2 to a variable right ? If you want a hash variable use %hash = %{$HoH{Key2}} Of course this way the hash is *copied* into %hash and now changing %hash does not affect the %HoH data Bye Ram -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Progress.....
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. Thanx Me Charlene Gentle E-pos/E-mail: [EMAIL PROTECTED] Hierdie boodskap (en aanhangsels) is onderhewig aan beperkings en 'n vrywaringsklousule. Volledige besonderhede beskikbaar by http://www.puk.ac.za/itb/e-pos/disclaimer.html , of by [EMAIL PROTECTED] This message (and attachments) is subject to restrictions and a disclaimer. Please refer to http://www.puk.ac.za/itb/e-pos/disclaimer.html for full details, or at [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Assigning a variable to hash keys and values
On Tuesday 29 June 2004 08:49, Daniel Falkenberg wrote: Hello All, Hi Dan, I currently have a hash of a hash... %HoH = ( Key1= { Apple = Green, Banna = Yellow, }, Key2= { Carrot= Orange, Tomoatoe = Red, }, ); How can I assign Key2 to a variable? # If you want to assign Key2's value, you could so something like: my $key2_ref = $HoH{Key2}; print key2_ref : $key2_ref\n; # Note that $key2_ref contains a hash-ref now, so if you want to use it as a # hash, you should tell perl that you want to use it as an hash: my %key2_hash = %{$key2_ref}; print key2-carrot : . $key2_hash{Carrot} . \n; # You can use the same technique to access the inner hashes: my $carrot_color = ${$HoH{Key2}}{Carrot}; print carrot color : $carrot_color\n; # Theres another version of accessing a value of a hash ref # that more pleasant to the eye: my $carrot_color2 = $HoH{Key2}-{Carrot}; print carrot color 2 : $carrot_color2\n; Take a look at perldoc perlreftut It's a very good (and short) tutorial about references that explains all this much better than I can. HTH, Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Assigning a variable to hash keys and values
Daniel Falkenberg wrote: Hello All, Hello, I currently have a hash of a hash... %HoH = ( Key1= { Apple = Green, Banna = Yellow, }, Key2= { Carrot= Orange, Tomoatoe = Red, }, ); How can I assign Key2 to a variable? my $variable = $HoH{ Key2 }; 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: Creating images
LRMK - Original Message - From: dan [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, June 29, 2004 3:33 AM Subject: Re: Creating images This does exactly what I want, except I used the output code from JupiterHost.Net's suggestion, as i wanted to output straight to the browser, not to a file. The only other issue I'd have, is it possible to change the font of Custom Text to Tahoma? If so, how do it do it, and do I need any additional files? Cheers, Dan Randy W. Sims [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] On 6/25/2004 6:56 PM, dan wrote: Hi all, again! I'm attempting to make a web page, where all the buttons are dynamic, where dynamic I say there's 1 template button image with nothing written on it, and I want to put requests into a html page to call a script as an image to put text on top of the image, then output as 1 image. Does this make sense what I'm try to do? Is this even possible? If so, what's the best way of going about it, as I have absolutely no idea where to start on this one. I've aquired Apache::ImageMagick, but can't make head nor tail of the readme. Try the GD module. I think it does what you want. (untested) use GD; my $img = GD::Image-newFromJpeg( $file ); my $black = $img-colorAllocate( 0, 0, 0 ); $img-string( gdSmallFont, 10, 10, 'Custom Text', $black ); # open( FH, 'outfile' ) or die; #binmode( FH ); #print FH $img-png(); #close( FH ); #To output to the browser use the following method print Cache-Control: no-cache\n;#probably you will need this line to stop browsing from caching your output print Content-Type: image/png\n\n; #tell the browser and the server what type of data that you are sending binmode(STDOUT); print $img-png(); __END__ Regards, Randy. -- 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: Creating images
dan wrote: The only other issue I'd have, is it possible to change the font of Custom Text to Tahoma? If so, how do it do it, and do I need any additional files? see `perldoc GD` : look for the 'stringFT' method see also `perldoc GD::Text` example: $img-stringFT( $black, # color ref 'path/too/tahoma.ttf', # absolute path to TTF 12,# point size 0 # rotation angle $x,$y, $string ); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: is perl a script language?
On Sunday 27 June 2004 03:06 pm, lfm wrote: hello ,beau I have installed bugzilla on the windows, but failed on the linux! where? the perl module installation! I download the perl module from cpan, tar them and perl Makefile.PL make make test make install But some of them failed ! e.g. DBD-mysql-2.9003 --- [EMAIL PROTECTED] bugzilla]# cd DBD-mysql-2.9003/ [EMAIL PROTECTED] DBD-mysql-2.9003]# ls ChangeLogdbdimp.c INSTALL.html Makefile.PL MANIFEST.SKIP mysql.xs t constants.h dbdimp.h lib MANIFEST myld README TODO [EMAIL PROTECTED] DBD-mysql-2.9003]# perl Makefile.PL Can't exec mysql_config: No such file or directory at Makefile.PL line 174. readline() on closed filehandle PIPE at Makefile.PL line 176. Can't exec mysql_config: No such file or directory at Makefile.PL line 174. readline() on closed filehandle PIPE at Makefile.PL line 176. Can't exec mysql_config: No such file or directory at Makefile.PL line 174. readline() on closed filehandle PIPE at Makefile.PL line 176. Can't exec mysql_config: No such file or directory at Makefile.PL line 174. readline() on closed filehandle PIPE at Makefile.PL line 176. Can't exec mysql_config: No such file or directory at Makefile.PL line 174. readline() on closed filehandle PIPE at Makefile.PL line 176. Failed to determine directory of mysql.h. Use perl Makefile.PL --cflags=-Idir to set this directory. For details see the INSTALL.html file, section C Compiler flags or type perl Makefile.PL --help --- so ,can you help? Have you installed mysql on your Linux box? If not, do that first; Configure it and find out where the two files above (mysql_config and mysql.h) are, read the DBD-mysql docs, and it should work. Aloha = Beau; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Creating images
dan wrote: The only other issue I'd have, is it possible to change the font of Custom Text to Tahoma? If so, how do it do it, and do I need any additional files? see `perldoc GD` : look for the 'stringFT' method see also `perldoc GD::Text` example: $img-stringFT( $black, # color ref 'path/too/tahoma.ttf', # absolute path to TTF 12,# point size 0 # rotation angle $x,$y, $string ); -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Hi All, I have two arrays @a and @b, each of the arrays have lotz of elements. what i want is the first element of @a should be assigned the first element of array @b. The result should be combined in one array @c, so that i can send the @c mail. I have a rough idea that we can in HASH, but not sure. can sombody help me out rgds jack - Do you Yahoo!? Yahoo! Mail - 50x more storage than other providers!
Re: mail
Jack Jack wrote: I have two arrays @a and @b, each of the arrays have lotz of elements. what i want is the first element of @a should be assigned the first element of array @b. The result should be combined in one array @c, so that i can send the @c mail. I have a rough idea that we can in HASH, but not sure. Is this what you mean: my %c; # declares the hash %c @c{ @a } = @b; # populates %c using a hash slice Not that I understand how this relates to sending mails... -- 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: mail
Please use a more descriptive subject line, such as Combining arrays of email addresses... Hi All, I have two arrays @a and @b, each of the arrays have lotz of elements. what i want is the first element of @a should be assigned the first element of array @b. Do you mean the first element of @a and @b should be associated, or you really do want to assign (read: clobber) $a[0] with $b[0]?? It might help if you used more descriptive array names. # Assignment (clobbering) @a = @b; # Association (hash slice) my %associated; @associated{ @a } = @b; The result should be combined in one array @c, so that i can send the @c mail. What's the result and how are they to be combined? push @c, @a, @b; # ??? I have a rough idea that we can in HASH, but not sure. can sombody help me out Can what? Remember we can't read your thoughts, you need to be as explicit as possible. 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
Extracting fields from a data file
Hi all, I have input file like this: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,root,other,315,565690, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,dba,5, subject,bscs,sgrp,9936,6785,0 ,return,success,0 (line2) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,tom,other,315,56,11,54,77,10,88, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line3) --- I need to generate an output file like this (deleting fields between attribute and subject, please note that number of those fields is variable): --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0(line 3) --- Thanks a lot , CHAFIK -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
Hi all, I have input file like this: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,root,other,315,565690, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,dba,5, subject,bscs,sgrp,9936,6785,0 ,return,success,0 (line2) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,tom,other,315,56,11,54,77,10,88, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line3) --- I need to generate an output file like this (deleting fields between attribute and subject, please note that number of those fields is variable): --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0(line 3) --- What have you tried, where did you fail? Asking for free solutions isn't well looked upon... 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: Extracting fields from a data file
mohammed chafik wrote: Hi all, I have input file like this: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,root,other,315,565690, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) ... I need to generate an output file like this (deleting fields between attribute and subject, please note that number of those fields is variable): --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) ... I would take the input line and split on comma into an array. It looks like you want to keep the first 4 elements, and then shift the element starting with subject over into the fifth slot. Am I right? I'd just call splice() in a loop to remove one element at a time until 'subject' slides into the fifth element. Then you're done. perldoc -f split perldoc -f splice Show us your program if you want more help than that :~) HTH -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Installing a module when you have limited permissions
Hello. I wanted to know if someone has installed a PERL module on a server where they had limitied permissions? I am not extremely UNIX savy but I do know the basic and know the something about the file structures, etc. Can someone tell me how I can install MIME::Lite on a server where I may use it, and give others permission to use my install? Thanks, JC
RE: Installing a module when you have limited permissions
jason corbett wrote: Hello. I wanted to know if someone has installed a PERL module on a server where they had limitied permissions? I am not extremely UNIX savy but I do know the basic and know the something about the file structures, etc. Can someone tell me how I can install MIME::Lite on a server where I may use it, and give others permission to use my install? perldoc -q 'How do I keep my own module/library directory?' -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
Bob Showalter wrote: mohammed chafik wrote: I have input file like this: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,root,other,315,565690, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) ... I need to generate an output file like this (deleting fields between attribute and subject, I would take the input line and split on comma into an array. It looks like you want to keep the first 4 elements, and then shift the element starting with subject over into the fifth slot. Am I right? I'd just call splice() in a loop to remove one element at a time until 'subject' slides into the fifth element. Then you're done. perldoc -f split perldoc -f splice I'd use the m// operator: /(.+)attribute.+( subject.+)/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
ways to change the first char from a filename (with full path)
Hi all, i'm trying to make a code that get a file name (with full path) and change the first char of the filename. Someone can say me if there's a better way to do this?: _BEGIN_ #!/usr/bin/perl -w my($file) = $ARGV[0]; #receives the filename my @tmp = split(/\//,$file); #split the path $tmp[$#tmp] =~ s/.(\w+)/c$1/g;#change the first char of the filename my $IPPFile = join('/',@tmp); #join again path+'/'+filename print Original Filename: $file - Changed Filename: $IPPFile\n; #print the result _END_ e.g. ./filename.pl /var/spool/cups/d1 will print: Original Filename: /var/spool/cups/d1 - Changed Filename: /var/spool/cups/c1 Thank you. Rod __ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! 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: Installing a module when you have limited permissions
Jason Corbett wrote: I wanted to know if someone has installed a PERL module on a server where they had limitied permissions? It depends on what you mean by limited permissions. If you have shell access, you can follow the FAQ answer Bob pointed you to. If not, and provided that it's a plain Perl module, you can simply upload it with e.g. an FTP program. This documentation includes instructions how to do that: http://search.cpan.org/perldoc?CGI%3A%3AContactForm (see Manual Installation) -- 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: parsing large amounts of text
John W. Krahn wrote: Andrew Gaffney wrote: I'm working on a custom Perl script to parse my Apache logs and report custom information. When I run the following program, it ends up eating all available RAM (the system has 1GB) and dying. My access_log is ~410MB. Am I doing something wrong? The only problems I can see is that your regular expression is inefficient and your AoA @requests may get very large. #!/usr/bin/perl use strict; use warnings; use CGI(); my $months = { Jan = 1, Feb = 2, Mar = 3, Apr = 4, May = 5, Jun = 6, Jul = 7, Aug = 8, Sep = 9, Oct = 10, Nov = 11, Dec = 12 }; my @requests; my $start = time; open LOG, /var/log/apache/access_log; You should *ALWAYS* verify that the file opened correctly. open LOG, ' /var/log/apache/access_log' or die Cannot open '/var/log/apache/access_log' $!; while(LOG) { my $line = $_; Why not just: while ( my $line = LOG ) { Why use $line at all? $line =~ /^(\d+\.\d+\.\d+\.\d+) (.+?) (.+?) \[(.+?)\] \(?:(.+?) )?(.+)(?: (.+?))?\ (\d+) (.+?) \(.+?)\ \(.+?)\$/; If you are not using $2, $3, $5, $7 and $10 why capture them? You should probably replace .+? with something more meaningful that won't backtrack. my ($ip, $date, $request, $requestcode, $bytesreturned, $browser) = ($1, $4, $6, $8, $9, $11); You shouldn't use the numererical scalars unless the regular expression succeeded or they will just contain the values from the last successful match. $request = CGI::unescape($request); push @requests, [$ip, $date, $request, $requestcode, $bytesreturned, $browser]; } I would write that while loop as: while ( LOG ) { my @fields = /^(\d+\.\d+\.\d+\.\d+) .+? .+? \[(.+?)\] (?:.+? )?(.+)(?:.+?)? (\d+) (.+?) .+? (.+?)$/ or next; $fields[ 2 ] = CGI::unescape( $fields[ 2 ] ); push @requests, [EMAIL PROTECTED]; } my $end = time; my $elapsed = $end - $start; close LOG; print $#requests total records. $elapsed seconds elapsed\n; John I had originally wrote this program about 6 months ago when I still had a lot more Perl bad habits. I just started expanding upon the program without really thinking about all that. I'll take your suggestions, though. -- 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
creating a table in Microsoft Word
Does anyone know how to access Microsoft Word and create a table? Henri [EMAIL PROTECTED]
RE: ways to change the first char from a filename (with full path )
Rod Za wrote: Hi all, i'm trying to make a code that get a file name (with full path) and change the first char of the filename. Someone can say me if there's a better way to do this?: _BEGIN_ #!/usr/bin/perl -w use strict; my($file) = $ARGV[0]; #receives the filename my $file = shift;(the traditional idiom) my @tmp = split(/\//,$file); #split the path use File::Basename; my ($name, $path) = fileparse($file); (more portable) $tmp[$#tmp] =~ s/.(\w+)/c$1/g;#change the first char of the filename substr($name, 0, 1) = 'c'; (no need for regex) my $IPPFile = join('/',@tmp); #join again path+'/'+filename print Original Filename: $file - Changed Filename: $IPPFile\n; #print the result _END_ use File::Spec print Original name: , $file, Changed name: , File::Spec-catfile($path, $name), \n; You might also have a look at the ubiquitous (and ancient) perl rename script: http://www.cpan.org/scripts/nutshell/ch6/rename -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: ways to change the first char from a filename (with full path)
use File::Basename; -Thomas Kinzer Original Message Follows From: Rod Za [EMAIL PROTECTED] To: [EMAIL PROTECTED] Subject: ways to change the first char from a filename (with full path) Date: Tue, 29 Jun 2004 09:03:42 -0700 (PDT) Hi all, i'm trying to make a code that get a file name (with full path) and change the first char of the filename. Someone can say me if there's a better way to do this?: _BEGIN_ #!/usr/bin/perl -w my($file) = $ARGV[0]; #receives the filename my @tmp = split(/\//,$file); #split the path $tmp[$#tmp] =~ s/.(\w+)/c$1/g; #change the first char of the filename my $IPPFile = join('/',@tmp); #join again path+'/'+filename print Original Filename: $file - Changed Filename: $IPPFile\n; #print the result _END_ e.g. ./filename.pl /var/spool/cups/d1 will print: Original Filename: /var/spool/cups/d1 - Changed Filename: /var/spool/cups/c1 Thank you. Rod __ Do you Yahoo!? New and Improved Yahoo! Mail - 100MB free storage! 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 _ FREE pop-up blocking with the new MSN Toolbar get it now! http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
On Tuesday 29 June 2004 17:04, mohammed chafik wrote: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,tom,other,315,56,11,54,77,10,88, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line3) --- I need to generate an output file like this (deleting fields between attribute and subject, please note that number of those fields is variable): --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) I'd use a regular expression to pull out the parts before attribute and after subject (maybe including it, depends on what you want) and just concatenate them together. Take a look at perldoc perlre If you need help with the regex, let us know. HTH, Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
That's what i've tried (may be it is not the best approch); Any way, My script doesn't work, it returns an error message (Use of uninitialized value at formater.pl line 22, INDATA chunk 4.) - #!/usr/local/bin/perl -w $i=1; $k=1; open (INDATA, in_file.txt) || die(Can't open in file); open (OUTDATA, out_file.txt) || die(Can't open out file); while( $line = INDATA ) { chomp; @fields = split(,, $_); for ($i = 0; $i 400; $i++) { if( $fields[$i]=~ /subject/ ) { $k=$i} } $line = join(:, $fields[0], $fields[2],$fields[$k], $fields[$k+1]); print OUTDATA $line\n; } close INDATA; close OUDATA; --- Thanks ; CHAFIK - Original Message - From: Wiggins d Anconia Date: Tue, 29 Jun 2004 09:07:09 -0600 To: mohammed chafik , [EMAIL PROTECTED] Subject: Re: Extracting fields from a data file Hi all, I have input file like this: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,root,other,315,565690, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,dba,5, subject,bscs,sgrp,9936,6785,0 ,return,success,0 (line2) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,tom,other,315,56,11,54,77,10,88, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line3) --- I need to generate an output file like this (deleting fields between attribute and subject, please note that number of those fields is variable): --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 3) --- What have you tried, where did you fail? Asking for free solutions isn't well looked upon... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: ways to change the first char from a filename (with full path )
Bob and Thomas, Thank you, very much. Rod Za --- Bob Showalter [EMAIL PROTECTED] wrote: Rod Za wrote: Hi all, i'm trying to make a code that get a file name (with full path) and change the first char of the filename. Someone can say me if there's a better way to do this?: _BEGIN_ #!/usr/bin/perl -w use strict; my($file) = $ARGV[0]; #receives the filename my $file = shift;(the traditional idiom) my @tmp = split(/\//,$file); #split the path use File::Basename; my ($name, $path) = fileparse($file); (more portable) $tmp[$#tmp] =~ s/.(\w+)/c$1/g;#change the first char of the filename substr($name, 0, 1) = 'c'; (no need for regex) my $IPPFile = join('/',@tmp); #join again path+'/'+filename print Original Filename: $file - Changed Filename: $IPPFile\n; #print the result _END_ use File::Spec print Original name: , $file, Changed name: , File::Spec-catfile($path, $name), \n; You might also have a look at the ubiquitous (and ancient) perl rename script: http://www.cpan.org/scripts/nutshell/ch6/rename __ Do you Yahoo!? Yahoo! Mail is new and improved - Check it out! 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: s::LocalGroupGetMembers
Thanks. So I have to pass the SID to some other function to get the actual username? or call a different function? I tried LocalGroupGetMembersWithDomain (which should give domain\users) but it's not any better and it returns non-zero (error) without providing any information about the error? On Mon, 28 Jun 2004 17:37:12 -0700, Tim Johnson wrote That's because the SID is stored in binary, and when you try to print it, it tries to convert that binary value into a series of characters, one of which is the beep sound (I know it doesn't make any sense, but it's true). Subject: Win32::NetAdmin::LocalGroupGetMembers Date: Fri, 25 Jun 2004 17:40:05 -0400 From: perl.org [EMAIL PROTECTED] To: [EMAIL PROTECTED] I need to get the members of a local group on a Windows 2000 server. I was reading the docs for Win32::NetAdmin (http://perlhelp.web.cern.ch/PerlHelp/site/lib/Win32/NetAdmin.html) which looks like the place to start, but it is giving me weird results (including beeps). Any suggestions? SIDs I could understand, but a repeated binary value is a little weird. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Extracting fields from a data file
From: mohammed chafik mailto:[EMAIL PROTECTED] wrote: : Hi all, : : I have input file like this: : -- : -- : header, 06-12-2004, path, : /usr/bin/sh,attribute,100555,root,other,315,565690, : subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) : : header, 06-12-2004, path, /usr/bin/sh,attribute,100555,dba,5, : subject,bscs,sgrp,9936,6785,0 ,return,success,0 (line2) : : header, 06-12-2004, path, : /usr/bin/sh,attribute,100555,tom,other,315,56,11,54,77,10,88, : subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line3) : -- : - Is the subject field always the second to last filed? : I need to generate an output file like this (deleting fields : between attribute and subject, please : note that number of those fields is variable): : -- : - : header, 06-12-2004, path, /usr/bin/sh, : subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) : : header, 06-12-2004, path, /usr/bin/sh, : subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) : : header, 06-12-2004, path, /usr/bin/sh, : subject,bscs,sgrp,9936,6785,0 0,return,success,0(line 3) : -- : - What determines the extra spacing that appears between the subject field and the last fields ( (line1), (line2), (line3), etc.)? Or is that just a typo? HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
Please bottom post... That's what i've tried (may be it is not the best approch); Any way, My script doesn't work, it returns an error message (Use of uninitialized value at formater.pl line 22, INDATA chunk 4.) - #!/usr/local/bin/perl -w use strict; # ALWAYS! $i=1; $k=1; why declare these way up here? open (INDATA, in_file.txt) || die(Can't open in file); open (OUTDATA, out_file.txt) || die(Can't open out file); while( $line = INDATA ) { chomp; your line of input data is in $line, but you are chomping $_, what does it have in it? @fields = split(,, $_); Splitting $_, but your input is in $line?? for ($i = 0; $i 400; $i++) { if( $fields[$i]=~ /subject/ ) { $k=$i} So i was originally 1, then you set it to 0, then you set k to the value of i... where did 400 come from? } $line = join(:, $fields[0], $fields[2],$fields[$k], $fields[$k+1]); You could use a slice in the above, though there really isn't a difference other than typing, $line = join(':', @fields[0,2,$k,$k+1]); Note that you have just clobbered your input string, re-using $line may not be the best idea, though so far it doesn't matter. print OUTDATA $line\n; } close INDATA; close OUDATA; I suspect turning on the strictures will clear up the issue. HTH, http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
On Tuesday 29 June 2004 18:44, mohammed chafik wrote: That's what i've tried (may be it is not the best approch); If you ask me, the general approach is quite ok... Any way, My script doesn't work, it returns an error message (Use of uninitialized value at formater.pl line 22, INDATA chunk 4.) - #!/usr/local/bin/perl -w I'd always include use strict; as first statement in your script. This saves you a lot of time. $i=1; $k=1; open (INDATA, in_file.txt) || die(Can't open in file); open (OUTDATA, out_file.txt) || die(Can't open out file); while( $line = INDATA ) { You're reading each line into a variable called $line... chomp; @fields = split(,, $_); but here you're working on $_. You should either do while ( $_ = INDATA ) { chomp; my @fields = split(,); .. } or while ( my $line = INDATA ) { chomp $line; my @fields = split(,, $line); } This in one source for the uninitialized value messages. for ($i = 0; $i 400; $i++) { The other source for the messages is that you're trying to access values in the array @fields that do not exist. In your data file, @fields holds something like 15 records, certainly not 400. I'd do something like for (my $i = 0; $i = $#fields, $i++) { which loops until $i has reached the last field of @fields ($#array_name holds the last index of an array). if( $fields[$i]=~ /subject/ ) { $k=$i} } $line = join(:, $fields[0], $fields[2],$fields[$k], $fields[$k+1]); print OUTDATA $line\n; } close INDATA; close OUDATA; Another warning message tells you that you've got a typo here ;-) HTH, Philipp PS.: Please bottom-post. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: ways to change the first char from a filename (with full path)
Rod Za wrote: i'm trying to make a code that get a file name (with full path) and change the first char of the filename. Someone can say me if there's a better way to do this?: Bob gave you a more *portable* solution. A *simpler* (but not portable) way is to skip the split and join operations and replace my @tmp = split(/\//,$file);#split the path $tmp[$#tmp] =~ s/.(\w+)/c$1/g; #change the first char of the filename my $IPPFile = join('/',@tmp); #join again path+'/'+filename with ( my $IPPFile = $file ) =~ s!(.+/).!$1c!; -- 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: Extracting fields from a data file
On Tuesday 29 June 2004 18:44, mohammed chafik wrote: That's what i've tried (may be it is not the best approch); If you ask me, the general approach is quite ok... snip for ($i = 0; $i 400; $i++) { The other source for the messages is that you're trying to access values in the array @fields that do not exist. In your data file, @fields holds something like 15 records, certainly not 400. I'd do something like for (my $i = 0; $i = $#fields, $i++) { which loops until $i has reached the last field of @fields ($#array_name holds the last index of an array). if( $fields[$i]=~ /subject/ ) { $k=$i} } Good suggestions, if we are going to stick with the loop, and we only care that we advance as long as we haven't found the subject then throwing a 'last' in after the assignment, would provide at least some speed up. If there are a significant # of lines to parse and the subject may appear early enough on the line then this could be a noticeable improvement. It would also make sense to adjust $i initial point forward if we can be guaranteed that subject occurs after a minimum number of fields on a line, which does seem indicated since we are using 0,2 indexes later not relative to the subject, so $i could be set at 3 initially. Turn my nitpicking back off now ;-)... 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: Win32::NetAdmin::LocalGroupGetMembers
Thanks. I hadn't thought to try this on my workstation but it works there, so my guess is it's the version of Perl on the server (I don't think the library is corrupt since I get the same results in dev and prod). Unfortunately this is from the vendor so I can't fix it. This is perl, version 5.005_03 built for MSWin32-x86 Is there any way to get the users in a group in this version of Perl? On Mon, 28 Jun 2004 09:57:36 -0500, Mike Flannigan wrote I just tried this on my Win2000 client machine and it gave the following: $VAR1 = 'Administrator'; $VAR2 = 'Mike Flannigan'; So it appeared to work to me. It made no sounds. Mike Subject: Win32::NetAdmin::LocalGroupGetMembers Date: Fri, 25 Jun 2004 17:40:05 -0400 From: perl.org [EMAIL PROTECTED] To: [EMAIL PROTECTED] I need to get the members of a local group on a Windows 2000 server. I was reading the docs for Win32::NetAdmin (http://perlhelp.web.cern.ch/PerlHelp/site/lib/Win32/NetAdmin.html) which looks like the place to start, but it is giving me weird results (including beeps). Any suggestions? SIDs I could understand, but a repeated binary value is a little weird. C:\temptype try.ipl use strict; use Data::Dumper; use Win32::NetAdmin; my @{users} = (); if ( ! Dumper( Win32::NetAdmin::LocalGroupGetMembers( '', 'administrators', [EMAIL PROTECTED] ))) { print 'LocalGroupGetMembers call failed.' . ${/}; } print Dumper( @{users} ); C:\tempiwperl try.ipl $VAR1 = '?¦nw?4'; $VAR2 = '?¦nw?4'; $VAR3 = '?¦nw?4'; $VAR4 = '?¦nw?4'; $VAR5 = '?¦nw?4'; $VAR6 = '?¦nw?4'; $VAR7 = '?¦nw?4'; $VAR8 = '?¦nw?4'; $VAR9 = '?¦nw?4'; $VAR10 = '?¦nw?4'; $VAR11 = '?¦nw?4'; $VAR12 = '?¦nw?4'; $VAR13 = '?¦nw?4'; $VAR14 = '?¦nw?4'; $VAR15 = '?¦nw?4'; $VAR16 = '?¦nw?4'; $VAR17 = '?¦nw?4'; $VAR18 = '?¦nw?4'; $VAR19 = '?¦nw?4'; $VAR20 = '?¦nw?4'; $VAR21 = '?¦nw?4'; C:\tempiwperl -v -- 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: Extracting fields from a data file
Thank you, Due to your remarques, my script works properly now : Here is the new version after modifications (I'll be glad, if you have any seggestion to make it better, actually the script uses big files, more than 200MB ) : #/usr/local/bin/perl -w $i=0; $k=0; open (INDATA, in_file.txt) || die(Can't open in file); open (OUTDATA, out_file.txt) || die(Can't open out file); while( my $line = INDATA ) { chomp $line; my @fields = split(,, $line); for (my $i = 0; $i = $#fields; $i++) { if( $fields[$i]=~ /subject/ ) { $k=$i} } $line = join(:, $fields[0], $fields[2], $fields[$k], $fields[$k+1]); print OUTDATA $line\n; } close INDATA; close OUDATA; Sorry to bother you with my problems, CHAFIK. - Original Message - From: Wiggins d Anconia Date: Tue, 29 Jun 2004 11:26:27 -0600 To: Philipp Traeder , [EMAIL PROTECTED] Subject: Re: Extracting fields from a data file On Tuesday 29 June 2004 18:44, mohammed chafik wrote: That's what i've tried (may be it is not the best approch); If you ask me, the general approach is quite ok... for ($i = 0; $i 400; $i++) { The other source for the messages is that you're trying to access values in the array @fields that do not exist. In your data file, @fields holds something like 15 records, certainly not 400. I'd do something like for (my $i = 0; $i = $#fields, $i++) { which loops until $i has reached the last field of @fields ($# holds the last index of an array). if( $fields[$i]=~ /subject/ ) { $k=$i} } Good suggestions, if we are going to stick with the loop, and we only care that we advance as long as we haven't found the subject then throwing a 'last' in after the assignment, would provide at least some speed up. If there are a significant # of lines to parse and the subject may appear early enough on the line then this could be a noticeable improvement. It would also make sense to adjust $i initial point forward if we can be guaranteed that subject occurs after a minimum number of fields on a line, which does seem indicated since we are using 0,2 indexes later not relative to the subject, so $i could be set at 3 initially. Turn my nitpicking back off now ;-)... http://danconia.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
On Tuesday 29 June 2004 19:26, Wiggins d Anconia wrote: On Tuesday 29 June 2004 18:44, mohammed chafik wrote: That's what i've tried (may be it is not the best approch); If you ask me, the general approach is quite ok... Good suggestions, if we are going to stick with the loop, and we only care that we advance as long as we haven't found the subject then throwing a 'last' in after the assignment, would provide at least some speed up. If there are a significant # of lines to parse and the subject may appear early enough on the line then this could be a noticeable improvement. You're right, of course... It would also make sense to adjust $i initial point forward if we can be guaranteed that subject occurs after a minimum number of fields on a line, which does seem indicated since we are using 0,2 indexes later not relative to the subject, so $i could be set at 3 initially. Turn my nitpicking back off now ;-)... ...but I was just trying to keep my own perfectionism at a tolerable level. ;-) I'm quite sure that some people on this list would re-write this script in a maximum of two lines, but since Chafik's scripts is working after all, I thought it might be fair to give him a chance of improving his own script... Generally, I'd (still) think that regular expressions might be a good idea here...e.g. see Gunnar´s post ;-) Philipp -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
disabling Perl threads and debugging to allow DBI install
I have tried to install the DBI module for Perl and experienced the bug mentioned in the DBI Readme file: Note: There is a bug in perl 5.8.2 when configured with threads and debugging enabled (bug #24463) which causes a DBI test to fail. How can I disable threads and debugging ? Is there another solution to this bug? Thanks. Tom -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Extracting fields from a data file
mohammed chafik [EMAIL PROTECTED] wrote: : Due to your remarques, my script works properly now: : Here is the new version after modifications (I'll be : glad, if you have any seggestion to make it better, : actually the script uses big files, more than 200MB): The report produced is very different from the one you said you were seeking. Report produced: -- header: path: subject:bscs header: path: subject:bscs header: path: subject:bscs -- VS. Report you asked for: --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 3) --- Why the change? HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: s::LocalGroupGetMembers
On Tue, 29 Jun 2004 12:50:14 -0400, perl.org wrote Thanks. So I have to pass the SID to some other function to get the actual username? or call a different function? I tried LocalGroupGetMembersWithDomain (which should give domain\users) but it's not any better and it returns non-zero (error) without providing any information about the error? When in doubt, shell out. sub getGroupMembers { my %{params} = IWAPI::SysUtil::normalizeParams( @{_} ); my @{users} = (); my %{results} = IWAPI::SysUtil::run( -cmd = 'net localgroup ' . ${params{'group'}} ); if ( ${results{'ret'}} != 0 || ${results{'out'}} !~ m#The command completed successfully# ) { new IWAPI::Exception( -file = __FILE__, -line = __LINE__, -msg = ${results{'msg'}} ); } my ${parse} = undef; foreach my ${line} ( split( /[\r\n]+/, ${results{'out'}} )) { if ( ${line} =~ m#^-{40}# ) { ${parse} = 1; } elsif ( defined( ${parse} ) ${line} !~ m#\\# ) { ${line} =~ s#\s+$##; if ( ${line} ne '' ${line} !~ m#The command completed successfully# ) { push( @{users}, ${line} ); } } } return( @{users} ); } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Extracting fields from a data file
There is almost no difference, the only thing to do (to have the first format) is changing: $line = join(:, $fields[0], $fields[2], $fields[$k], $fields[$k+1]); by $line = join(,, $fields[0], $fields[1], $fields[2],$fields[$k], $fields[$k+1]..); - Original Message - From: Charles K. Clarkson Date: Tue, 29 Jun 2004 13:20:08 -0500 To: 'mohammed chafik' , Subject: RE: Extracting fields from a data file mohammed chafik wrote: : Due to your remarques, my script works properly now: : Here is the new version after modifications (I'll be : glad, if you have any seggestion to make it better, : actually the script uses big files, more than 200MB): The report produced is very different from the one you said you were seeking. Report produced: -- header: path: subject:bscs header: path: subject:bscs header: path: subject:bscs -- VS. Report you asked for: --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 3) --- Why the change? HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- ___ Sign-up for Ads Free at Mail.com http://promo.mail.com/adsfreejump.htm -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Extracting fields from a data file
Mohammed Chafik wrote: Due to your remarques, my script works properly now : Does it? It does not meet your original specification. This is what it outputs for me: header: path: subject:bscs header: path: subject:bscs header: path: subject:bscs #/usr/local/bin/perl -w --^^ Please copy and paste, and do not re-type code that you post to the list. $i=0; $k=0; That should be use strict; my $k = 0; (you are not using any $i variable outside the for loop). while( my $line = INDATA ) { chomp $line; my @fields = split(,, $line); for (my $i = 0; $i = $#fields; $i++) { if( $fields[$i]=~ /subject/ ) { $k=$i} } $line = join(:, $fields[0], $fields[2], $fields[$k], $fields[$k+1]); print OUTDATA $line\n; } For the sake of comparison, all that can be replaced with print OUTDATA /(.+)attribute.+( subject.+)/s while INDATA; (assuming that you still want the program to meet your original specification). -- 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
Help on permissions for CGI
Hello everybody. I am on a new server and have discovered the Directories in the CGI-BIN are visible to everybody. This is, if a type www.mysite.com/cgi-bin I get a list of all the files and subdirectories, and so for every subdirectory. I had never had this issue. What is the best permission for my directories? Now, they are 755, but I'm not sure if changing it will cause the scripts not to run. The other way would be to place an index.html file in every directory causein the files not to get listed, but I'm sure there's a correct way to do it. Any advise would be very appreciated. -Ramón- -- 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 on permissions for CGI
WEBMASTER wrote: Hello everybody. Hi. Real names appreciated. I am on a new server and have discovered the Directories in the CGI-BIN are visible to everybody. This is, if a type www.mysite.com/cgi-bin I get a list of all the files and subdirectories, and so for every subdirectory. I had never had this issue. Somebody has mucked with the server configuration. What is the best permission for my directories? Not the issue. Now, they are 755, but I'm not sure if changing it will cause the scripts not to run. That should be fine. The other way would be to place an index.html file in every directory causein the files not to get listed, but I'm sure there's a correct way to do it. You need to disable index generation. It's not a permission issue. It's also not a Perl issue. Read the docs for your web server. HTH -- 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 on permissions for CGI
Webmaster wrote: I am on a new server and have discovered the Directories in the CGI-BIN are visible to everybody. Your question is very much off topic. This list is for Perl, not for configuration of web servers. My first advice would be to leave the server for a sensibly configured one. This is, if a type www.mysite.com/cgi-bin I get a list of all the files and subdirectories, and so for every subdirectory. I had never had this issue. What is the best permission for my directories? Ask your hosting provider. The other way would be to place an index.html file in every directory causein the files not to get listed, but I'm sure there's a correct way to do it. There are better ways, and the natural thing to do is asking your provider to fix it. For the case it's an Apache web server, you might be able to prevent indexing by uploading an .htaccess file to your cgi-bin with the applicable directive. See the Apache documentation. -- 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: Help on permissions for CGI
First. Sorry for the name. I had the Outlook Express configured that way. Second Thanks, I had the idea that problem was new. I'll check it with the service provider before attemping to use the .httaccess Thanks again. -rm- - Original Message - From: Gunnar Hjalmarsson [EMAIL PROTECTED] To: [EMAIL PROTECTED] Sent: Tuesday, June 29, 2004 2:36 PM Subject: Re: Help on permissions for CGI Webmaster wrote: I am on a new server and have discovered the Directories in the CGI-BIN are visible to everybody. Your question is very much off topic. This list is for Perl, not for configuration of web servers. My first advice would be to leave the server for a sensibly configured one. This is, if a type www.mysite.com/cgi-bin I get a list of all the files and subdirectories, and so for every subdirectory. I had never had this issue. What is the best permission for my directories? Ask your hosting provider. The other way would be to place an index.html file in every directory causein the files not to get listed, but I'm sure there's a correct way to do it. There are better ways, and the natural thing to do is asking your provider to fix it. For the case it's an Apache web server, you might be able to prevent indexing by uploading an .htaccess file to your cgi-bin with the applicable directive. See the Apache documentation. -- 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: ways to change the first char from a filename (with full path)
Gunnar Hjalmarsson wrote: Rod Za wrote: i'm trying to make a code that get a file name (with full path) and change the first char of the filename. Someone can say me if there's a better way to do this?: Bob gave you a more *portable* solution. A *simpler* (but not portable) way is to skip the split and join operations and replace my @tmp = split(/\//,$file);#split the path $tmp[$#tmp] =~ s/.(\w+)/c$1/g; #change the first char of the filename my $IPPFile = join('/',@tmp); #join again path+'/'+filename with ( my $IPPFile = $file ) =~ s!(.+/).!$1c!; TMTOWTDI :-) substr my $IPPFile = $file, rindex( $file, '/' ) + 1, 1, 'c'; 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: Extracting fields from a data file
Mohammed Chafik wrote: Hi all, Hello, I have input file like this: header, 06-12-2004, path, /usr/bin/sh,attribute,100555,root,other,315,565690, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,dba,5, subject,bscs,sgrp,9936,6785,0 ,return,success,0 (line2) header, 06-12-2004, path, /usr/bin/sh,attribute,100555,tom,other,315,56,11,54,77,10,88, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line3) --- I need to generate an output file like this (deleting fields between attribute and subject, please note that number of those fields is variable): --- header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line1) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0 (line 2) header, 06-12-2004, path, /usr/bin/sh, subject,bscs,sgrp,9936,6785,0 0,return,success,0(line 3) --- while ( IN ) { my @fields = split /,/; print OUT join ',', @fields[ 0 .. 3, -9 .. -1 ]; } 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: mail
Jack Jack wrote: Hi All, Hello, I have two arrays @a and @b, each of the arrays have lotz of elements. what i want is the first element of @a should be assigned the first element of array @b. If you want to replace the first element of @a with the first element of @b: $a[ 0 ] = $b[ 0 ]; If you want to insert the first element of @b without changing @a: unshift @a, $b[ 0 ]; If you also want to remove the first element of @b: $a[ 0 ] = shift @b; Or: unshift @a, shift @b; The result should be combined in one array @c, so that i can send the @c mail. I have a rough idea that we can in HASH, but not sure. can sombody help me out @c = ( $b[ 0 ], @a[ 1 .. $#a ] ); Or: @c = ( $b[ 0 ], @a ); Or: @c = ( shift @b, @a ); Or: @c = ( shift @b, splice( @a, 1 ) ) It depends on what you want to do. :-) 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
Favorite email parser?
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. 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? Anyone dealt with this type of thing before and have any gotchas for me? 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? 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? ...and, umm, if you could point me to any Getting Started docs, that would be just lovely. :) 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. :) Answers to any or all of the above gratefully received! aTdHvAaNnKcSe- Brian /~~\ | Brian Gerard O'Reilly is to a system administrator| | First initial + 'lists' as a shoulder length | | at technobrat dot com latex glove is to a veterinarian. | \__/ -- 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?
Forgot to mention the platform. This will be on a FreeBSD system, and the emails will be in the standard flat file format (mbox). Didn't want anyone going too deep on the M$/Exchange side of the house. :) /~~\ | Brian GerardRed meat isn't bad for you. Fuzzy | | First initial + 'lists' blue-green meat is bad for you. | | at technobrat dot com | \__/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Need suggestions
All, Being only moderately comfortable with Perl, I find myself in need of some direction on a more complex task. I have a tex file containing a large number of exercises shaped as follows: \ex This is the text of the exercise as it appears in the book. The exercise may have several parts. \pt This is the first part. \ans This is the solution to the first part. \endans \backans{This is the answer to the first part that goes in the back of the book. These are present only for the odd-numbered exercises.} \pt This is the second part. \ans This is the solution to the second part. \endans \backans{This is the answer to the second part that goes in the back of the book.} I need to change each of these into the following form: \begin{exer} \begin{exertext} This is the text of the exercise as it appears in the book. The exercise may have several parts. \begin{subenumerate} \item This is the first part. \item This is the second part. \end{subenumerate} \end{exertext} \begin{soln} \begin{subsoln} \item This is the solution to the first part. \item This is the solution to the second part. \end{subsoln} \end{soln} \begin{answer} \begin{subanswer} \item This is the answer to the first part that goes in the back of the book. These are present only for the odd-numbered exercises. \item This is the answer to the second part that goes in the back of the book. \end{subanswer} \end{answer} \end{exer} I am looking for suggestions on how to attack this assignment. Perhaps there are modules on CPAN that would help me of which I am not aware. Or, perhaps a kind soul will suggest an attack. Thanks. Any help appreciated. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Regexp::Parser v0.01
The first version of Regexp::Parser is now available. It's not on CPAN because the uploading server is down right now. You can get it from http://japhy.perlmonk.org/modules/ In the near future, I'll have Regexp::Explain ready for downloading. For those of you familiar with YAPE::Regex::Explain, this is the new generation of the YAPE::Regex::* modules. -- 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
Nested {}
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. 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: Favorite email parser?
--As of Tuesday, June 29, 2004 3:46 PM -0700, Brian Gerard is alleged to have said: 1) Does this sound like a reasonable approach to the problem, given the relatively low amount of detail I've provided? Anyone dealt with this type of thing before and have any gotchas for me? I can't say anything about gotchas, but I would look at trying to eliminate the mail step. It might be possible to directly query the resource monitors, or modify them to do the database entry instead of mailing. Of course, that depends on what you are doing. If you have a standard 'alert format' that everything uses, and mails to the same address, from all over a large site/company, where every system has it's own alert generator, this may be the best way. Just saying to check if they are all a couple line Perl scripts, then it may be you can create a database entry template and stick it in instead of the email code. 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? 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? ...and, umm, if you could point me to any Getting Started docs, that would be just lovely. :) The DBI modules are what you want to use here. If you use them correctly it almost doesn't matter what database you are using (at least to the programmer). I'd recommend the book 'Programming for the Perl DBI' as an intro. It goes over everything you're likely to need. (O'Reilly press.) As for DB... It would depend on what you need out of it. A little googling will bring up sites with the advantages and disadvantages of the various DBs for you, with some explanation of when you should care about each. 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. Daniel T. Staal --- This email copyright the author. Unless otherwise noted, you are expressly allowed to retransmit, quote, or otherwise use the contents for non-commercial purposes. This copyright will expire 5 years after the author's death, or in 30 years, whichever is longer, unless such a period is in excess of local copyright law. --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: Nested {}
David Arnold [EMAIL PROTECTED] wrote: : 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. As long as the lines do not wrap, you don't need to worry about the nesting. Perl regexes are greedy by default. So '.+' will try to suck in the longest match possible. Which is just what you want. while ( DATA ) { printf \\begin{answer}\n%s\n\\end{answer}\n, $1 if /^\\backans{(.+)}/; } __END__ \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Installing a module when you have limited permissions
I used to upload the pm files in to a directory using a FTP program and in to a folder in my web site and add the full path of that directory in to the @INC array in each of the perl scripts that uses that module and then inport the module. So far it worked for me. ex:- if your module is MyModule.pm ant it is uploaded to /home/myuser/my_module_store add this code to your scripts unshift @INC '/home/myuser/my_module_store'; use MyModule; I am not sure whether this works for complex modules that has c compiled files in it. LRMK - Original Message - From: jason corbett [EMAIL PROTECTED] To: perl beginners [EMAIL PROTECTED] Sent: Tuesday, June 29, 2004 9:39 PM Subject: Installing a module when you have limited permissions Hello. I wanted to know if someone has installed a PERL module on a server where they had limitied permissions? I am not extremely UNIX savy but I do know the basic and know the something about the file structures, etc. Can someone tell me how I can install MIME::Lite on a server where I may use it, and give others permission to use my install? Thanks, JC -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Installing a module when you have limited permissions
Lrmk wrote: I used to upload the pm files in to a directory using a FTP program and in to a folder in my web site and add the full path of that directory in to the @INC array in each of the perl scripts that uses that module and then inport the module. So far it worked for me. ex:- if your module is MyModule.pm ant it is uploaded to /home/myuser/my_module_store add this code to your scripts unshift @INC '/home/myuser/my_module_store'; use MyModule; That does not work. unshift() is executed at run time, while use statements are executed at compile time. You can do unshift @INC '/home/myuser/my_module_store'; require MyModule; or BEGIN { unshift @INC '/home/myuser/my_module_store' } use MyModule; or use lib '/home/myuser/my_module_store'; use MyModule; I am not sure whether this works for complex modules that has c compiled files in it. Typically it doesn't. -- 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: Nested {}
Charles, Very nice indeed. I learned a lot with your example. Unfortunately, there are a lot of situations where the lines wrap. For example, \backans{Now is the time for all good men to come to the aid of their country. The domain of $f(x)=\sqrt{2x+3}$ is $\{x:\,x\ge -3/2\}$.} Do you have similar good advice for the wrapping situation? At 09:18 PM 6/29/04 -0500, Charles K. Clarkson wrote: David Arnold [EMAIL PROTECTED] wrote: : 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. As long as the lines do not wrap, you don't need to worry about the nesting. Perl regexes are greedy by default. So '.+' will try to suck in the longest match possible. Which is just what you want. while ( DATA ) { printf \\begin{answer}\n%s\n\\end{answer}\n, $1 if /^\\backans{(.+)}/; } __END__ \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} \backans{If $x=y^{2n}$ and $z=y^{3n}_{11}$, then we can ...} HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
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. Thanks in Advance. Rgds Suresh = Suresh Bangalore __ 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: Favorite email parser?
Brian Gerard wrote: Hi all- Hello, 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. 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? Anyone dealt with this type of thing before and have any gotchas for me? 2) From what I've read, Postgres beats MySQL performance-wise, which is why I Where'd you read that, postgres.org ? :) chose it, but IANADBA. Any votes on a free DB to use for this? Obviously, it MySQL is my .02 :) its always been there for me and soem quite hefty assignments.. 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? ...and, umm, if you could point me to any Getting Started docs, that would be just lovely. :) 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'm a little bit away from a module that has an nice email parsing function. It uses Mail::Internet underneath but take its a step further by simplifying the calling and returning other useful values like a plain text version and an attachement-less version (text or multipart with HTML) It works like this: my %email = emailhash(\*STDIN); $email{FROM} $email{SUBJECT} etc.. The only thing left is to parse the attachements into a nice hashref that can be used with the internal mailing function. That might be for version 2 :) Other than that its quite handy.. Watch for SimpleMood.pm :) Odd name, easy to use and handy (I hope ;p) Answers to any or all of the above gratefully received! HTH Lee.M - JupiterHost.Net -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Nested {}
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
help with compiling on win2000 with vs.net
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 the error I get is NMAKE : fatal error U1073: don't know how to make 'config_H.vc' Stop. My Makefile settings are: INST_DRV= c: INST_TOP= $(INST_DRV)\perl #INST_VER = \5.8.3 #INST_ARCH = \$(ARCHNAME) USE_MULTI = define USE_ITHREADS = define USE_IMP_SYS = define USE_PERLIO = define USE_LARGE_FILES = define #USE_5005THREADS= define #CCTYPE = MSVC20 CCTYPE = MSVC60 #CFG= Debug #USE_PERLCRT= define #USE_SETARGV= define CRYPT_SRC = fcrypt.c #CRYPT_LIB = fcrypt.lib #PERL_MALLOC= define #DEBUG_MSTATS = define CCHOME = c:\program files\microsoft visual studio .net 2003\vc7 CCINCDIR= $(CCHOME)\include CCLIBDIR= $(CCHOME)\lib #BUILDOPT = $(BUILDOPT) -DPERL_POLLUTE #BUILDOPT = $(BUILDOPT) -DPERL_EXTERNAL_GLOB #BUILDOPT = $(BUILDOPT) -DPERL_TEXTMODE_SCRIPTS EXTRALIBDIRS= TIA Lonnie Percent -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response