cant read cookie values from popup window....... plzz help me........
Hai all, I use the strict paragma and and declared variable as correctly. After compilation there is no error and this time i cant read the cookie from the second window (pop up window generated by javascript). I request you to please point out the error if any one faced this problem. i send thecode that i corrected as follows. Thanks in Advance... Regards Manoj ** #!/usr/bin/perl use strict; use CGI; our $output = new CGI(); our $input = new CGI; our $cookie; print Content-type: text/html\r\n\r\n; if ($input-param('cmd') eq 'test2') {test2;} else { test; } sub test { $cookie = $output-cookie(-name = 'uid', -value = u100', -expires = '+1d'); $output-header(-expires = '-1d',-cookie =$cookie); print html\n; print head\n; print $cookie. ssf \n; print script language=\Javascript\\n; print function spawn(page) {; print window.open(page,\\,\left=5,top=5,height=480,width=600,status=yes,toolbar=no,menubar=no,scrollbars=yes\);} /script\n; print /head\n; print body lang=en-US style=\background-color: rgb(153,204, 255);\\n; printh3MENU/h3\n; print pa href=\#\ Onclick='spawn(\/testcookie.pl?cmd=test2\)\'OnlineTest /a/p; print /body/html\n; } sub test2 { print html\n; print head\n; print /head\n; print body lang=en-US style=\background-color: rgb(153, 204, 255);\\n; print $cookie. dff \n; printh3MENU/h3\n; print pa href=\#\ Online Test /a/p; print /body/html\n; } * -- __ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: cant read cookie values from popup window....... plzz help me........
--- manoj tr [EMAIL PROTECTED] wrote: i send thecode that i corrected as follows. $cookie = $output-cookie(-name = 'uid', -value = u100', -expires = '+1d'); Well, for one, your quotes are unba;nced starting at the above line. Also, I would use - use strict; use warnings; use diagnostics; HTH; -Sx- = -Sx- seeking employment: http://youve-reached-the.endoftheinternet.org/ __ Do you Yahoo!? New and Improved Yahoo! Mail - Send 10MB messages! 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: Two easy questions.
Your answer actually lies in the system that you are using first. The reason the CGI scripts hold the .cgi extension. Is because that is what your webserver uses to grab your CGI scripts from your CGI directory. As for using perl myscript. That is a windows thing. If I remember correctly (Don't qoute me on this, because I don't use perl on windows.) but if you run your script in the directory that you have perl installed in, you don't need the perl part. Hopefully I have explained it clearly enough, sorry it is rather late, and I am friggin tired, if when I read this in th morning it sounds shitty, I will reword it and re-email it. Drue Reeves [EMAIL PROTECTED] wrote: Truly newbie questions Why do some scripts have a CGI extension while other a .pl and still other a .plx? Does the .cgi extension give it some web characteristics? Is there a way to run my script without specifying perl before the script? In other words, I want to type c:\myscript.plx instead of c:\perl myscript.plx. Thanks, Drue - Do you Yahoo!? vote.yahoo.com - Register online to vote today!
Re: Two easy questions.
yes.I think your question is making the 'perl command interpret' default to excute the plx file that you made.You can make the configration in windos to solve the problem. -Sandy Drue Reeves wrote: Truly newbie questions Why do some scripts have a CGI extension while other a .pl and still other a .plx? Does the .cgi extension give it some web characteristics? Is there a way to run my script without specifying perl before the script? In other words, I want to type c:\myscript.plx instead of c:\perl myscript.plx. Thanks, Drue -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: calling Perl Script from JSP?
-Original Message- From: Drue Reeves [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 4:49 AM To: [EMAIL PROTECTED]; Cary Andrews Subject: calling Perl Script from JSP? Anyone know how to call a PERL Script from a JSP and pass parameters to the script? I have a JSP that will call PERL but, everytime we try to add a script nothing happens. Any ideas? Very bad idea trying to mix Perl and JSP ... Which feature of Perl do you want to use in your JSP page that you can't get from Java ? José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
simple windows process list
The object of the code below is to output a list of space seperated fields with PID, username and process. The code generates te correct output. My guess is that my perl code can be smaller. Who dares? #!perl # # Object: # To output a tab separated list of PID, username and process # for windows XP # # Prerequisites: # 1) ActiveState Perl # 2) Windows XP use warnings; use strict; for my $line (`tasklist /v /nh`) { chomp($line); if ( $line ne ) { # extract PID my $pid = substr($line, 26, 6); # remove leading spaces $pid =~ s/^ *([0-9]+)$/$1/g; # extract username my $user = substr($line, 88, 50); # remove trailing spaces $user =~ s/^(.*\S)\s+$/$1/g; # change spaces in username to underscores $user =~ s/\s/\_/g; # extract process my $proc = substr($line, 0, 24).substr($line, 152, 72); # change multiple spaces to single spaces $proc =~ s/\s\s\s*/ /g; # remove trailing space $proc =~ s/\s$//g; # remove trailing N/A $proc =~ s/ N\/A$//g; # print tab seperated fields print $pid, , $user, , $proc, \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: Mime Lite attachments
All, Was hoping for some advise b/c I cannot seem to get this to work. My problem is that it attaches the path name when I need to actual data attached. So my goal is as if it would be cat test |uuencode test | mailx -s test [EMAIL PROTECTED] thanks, my $scratchtps = /usr/local/log/filename; code snippet there is a process that may/may not populate this file. if ( -s $scratchtps ) { mailme; The above is usually better written as: mailme(); } sub mailme { my $msg = MIME::Lite-new( From= 'EDM01 [EMAIL PROTECTED]', To = 'Derek Smith [EMAIL PROTECTED]', Subject = Return EDM Tapes, Type= 'TEXT', Data = $scratchtps, 'Data' is for the body, you need to either use the separate Cattach method, or provide the filename as the 'Path' argument. You really should start reading the docs thoroughly, you have asked a number of questions that are pretty simple if you just pay attention to the API, and MIME::Lite has very thorough and simple documentation, http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm#Create_a_simple_message_containing_just_an_image Disposition = 'attachment'); $msg-send; } 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: CSV type data into hash?
* Tim Musson [EMAIL PROTECTED] [2004-09-21T09:25:23] It looks something like this; Name,Location,Function,IPAddress uas123,123 street,Mail,10.11.12.13 uas321,123 street,Mail,10.11.12.14 As is often the case, I suggest going to the CPAN and searching for CSV. You'll find lots of relevent modules. Of course, if you want to take care of this yourself, as an exercise, consider something long the lines of the following: open my $csv_file, '', filename.csv or die couldn't open file!; my @columns = split(/,/, $csv_file); chomp $columns[-1]; my @rows; while ($csv_file) { chomp; push @rows, {}; @[EMAIL PROTECTED] = split /,/; } So: Read the first line and break it up on commas to get column names. Chomp the newline from the last column name. Keep reading line, chomping their newlines. Add an empty hash to the end of the rows, then populate it, matching column names to field positions. That code is off-the-cuff, but should work, I think. :) If not, or if you want more information, just holler. -- rjbs pgpXoqWq0mKDt.pgp Description: PGP signature
Re: CSV type data into hash?
On Tue, 21 Sep 2004, Ricardo SIGNES wrote: my @columns = split(/,/, $csv_file); That's optimistic. id,name,title 42,Adams, Douglas,Author, HHGTTG et al id;name;title 42;Adams, Douglas;Author, HHGTTG et al Etc. There are various ways -- most ad hoc -- of embedding commas in CSV files, nearly all of which will fail if you just split on commas. One good way around this is to use DBD::CSV, and just write normal DBI code that treats your CSV file as if it were a SQL database. This works surprisingly well, and is much easier to do if you already know DBI. Splitting on commas, as above, is the easy way to do it, but it should really only be done if you *know* your data file is well behaved, i.e. you wrote it, you've validated it, it has no funny rows, etc. If there's any reasonable chance that the data gets funny, things get much harder to do right and you're better off going with a module like DBD::CSV. -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: simple windows process list
In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Jp) writes: The object of the code below is to output a list of space seperated fields with PID, username and process. The code generates te correct output. My guess is that my perl code can be smaller. Who dares? Don't care about smaller. Care about clearer. Sometimes the two go together. #!perl # # Object: # To output a tab separated list of PID, username and process # for windows XP # # Prerequisites: # 1) ActiveState Perl # 2) Windows XP use warnings; use strict; for my $line (`tasklist /v /nh`) { chomp($line); if ( $line ne ) { Avoid creating a whole new block by instead writing: $line ne or next; # extract PID my $pid = substr($line, 26, 6); # remove leading spaces $pid =~ s/^ *([0-9]+)$/$1/g; Why check for digits? What's going to go wrong if you don't? # extract username my $user = substr($line, 88, 50); # remove trailing spaces $user =~ s/^(.*\S)\s+$/$1/g; # change spaces in username to underscores $user =~ s/\s/\_/g; Why? # extract process my $proc = substr($line, 0, 24).substr($line, 152, 72); # change multiple spaces to single spaces $proc =~ s/\s\s\s*/ /g; This is usually written as s/\s+/ /g. even though technically there is a redundancy there. Or if you really mean 'space' and not 'white space', you can do: $proc =~ tr/ //s; # remove trailing space $proc =~ s/\s$//g; # remove trailing N/A $proc =~ s/ N\/A$//g; # print tab seperated fields print $pid, , $user, , $proc, \n; I don't see any tabs there. Try this: print $pid\t$user\t$proc\n; } } It is better design to have a subroutine that returns the values you want than to print them so close to having figured them out. One day you may want to do something other than printing them and you would like to be able to use the same code. -- Peter Scott http://www.perldebugged.com/ *** NEW *** http://www.perlmedic.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
RE: simple windows process list
JP wrote: The object of the code below is to output a list of space seperated fields with PID, username and process. The code generates te correct output. My guess is that my perl code can be smaller. Who dares? unpack() with 'A' is handy for extracting and removing trailing blanks in one step. for (grep /\S/, `tasklist /v /nh`) { chomp; my ($proc, $pid, $user, $title) = unpack 'A24 A8 x56 A50 x14 A*', $_; $proc = $proc $title unless $title eq 'N/A'; $proc =~ s/ +/ /g; # compress multiple spaces $pid += 0; # convert to number $user =~ tr/ /_/; # change blanks to underscores print join(\t, $pid, $user, $proc), \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: Mime Lite attachments
Hello everybody, I have used something like this to send e-mail with three parts: one is an html code that internally refers to other two files to compose the final design. This code may be adaptable to other needs. May be this help somebody. Josimar Nunes de Oliveira == $msg = MIME::Lite-new( From = $from_id, To = $to_id, Cc = $cc_id, Subject = $subject_text, Type = 'multipart/related', ); my $var = 'htmlbody table border=1 background=cid:InternalFileNameA.gif;... img src=cid:InternalFileNameB.jpg; /body/html'; $msg-attach( Type = 'text/html', Data = $var ); $msg-attach( Type = 'image/gif', Id = 'InternalFileNameA.gif', Path = 'FileNameA.gif' ); $msg-attach( Type = 'image/jpeg', Id = 'InternalFileNameB.jpg', Path = 'FileNameB.jpg' ); == - Original Message - From: Wiggins d Anconia [EMAIL PROTECTED] To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 10:33 AM Subject: Re: Mime Lite attachments All, Was hoping for some advise b/c I cannot seem to get this to work. My problem is that it attaches the path name when I need to actual data attached. So my goal is as if it would be cat test |uuencode test | mailx -s test [EMAIL PROTECTED] thanks, my $scratchtps = /usr/local/log/filename; code snippet there is a process that may/may not populate this file. if ( -s $scratchtps ) { mailme; The above is usually better written as: mailme(); } sub mailme { my $msg = MIME::Lite-new( From= 'EDM01 [EMAIL PROTECTED]', To = 'Derek Smith [EMAIL PROTECTED]', Subject = Return EDM Tapes, Type= 'TEXT', Data = $scratchtps, 'Data' is for the body, you need to either use the separate Cattach method, or provide the filename as the 'Path' argument. You really should start reading the docs thoroughly, you have asked a number of questions that are pretty simple if you just pay attention to the API, and MIME::Lite has very thorough and simple documentation, http://search.cpan.org/~yves/MIME-Lite-3.01/lib/MIME/Lite.pm#Create_a_simple_message_containing_just_an_image Disposition = 'attachment'); $msg-send; } 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 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Two easy questions.
If you are in 2K or XP you can go to the System Properties screen. In there click on the advanced tab then Environment Variables. Under System Variables locate PATHEXT. Add ;.pl to the end of the list then click OK. The system should allow for executing .pl files. As long as you have the #!.. info at the top of the file you should be OK. Regards, -- --==[ Bob Gordon ]==-- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Delete all hash entries except for a specific list
Consider, my %hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); I would like to remove all the entries in the hash except for 'bar' and 'qux'. (Actual hash has other entries which can vary at runtime. I know that I only want to keep 'bar' and 'qux' however). Here's what I'm doing: my @keys = qw(bar qux); my @values = @[EMAIL PROTECTED]; %hash = (); @[EMAIL PROTECTED] = @values; Is there a more elegant approach? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: simple windows process list
On 21 Sep 2004 13:03:21 -, Peter Scott [EMAIL PROTECTED] wrote: In article [EMAIL PROTECTED], [EMAIL PROTECTED] (Jp) writes: The object of the code below is to output a list of space seperated fields with PID, username and process. The code generates te correct output. My guess is that my perl code can be smaller. Who dares? Don't care about smaller. Care about clearer. Sometimes the two go together. SNIP It is better design to have a subroutine that returns the values you want than to print them so close to having figured them out. One day you may want to do something other than printing them and you would like to be able to use the same code. -- Peter Scott http://www.perldebugged.com/ *** NEW *** http://www.perlmedic.com/ Hi JP, I implemented some of Peter's suggestions for you, including making the meat of this code a subroutine for future use. Here's the sub: sub proclist { my %output; foreach my $line ( `tasklist /v /nh` ) { chomp( $line ); $line ne or next; # extract PID my $pid = substr($line, 26, 6); # remove leading spaces $pid =~ s/^\s*//; # extract username my $user = substr($line, 88, 50); # remove trailing spaces $user =~ s/\s*$//; # extract process my $proc = substr($line, 0, 24).substr($line, 152, 72); # change multiple spaces to single spaces $proc =~ s/\s+/ /g; # remove trailing N/A $proc =~ s/N\/A\s*$//g; # build the return hash $output{$pid} = join( ':', $user, $proc ); } return %output; } And here's some code that uses that sub to produce the output you were looking for: #!perl # # Object: # To output a tab separated list of PID, username and process # for windows XP # # Prerequisites: # 1) ActiveState Perl # 2) Windows XP use warnings; use strict; # here is an example of using the sub 'proclist' to produce the output # you described. Notice that # split(':', $proclisthash{$pid}) # will seperate the user info from the process info for you my %plist = proclist(); foreach my $pid( keys %plist ) { my( $out_pid, $out_user, $out_proc ) = ( $pid, split( ':', $plist{$pid} ) ); print $out_pid\t$out_user\t$out_proc\n; } cheers, --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
PROTO in sub NAME (PROTO) {
how is the (PROTO) operator in 'sub NAME (PROTO) {' supposed to be useful ? sub foo { sub foo ($) { sub foo ($$) { sub foo ($$$) { sub foo ($@) { sub foo (@) { i see the relation to the amount of arguments supposed to be in @_ --- my handy perl QRG provides a worthless explenation. there doesnt seem to be any warning or error when you ($$$) but only provide 1 argument, for example. Jeremy Kister http://jeremy.kister.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: Delete all hash entries except for a specific list
Bob Showalter wrote: Consider, my %hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); I would like to remove all the entries in the hash except for 'bar' and 'qux'. (Actual hash has other entries which can vary at runtime. I know that I only want to keep 'bar' and 'qux' however). Here's what I'm doing: my @keys = qw(bar qux); my @values = @[EMAIL PROTECTED]; %hash = (); @[EMAIL PROTECTED] = @values; Is there a more elegant approach? This is slightly shorter: %hash = map { $_, $hash{$_} } qw(bar qux); -- 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: PROTO in sub NAME (PROTO) {
Prototyping can be useful in Perl. It shouldn't be overused, however. They can be powerful when trying to make functions that look and feel like built-ins. Trying to, for example, create a subroutine that looks like map, grep, and sort is made by prototyping it as (@) (will pass coderef and an array). If you want to accept an array and handle it like splice does you can do (\@;@) (will pass array ref and an optional array). There are very specific examples found in the manual in perldoc perlsub. And there is a warning IF the subroutine is declared before you call it. Prototyping(1,2); #No exception, just a warning sub Prototyping ($$$) { print pop; } Prototyping 1, 2, 3; #Good job Prototyping(1,2); #works, read perldoc perlsub Prototyping(1); #Death I'm an advocate of prototyping. I like the power it can display in making your own functions behave like built-ins. But you can't go crazy with it and prototype every sub you write. Only do it when it makes your and the enduser's/maintainer's life easier. -- -will http://www.wgunther.tk (the above message is double rot13 encoded for security reasons) Most Useful Perl Modules -strict -warnings -Devel::DProf -Benchmark -B::Deparse -Data::Dumper -Clone -Perl::Tidy -Beautifier -DBD::SQLite -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Delete all hash entries except for a specific list
On Sep 21, Bob Showalter said: my %hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); I would like to remove all the entries in the hash except for 'bar' and 'qux'. (Actual hash has other entries which can vary at runtime. I know that I only want to keep 'bar' and 'qux' however). my @keys = qw(bar qux); You could do: my %keep_these_keys; @keep_these_keys{qw( bar qux )} = (); delete @hash{ grep !exists $keep_these_keys{$_}, keys %hash }; -- Jeff japhy Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: PROTO in sub NAME (PROTO) {
On Sep 21, Jeremy Kister said: how is the (PROTO) operator in 'sub NAME (PROTO) {' supposed to be useful ? Prototypes are only useful: 1. when the function is prototyped BEFORE it is called, 2. when the function is called without an , and 3. when the function is not a method of an object. See the documentation for prototypes. Chances are, you don't need them. -- Jeff japhy Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: simple windows process list
Cool! I'm down to 161 bytes now, short enough for a oneliner at the C:\ prompt. for(grep/\S/,`tasklist /v /nh`){ chomp;my($p,$i,$u,$t)=unpack'A24A8x56A50x14A*',$_;$p=$p $tunless$t eq'N/A';$p=~s/ +/ /g;$i+=0;$u=~tr/ /_/;print$i $u $p\n} Don't worry guys, my other scripts are far more readable :-) JP Bob Showalter [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED] JP wrote: The object of the code below is to output a list of space seperated fields with PID, username and process. The code generates te correct output. My guess is that my perl code can be smaller. Who dares? unpack() with 'A' is handy for extracting and removing trailing blanks in one step. for (grep /\S/, `tasklist /v /nh`) { chomp; my ($proc, $pid, $user, $title) = unpack 'A24 A8 x56 A50 x14 A*', $_; $proc = $proc $title unless $title eq 'N/A'; $proc =~ s/ +/ /g; # compress multiple spaces $pid += 0; # convert to number $user =~ tr/ /_/; # change blanks to underscores print join(\t, $pid, $user, $proc), \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: calling Perl Script from JSP?
From: NYIMI Jose \(BMB\) [EMAIL PROTECTED] -Original Message- From: Drue Reeves [mailto:[EMAIL PROTECTED] Anyone know how to call a PERL Script from a JSP and pass parameters to the script? I have a JSP that will call PERL but, everytime we try to add a script nothing happens. Any ideas? Very bad idea trying to mix Perl and JSP ... Which feature of Perl do you want to use in your JSP page that you can't get from Java ? Jos. Ease of use? Freedom? The loads of CPAN modules? Simply ... the power? What exactly do you mean by call? Do you need to 1) run a Perl script after the user clicks a link or button on the page returned by your JSP? 2) start a local Perl script while processing the JSP on the server, capture the output and include it in the resulting page? 3) start a remote Perl CGI script while processing the JSP on the server, capture the output and include it in the resulting page? In the first case you just need to either construct the URL to the script plus the parameters or create a form action=URL of the script with some hidden fields for those values and let the user submit the form. In the other two cases you are very unlikely to get much help in here. Try a Java/JSP related mailing list. I have no idea how to do either in Java and I'd love it to remain so. Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
starting position of RE match
Is there an equivalent for index that uses regular expressions instead of exact string? I've been looking at index, pos, m//, and the corresponding $ variables but nothing I've found so far does what I'm looking for. Specifically, what I'm trying to do is find all the starting locations of a RE match. For example, using an exact string match: $ perl -e '$foo=bb; $re=aa ; for ($bar=index($foo, $re); $bar = 0 ; $bar=index($foo, $re, $bar+1)) { print $bar, \t } print \n ; ' 1 2 3 I'd like to do the same except use a regular expression. BTW, notice that matches can overlap. Any thoughts or ideas? Regards, - Robert http://www.cwelug.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
array rotate question
Hello! I am thinking about making clear and short script to rotate array, let's say: input: @list = (1 .. 20); $start = 10; #starting position $values = 10;#how much values in result how to get output: @result = ( 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ); #10 values (I don't want $start in @result) ofcoure script should work with overlapping too: @list = (1 .. 20); $start = 18; $items = 10; output: @result = ( 13, 14, 15, 16, 17, 19, 20, 1, 2, 3 ); #10 values any ideas ? thanks. /brano -=x=- Skontrolované antivírovým programom NOD32 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: array rotate question
Ing. Branislav Gerzo wrote: Hello! Hello, I am thinking about making clear and short script to rotate array, let's say: input: @list = (1 .. 20); $start = 10; #starting position $values = 10;#how much values in result how about for starters: my @list = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); my $result= getsection([EMAIL PROTECTED],20,10); for( @{ $result }) { print -$_-\n; } sub getsection { my @newa = (); my ($aref,$strt,$amnt) = @_; return undef if ref($aref) ne 'ARRAY' || $strt !~ m/^\d+$/ || $amnt !~ m/^\d+$/; my $last = scalar(@{ $aref }); $last--; my $begn = 0; for( $strt .. (($strt + $amnt) - 1) ) { if($_ = $last) { push @newa, $aref-[$_]; } else { push @newa, $aref-[$begn];$begn++; } } return [EMAIL PROTECTED]; } how to get output: @result = ( 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ); #10 values (I don't want $start in @result) ofcoure script should work with overlapping too: @list = (1 .. 20); $start = 18; $items = 10; output: @result = ( 13, 14, 15, 16, 17, 19, 20, 1, 2, 3 ); #10 values any ideas ? Why is there a difference of 5 each time: $start = 10 $result[0] = 5 $start = 18 $result[0] = 13 That's throwing me a bit 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: array rotate question
From: Ing. Branislav Gerzo [EMAIL PROTECTED] I am thinking about making clear and short script to rotate array, let's say: input: @list = (1 .. 20); $start = 10; #starting position $values = 10;#how much values in result many (taky si to furt pletu) how to get output: @result = ( 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ); #10 values (I don't want $start in @result) ofcoure script should work with overlapping too: @list = (1 .. 20); $start = 18; $items = 10; output: @result = ( 13, 14, 15, 16, 17, 19, 20, 1, 2, 3 ); #10 values Assuming $values does not get bigger than the number of items in the list and $start is always = the number of items in the list: @list = (@list, @list); @result = ( @list[($start-$values/2-1) .. ($start-2)], @list[($start) .. ($start+$values/2-1)] ); HTH, Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: array rotate question
Ing. Branislav Gerzo wrote: I am thinking about making clear and short script to rotate array, let's say: input: @list = (1 .. 20); $start = 10; #starting position $values = 10;#how much values in result how to get output: @result = ( 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ); #10 values (I don't want $start in @result) Did you suddenly change $start to 4? ofcoure script should work with overlapping too: @list = (1 .. 20); $start = 18; $items = 10; output: @result = ( 13, 14, 15, 16, 17, 19, 20, 1, 2, 3 ); #10 values I fail to see how that would be the result of $start = 18. Anyway, even if it's unclear what you mean by start position, something like this may be what you want: sub rotate { my @list = @{ +shift }; my ($start, $values) = @_; unshift @list, splice(@list, $start); @list[ 0 .. $values-1 ] } my @result = rotate( [EMAIL PROTECTED], $start, $values ); -- 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: array rotate question
how about for starters: my @list = qw(a b c d e f g h i j k l m n o p q r s t u v w x y z); my $result= getsection([EMAIL PROTECTED],20,10); for( @{ $result }) { print -$_-\n; } sub getsection { my @newa = (); my ($aref,$strt,$amnt) = @_; return undef if ref($aref) ne 'ARRAY' || $strt !~ m/^\d+$/ || $amnt !~ m/^\d+$/; my $last = scalar(@{ $aref }); $last--; my $begn = 0; for( $strt .. (($strt + $amnt) - 1) ) { if($_ = $last) { push @newa, $aref-[$_]; } else { push @newa, $aref-[$begn];$begn++; } } return [EMAIL PROTECTED]; } Doh! Of course there was a shorter sexxier way! Jenda and Gunnar, you always rock! ;p 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: starting position of RE match
From: Robert Citek [EMAIL PROTECTED] Is there an equivalent for index that uses regular expressions instead of exact string? I've been looking at index, pos, m//, and the corresponding $ variables but nothing I've found so far does what I'm looking for. Specifically, what I'm trying to do is find all the starting locations of a RE match. For example, using an exact string match: $ perl -e '$foo=bb; $re=aa ; for ($bar=index($foo, $re); $bar = 0 ; $bar=index($foo, $re, $bar+1)) { print $bar, \t } print \n ; ' 1 2 3 I'd like to do the same except use a regular expression. BTW, notice that matches can overlap. Any thoughts or ideas? How about this: $s = sasas dfgfgh asasas asedsase; while ($s =~ /\G.*?(?=sas)./g) { print pos=,pos($s)-1, = ',substr($s,pos($s)-1,3),'\n; } the sas is the regexp being matched. The \G matches where the last match left off, the .*? skips as few characters as possible, the (?=) makes sure the regexp matches at that place, but doesn't move the position in string and the . at the end moves the position so that the next round doesn't find the same occurrence. That's also why I have to subtrct the 1 from the pos($s). You could also do this: while ($s =~ /\G.+?(?=sas)/g) { print pos=,pos($s), = ',substr($s,pos($s),3),'\n; } Which looks a bit nicer, but it would miss the match at the very beginning of the string. HTH, Jenda = [EMAIL PROTECTED] === http://Jenda.Krynicky.cz = When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Delete all hash entries except for a specific list
On Tue, 21 Sep 2004 14:58:43 -0400 (EDT), Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote: On Sep 21, Bob Showalter said: my %hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); I would like to remove all the entries in the hash except for 'bar' and 'qux'. (Actual hash has other entries which can vary at runtime. I know that I only want to keep 'bar' and 'qux' however). my @keys = qw(bar qux); You could do: my %keep_these_keys; @keep_these_keys{qw( bar qux )} = (); delete @hash{ grep !exists $keep_these_keys{$_}, keys %hash }; -- Jeff japhy Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart So ... is there a way to return a 'not' slice of hashes? What I mean is, the 'keys' function returns a list of all keys in a slice. Is there a function to return a list of all keys in slice EXCEPT those keys that I explicitely pass? like this, maybe: my %my_hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); my @other_keys = not_keys( %my_hash, foo, bar ) and then @other_keys = qw( baz qux ) ??? --Errin -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: starting position of RE match
On Tuesday, Sep 21, 2004, at 17:17 US/Central, Jenda Krynicky wrote: How about this: $s = sasas dfgfgh asasas asedsase; while ($s =~ /\G.*?(?=sas)./g) { print pos=,pos($s)-1, = ',substr($s,pos($s)-1,3),'\n; } Thanks. Seems to work, although I'm still trying to grok it. I'll probably have questions later. Regards, - Robert http://www.cwelug.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: array rotate question
JupiterHost.Net wrote: Doh! Of course there was a shorter sexxier way! Jenda and Gunnar, you always rock! ;p Maybe Jenda, not me. Actually, both you and I misunderstood the OP. $start is not the beginning of a slice, it's the middle... -- 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: Delete all hash entries except for a specific list
On Sep 21, Errin Larsen said: On Tue, 21 Sep 2004 14:58:43 -0400 (EDT), Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote: On Sep 21, Bob Showalter said: my %hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); I would like to remove all the entries in the hash except for 'bar' and 'qux'. (Actual hash has other entries which can vary at runtime. I know that I only want to keep 'bar' and 'qux' however). my @keys = qw(bar qux); my %keep_these_keys; @keep_these_keys{qw( bar qux )} = (); delete @hash{ grep !exists $keep_these_keys{$_}, keys %hash }; So ... is there a way to return a 'not' slice of hashes? What I mean is, the 'keys' function returns a list of all keys in a slice. Is there a function to return a list of all keys in slice EXCEPT those keys that I explicitely pass? like this, maybe: my %my_hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); my @other_keys = not_keys( %my_hash, foo, bar ) and then @other_keys = qw( baz qux ) Write your own function. This is where prototypes come in handy: # declare the function BEFORE you use it # we could also define it here, but that might look ugly sub not_keys (\%@); # ... my @other_keys = not_keys(%my_hash, foo, bar); # ... sub not_keys (\%@) { my $hash = shift; my %exclude; @[EMAIL PROTECTED] = (); # build hash of keys to exclude return grep !exists $exclude{$_}, keys %$hash; } -- Jeff japhy Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ %-- Meister Eckhart -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
DBD::Oracle installation Woes
Ok here is the deal, our admin is trying to install DBD::Oracle for me to access one of our affiliates databases. The oracle instant basic client and sqlplus has been installed as well as GetOpt::Long. The installations all went well except for DBD::Oracle, it fails to install, I am pretty sure because Oracle is NOT installed on this machine, and will NOT be installed on this machine. S here is the actual situation, we cannot NFS mount the remote DB server in order to use that path as ORACLE_HOME, We cannot install Oracle on our machine, is there a way to get DBD::Oracle built and installed on my machine, without the Oracle files locally? OH, btw, I cannot FTP the files from the DB server to my machine either, this is a case of a partner company at an international location, with limited (very limited) access to the actual DB server, which is why I am scripting the queries from my machine and just getting the data I need from them. Oh and P.S. my machine is Red Hat Enterprise Linux ES release 3 (Taroon Update 3) 2.4.21-15.0.4.EL . Chris Hood Investigator Verizon Global Security Operations Center Email:[EMAIL PROTECTED] Desk: 972.399.5900 Verizon Proprietary -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response
Re: Delete all hash entries except for a specific list
Bob Showalter wrote: Consider, my %hash = ( foo = 1, bar = 2, baz = 3, qux = 4, ); I would like to remove all the entries in the hash except for 'bar' and 'qux'. (Actual hash has other entries which can vary at runtime. I know that I only want to keep 'bar' and 'qux' however). Here's what I'm doing: my @keys = qw(bar qux); my @values = @[EMAIL PROTECTED]; %hash = (); @[EMAIL PROTECTED] = @values; Is there a more elegant approach? I don't know if it is more elegant but you could do it like this: %hash = map @$_, grep $_-[0] =~ /^(?:bar|qux)$/, map [ $_, $hash{$_} ], keys %hash; :-) 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: calling Perl Script from JSP?
Mainly some LDAP calls. PERL makes it easy to develop applications that do search and modify in LDAP with very little code. Java and C++ take much more code. Plus, PERL had some example code that made the development very simple. Why is it bad to mix JSP and PERL? Maybe a better question is how do you call a PERL script from a web page (and pass parameters)? Thank you, Drue NYIMI Jose (BMB) [EMAIL PROTECTED] wrote: -Original Message- From: Drue Reeves [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 21, 2004 4:49 AM To: [EMAIL PROTECTED]; Cary Andrews Subject: calling Perl Script from JSP? Anyone know how to call a PERL Script from a JSP and pass parameters to the script? I have a JSP that will call PERL but, everytime we try to add a script nothing happens. Any ideas? Very bad idea trying to mix Perl and JSP ... Which feature of Perl do you want to use in your JSP page that you can't get from Java ? José. DISCLAIMER This e-mail and any attachment thereto may contain information which is confidential and/or protected by intellectual property rights and are intended for the sole use of the recipient(s) named above. Any use of the information contained herein (including, but not limited to, total or partial reproduction, communication or distribution in any form) by other persons than the designated recipient(s) is prohibited. If you have received this e-mail in error, please notify the sender either by telephone or by e-mail and delete the material from any computer. Thank you for your cooperation. For further information about Proximus mobile phone services please see our website at http://www.proximus.be or refer to any Proximus agent.
Re: array rotate question
Ing. Branislav Gerzo wrote: Hello! Hello, I am thinking about making clear and short script to rotate array, let's say: input: @list = (1 .. 20); $start = 10; #starting position $values = 10;#how much values in result how to get output: @result = ( 5, 6, 7, 8, 9, 11, 12, 13, 14, 15 ); #10 values (I don't want $start in @result) ofcoure script should work with overlapping too: @list = (1 .. 20); $start = 18; $items = 10; output: @result = ( 13, 14, 15, 16, 17, 19, 20, 1, 2, 3 ); #10 values any ideas ? my @result = @list[ map { $_ @list ? $_ : $_ - $#list - 1 } $start .. $start + $items - 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: calling Perl Script from JSP?
First of all, Perl is the language, perl is the program that runs programs written in Perl, and PERL isn't a word. On Tue, 21 Sep 2004, Drue Reeves wrote: Why is it bad to mix JSP and Perl? They are just much different frameworks. Most Java systems I'm aware of (and I'll plead guilty to some ignorance here) pretty much want you to do everything in Java, from the JSP scripts that display pages to the beans (or whatever) that implement the site logic to, sometimes, the database itself. Perl on the other hand is often the glue holding a heterogeneous system together. It's very good for getting a bunch of disparate pieces that are either old or maybe came from different places to play nicely together. I know nothing about your JSP system, but conventionally, shops that have decided to go with JSP seem to do everything in JSP, just because there's so much inertia behind getting everything locked in to Java. I seem to be talking about the cultures more than the languages. Oh well. Maybe a better question is how do you call a Perl script from a web page (and pass parameters)? There is a lot of flexibility here. Often, Perl *is* the web page, whether by a CGI script that runs perl and executes the script with each page view, or a mod_perl plugin that embeds perl into Apache so that scripts are persistent in memory (which is the approach that JSP and other languages seem to take, right?). But if you just have a static HTML document that needs to call Perl somehow, the usual way is either by a form's action tag or just by following a link. In either case, this usually ends up being a GET or POST request to a Perl script that has been exposed as a web page with a URL. For POST requests, the parameters are sent to the script basically as a text document that is uploaded to the server, while for GET requests the data comes in following the script. Hence, http://google.com/search?q=http%20protocol ^ ^ ^ ^-- parameters to the script | | +--- the script / program / whatever | + the domain +- the protocol And if this doesn't make sense, there's lots of documentation out there. This book may help clarify things -- it's old now, but the fundamentals haven't changed since it was published: http://www.oreilly.com/openbook/webclient/ So, if you're working via HTTP -- as you're doing on the web -- then it just ends up being a URL that you GET from or maybe POST to. Make sense? More questions? -- Chris Devers -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ http://learn.perl.org/first-response