Re: fastest regexp: split or (.*)?
On Thu, Jul 11, 2002 at 09:17:18PM -0700, drieux wrote: > http://www.wetware.com/drieux/pbl/Other/BenchMarks/split_v.re_for_RTF.txt > > Thanks. It appears splitting is quickest. What is bizzare about your link is that the code appear *almost identical* to what I had written. I mean, I asked a question with an example line, and the same example line was used; I chose two variables, and the same two variables were used. I kept having to say "no they didn't use your code you posed a few hours ago." Paul -- *Paul Tremblay * *[EMAIL PROTECTED]* -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
: VIM: How do you place abbreviations in permanent memory?
> -Original Message- > From: LRZ [mailto:[EMAIL PROTECTED]] > Sent: 12 July 2002 00:53 > To: [EMAIL PROTECTED] > Subject: : VIM: How do you place abbreviations in permanent memory? > > > I created the abbreviation foo to represent > #!/usr/bin/perl. It works if I hit any non character > key (ex. shift) and then type foo.Though it only works > for the time that that particular emulation terminal > is running. When a new emulation window is open, that > abbreviation is forgotten. How do I keep it in > permanent memory? The following is a bit from my vimrc it maps the key to toggle highlighting the last search off in vim. map :set hls!set hls? H * COLT Telecommunications Registered in England No. 2452736 Registered Office: Bishopsgate Court, 4 Norton Folgate, London E1 6DQ Tel. +44 20 7390 3900 This message is subject to and does not create or vary any contractual relationship between COLT Telecommunications, its subsidiaries or affiliates ("COLT") and you. Internet communications are not secure and therefore COLT does not accept legal responsibility for the contents of this message. Any view or opinions expressed are those of the author. The message is intended for the addressee only and its contents and any attached files are strictly confidential. If you have received it in error, please telephone the number above. Thank you. * -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
disable printing an output of a perl script file
I have a quiz program, the script queries the DB and print to the browser a test for the student to take. I would like to prevent them from printing that test. All my clients are IE 6.0 Thanks Jim
format
Hi all, when i execute the command given below: $cmd = `blrk2254d\\post\\postie\\postie.exe -host:$SMTP_SERVER -to:SAR.Javeed\@sisl.co.in -cc:@EMAIL_TO_LIST1 -from:$ENV{'CLEARCASE_USER'}\@sisl.co.in -s:\"$SUBJECT\" -msg:\"$file is added to clearcase by $user \",\"time is :$date \",\" the operation he has done is:$operation \",\" the comments he has given are:$comment \" -user:eed -pass:d777`; i get the following output: M:\jav_test\train\.\removexyzooo.exe:is added to clearcase by jav,the time is : Fri Jul 12 15:27:44 2002, the operation he has done is : mkelem,the comments he has added are : hi how do u do i want the output in this format: M:\jav_test\train\.\removexyzooo.exe:is added to clearcase by jav the time is : Fri Jul 12 15:27:44 2002 the operation he has done is : mkelem the comments he has added are : hi how do u do How to do that user: jav operation: mkelem date: Thu Jul 11 15:59:09 2002 element: M:\jav_test\train\.\removexyzooo.exe comment: TIA Regards javeed
Re: DBF File
> Hi, > > Anyone knows if PERL can talk to a .dbf file that is sitting on the > same machine where PERL is installed? See perldoc DBD::XBase and perldoc DBD::ODBC If you do not have these modules, install DBI. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Date
I need to do a Perl script who do a certain command after 2 days.Example: my file contains 8 Jul 2002 when I lunch the script it must control the date and if it's equal to date+2 (in this case 10 Jul 2002) execute my commands trought system.I thought to do this transforming the date in this format to days from the begin of the year but I don't know how.Thanks for your help, Francesco -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date
I don't know if this will help, but in: ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime (time); $yday will give you the number of days since the beginning of the year. Carson -- Original Message -- From: Francesco Guglielmo <[EMAIL PROTECTED]> Date: Fri, 12 Jul 2002 15:58:24 +0200 >I need to do a Perl script who do a certain command after 2 days.Example: >my file contains > >8 Jul 2002 > >when I lunch the script it must control the date and if it's equal to >date+2 (in this case 10 Jul 2002) execute my commands trought system.I >thought to do this transforming the date in this format to days from the >begin of the year but I don't know how.Thanks for your help, >Francesco > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date
> I need to do a Perl script who do a certain command after 2 days.Example: > my file contains > > 8 Jul 2002 > > when I lunch the script it must control the date and if it's equal to > date+2 (in this case 10 Jul 2002) execute my commands trought system.I > thought to do this transforming the date in this format to days from the > begin of the year but I don't know how.Thanks for your help, > Francesco Why do you need to do things this way? There is a perfectly good deamon in *nix called crond that would help you to schedule tasks at certain times. I think the list would like to know more exactly what you want to achieve in order to help you better... Thanks! //Anders// -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date
Anders Holm wrote: >>I need to do a Perl script who do a certain command after 2 days.Example: >>my file contains >> >>8 Jul 2002 >> >>when I lunch the script it must control the date and if it's equal to >>date+2 (in this case 10 Jul 2002) execute my commands trought system.I >>thought to do this transforming the date in this format to days from the >>begin of the year but I don't know how.Thanks for your help, >>Francesco >> > >Why do you need to do things this way? There is a perfectly good deamon in >*nix called crond that would help you to schedule tasks at certain times. > >I think the list would like to know more exactly what you want to achieve in >order to help you better... > I want to delete a "file" two days after his creation.Files are listed in another file.How can I do this?\ And how with crond?Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date
You could write a script that reads a file that contains a list of files. Compare the modification file of each file to the current date, if the file is at least two days old try and delete it. Then schedule this script to run everyday, take a look at: man crontab Cheers, - Craig Moynes Francesco GuglielmoTo: Anders Holm <[EMAIL PROTECTED]>, beginners <[EMAIL PROTECTED]> Subject: Re: Date 07/12/2002 10:41 AM Anders Holm wrote: >>I need to do a Perl script who do a certain command after 2 days.Example: >>my file contains >> >>8 Jul 2002 >> >>when I lunch the script it must control the date and if it's equal to >>date+2 (in this case 10 Jul 2002) execute my commands trought system.I >>thought to do this transforming the date in this format to days from the >>begin of the year but I don't know how.Thanks for your help, >>Francesco >> > >Why do you need to do things this way? There is a perfectly good deamon in >*nix called crond that would help you to schedule tasks at certain times. > >I think the list would like to know more exactly what you want to achieve in >order to help you better... > I want to delete a "file" two days after his creation.Files are listed in another file.How can I do this?\ And how with crond?Thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date
What I tend to do is use the Time::Local module, specifically them timelocal funciton. It's like the reverse of the localtime function. You give timelocal a series of parameters defining a date and it returns you the seconds since epoch. Then you can add (24*60*60)x2 for 2 days worth of seconds... You may want to watch your time manipulation, if you are looking for two full days (48 hours) this will work. If you are looking for fuzzy 2 days (ie: if it was created monday then anytime on wednesday it can be deleted, you may want to change the time on the file to reflect midnight on the day the file was last modified, and then do you time manipulation from there Ok that doesn't sound to clearI can give it another shot if you want :) #grab the modification time from the file my $modtime = (stat($filename))[9]; # Already in seconds since epoch #add two days worth of seconds my $tmptime = $modtime + 2*(24*60*60); #get localtime in seconds since epoch my $currtime = time; #and compare unlink $filename if ($currtime > $tmptime) something like that should work, its pretty ugly and can be made better, but that gives you a plan Francesco GuglielmoTo: Craig Moynes/Markham/IBM@IBMCA Subject: Re: Date 07/12/2002 10:53 AM Craig Moynes/Markham/IBM wrote: >You could write a script that reads a file that contains a list of files. >Compare the modification file of each file to the current date, if the file >is at least two days old try and delete it. > >Then schedule this script to run everyday, take a look at: > man crontab > That's clear!!! But if the date in my file is 30 July?How can I say that 30 July + 2 days = 1 Aug? > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Date
You could always try storing the value in time() format. (E.g. print OUTFILE time."\n";) Then you can check to see if the file is over two days old like this: my $time = time; if($time > $filetime + 172800){ unlink $file; } #172800 is the number of seconds in two days. -Original Message- From: Francesco Guglielmo [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 6:58 AM To: [EMAIL PROTECTED] Subject: Date I need to do a Perl script who do a certain command after 2 days.Example: my file contains 8 Jul 2002 when I lunch the script it must control the date and if it's equal to date+2 (in this case 10 Jul 2002) execute my commands trought system.I thought to do this transforming the date in this format to days from the begin of the year but I don't know how.Thanks for your help, Francesco -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: source a script from with perl
On Thursday, July 11, 2002, at 12:08 , Carson Wilcox wrote: > I have a need to source a ksh script from within a perl script. > Does anyone know if this is possible and how to do it. You may need to help us out here - since this sounds like you have a set of variables being assigned in a ksh fashion in a 'file' that would normally be simply 'sourced' into a ksh script with something like . /path/to/file I have an illustration of this behavior at the end. In that illustration, in the main, it is about setting environmental variables - all of which would be accessed in perl in th %ENV... the quick solution then is to have a simple wrapper script that sources all of the env context, and then launches the perl script. If on the other hand, one's ksh script is more towards a 'library' where it has a bunch of defined 'functions' - then your problem can be a bit more complex - and you have a few strategies to look at: a) porting this library to a perl lib, with a nice little parser code that knows how to translate ksh syntax into perl syntax b) build a ksh wrapper that does the sourcing, and based upon command line options invokes the functions in the ksh lib - so that you can call this in any of the standard perl ways of back-tick, system() or open(CALL, "wrapper $arg |") so it rather depends upon which you are really trying to solve with which 'sourcing' you are using. esoterica note: I agree with peter on the 'problem' of setting up the ENV stuff in a child - the solution I have always used is to 'contain' the ENV information in a script and then exec script so as to replace the login shell I was originally working in, with an alternative definition - as I did with the ksh scriptology below. ciao drieux --- an illustration of a ksh sourcing play ### #!/bin/ksh ### ### CommonDefFile=${HOME}/etc/drieuxTool.dfn ### ### if [ -f ${CommonDefFile} ] ### then ### . ${CommonDefFile} ### else ### echo "unable to find ${CommonDefFile}" ### exit ### fi ### ### PS="HappyMars > " ### export PS ### ENV=${HOME}/.mars.kshrc ### export ENV ### ### ksh ### ### exit where it specifically grabs: vladimir: 60:] sed 's/^/### /' ${HOME}/.mars.kshrc ### #!/bin/ksh ### ### # ### # the common kornsheel things for a Mars Complex ### # ### ### set -o vi ### alias gobin="cd ${MARS_BIN}" ### alias goconf="cd ${MARS_ETC}" ### alias golog="cd ${MARS_VAR}" ### alias golib="cd ${MARS_LIB}" ### ### alias gotools="cd ${MARS_TOOLS_BIN}" ### ### PS1="HappyMarsLand > " ### ### vladimir: 61:] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: disable printing an output of a perl script file
On Fri, 12 Jul 2002 07:25:19 -0400, [EMAIL PROTECTED] (Jim-Cont Flaherty) wrote: >I have a quiz program, the script queries the DB and print to the browser a >test for the student to take. I would like to prevent them from printing >that test. All my clients are IE 6.0 I don't think that is possible. They can always save the page, or even take screenshots. Then email them off to themselves. Your best best is to make randomized tests, so no student recives the same set of questions. Just have a huge base of questions. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: source a script from with perl
That's what I wound up doing, a wrapper script. Thanks for the response Carson -- Original Message -- From: drieux <[EMAIL PROTECTED]> Date: Fri, 12 Jul 2002 08:34:39 -0700 > >On Thursday, July 11, 2002, at 12:08 , Carson Wilcox wrote: > >> I have a need to source a ksh script from within a perl script. >> Does anyone know if this is possible and how to do it. > >You may need to help us out here - since this sounds like >you have a set of variables being assigned in a ksh fashion >in a 'file' that would normally be simply 'sourced' into >a ksh script with something like > > . /path/to/file > >I have an illustration of this behavior at the end. > >In that illustration, in the main, it is about setting >environmental variables - all of which would be accessed >in perl in th %ENV... > >the quick solution then is to have a simple wrapper script >that sources all of the env context, and then launches >the perl script. > >If on the other hand, one's ksh script is more towards a >'library' where it has a bunch of defined 'functions' - >then your problem can be a bit more complex - and you >have a few strategies to look at: > > a) porting this library to a perl lib, > with a nice little parser code that knows > how to translate ksh syntax into perl syntax > > b) build a ksh wrapper that does the sourcing, and > based upon command line options invokes the > functions in the ksh lib - so that you can > call this in any of the standard perl ways > of back-tick, system() or open(CALL, "wrapper $arg |") > >so it rather depends upon which you are really trying to solve >with which 'sourcing' you are using. > >esoterica note: > >I agree with peter on the 'problem' of setting up >the ENV stuff in a child - the solution I have always >used is to 'contain' the ENV information in a script >and then > > exec script > >so as to replace the login shell I was originally >working in, with an alternative definition - as >I did with the ksh scriptology below. > > >ciao >drieux > >--- > >an illustration of a ksh sourcing play > >### #!/bin/ksh >### >### CommonDefFile=${HOME}/etc/drieuxTool.dfn >### >### if [ -f ${CommonDefFile} ] >### then >### . ${CommonDefFile} >### else >### echo "unable to find ${CommonDefFile}" >### exit >### fi >### >### PS="HappyMars > " >### export PS >### ENV=${HOME}/.mars.kshrc >### export ENV >### >### ksh >### >### exit > >where it specifically grabs: >vladimir: 60:] sed 's/^/### /' ${HOME}/.mars.kshrc >### #!/bin/ksh >### >### # >### # the common kornsheel things for a Mars Complex >### # >### >### set -o vi >### alias gobin="cd ${MARS_BIN}" >### alias goconf="cd ${MARS_ETC}" >### alias golog="cd ${MARS_VAR}" >### alias golib="cd ${MARS_LIB}" >### >### alias gotools="cd ${MARS_TOOLS_BIN}" >### >### PS1="HappyMarsLand > " >### >### >vladimir: 61:] > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: disable printing an output of a perl script file
> -Original Message- > From: FLAHERTY, JIM-CONT [mailto:[EMAIL PROTECTED]] > Sent: Friday, July 12, 2002 7:25 AM > To: Beginners (E-mail) > Subject: disable printing an output of a perl script file > > > I have a quiz program, the script queries the DB and print to > the browser a > test for the student to take. I would like to prevent them > from printing > that test. All my clients are IE 6.0 > You can add something like this to the section of your page: @media print { BODY { display: none; } } But that is easily defeated of course, using any number of methods. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date and Time
Peter, et al -- ...and then Peter Scott said... % ... % code. (Yes, IMHO, if you insist.) My students see it in every program % I show them, from Hello World onward. I tell them that if anyone gives % them code without it to maintain, they should refuse if at all % possible. Later on I show the beginners a nasty example of the % consequences of leaving out use strict, -w/use warnings, or both. Oooh! Oooh! Show me an example or two! Please? Sounds great! Simple, concise examples are great convincers. TIA & HAND :-D -- David T-G * It's easier to fight for one's principles (play) [EMAIL PROTECTED] * than to live up to them. -- fortune cookie (work) [EMAIL PROTECTED] http://www.justpickone.org/davidtg/Shpx gur Pbzzhavpngvbaf Qrprapl Npg! msg27469/pgp0.pgp Description: PGP signature
Pass variables from perl to asp
is it possible to pass variables from perl to asp... from my asp page (running on unix/apache), id like to call a perl script (module maybe?) and have the script return back something to the asp page, much like a function. is that possible??? and i would like to do this without any redirections (ie...redirect from the perl to my asp page using GET url) any helps,leads,tips would be very appreciated. -pete -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Fork to run a sub -process
Hi everyone, I am stuck. I have a perl script that I wrote. It runs on a Solaris 8 box and goes out to linux boxes and tars up user data and mysql data and stores it on particular drives of the sun box. Right now the script only goes out and tars up one server at a time. I was thinking of putting that process as a sub routine and try to go out and "backup" two servers (or three) at a time. I am thinking I should try and fork child processes to do each server. The child being the sub routine. What do you think? Would this be the best way to go about this? Where is the best resource for examples on forking? I am going through google groups but most of them entail system calls or networking. Not a sub routine. thanks for the help... --chad -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Fork to run a sub -process
> -Original Message- > From: chad kellerman [mailto:[EMAIL PROTECTED]] > Sent: Friday, July 12, 2002 12:57 PM > To: [EMAIL PROTECTED] > Subject: Fork to run a sub -process > > > Hi everyone, > > I am stuck. I have a perl script that I wrote. It runs > on a Solaris 8 > box and goes out to linux boxes and tars up user data and > mysql data and > stores it on particular drives of the sun box. > >Right now the script only goes out and tars up one server > at a time. I was > thinking of putting that process as a sub routine and try to > go out and > "backup" two servers (or three) at a time. > > I am thinking I should try and fork child processes to do > each server. The > child being the sub routine. > > What do you think? Would this be the best way to go about > this? Where is > the best resource for examples on forking? I am going > through google groups > but most of them entail system calls or networking. Not a > sub routine. The Perl Cookbook from O'Reilly has nice examples, IMO. The basic idea is really quite simple: Iterative example: for my $server (qw(huey duey louie)) { do_lengthy_process($server); } sub do_lengthy_proces { ... blah blah ... } Forking example: for my $server (qw(huey duey louie)) { defined(my $pid = fork) or die "Couldn't fork: $!"; unless ($pid) { do_lengthy_process($server); exit; } } That's really all you need to do. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Fork to run a sub -process
Where is the command that runs inside the fork (ie. _lengthy_process running in the fork)? Forking example: for my $server (qw(huey duey louie)) { defined(my $pid = fork) or die "Couldn't fork: $!"; # forked command(s) begin/end here? unless ($pid) { do_lengthy_process($server);# runs unforked if fork fails exit; } } - Original Message - From: "Bob Showalter" <[EMAIL PROTECTED]> To: "'chad kellerman'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Friday, July 12, 2002 10:11 AM Subject: RE: Fork to run a sub -process : > -Original Message- : > From: chad kellerman [mailto:[EMAIL PROTECTED]] : > Sent: Friday, July 12, 2002 12:57 PM : > To: [EMAIL PROTECTED] : > Subject: Fork to run a sub -process : > : > : > Hi everyone, : > : > I am stuck. I have a perl script that I wrote. It runs : > on a Solaris 8 : > box and goes out to linux boxes and tars up user data and : > mysql data and : > stores it on particular drives of the sun box. : > : >Right now the script only goes out and tars up one server : > at a time. I was : > thinking of putting that process as a sub routine and try to : > go out and : > "backup" two servers (or three) at a time. : > : > I am thinking I should try and fork child processes to do : > each server. The : > child being the sub routine. : > : > What do you think? Would this be the best way to go about : > this? Where is : > the best resource for examples on forking? I am going : > through google groups : > but most of them entail system calls or networking. Not a : > sub routine. : : The Perl Cookbook from O'Reilly has nice examples, IMO. : : The basic idea is really quite simple: : : Iterative example: : : for my $server (qw(huey duey louie)) { : do_lengthy_process($server); : } : : sub do_lengthy_proces : { : ... blah blah ... : } : : Forking example: : : for my $server (qw(huey duey louie)) { : defined(my $pid = fork) or die "Couldn't fork: $!"; : unless ($pid) { : do_lengthy_process($server); : exit; : } : } : : That's really all you need to do. : : -- : To unsubscribe, e-mail: [EMAIL PROTECTED] : For additional commands, e-mail: [EMAIL PROTECTED] : : -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Pass variables from perl to asp
On Friday, July 12, 2002, at 09:24 , Peter wrote: > is it possible to pass variables from perl to asp... there are several ways to pass 'stuff' around - a) simple numerical style by testing for the exit value traditionally the shell exits with 0 if all is ok non-zero if something happened b) parse the output of the command one called c) get way harry and have the child process re-attach to the parent process on a specified port and exchange messages... d) write your perl as a CGI piece of code - that you would invoke with something like http://vbs-wsh-iis- dictionary.pstruh.cz/tips/detpg_a-remote-asp-application-access.htm > from my asp page (running on unix/apache), id like to call a perl script > (module maybe?) think of module as you would of a 'library' - or a 'class definition' as they are variations on the basic idea of 'how to put a stack of functions somewhere' - hence you will want to call a 'perl script' that may or may not use one or more module. > and have the script return back something to the asp page, much like a > function. > is that possible??? If you can get your asp page to execute any external piece of code and read what happened then it is just that simple. hence if your perl code could execute the unix command date and get the string back in a way you could use, then you can just as easily call a piece of perl to return you information.. > and i would like to do this without any redirections (ie...redirect from > the > perl to my asp page using GET url) on the asp specific side you will of course want to check with resources like: http://www.aspin.com/ on the implementation details about how asp can invoke external code. solve that part and you are ready to deal with the "so, ok, how do I get this perl code I am working on to do.." ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: fastest regexp: split or (.*)?
On Friday, July 12, 2002, at 12:31 , Paul Tremblay wrote: > On Thu, Jul 11, 2002 at 09:17:18PM -0700, drieux wrote: >> http://www.wetware.com/drieux/pbl/Other/BenchMarks/split_v.re_for_RTF.txt > > Thanks. It appears splitting is quickest. that is not a 'generalizable' solution - as there are cases where it is not the 'best fit' [..] > I kept having to say "no they didn't use your code you posed a few hours > ago." what is so bizzarrO about it? Someone pointed you at 'benchmarks' - I merely opted to demonstrate it - so - the answer is, a) when building a simple bench mark use the cats original specs b) this way the cat has less issues with what they read since it is implementation specific as you will note with say http://www.wetware.com/drieux/pbl/perlTrick/drieuxTemplates/ I have a stock set of these that I use for a variety of quick illustrations and demonstrations - so it is rather simple to use bbedit with a template I have stashed in the Stationery - gin up an example, test it, hang it in my webPages - and ship the URL. it takes a little longer if we need to demonstrate things as inter-operable across multiple manifestations of *nix ciao drieux http://www.wetware.com/drieux/pbl/ -- This space left intentionally blank. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBF File
Hi Here are some lines that may help you this will open and write to a database file. my $database = 'c:\apache\your.dbf'; this is where you define the .dbf file open (DATABASE, ">>$database"); flock (DATABASE, 2); print DATABASE "$username|$password|$date\n"; flock (DATABASE, 8); close (DATABASE); Hope this is of help jffusion On Fri, 12 Jul 2002 14:26:25 +0800 "Karen Liew Ying Ping" <[EMAIL PROTECTED]> writes: > Hi, > > Anyone knows if PERL can talk to a .dbf file that is sitting on the > same machine where PERL is installed? > > or remote system? > > Thanks. > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: source a script from with perl
On Jul 12, drieux said: > >On Thursday, July 11, 2002, at 12:08 , Carson Wilcox wrote: > >> I have a need to source a ksh script from within a perl script. >> Does anyone know if this is possible and how to do it. > >You may need to help us out here - since this sounds like >you have a set of variables being assigned in a ksh fashion >in a 'file' that would normally be simply 'sourced' into >a ksh script with something like > > . /path/to/file > >I have an illustration of this behavior at the end. > >In that illustration, in the main, it is about setting >environmental variables - all of which would be accessed >in perl in th %ENV... > >the quick solution then is to have a simple wrapper script >that sources all of the env context, and then launches >the perl script. > >If on the other hand, one's ksh script is more towards a >'library' where it has a bunch of defined 'functions' - >then your problem can be a bit more complex - and you >have a few strategies to look at: > > a) porting this library to a perl lib, > with a nice little parser code that knows > how to translate ksh syntax into perl syntax > > b) build a ksh wrapper that does the sourcing, and > based upon command line options invokes the > functions in the ksh lib - so that you can > call this in any of the standard perl ways > of back-tick, system() or open(CALL, "wrapper $arg |") > >so it rather depends upon which you are really trying to solve >with which 'sourcing' you are using. > >esoterica note: > >I agree with peter on the 'problem' of setting up >the ENV stuff in a child - the solution I have always >used is to 'contain' the ENV information in a script >and then > > exec script > >so as to replace the login shell I was originally >working in, with an alternative definition - as >I did with the ksh scriptology below. > > >ciao >drieux > >--- > >an illustration of a ksh sourcing play > >### #!/bin/ksh >### >### CommonDefFile=${HOME}/etc/drieuxTool.dfn >### >### if [ -f ${CommonDefFile} ] >### then >### . ${CommonDefFile} >### else >### echo "unable to find ${CommonDefFile}" >### exit >### fi >### >### PS="HappyMars > " >### export PS >### ENV=${HOME}/.mars.kshrc >### export ENV >### >### ksh >### >### exit > >where it specifically grabs: >vladimir: 60:] sed 's/^/### /' ${HOME}/.mars.kshrc >### #!/bin/ksh >### >### # >### # the common kornsheel things for a Mars Complex >### # >### >### set -o vi >### alias gobin="cd ${MARS_BIN}" >### alias goconf="cd ${MARS_ETC}" >### alias golog="cd ${MARS_VAR}" >### alias golib="cd ${MARS_LIB}" >### >### alias gotools="cd ${MARS_TOOLS_BIN}" >### >### PS1="HappyMarsLand > " >### >### >vladimir: 61:] > > >-- >To unsubscribe, e-mail: [EMAIL PROTECTED] >For additional commands, e-mail: [EMAIL PROTECTED] > > > -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
an error in a simple regexp
Hi, I typed this simple cmd in the bash: echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' and expected ouput like 1.2.3 but obtained this one: 1.23 What's wrong and how to write a regexp cmd which will transfer a number to digits with dots in between? eg: 1234 -> 1.2.3.4 Thanx Regards, Dusan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32 registry question
Hello, Does anyone have a script that will query a registry key on a remote PC? I'm doing some maintenance work this would really help a lot. Thanks, Ed Beaugard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Win32 registry question
Hello, Anyone have a script that will query the registry for the value of a particular key? I'm doing some maintenance work and haven't been able to figure out the TieHash way of accessing the registry. Thanks, Ed Beaugard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Fork to run a sub -process
> -Original Message- > From: George Szynal [mailto:[EMAIL PROTECTED]] > Sent: Friday, July 12, 2002 1:34 PM > To: Bob Showalter; 'chad kellerman'; [EMAIL PROTECTED] > Subject: Re: Fork to run a sub -process > > > Where is the command that runs inside the fork (ie. > _lengthy_process running > in the fork)? In my example, I assume that do_lengthy_process is a normal perl sub that does whatever the OP was wanting to do. It can make system calls or whatever... I don't know what you mean by "inside the fork". fork creates a new process. after the fork, there are two identical copies of the original process running. The only difference is that $pid is 0 for the child and non-zero for the parent. If $pid is zero, the child runs the lengthy process and then exits. The parent skips the lengthy process and loops back around to fork the next child. > > > > Forking example: > > for my $server (qw(huey duey louie)) { > defined(my $pid = fork) or die "Couldn't fork: $!"; > > # forked command(s) begin/end here? > unless ($pid) { > do_lengthy_process($server); > # runs > unforked if fork fails No. we will only get here if the fork succeeded. If the fork fails, we die above. > exit; > } > } > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: an error in a simple regexp
On Jul 12, Dusan Juhas said: >I typed this simple cmd in the bash: >echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' >and expected ouput like >1.2.3 >but obtained this one: >1.23 The reason you don't get "1.2.3" is because by the time Perl has matched "12", it can't match the "2" again. Here's a working regex: s/(\d)(?=\d)/$1./g; The (?=\d) looks ahead for a digit, without actually consuming it. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Win32 registry question
Here's a littel tutorial I wrote for a friend of mine. It shows the basics of setting/reading keys. -Original Message- From: Edouard Beaugard [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 11:02 AM To: [EMAIL PROTECTED] Subject: Win32 registry question Hello, Anyone have a script that will query the registry for the value of a particular key? I'm doing some maintenance work and haven't been able to figure out the TieHash way of accessing the registry. Thanks, Ed Beaugard -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] # ## ## ## Win32-TieRegistry_Tutorial v1.0.052302 ## ##written by Tim Johnson ## ## 05-23-2002 ## ## ## # #Welcome to the tutorial. This should give you a good #enough idea of how to manipulate the Windows registry #to perform most tasks. Let's get started by declaring #our modules. use strict; #always a good idea in general use Win32::TieRegistry(Delimiter => "/");#So that we can use forward slashes #A new Win32::TieRegistry object is automatically created #called $Registry. $Registry is a hash reference[1]. Each #key of the hash it points to is either another reference to #another hash or a scalar which corresponds to a"value"(to #use the registry term). This will make a little more #sense after you've used it a while. #Now that we've created the registry hashes, let's try #working with what we've created. We can create a new #object[1] that points to a specific part of the registry #or we can just shoot for the part we want to change. #For the purposes of making this easier to read, I'll make #a new object. my $IEKey = $Registry->{'HKEY_CURRENT_USER/Software/Microsoft/Internet Explorer/Main/'}; #The arrow operator, the way it is used in this example, denotes that we are #working with a hash reference, and not a key of %Registry. We now have #an object that represents the exact key we want to work with. Now let's #change the 'Start Page' value. $IEKey->{'Start Page'} = "http://www.perl.org";; #Viola! Your start page has changed. Now let's try creating a new key. $Registry->{'HKEY_CURRENT_USER/Software/Perl Beginners/'} = {}; #We've created a new, empty key. Now let's set the default value. $Registry->{'HKEY_CURRENT_USER/Software/Perl Beginners//'} = "Camel"; #Notice that since the default value does not have a name, there #are TWO slashes at the end of the key. With Win32::TieRegistry, #If you want to resolve ambiguities about whether the item at the end #is a registry key or registry value, you can (a)add a slash to the end #to denote a key, or (b)add two slashes before the value, so our #double-slash denotes a value with a zero-length name[2]. #For our next trick, lets create a new object for simplicity, and add #a value to our new key. my $BeginnerKey = $Registry->{'HKEY_CURRENT_USER/Software/Perl Beginners/'}; $BeginnerKey->{'TIMTOWTDI'} = "There Is More Than One Way To Do It"; #And for a variation on a theme, lets try a REG_DWORD value. This changes #things a little because it is a binary value. We will have to specify #both the value and the type like so, to avoid accidentally creating #a string value. $BeginnerKey->{'MyDWORD'} = ['0x0001',REG_DWORD]; #Finally, let's look at reading values. We are still treating each #key as a hash reference, so we will have to dereference our hash to #get the value. my $KeyValue = $BeginnerKey->{'TIMTOWTDI'}; print "My new variable's value is: $KeyValue\n\n"; #That looks pretty clean, but what about getting all of the keys? #If we dereference the hash, we can use the keys() function. my @KeyArray = keys %{$BeginnerKey}; print "Here are the values in my registry key:\n"; foreach(@KeyArray){ if($_ eq '/'){ print " /(default)\n"; }else{ print " $_\n"; } } #There are more things you can do with this module, but I think that #covers the basics. If you have any questions or comments, please post #them back to the list and I'll try to answer them if I can. #[1]Technically $Registry is a Win32::TieRegistry object. It is a tied # hash that allows you to manipulate the hash and automagically # cause changes to be made to the registry at the same time as changes # are made to the hash. Just think of it as a hash reference if that # seems confusing. #[2]Win32::TieRegistry will cut you a little slack when it comes to # calling keys and values, but it is always a good idea to add a slash # to the end whenever you are working with a key. This reduces the # possibility of accidentally creating a value when you meant to create # a key, or vice versa. -- To unsubscribe, e-mail: [EMAIL PROTECTED]
Re: an error in a simple regexp
Dusan Juhas wrote at Fri, 12 Jul 2002 18:16:44 +0200: > Hi, > I typed this simple cmd in the bash: > echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' > and expected ouput like > 1.2.3 > but obtained this one: > 1.23 > First your regexp finds (1)(2) what is a matching. So 1.2 is written. Then 3 is left, it doesn't match, but it won't be changed => 3 is written => 1.23 is written. > What's wrong and how to write a regexp cmd which will transfer a number to digits >with dots in > between? > eg: 1234 -> 1.2.3.4 Don't write a regexp: echo 1234 |perl -e 'print join ".", split //' or if you really need a regexp: echo 1234 | perl -pe 's/(\d)(?=\d)/$1./g'; Best Wishes, Janek -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: an error in a simple regexp
That's because after your regex has processed the first two numbers, it moves on to the next two numbers. If you inputted 1234, you would probably get back "1.23.4". If I were you, I'd try something more like this: my @numarray = split(//,$_); $_ = join('.',$_); -Original Message- From: Dusan Juhas [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 9:17 AM To: [EMAIL PROTECTED] Subject: an error in a simple regexp Hi, I typed this simple cmd in the bash: echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' and expected ouput like 1.2.3 but obtained this one: 1.23 What's wrong and how to write a regexp cmd which will transfer a number to digits with dots in between? eg: 1234 -> 1.2.3.4 Thanx Regards, Dusan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: an error in a simple regexp
You need '?'; echo 123 | perl -pe 's/(\d?)(\d)/$1.$2/g' [Jess] -Original Message- From: Dusan Juhas [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 12:17 PM To: [EMAIL PROTECTED] Subject: an error in a simple regexp Hi, I typed this simple cmd in the bash: echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' and expected ouput like 1.2.3 but obtained this one: 1.23 What's wrong and how to write a regexp cmd which will transfer a number to digits with dots in between? eg: 1234 -> 1.2.3.4 Thanx Regards, Dusan -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: an error in a simple regexp
Ooh. I like that better than mine. :) -Original Message- From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 11:08 AM To: [EMAIL PROTECTED] Cc: [EMAIL PROTECTED] Subject: Re: an error in a simple regexp On Jul 12, Dusan Juhas said: >I typed this simple cmd in the bash: >echo 123 |perl -pe 's/(\d)(\d)/$1.$2/g' >and expected ouput like >1.2.3 >but obtained this one: >1.23 The reason you don't get "1.2.3" is because by the time Perl has matched "12", it can't match the "2" again. Here's a working regex: s/(\d)(?=\d)/$1./g; The (?=\d) looks ahead for a digit, without actually consuming it. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Date and Time
At 11:18 AM 7/12/02 -0500, David T-G wrote: >Peter, et al -- > >...and then Peter Scott said... >% >... >% code. (Yes, IMHO, if you insist.) My students see it in every program >% I show them, from Hello World onward. I tell them that if anyone gives >% them code without it to maintain, they should refuse if at all >% possible. Later on I show the beginners a nasty example of the >% consequences of leaving out use strict, -w/use warnings, or both. > >Oooh! Oooh! Show me an example or two! Please? Sounds great! > >Simple, concise examples are great convincers. Well, I actually use it to illustrate scoping, but then I show what happens with the -w and strict removed; anyway, here you are: #!/usr/bin/perl -w use strict; my $x = "global"; my $y = "also global"; { my $x = "local"; my $z = "also local"; can_I_see_z(); print "$x, $y\n"; } sub can_I_see_z { my $y = "trashed???"; print $z; } With strict/-w it does not run. With -w it warns but runs. With neither it runs without any indication that it cannot possibly be doing what the author probably intended, and yet the author clearly has a fundamental misunderstanding about the nature of scoping. Then I suggest to them that all those strict/-w - less scripts they've encountered probably have all kinds of problems like this within them. An even more killer example of this would be very handy. One of the best testimonials I got (probably on this issue) was second-hand: someone was relating how a mutual colleague was creating a program and said, "This isn't how Peter would do it, but it saves time." It didn't work. So then they asked deferentially, "So... how would Peter do it?" He changed the program and it worked. Anecdotes like that make this job so worthwhile :-) -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
anonymous reference problems
I have a loop, each iteration through the loop the hash %tmpEntry gets a new set of values. And each iteration through the loop I place this hash into another hash, like so: [snip] print "Added entry.\n"; $oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; [snip] tmpEntry is defined outside the loop, because I need to handle the last case outside of the loop. This doesn't work, all the entries end up being the same, because of the reference to the memory location. I need something similar ...I thought about taking each value of tmpEntry and setting each variable like so: $oncall{$tmpEntry{'StartDate'}}->{x} = $tmpEntry{x}; $oncall{$tmpEntry{'StartDate'}}->{y} = $tmpEntry{y}; but that seem inelegant at best. Thoughts ? - Craig Moynes [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: anonymous reference problems
On Jul 12, Craig Moynes/Markham/IBM said: >I have a loop, each iteration through the loop the hash %tmpEntry gets a >new set of values. And each iteration through the loop I place this hash >into another hash, like so: > >[snip] > print "Added entry.\n"; >$oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; >[snip] > >tmpEntry is defined outside the loop, because I need to handle the last >case outside of the loop. This doesn't work, all the entries end up >being the same, because of the reference to the memory location. You'll need to use { %tmpEntry } then, instead of \%tmpEntry. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: anonymous reference problems
- Original Message - From: "Craig Moynes/Markham/IBM" <[EMAIL PROTECTED]> To: <[EMAIL PROTECTED]> Sent: Friday, July 12, 2002 2:48 PM Subject: anonymous reference problems > I have a loop, each iteration through the loop the hash %tmpEntry gets a > new set of values. > And each iteration through the loop I place this hash into another hash, > like so: > > [snip] > print "Added entry.\n"; > $oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; > [snip] > > tmpEntry is defined outside the loop, because I need to handle the last > case outside of the loop. > This doesn't work, all the entries end up being the same, because of the If $tmpEntry{'StartDate'} is ever repeated, you will always over write the date that was in that hash key... if you are wanting multiple entries for any key, do a push like so: push @{$oncall{$tmpEntry{'StartDate'}}}, \%tmpEntry; This will make a referenced array of hashes that you can iterate over... Shawn > reference to the memory location. > > I need something similar ...I thought about taking each value of tmpEntry > and setting each variable like so: > $oncall{$tmpEntry{'StartDate'}}->{x} = $tmpEntry{x}; > $oncall{$tmpEntry{'StartDate'}}->{y} = $tmpEntry{y}; > > but that seem inelegant at best. > > Thoughts ? > > - > Craig Moynes > [EMAIL PROTECTED] > > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: anonymous reference problems
Thanks, two little braces should solve all problems - Craig Moynes [EMAIL PROTECTED] "Jeff 'japhy' Pinyan" To: Craig Moynes/Markham/IBM@IBMCA <[EMAIL PROTECTED]cc: <[EMAIL PROTECTED]> rg> Subject: Re: anonymous reference problems 07/12/2002 03:56 PM Please respond to japhy On Jul 12, Craig Moynes/Markham/IBM said: >I have a loop, each iteration through the loop the hash %tmpEntry gets a >new set of values. And each iteration through the loop I place this hash >into another hash, like so: > >[snip] > print "Added entry.\n"; >$oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; >[snip] > >tmpEntry is defined outside the loop, because I need to handle the last >case outside of the loop. This doesn't work, all the entries end up >being the same, because of the reference to the memory location. You'll need to use { %tmpEntry } then, instead of \%tmpEntry. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: anonymous reference problems
On Fri, 2002-07-12 at 15:48, Craig Moynes/Markham/IBM wrote: > I have a loop, each iteration through the loop the hash %tmpEntry gets a > new set of values. > And each iteration through the loop I place this hash into another hash, > like so: > > [snip] > print "Added entry.\n"; > $oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; > [snip] > > tmpEntry is defined outside the loop, because I need to handle the last > case outside of the loop. > This doesn't work, all the entries end up being the same, because of the > reference to the memory location. > > I need something similar ...I thought about taking each value of tmpEntry > and setting each variable like so: > $oncall{$tmpEntry{'StartDate'}}->{x} = $tmpEntry{x}; > $oncall{$tmpEntry{'StartDate'}}->{y} = $tmpEntry{y}; > > but that seem inelegant at best. > > Thoughts ? > > - > Craig Moynes > [EMAIL PROTECTED] > #!/usr/bin/perl -w use strict; use Data::Dumper; my %hash = ( this => 10, that => 20 ); my %HoH; $HoH{one} = { %hash }; @hash{'this','that'} = (50,100); $HoH{two} = { %hash }; print Dumper(\%HoH); -- Today is Pungenday the 47th day of Confusion in the YOLD 3168 Wibble. Missile Address: 33:48:3.521N 84:23:34.786W -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Problem in fetching CLOB data using perl DBI
Hi , I have perl script to fetch CLOB data from oracle table Table structure is ID number ( 5) long_field clob Perl code : #!/usr/local/bin/perl5 use DBI qw(:sql_types); $dbh= DBI->connect ( . ); $dbh->{LongReadLen}=512*1024; $sql="select * from table"; $sth = $dbh->prepare($sql); $sth->execute(); while ( ($id , $edi_data ) = $sth->fetchrow ) { print "id=$id\n"; print "data=$edi_data\n"; } When I try to fetch data I get error like ORA-03115: unsupported network datatype or representation (DBD: odescr failed) Can anyone suggest why I am geting this error and what is the resolution. thanks Paresh.
Re: Win32 registry question
From: "Edouard Beaugard" <[EMAIL PROTECTED]> > Does anyone have a script that will query a registry key on a remote > PC? I'm doing some maintenance work this would really help a lot. > > Thanks, > Ed Beaugard Assuming you installed my Win32::Registry2 patch : use Win32::Registry; $remoteHKLM = $HKLM->Connect( $server) or die "Cannot connect $server : $^E\n"; print $remoteHKLM->Open('SOFTWARE\Microsoft\Internet Explorer') ->GetValue("Version"); The patch may be downloaded from http://Jenda.Krynicky.cz/#Win32::Registry2 HTH, Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: DBF File
From: [EMAIL PROTECTED] > Here are some lines that may help you > this will open and write to a database file. > > my $database = 'c:\apache\your.dbf'; this is where you define the > .dbf file > > open (DATABASE, ">>$database"); > flock (DATABASE, 2); > print DATABASE "$username|$password|$date\n"; > flock (DATABASE, 8); > close (DATABASE); No, this will open and append to a FLAT file. While you may use a flat text file as a database it's most probably not what Karen needed. She has some files in dBase or FoxBase format ... which is NOT plain text. Jenda === [EMAIL PROTECTED] == http://Jenda.Krynicky.cz == There is a reason for living. There must be. I've seen it somewhere. It's just that in the mess on my table ... and in my brain I can't find it. --- me -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Problem in fetching CLOB data using perl DBI
I use the oracle driver to retrieve data from my database. You should download and install it along with DBI. #!/usr/local/bin/perl use strict; use DBI; my $statement = "SELECT * from table"; my $dbh = DBI->connect('dbi:Oracle:host=hostname;sid=mysid','username','password') or die "could not co nnect to database: ".DBI->errstr; my $sth = $dbh->prepare($statement); my $rv = $sth->execute; while (my @row = $sth->fetchrow_array) { print "@row\n"; } my $rc = $dbh->disconnect; -Original Message- From: Paresh Kakrecha [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 3:14 PM To: [EMAIL PROTECTED] Subject: Problem in fetching CLOB data using perl DBI Hi , I have perl script to fetch CLOB data from oracle table Table structure is ID number ( 5) long_field clob Perl code : #!/usr/local/bin/perl5 use DBI qw(:sql_types); $dbh= DBI->connect ( . ); $dbh->{LongReadLen}=512*1024; $sql="select * from table"; $sth = $dbh->prepare($sql); $sth->execute(); while ( ($id , $edi_data ) = $sth->fetchrow ) { print "id=$id\n"; print "data=$edi_data\n"; } When I try to fetch data I get error like ORA-03115: unsupported network datatype or representation (DBD: odescr failed) Can anyone suggest why I am geting this error and what is the resolution. thanks Paresh. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
How can I get element location in array ?
Hi all, I now have an array like this : @list = ('1234', '4567', '789A', 'BCDE', 'FGHI', .); and now, I want to find where is the location of 'BCDE' in list , so I write like this : my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI'); my $GetLocation = 0; my $value = 'BCDE'; for (my $atLoc = 0; $atLoc <= $#list and ! $GetLocation ; $atLoc++) { $GetLocation = $atLoc if ($value eq $list[$atLoc]) } ok, so $GetLocation is the result I want... but any other smarter method ? Rgds, Connie
Any warning if I use '03E9' like string as a key in hash ?
Rgds, Connie
RE: Any warning if I use '03E9' like string as a key in hash ?
My only thought is that seeing it out of context, it's not very descriptive. I usually try to pick key names that will help me figure out what I was thinking when I made the hash. But like I said, it depends on context. Otherwise if -w and strict don't care, why should I? :) -Original Message- From: Connie Chan [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 1:50 PM To: [EMAIL PROTECTED] Subject: Any warning if I use '03E9' like string as a key in hash ? Rgds, Connie -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How can I get element location in array ?
On Jul 13, Connie Chan said: >I now have an array like this : @list = ('1234', '4567', '789A', 'BCDE', >'FGHI', .); > >and now, I want to find where is the location of 'BCDE' in list , so I >write like this : > >my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI'); >my $GetLocation = 0; >my $value = 'BCDE'; > >for (my $atLoc = 0; $atLoc <= $#list and ! $GetLocation ; $atLoc++) >{ $GetLocation = $atLoc if ($value eq $list[$atLoc]) } > >ok, so $GetLocation is the result I want... >but any other smarter method ? Once you have FOUND the element, you can exit the loop. Also, your loop is testing !$GetLocation, which returns true if the element is found at index 0. Your code will end up ASSUMING the element is index 0 if it isn't found in the array at all. Here's are two solutions: my @list = ...; my $wanted = 'foo'; my $pos = -1; # -1 means not found for (my $i = 0; $i < @list; $i++) { $pos = $i, last if $list[$i] eq $wanted; } Now you'll have $pos being either -1 (not found) or the index in the array. You'd check via if ($pos != -1) { ... } # it was found else { ... } # it wasn't found Here's the other solution: my @list = ...; my $wanted = 'foo'; my $pos = 0; # 0 means not found for (my $i = "0E0"; $i < @list; $i++) { $pos = $i, last if $list[$i] eq $wanted; } Now you'll have $pos being either 0 (not found), or the index in the array, BUT! it will be "0E0" if it was the first element. This means you CAN test it like so: if ($pos) { ... } # it was found else { ... } # it wasn't found because "0E0" is a string that is not false, but is treated as the number 0 when used numerically. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** what does y/// stand for? why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Help installing Mail::Audit
I am running win200 and ActiveState Perl. I am attempting to install Mail-Audit with the PPM. I have successfully install Mail-tools and Mime-tools. However, when I use "install Mail-Audit", I get "Error: no suitable installation target found for package Mail-Audit." Any help anyone can give is appreciated. David Gerler Gerler Enterprises PO BOX 16357 Chesapeake VA 23328 http://www.GerlerEnterprises.com/ Nationwide Dial-up from $12.45 http://www.EasySitesForLess.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Any warning if I use '03E9' like string as a key in hash ?
Hee... sorry, I just think if I can make the problem becomes more visible and simple What I am now doing is a transation script. From Traditional Chinese(Big5) to Simiplified Chinese(GB2312). As Note, Chinese Chars is a combination of 2 bytes... So, I got every word back to ASCII format, and where I got something like this : . b855=cdf2 a456=d5c9 a454=c8fd a457=c9cf a455=cfc2 .. LHS is the Big5 Char, and RHS is GB2312. So I tried to make a hash say $ch{'b855'} = 'cdf2' ; # something like that . Then I can operate it like this $checkThis = 'b855'; $newChar =~ s/($checkThis)/$ch{$1}/eg; # dunno it works or not, not tested yet =) So... any warning here ? =) Rgds, Connie - Original Message - From: "Timothy Johnson" <[EMAIL PROTECTED]> To: "'Connie Chan'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]> Sent: Saturday, July 13, 2002 4:53 AM Subject: RE: Any warning if I use '03E9' like string as a key in hash ? > > My only thought is that seeing it out of context, it's not very descriptive. > I usually try to pick key names that will help me figure out what I was > thinking when I made the hash. But like I said, it depends on context. > Otherwise if -w and strict don't care, why should I? :) > > -Original Message- > From: Connie Chan [mailto:[EMAIL PROTECTED]] > Sent: Friday, July 12, 2002 1:50 PM > To: [EMAIL PROTECTED] > Subject: Any warning if I use '03E9' like string as a key in hash ? > > > Rgds, > Connie > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Code Review/Mentoring session at TPC (reminder)
Reminder: For those of you attending the Perl Conference #6 (or Open Source Conference), there is a golden opportunity to get some free coaching and consultation on your work. A Birds-of-a-Feather session on "Perl Mentoring/Code Reviews" will be given for the third year running. Some of the top Perl People will be on hand as resident experts to advise you on your own Perl projects. Here's how it works: You bring some Perl code (ideally at most 3 pages, as a printout, or on a laptop, handheld, or floppy) and receive specific advice which would normally cost a large amount of money in consulting fees. Feel free to ask for advice on anything from style to improving efficiency. This is *one-on-one* coaching: No spectators, no audience, no distractions; just the kind of personal mentoring, targeted to your specific application, from some of the best people qualified to give it. Time spent with the expert will depend on supply and demand. Date: Thursday 7/25 Time: 7:00pm - 9:00pm Location: Grande Ballroom A in the East Tower (See http://conferences.oreillynet.com/pub/w/15/bof.html#thursday) -- Peter Scott Pacific Systems Design Technologies http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: How can I get element location in array ?
Right, I better set $GetLocation = -1, but, what I am looking for is if there is something working like grep does ? @elemLoc = grepIndex (/pattern/, @list); # something like that ? And is that I can't aviod to use loop to search for matching ? Rgds, Connie - Original Message - From: "Jeff 'japhy' Pinyan" <[EMAIL PROTECTED]> To: "Connie Chan" <[EMAIL PROTECTED]> Cc: <[EMAIL PROTECTED]> Sent: Saturday, July 13, 2002 4:54 AM Subject: Re: How can I get element location in array ? > On Jul 13, Connie Chan said: > > >I now have an array like this : @list = ('1234', '4567', '789A', 'BCDE', > >'FGHI', .); > > > >and now, I want to find where is the location of 'BCDE' in list , so I > >write like this : > > > >my @list = ('1234', '4567', '789A', 'BCDE', 'FGHI'); > >my $GetLocation = 0; > >my $value = 'BCDE'; > > > >for (my $atLoc = 0; $atLoc <= $#list and ! $GetLocation ; $atLoc++) > >{ $GetLocation = $atLoc if ($value eq $list[$atLoc]) } > > > >ok, so $GetLocation is the result I want... > >but any other smarter method ? > > Once you have FOUND the element, you can exit the loop. Also, your loop > is testing !$GetLocation, which returns true if the element is found at > index 0. Your code will end up ASSUMING the element is index 0 if it > isn't found in the array at all. Here's are two solutions: > > my @list = ...; > my $wanted = 'foo'; > my $pos = -1; # -1 means not found > > for (my $i = 0; $i < @list; $i++) { > $pos = $i, last if $list[$i] eq $wanted; > } > > Now you'll have $pos being either -1 (not found) or the index in the > array. You'd check via > > if ($pos != -1) { ... } # it was found > else { ... } # it wasn't found > > Here's the other solution: > > my @list = ...; > my $wanted = 'foo'; > my $pos = 0; # 0 means not found > > for (my $i = "0E0"; $i < @list; $i++) { > $pos = $i, last if $list[$i] eq $wanted; > } > > Now you'll have $pos being either 0 (not found), or the index in the > array, BUT! it will be "0E0" if it was the first element. This means you > CAN test it like so: > > if ($pos) { ... } # it was found > else { ... } # it wasn't found > > because "0E0" is a string that is not false, but is treated as the number > 0 when used numerically. > > -- > Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ > RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ > ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** > what does y/// stand for? why, yansliterate of course. > [ I'm looking for programming work. If you like my work, let me know. ] > > > -- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: Help installing Mail::Audit
David - Mail-Audit is not available for Win32. Under ppm3 you can use the 'describe' command: ppm> describe mail-audit The output shows available platforms (in this case linux and solaris). Aloha => Beau. -Original Message- From: David Gerler [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 11:00 AM To: Beginners Subject: Help installing Mail::Audit I am running win200 and ActiveState Perl. I am attempting to install Mail-Audit with the PPM. I have successfully install Mail-tools and Mime-tools. However, when I use "install Mail-Audit", I get "Error: no suitable installation target found for package Mail-Audit." Any help anyone can give is appreciated. David Gerler Gerler Enterprises PO BOX 16357 Chesapeake VA 23328 http://www.GerlerEnterprises.com/ Nationwide Dial-up from $12.45 http://www.EasySitesForLess.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: anonymous reference problems
Hey Jeff, > >I have a loop, each iteration through the loop the hash %tmpEntry gets a > >new set of values. And each iteration through the loop I place this hash > >into another hash, like so: > > > >[snip] > > print "Added entry.\n"; > >$oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; > >[snip] > > > >tmpEntry is defined outside the loop, because I need to handle the last > >case outside of the loop. This doesn't work, all the entries end up > >being the same, because of the reference to the memory location. > > You'll need to use { %tmpEntry } then, instead of \%tmpEntry. Can you explain the difference between the anonymous hash and the referenced hash, and why it would make a difference here? Is it because the anonymous scalar reference does not keep the same memory space? I guess my question is: aren't these two equal statements? my $hash=\%tmpEntry; my $hash={ %tmpEntry }; This is what I get from the command line: >perl -e "%hash=(1=>'one',2=>'two'); my $hash=\%hash; print $hash,qq~\n~; >$hash={%hash}; print $hash,qq~\n~;" HASH(0x1ac2db8) HASH(0x1acf150) >perl -e "%hash=(1=>'one',2=>'two'); my $hash=\%hash; print %$hash,qq~\n~; >$hash={%hash}; print %$hash,qq~\n~;" 1one2two 1one2two Shawn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
RE: anonymous reference problems
>I guess my question is: aren't these two equal statements? > > my $hash=\%tmpEntry; > my $hash={ %tmpEntry }; > >This is what I get from the command line: No, they're not the same. See below: ---===+===--- my $hash = \%tmpEntry; #creates a new scalar variable that is #a reference to %tmpEntry; ---===+===--- my $hash = { %tmpEntry }; #creates a new, empty, anonymous hash and inserts #the keys and values of %tmpEntry into it. Then #it creates a new scalar variable that is a #reference to the anonymous hash. ---===+===--- -Original Message- From: Shawn [mailto:[EMAIL PROTECTED]] Sent: Friday, July 12, 2002 3:13 PM To: [EMAIL PROTECTED]; Craig Moynes/Markham/IBM Cc: [EMAIL PROTECTED] Subject: Re: anonymous reference problems Hey Jeff, > >I have a loop, each iteration through the loop the hash %tmpEntry gets a > >new set of values. And each iteration through the loop I place this hash > >into another hash, like so: > > > >[snip] > > print "Added entry.\n"; > >$oncall{$tmpEntry{'StartDate'}} = \%tmpEntry; > >[snip] > > > >tmpEntry is defined outside the loop, because I need to handle the last > >case outside of the loop. This doesn't work, all the entries end up > >being the same, because of the reference to the memory location. > > You'll need to use { %tmpEntry } then, instead of \%tmpEntry. Can you explain the difference between the anonymous hash and the referenced hash, and why it would make a difference here? Is it because the anonymous scalar reference does not keep the same memory space? I guess my question is: aren't these two equal statements? my $hash=\%tmpEntry; my $hash={ %tmpEntry }; This is what I get from the command line: >perl -e "%hash=(1=>'one',2=>'two'); my $hash=\%hash; print $hash,qq~\n~; $hash={%hash}; print $hash,qq~\n~;" HASH(0x1ac2db8) HASH(0x1acf150) >perl -e "%hash=(1=>'one',2=>'two'); my $hash=\%hash; print %$hash,qq~\n~; $hash={%hash}; print %$hash,qq~\n~;" 1one2two 1one2two Shawn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Any warning if I use '03E9' like string as a key in hash ?
On Friday, July 12, 2002, at 02:06 , Connie Chan wrote: [..] p0: I will defer to your understanding of chinese 'encryption' - since I haven't been in that since the wade-giles v. pin-yin debates but if it is a simple mapping as you suggest. > b855=cdf2 > a456=d5c9 > a454=c8fd > a457=c9cf > a455=cfc2 > .. where everything on the left hand side is 'uniq' the problem comes when you have say ff33 -> and ff33 -> but is context dependent on some ordering of characters before or after it So as long as they are always a simple one to one relationship you should be ok. > LHS is the Big5 Char, and RHS is GB2312. > So I tried to make a hash say > > $ch{'b855'} = 'cdf2' ; # something like that . > > Then I can operate it like this > $checkThis = 'b855'; > $newChar =~ s/($checkThis)/$ch{$1}/eg; # dunno it works or not, not tested > yet =) > > So... any warning here ? =) here is where I would argue for $new_char = ( exists $big_5{$check_this} ) ? $big_5{$check_this} : 'UNK'; since the possibility exists that there is a character in Big5 that is not in GB2312 ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
Re: Avoiding Duplicate Entries
On Wednesday, July 10, 2002, at 09:12 , John W. Krahn wrote: [..] > > Something like that. :-) But what if the log file has been rotated and > the last line is no longer in the file? > > my $last_line = get_last_line_from_cache(); > > open LOG, or die "$!"; > > while ( ) { > rollback_db_data() if $_ eq $last_line; > > process_db_data(); > > $last_line = $_ if eof( LOG ); > } > > commit_db_data(); > > push_into_cache( $last_line ); that is why I was thinking of avoiding the 'walk the file' approach by caching the stat data - especially if the file is like say syslog where there is a known 'step back' strategy that IF /var/adm/messages has been rolled check /var/adm/mess*.[0-N] till you find your correct one... cf perldoc -f stat hence my $cache_hash_ref = get_hash_from_cache(); open(LOG, ) my @stat_dope = lstat(LOG); if ( $stat_dope[7] > $cache_hash_ref->{stat_size} ) { # # the file has grown, we need to lseek forward to # $cache_hash_ref->{stat_size} lseek_der_log(); } else { # fremonge they rolled the log so let's solve that # one and then come back through here... grovel_prior_log($cache_hash_ref); $new_log++; # boolean initialized to 0 # set here since after we finish processing # will need to check if we should whine_at_apes(); } # # in theory at this point we are looking at the correct # line of dope in the Log to grovel... # yes, there are those who like to check ino but... ciao drieux --- -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
out of memory
Hi , Here is the my script which fetch the data from oracle while ( ($data=$sth->fetchrow ) { print $data; } since it is a huge data around ( 650 kb ) , this gives out of memory error. Anyone knows how to solve this issue Thanks in advance -Paresh. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]