RE: Escaping a plus sign
Is it the if ($MGMTCMNT =~ /$MGMTNM/) part that is tripping you up? I believe you could change it to if ($MGMTCMNT =~ /\Q$MGMTNM\E/) if you need to keep the regular expression. Another idea might be to change it to if ( ($start = index($MGMTCMNT, $MGMTNM ()) 0) { -Original Message- From: Paul Nowosielski Sent: Tuesday, May 30, 2006 4:13 PM To: beginners@perl.org Subject: Escaping a plus sign Dear All, I have a perl script that runs nightly. It create a data feed. The script will die if the is a + sign in the fields its parsing. Here is the snippet: while (($PKEY, $MGMTCMNT, $manager_id, $MGMTNM, $UPDATE1, $UPDATE2) = $sth-fetchrow_array) { $comment = ; if ($MGMTCMNT =~ /$MGMTNM/) { $len = length($MGMTNM); $start = index($MGMTCMNT, $MGMTNM (); $start += $len + 2; $end = index($MGMTCMNT, ), $start) - $start; $comment = substr($MGMTCMNT, $start, $end); } if ($UPDATE1 $artisttime || $UPDATE2 $artisttime ) { print (ARTMGRFILE $PKEY\t$manager_id\t$comment\n); } } Here is the error message: Quantifier follows nothing in regex; marked by -- HERE in m/+ -- HERE 1 Public Relations/ at /srv/www/htdocs/admin/utilities/aeg/manart.pl line 102. In this error the problem file had the text +1 Public Relations; Is there a way to escape this character so in the future it won't kill the script? Thank you, -- Paul Nowosielski -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response This email and any attachments have been scanned for known viruses using multiple scanners. We believe that this email and any attachments are virus free, however the recipient must take full responsibility for virus checking. This email message is intended for the named recipient only. It may be privileged and/or confidential. If you are not the intended named recipient of this email then you should not copy it or use it for any purpose, nor disclose its contents to any other person. You should contact Misys Banking Systems so that we can take appropriate action at no cost to yourself. www.misys.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Can I set '$!' ?
I want to be able to return a true or false value from a function in a module and populate the $! variable with the specific errors. Is this possible? Is there documentation on how to do this? I can find docs on how to use $! but not how to set it. Thanks for any help -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
HOWTO:Dynamically getting all of the global variables and their v alues
I would like to write a function that will get all the global variables that are declared in my script plus their values( which will all be strings if that matters). This is what I have so far: my ( $varName, $globValue ); while ( ($varName, $globValue) = each %main:: ) { print \$$varName $globValue \n; } This prints a whole lot of stuff including function names but the variables are not in here. My goal is to have this function pick up the variables dynamically everytime the script is run, get the values and do some varification before getting into the meat of the script, without having to add or remove the variables manually from the sub whenever I add or remove a variable from the script. Thanks in advance for any help -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
hex to dec and dec to hex
Is there an easy way to go back and forth between decimal and hex in perl. I know of the hex function which solves my hex to dec problem but how about a dec-hex function or module? I need the value which is why printf isn't working for me. Thanks for any help. -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Javascript and Perl Problem
One issue I ran into was using Here document without single quotes print EOJS and perl was trying to interpret things in my javascript. Saying print 'EOJS' fixed it, perl trying to interpret things may also be the problem if you are using print statements. -Ken -Original Message- From: Peter Fleck [mailto:[EMAIL PROTECTED] Sent: Friday, May 30, 2003 1:09 PM To: [EMAIL PROTECTED] Subject: Javascript and Perl Problem I have some complex (at least to me) javascript on a perl-generated page that's not working correctly. The same javascript works fine on a static page. I should mention that some javascript is working on the dynamic page but it's not doing what it's supposed to do. Before I post any code, I'm hoping that there may be some problems that I'm not aware of concerning javascript on perl pages. I just finished optimizing the javascript for display on multiple browsers and it's working fine for static pages. Thanks. -- Peter Fleck Webmaster | University of Minnesota Cancer Center Dinnaken Office Bldg. 925 Delaware St. SE Minneapolis, MN 55414 612-625-8668 | [EMAIL PROTECTED] | www.cancer.umn.edu Campus Mail: MMC 806 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: warning message
looks like you tried to call the sub before you defined it, try putting a definition just below all the use statements or just move the whole sub up there -Ken -Original Message- From: Christopher G Tantalo [mailto:[EMAIL PROTECTED] Sent: Wednesday, April 02, 2003 3:43 PM To: [EMAIL PROTECTED] Subject: warning message Hello, In a recent perl script I wrote, I have a procedure, read_config(), which reads a config file I have set up and sets a hash to what is in the file. Now, before you mention it, I have stricts on and use the -w on the 1st line, and the following message appears. main::read_config() called too early to check prototype at ./eleadtest.pl line 19. What does this mean? Code snippets of the procedure call, and the procedure itself are below. #!/home/ctantalo/perl5/bin/perl -w # # Programmer: Chris Tantalo # # This program will call eleadsht.sqt and email the eleadsht.lis file # based on the data in the dmg.eleadsht_parameters table # # $Version_id = @(#) elead.pl [@@/main/dec02_corp_sup/1] ; use strict; use Mail::Sender; use DBI; # check to see if test machine(cad2) or production(sam) my $node = `hostname`; chomp $node; our %hash; read_config($node); snip # the read_config procedure sub read_config() { my $node = shift @_; my $cfg_file = ; my $key; my $value; $cfg_file = /opt/appl/hrstmk/bin/elead.cfg if($node eq sam); $cfg_file = /usr/appl/cad/prod/hrstmk/bin/elead.cfg if($node eq cad2); open(CFG_FILE,$cfg_file) ||die cannot open $cfg_file for reading:$!; while(CFG_FILE) { next if($_ =~ /^#/); ($key,$value) = split(/=/,$_); $hash{$key}=$value; } close(CFG_FILE); } TIA, Chris -- --- Just Your Friendly Neighborhood _SPIDEY_ -- Anything added after this was added by my mail server and not me. -- - The information contained in this message may be privileged, confidential, and protected from disclosure. If the reader of this message is not the intended recipient, or any employee or agent responsible for delivering this message to the intended recipient, you are hereby notified that any dissemination, distribution, or copying of this communication is strictly prohibited. If you have received this communication in error, please notify us immediately by replying to the message and deleting it from your computer. Thank you. Paychex, Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
howto: open/create a file as executable
Is it possible to open/create a file with open that does not exist and give it a umask that makes it executable, say for the purpose of generating shell scripts? For example, say open OUT_FILE, MAGIC_UMASK, /scripts/new_script; where the current umask is 2. Is the only option to chmod the file after it has been created? Thanks for any help. -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Formatting Variables.
Have you tried using printf? -Original Message- From: Ramón Chávez [mailto:[EMAIL PROTECTED]] Sent: Tuesday, February 11, 2003 9:07 AM To: [EMAIL PROTECTED] Subject: Formatting Variables. Hello boys and girls. Is there a way to give format to a Variable. I mean, if I don't want to get printed 3.1415926535 (Or any irrational number) but something like 3.14, is there a way to use format?? Or I need to make some string treating (more lines)?? Thank you everyone. -rm- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How do I test a variable to see if it is a scalar or a hash?
How do I test a variable to see what type of variable it is(scalar, array, hash, etc...)? What I am trying to accomplish is I have a hash and some values are scalar data and some values are nested hashes and I need a way to tell the difference. Book or web site references are welcome, thanks in advance. -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Perl book
Pink is first edition, blue is second edition, i think there is a third edition out now, may as well go for the latest and greatest -Ken -Original Message- From: Robbie Staufer [mailto:[EMAIL PROTECTED]] Sent: Wednesday, January 15, 2003 12:20 PM To: [EMAIL PROTECTED] Subject: Re: Perl book There is a pink and a blue camel book from O'Reilly. What is the difference, and which comes most highly recommended? Robbie -- -*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-* Robbie Staufer NCAR/SCD 1850 Table Mesa Dr. Rm. 42 Boulder, CO. 80305 (303) 497-1836 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cgi Win xp Perl
Try putting the -T after the -w at the top of your perl script, make sure that your script ends in .cgi and your iis is setup to run scripts and change print $q-header (text/plain); to print $q-header (text/html); -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 3:02 PM To: Perl Subject: Cgi Win xp Perl I am running on a windows xp pro desktop with iis installed. I have active state Perl installed and have been using it with out a problem. I just started to play with cgi and I am having a lot of problems getting it to work right. I have a static html form that's action calls the following script. When it I hit submit all it does is display it as if it was a text file. If I rename it to .pl then it tries to download it. However if I have just call another test cgi script that displays some html then it runs fine (also named .pl) with one exception it tells me that it is to late to do -T. So basically I need to find out how to call this script from my form and have it execute. Second I need to find out how to get .cgi scripts to load instead of displaying or trying to download. Third I need to know how to pass the -t to the compiler before my script executes. (I am assuming this is a problem with Perl on windows not using the shebang. Even though -w works odd.) #!/usr/bin/perl -w use strict; use CGI; my $q=new CGI; print $q-header (text/plain); print These are the parameters I received:\n\n; my ($name, $value); foreach $name ($q-param){ print $name:\n; foreach $value ($q-param($name)){ print \t$value\n; } } Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Cgi Win xp Perl
Is this path right? This looks like a unix path and your trying this on windows right? #!/usr/bin/perl -w Anyway I setup my XP box to run perl, I am sorry to say I forget exactly what I did but I know I had to set something up in IIS settings. Sorry, you might get faster help from the cgi mailing list. -Ken -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 3:11 PM To: 'Ken Lehman'; 'Perl' Subject: RE: Cgi Win xp Perl It still just displays the contents of my script rather then running it. Do I need to some how associate .cgi with Perl? -Original Message- From: Ken Lehman [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 3:12 PM To: 'Paul Kraus'; Perl Subject: RE: Cgi Win xp Perl Try putting the -T after the -w at the top of your perl script, make sure that your script ends in .cgi and your iis is setup to run scripts and change print $q-header (text/plain); to print $q-header (text/html); -Original Message- From: Paul Kraus [mailto:[EMAIL PROTECTED]] Sent: Tuesday, January 07, 2003 3:02 PM To: Perl Subject: Cgi Win xp Perl I am running on a windows xp pro desktop with iis installed. I have active state Perl installed and have been using it with out a problem. I just started to play with cgi and I am having a lot of problems getting it to work right. I have a static html form that's action calls the following script. When it I hit submit all it does is display it as if it was a text file. If I rename it to .pl then it tries to download it. However if I have just call another test cgi script that displays some html then it runs fine (also named .pl) with one exception it tells me that it is to late to do -T. So basically I need to find out how to call this script from my form and have it execute. Second I need to find out how to get .cgi scripts to load instead of displaying or trying to download. Third I need to know how to pass the -t to the compiler before my script executes. (I am assuming this is a problem with Perl on windows not using the shebang. Even though -w works odd.) #!/usr/bin/perl -w use strict; use CGI; my $q=new CGI; print $q-header (text/plain); print These are the parameters I received:\n\n; my ($name, $value); foreach $name ($q-param){ print $name:\n; foreach $value ($q-param($name)){ print \t$value\n; } } Paul Kraus Network Administrator PEL Supply Company 216.267.5775 Voice 216-267-6176 Fax www.pelsupply.com -- -- The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
catch kill -9 from unix command prompt
Is there a way for my program to execute a few lines of code before dying when it is sent a kill -9 from a unix shell? The book I have says no, I don't want to ignore the signal, just some clean up. Thanks. -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: include .pl in html
This works where I am at, you could give it a try !--#exec cmd=./my_perl_script_here.pl-- -Original Message- From: Adam Wilson [mailto:[EMAIL PROTECTED]] Sent: Tuesday, December 10, 2002 11:27 AM To: [EMAIL PROTECTED] Subject: include .pl in html Hi, can anyone help me, i want to include the ouput of a perl file within an html file, without using a seperate frame. I am familiar with php, is there a way to include like there is in php? Or do i have to output the HTML from the perl script? Any help very much appreciated... i left my books at home!!! Adam. The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
HOWTO use system call on windows with a space in the path
I would like to write a perl script for windows that in the right situation fires off another program, the problem is I can't get it to work using system or exec calls. The file is in the program files directory I tried system(c:\program files\etc...) and some variations but I can't get it to work Help is appreciated Thanks in advance. -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
does perl have boolean variables?
I can't say: #!/yadayada/perl -w use strict; $seen = true; if( $seen ) { #whatever } else { #something different } I get a bareword error, I'm using perl 5.004_04. Does perl support booleans like this, do I need to use a package? Thanks in advance -Ken The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
howto: array index inside a foreach loop
Say I have a foreach loop that I used to modify elements when they match a pattern that I am searching for, but there is one special case where I get a match and I need the index for that element. Can I get that index or do I have to go with a for() loop. If this can be done how would I use it? Thanks in advance Ken # something along these lines foreach $temp_string (@array_of_strings) { if ($temp_string =~ /^CRASH/) { $array_of_strings[$this_is_what_I_need - 1] = LOOK OUT!; } } The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: howto: array index inside a foreach loop
yeah sorry, my problem is not quite as simple as the example. I just put that in to try and illustrate my point. I'm not trying to do a straight replace, I need to replace an element only if I find a certain string somewhere else. -Original Message- From: david [mailto:[EMAIL PROTECTED]] Sent: Friday, November 22, 2002 4:12 PM To: [EMAIL PROTECTED] Subject: Re: howto: array index inside a foreach loop Ken Lehman wrote: Say I have a foreach loop that I used to modify elements when they match a pattern that I am searching for, but there is one special case where I get a match and I need the index for that element. Can I get that index or do I have to go with a for() loop. If this can be done how would I use it? Thanks in advance Ken # something along these lines foreach $temp_string (@array_of_strings) { if ($temp_string =~ /^CRASH/) { $array_of_strings[$this_is_what_I_need - 1] = LOOK OUT!; } } sorry i might be missing your point but why not just: #!/usr/bin/perl -w use strict; my @array_of_strings = qw(CRASH Windoes use linux); s/^CRASH/LOOK OUT!/ for(@array_of_strings); print join(\n,@array_of_strings),\n; __END__ prints: LOOK OUT! windoes use linux david -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] The views and opinions expressed in this email message are the sender's own, and do not necessarily represent the views and opinions of Summit Systems Inc. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]