Re: First-time forking

2006-03-13 Thread Shawn Corey
Cornelis Swanepoel wrote: The SIG{CHLD} handler doesn't get called since the output from print LOG Child process no. $stiff exited with status $?\n; is missing. It's not missing; it was never there. Your parent process dies before its children are finished. It is no longer around to reap

Re: Padded 3 digit numeric series

2006-03-12 Thread Shawn Corey
Robin Sheat wrote: On Sunday 12 March 2006 18:22, Shawn Corey wrote: Believe it or not, write the number as a string. for ( '000' .. '100' ){ print $_\n; } Note that if you have a string such as 000, you can treat it like a number: my $a = '000'; $a++; print $a\n; This will print '001

Re: Padded 3 digit numeric series

2006-03-12 Thread Shawn Corey
Harry Putnam wrote: Ahh. Nice, thanks. I didn't recognize the `q[...]' usage but it appears to operate the same as %03d,ext, $number; No, it would be the same as '%03d.ext' On the other hand, qq[%03d.ext] would be the same as %03d.ext See `perldoc perlop` and search for Quote and

Re: Padded 3 digit numeric series

2006-03-12 Thread Shawn Corey
Harry Putnam wrote: This has the right output but its not very obvious how one would use this to increment a counter and files are being renamed. As you would any other variable that contains a string. my $file = $_.ext; or my $file = $_ . '.ext'; or my $file = sprintf( '%s.ext', $_

Re: What is wrong with this file copy script

2006-03-12 Thread Shawn Corey
Harry Putnam wrote: I'm already bald so don't have the luxury of pulling hair over this. I don't understand the error ouput or maybe I could get somewhere with this. Pouring over perldoc File::Copy isn't helping either... I think the error is before that but can't see what. The end result of

Re: script won't create text file on server

2006-03-12 Thread Shawn Corey
Elliot Holden wrote: for some reason or another, my script won't create the text file that it is supposed to create on the server. For example, I'm taking a survey and calculating votes for a favorite song. The script IS calculating the votes so the text file is being created somewhere, but

Re: What is wrong with this file copy script

2006-03-12 Thread Shawn Corey
Harry Putnam wrote: That formula did'nt do it either but it did show a different error that throws some light on this. Notice the first file is the directory name dir1 hpdb cp'ing ./dir1 = tmp/001 Failed to copy ./dir1 = tmp/001: Is a directory at ./renum2.pl line 113 Thats why

Re: What is wrong with this file copy script

2006-03-12 Thread Shawn Corey
Harry Putnam wrote: #!/usr/local/bin/perl -w @directories = (./dir1, ./dir2); for(@directories) { opendir(WRK_DIR,$_); opendir(WRK_DIR,$_) or die cannot opendir $_: $!\n; chdir $_; chdir $_ or die cannot chdir $_: $!\n; # This fails for the second directory since it chdir to './dir2'

Re: Padded 3 digit numeric series

2006-03-11 Thread Shawn Corey
Harry Putnam wrote: Taking the chicken way out... but I can't think of the right tricky search strings to uncover a tried and true way to output a 3 digit padded numeric series. In this case its for file names. And needs to roll over to 4 digit in the event there are enough files. There is no

Re: i say literal; perl says metacharacter

2006-03-10 Thread Shawn Corey
Tom Phoenix wrote: On 3/10/06, tom arnall [EMAIL PROTECTED] wrote: is there any way to get perl to interpret the contents of $f as a literal? I think you're looking for the quotemeta() function. Hope this helps! --Tom Phoenix Stonehenge Perl Training You can also use the \Q

Re: Does this script have the efficiency problems?

2006-03-09 Thread Shawn Corey
Chris Devers wrote: On Thu, 9 Mar 2006, Practical Perl wrote: Here is my script: #!/usr/bin/perl use strict; use warnings; my $date=`date +%y%m%d`; chomp $date; ^^^ Not that this is your problem, but why on earth are you shelling out for the date? Perl can do this just fine, you know,

Re: how to translate time string

2006-03-09 Thread Shawn Corey
Jeff Pang wrote: Hello,list, Maybe it's a simple problem,but I don't know how to do it. I have a time string,for example: Thu Mar 9 23:04:03 2006 How can I get it translated to unix timestamp,for example: 1141916656 Thanks. -- Jeff Pang NetEase AntiSpam Team http://corp.netease.com

Re: pushing csv vaules into hash

2006-03-09 Thread Shawn Corey
Curt Shaffer wrote: I am really stuck here. I need to split values from a csv value and push them into an array, then perform a routine for all of them in a foreach statement. In this example I am reading an email address, a username and a password and needing to send each user listed in the csv

Re: Strange problem assigning values to strings

2006-03-09 Thread Shawn Corey
Bisbal, Prentice wrote: I've got a strange problem. This perl code has been in use for a long time (6 - 12 mos, at least), and it just started behaving badly the other day. This code: foreach $num (@ids) { $infile = $tmpdir/lp-$num.mol; $outfile = $original_dir/lp-$num.$type;

Re: Strange problem assigning values to strings

2006-03-09 Thread Shawn Corey
Bisbal, Prentice wrote: I think you're on to something. This is what the debugger shows: DB17 x [EMAIL PROTECTED] 0 ARRAY(0x90c420c) 0 706840\cM 1 706846\cM 2 715596\cM 3 715620\cM 4 722292\cM 5 722300\cM 6 722327\cM 7 722330\cM 8 722340\cM 9 722468\cM

Re: question on pattern matching

2006-03-07 Thread Shawn Corey
Gavin Bowlby wrote: So (\.)? differs from (\.?) in that there is no match in the first case, but there is a match in the second case? I'm still confused as to why the placement of the ? operator inside or outside the parentheses makes a difference. I thought the parentheses were only

Re: import modules at begin block

2006-01-23 Thread Shawn Corey
Peter Scott wrote: Maybe I'm missing something, but the poster appears to be asking how to achieve the common and useful pattern of plugins, where you control dynamic behavior by deciding what modules are in a particular directory. Of course there's a lot more scaffolding than the poster

Re: File Parsing Question

2006-01-22 Thread Shawn Corey
William Black wrote: Hello, I'm trying to figure out how to read multiple lines from a file at once for parsing. For example,, If the file contained the following: input file Line 1 Line 2 Line 3 Line 4 Line 5 Line 6 Line 7 Line 8 I want to read in lines 1-4 for processing then

Re: somthing wrong with my codes???

2006-01-21 Thread Shawn Corey
chen li wrote: #!/usr/bin/perl use warnings; use strict; my $string=password=xyz verbose=9 score=0; my @keys=(); my @values=(); while ($string=~/(\w+)=(\w+)/g){ @keys=push(@keys, $1); push @keys, $1; print $1, \n; @values=push(@values,$2); push @values, $2; print $2,

Re: removing line feeds

2006-01-21 Thread Shawn Corey
Bowen, Bruce wrote: I know how to get rid of the carriage returns using s/\n//g, but haven't had any luck in finding the way to get rid of the line feeds following the |fs. Sorry, \n means a line feed. Try: s/\n//g; # Remove line feeds s/\r//g; # Remove carriage returns See: perldoc

Re: negative match

2006-01-20 Thread Shawn Corey
Adriano Allora wrote: hi to all, I cannot use a negative match, and I cannot understand why: someone may help me? I've got this four rows (for instance): arabaADJ arabo araboADJ arabo araboNOM arabo aranoVER:presarare and, with this regular expression, I

Re: filehandle question

2006-01-17 Thread Shawn Corey
radhika wrote: Hi, Can someone tell me what is going on in this peice of code? Especially, line 409. --code start-- 405my $fh; 406my $txtfile = $file-fileName(); 407open $fh, $txtfile; open $fh, $txtfile or die cannot open $txtfile: $!\n; 408my $plain_text = ''; 409

Re: about the var's scope

2006-01-16 Thread Shawn Corey
Jeff Pang wrote: I think the only difference between the two is Stat's code do the things of sharing vars across modules really. Under mod_perl,the situation is very different from common CGI environment,and the vars sharing sometimes is useful and needed. I hope I'm correct.If not,the

Re: assigning list to hash entry

2006-01-16 Thread Shawn Corey
Xavier Noria wrote: In Perl data estructures can only store scalar values. That's why references are used to emulate nested structures: $hash{$key}[0] = [EMAIL PROTECTED]; # note that @s are arrays, not lists $hash{$key}[1] = $string; $hash{$key}[2] = \%hash; There are some pages

Re: interpolation

2006-01-16 Thread Shawn Corey
John Doe wrote: The Ghost am Montag, 16. Januar 2006 06.34: I am storing text stings in a database. when I have the string: 'some perl $variable' which would print as: some perl $variable how can I force interpolation of '$variable'? one idea I thought of was: #!/usr/bin/perl my

Re: How to take a reference in line

2006-01-16 Thread Shawn Corey
Bill Gradwohl wrote: my $arrayPointer; # This works: @{$arrayPointer}=qw(Money preserver sunscreen); check_required_items(Mr. Howell, $arrayPointer); # These don't work: check_required_items(Mr. Howell, @{$arrayPointer}=qw(Money preserver sunscreen)); check_required_items(Mr. Howell, qw(Money

Re: Array of hashes

2006-01-16 Thread Shawn Corey
[EMAIL PROTECTED] wrote: Hi All Can anyone tell me whether there is any way for declaring an array of hashes similar to creating array of structure variables in C programming? There is a module, Class::Struct, that might be what you want. See `perldoc Class:Struct`. However, I would

Re: about the var's scope

2006-01-15 Thread Shawn Corey
Jeff Pang wrote: Hello,lists, Seeing these code below please.I can't know why the var defined in the main script can been accessed in the modules that used by the main script?thanks. From `perldoc vars`: While the vars pragma cannot duplicate the effect of package lexicals (total

Re: assigning list to hash entry

2006-01-15 Thread Shawn Corey
Anders Stegmann wrote: Hi! how do I assign a list to a hash entry like $hash{$key}[0]. I mean, something like this: $hash{$key}[0] = @list; must work. Anders. Close. Try: use Data::Dumper; $hash{$key} = [ @list ]; print Dumper( \%hash ); -- Just my 0.0002 million

Re: contest software

2006-01-15 Thread Shawn Corey
Mike Blezien wrote: Hello, we're looking for a good contest software written perl, for creating various types of contests. before we embark on building from the ground up, wanted too see if there any out there that may meet our needs. any feedback would be appreciated. TIA, Please write

Re: about the var's scope

2006-01-15 Thread Shawn Corey
John Doe wrote: [reordered to bottom style posting] Jeff Pang am Montag, 16. Januar 2006 01.59: Thanks for Shawn.The main script can see the global var $q coming from module,since the main script import this symbol via 'use My::HTML qw($q)'.But the modules have no any importing behavior,why

Re: the 'tail' problem

2006-01-14 Thread Shawn Corey
Jeff Pang wrote: hi,lists, I have a log file which is a symbol link to the real logfile,shown as following: $ll mssvr.log lrwxrwxrwx1 cmail root 40 Jan 14 00:00 mssvr.log - /home/cmail/logs/mssvr.log.2006-01-14 I have to access this file in perl script with unix 'tail -f'

Re: Matching the first string

2006-01-13 Thread Shawn Corey
John Doe wrote: [EMAIL PROTECTED] am Freitag, 13. Januar 2006 18.28: [...] i`ve written a script whose purpose is to put files in different directories by its first later, the problem is that every file begins with different chars for example 01 - Eminem Encore.mp3 my question is how can i get

Re: What does this line of code say?

2006-01-11 Thread Shawn Corey
Bill Gradwohl wrote: I'll study that one after I TOTALLY understand my original problem. Thank you for another eye opener head scratcher. To see what's inside a complex data structure, use Data::Dumper. In this case, add the lines: use Data::Dumper; print Dumper \%children; See

Re: Byte array

2006-01-10 Thread Shawn Corey
[EMAIL PROTECTED] wrote: I'm new to Perl and am trying to set a variable length byte array that is passed to a socket as a string for output. I have the following which works, but the commented out code doesn't. What am I doing wrong? Thanks. use IO::Socket; use Time::HiRes qw(usleep ualarm

Re: Need some help and direction

2006-01-08 Thread Shawn Corey
Daniel Gladstone wrote: I thought this would be easy but I can not get it to work - can someone please help me: Problem: I have a file of 7.5 million records that are pipe delimted, the first field is a record number. I want to search for around 10 records with a specific record number and

Re: new for reading file containing multiple records

2006-01-08 Thread Shawn Corey
chen li wrote: You are 50% right. This method is not correct for the first record(which actually contains ' only) but it is correct for the last record(and others in between). I want to edit the file first and try to delete the first in this big file. I browse Programming Perl and Perl

Re: executing external binaries

2006-01-07 Thread Shawn Corey
Saurabh Singhvi wrote: hi people i have a script that executes external binaries using the system command. now the problem is this: the external binary is HUGE in terms of ram usage so i need a way to keep it loaded in the memory so that i can keep passing the next parameters, instead of

Re: new for reading file containing multiple records

2006-01-06 Thread Shawn Corey
chen li wrote: Each record starts with . I want to read each record once at a time.I hear about a special variable call $/ might do the job but not sure how to use it. I wonder if anyone could help me out. See `perldoc perlvar` and search for INPUT_RECORD_SEPARATOR. Here is a simple script

Re: pack an array

2006-01-02 Thread Shawn Corey
Gerard Robin wrote: Hello, I guess that one can write in more perlish fashion that I did: the part between the of this script to pack the array @array. Please, can someone give me some hint ? #!/usr/bin/perl # pack_array.pl use strict; use warnings; my $string = [EMAIL PROTECTED]

Re: Running Other Programs from Perl (WAS: Am a newbie ....)

2005-12-20 Thread Shawn Corey
Brahadambal S wrote: Hi, Could anyone tell me how to execute a .bat or .exe file through Perl? i.e, the perl code should invoke the executable. Thanks so much for your help(in advance). Open a terminal and type: perldoc -f system perldoc perlop (and search for 'qx') perldoc perlopentut

Re: use constant

2005-12-20 Thread Shawn Corey
David Gilden wrote: I looked for documentation on 'use constant' but it has eluded it me. perldoc constant -- Just my 0.0002 million dollars worth, --- Shawn * Perl tutorials at http://perlmonks.org/?node=Tutorials * A searchable perldoc is available at http://perldoc.perl.org/

Re: syntax of a perl program?

2005-12-20 Thread Shawn Corey
anand kumar wrote: Hi all Can anyone let me know some functions or some tutorial on how to check the syntax of a perl program. perldoc -c your_script See: perldoc perlrun (and search for '-c') -- Just my 0.0002 million dollars worth, --- Shawn * Perl tutorials at

Re: Constant Hash problem

2005-12-19 Thread Shawn Corey
John W. Krahn wrote: Shawn Corey wrote: for my $key ( sort keys %{ { STOPWORDS } } ){ my $value = ${ { STOPWORDS } }{$key}; In both lines you are copying the entire list to an anonymous hash. If you want efficient code (and less punctuation) you should just use a hash. Efficiency

Re: Constant Hash problem

2005-12-17 Thread Shawn Corey
John W. Krahn wrote: You can't because perl implements constants using subroutines and subroutines can only return a list. Perl subroutines return only lists but it converts them to hashes automatically: #!/usr/bin/perl use strict; use warnings; use Data::Dumper; sub list_to_hash {

Re: A question about modules

2005-12-17 Thread Shawn Corey
Robert wrote: I simply use: my $dbh = DBConn::db1(); It does the right connection (i.e. subroutine) from the DBConn package and I didn't use Exporter. I should also mention that DBConn is in the same folder and the calling script so maybe that makes a difference. No, it doesn't. You can

Re: Time::Local

2005-12-15 Thread Shawn Corey
richard lavoie wrote: Hi dear list, I'm trying to write a little script for calculation with time like adding a few minutes to a certain time. I'm getting this message: Time::Local version 1134653954 required--this is only version 1.1 at /usr/lib/perl5/5.8.6/Exporter/Heavy.pm line 121.

Re: Equal length numbers

2005-12-15 Thread Shawn Corey
Andrej Kastrin wrote: Hi all, Suppose that we have numbers 1 to 1000 and we want all numbers be equal length; e.g.: 0001 0002 0003 ... .. 1000 Any idea on how to fix this problem? Best, Andrej # perldoc -f sprintf for ( 1 .. 1000 ){ printf %04d\n, $_; } # version 2 #!/usr/bin/perl

Re: split regex

2005-12-15 Thread Shawn Corey
Umesh T G wrote: I tried like this, where $line='*Options=-ahello -mt -ml3 -idir1\dir2 -k -p -idir3\dir4 -m'* This line won't compile. Which of the following is it? $line='Options=-ahello -mt -ml3 -idir1\dir2 -k -p -idir3\dir4 -m'; $line='*Options=-ahello -mt -ml3 -idir1\dir2 -k -p

Re: split regex

2005-12-15 Thread Shawn Corey
Umesh T G wrote: Hi Joe, just to correct my prevoius one, my $line does not have * in the begining, that was a type. the $line value is like this *Options=-ahello -mt -ml3 -idir1\dir2-k -p -idir3\dir4 -m* my grep return the values correct to my array and the values in array will be like

Re: extracting substrings from string using regexp

2005-12-12 Thread Shawn Corey
Ing. Branislav Gerzo wrote: you should learn regexpes, they are very powerful. perldoc perlre See also: perldoc perlrequick Perl regular expressions quick start perldoc perlretut Perl regular expressions tutorial -- Just my 0.0002 million dollars worth, ---

Re: indexing... in some way

2005-12-11 Thread Shawn Corey
Adriano Allora wrote: `sort tagged_files/* | uniq word+tag.txt`; ??? All files in tagged_files/* are unique. This looks like a lot of make work. Try File::Find instead. See `perldoc File::Find`. open(IDX, word+tag.txt); while(IDX) { next if /^\W.+/; open(TMP,

Re: How to promote the efficiency

2005-12-08 Thread Shawn Corey
Jennifer Garner wrote: hi,lists, I have a file which is so large,which looking as: 61.156.49.18:28360 61.183.148.130:27433 222.90.207.251:25700 202.117.64.161:25054 218.58.59.73:24866 221.233.24.9:22507 222.187.124.4:21016 ... and more than 4500 lines. the part after : is no use for me,I

Re: chop/chomp/?

2005-12-08 Thread Shawn Corey
Frank Bax wrote: What's the correct way to trim trailing newlines from a text file that might be either DOS or UNIX format for newlines? The docs (and my experience) is that chomp only works properly if the text file is native to the current operating system? I'm running on *bsd system.

Re: The Difference Between my Globals and our Globals (WAS: Parameterizing a module)

2005-12-08 Thread Shawn Corey
[EMAIL PROTECTED] wrote: I see. Thanks Shawn. Since we are at it, would you mind explaining a little bit about the significance of our keyword. I have never understood it properly. Most books that I referred to say that it's a lexically-scoped global variable. What does that mean? I understand

Re: Parameterizing a module

2005-12-07 Thread Shawn Corey
[EMAIL PROTECTED] wrote: In my script, I load the module by saying use PerlMQ;. However, now I want to load only certain use statements from the module depending on the parameter I give it. For example, in my script, I want to say use PerlMQ qw(some_parameter) in order to load the use statements

Re: Extract text from file

2005-12-07 Thread Shawn Corey
Andrej Kastrin wrote: Hello dears, I have a file in row data format, which stores different terms (e.g. genes) and look like: ABH HD HDD etc. Then I have second file which looks like: -- ID- 001 #ID number

Re: Extract text from file

2005-12-07 Thread Shawn Corey
Andrej Kastrin wrote: and additional question: how does Perl know where are the input files (while we only wrote: open (TERM, $file_terms) or die Can't open...)? It comes from the command line. The statements: my $file_terms = shift; my $file_medline = shift; are a shorten version of:

Re: Extract text from file

2005-12-07 Thread Shawn Corey
Andrej Kastrin wrote: I try your code; now I try to write each potential target in a record tab separated, like: TI- xx HD x AB- xxx HD x #record 1 TI- yy AB x AB- xxx AB x#record 2 etc... So \t separated within record and \n

Re: Parameterizing a module

2005-12-07 Thread Shawn Corey
[EMAIL PROTECTED] wrote: Thanks Shawn. But, in this case, how would we send a parameter to the module from the calling script. The module can see the name of the calling script, but I want to make my module available to other perl programmers, and let them have the flexibility of deciding which

Re: which is more effective between map and foreach?

2005-12-06 Thread Shawn Corey
Xavier Noria wrote: This is kind of a holy war. Some people have that point of view, some don't. All depends on the way you read map. The disagreement is such that recently map was optimized in void context to avoid the generation of the list. As always, Benchmark.pm is your friend for

Re: Help with eval (WAS: which is more effective between map and foreach?)

2005-12-06 Thread Shawn Corey
Jennifer Garner wrote: And, I have another syntax question here. I can't know clearly the difference between eval and eval {}. I have run perldoc -f eval and read it,but still can't know clearly.Can you help me on this? eval {} or eval BLOCK is parsed only once at compile time. This means

Re: when do vars go out of scope in this case?

2005-12-06 Thread Shawn Corey
JupiterHost.Net wrote: I'm thinking its B and and the best way to reclaim the memory in this case is to undef()ine $foo when its no longer used in the block. I always thought B too. But don't forget you can use a block anywhere you can use a statement. { { my $foo =

Re: when do vars go out of scope in this case?

2005-12-06 Thread Shawn Corey
JupiterHost.Net wrote: Good idea Shawn :) the actual project is one thing, I'm really mostly curious if that is true or not, that its out of scope when its last referenced in a block instead of the end of a block. I still think at the end of the block. Going out-of-scope when last used

Re: Skip then print

2005-12-05 Thread Shawn Corey
Ron McKeever wrote: I would like to skip the first ten lines of output from tail If you want the last line of a file, you can get tail to print only that. See `man tail`. $ tail -n 1 file -- Just my 0.0002 million dollars worth, --- Shawn Probability is now one. Any problems that

Re: config files

2005-12-02 Thread Shawn Corey
M. Lewis wrote: I'm trying to move the configuration variables out of three perl scripts and put them in a config file. Fine, no problem so far. The way this works is an email message with a given subject is processed by procmail then passed off to the first perl script. The first script

Re: Flushing Buffers (WAS: recursive search)

2005-12-02 Thread Shawn Corey
Jennifer Garner wrote: $|=1; Be careful with this one. The documentation for it makes it sound like it's a good idea to set this but doing so turns buffering OFF, not ON. Normally you leave this alone, even for pipes and sockets; Perl does the right thing in almost every case. See:

Re: Convert date to timestamp

2005-12-02 Thread Shawn Corey
Timothy Johnson wrote: Correction: That line should be: my $perlTime = timelocal(01,01,01,$day,$month - 1,$year); You should use noon, not midnight (or close to it). my $unix_epoch = timelocal( 0, 0, 12, $day, $month - 1, $year - 1900 ); Here in North America (at least in most places)

Re: recursive search

2005-12-02 Thread Shawn Corey
The Ghost wrote: So far I did this: #!/usr/bin/perl use File::Find; my $totalLines; find(\wanted, '@directories'); sub wanted { unless ($_=~m/.html|.mas|.pl|.txt$/i) {return 0;} #filter the kinds of files you want open FILE, $File::Find::name; print $_: ; my

Re: config files

2005-12-02 Thread Shawn Corey
Dr.Ruud wrote: If the .conf is in the same directory as the .pl, then $0 can help, see `perldoc perlvar` and File::Basename, or maybe even `perldoc FindBin`. True. But since the OP said 'mail' I assumed that meant more than one user, each with a different configuration. -- Just my

Re: Referring to the calling script from a module

2005-12-02 Thread Shawn Corey
[EMAIL PROTECTED] wrote: Is it possible for a module to refer to its calling script? For example, if I create a module called MyModule.pm, and use it in a script MyScript.pl by saying use MyModule;, is it possible to refer to the calling script (MyScript.pl in this case) and get some information

Re: Help with syntax local (*in);

2005-12-02 Thread Shawn Corey
Buehler, Bob wrote: local(*in); Does this indicate that you want to make all variables that begin with $in private? No. Perl has two kinds of scoping: lexical and dynamic. Lexical scoping means the name only has meaning with the block, or if outside any block, within the file. Dynamic

Re: Count number of times matched

2005-12-01 Thread Shawn Corey
SG Edwards wrote: If I want to count the number of times that a match occurs in a line is there a way of doing this, if there is I have not found it! e.g. $line=This is a sentence about matching sentences.\n; $line=~/sentence/ig; So I will have matched sentence twice and I want to record

Re: Adding the use statements to a different file

2005-11-28 Thread Shawn Corey
[EMAIL PROTECTED] wrote: Hi, I have to write several perl scripts with a number of modules included. Therefore, I have to type many use statements at the top of each script. Is there a way to dump all these use statements in a different file and then just include that file everytime I have to

Re: how to interupt a running program

2005-11-21 Thread Shawn Corey
S, karthik (IE03x) wrote: I need to control a perl program from another perl program. See: perldoc perlipc (search for Signals) perldoc perlvar (search for %SIG) perldoc -f kill Also: perldoc -f fork perldoc -f wait The kill function sends a signal to another process, it does not

Re: Execute newgrp system command

2005-11-21 Thread Shawn Corey
Suvajit Sengupta wrote: Hi, I want to login into a new group using 'newgrp' UNIX command.Every newgrp command invokes a new shell. But when I am trying to execute this system command from a perl script the script is terminating and returning the prompt of the new shell . Can anyone suggest on

Re: Modifying column values of file records and appending to end of file.

2005-11-21 Thread Shawn Corey
Danny Fang wrote: However, I'm not sure how I could rewrite the newly modified column values of that particular row back into the file - I want to use the particular row which had its columns modified to be duplicated and appended to the end of the current file for a specific number of time

Re: Hi All

2005-11-16 Thread Shawn Corey
Randal L. Schwartz wrote: Hridyesh == Hridyesh Pant [EMAIL PROTECTED] writes: Hridyesh Check this site http://perldoc.perl.org/ Why refer someone to a website that replicates everything that is on their own disk anyway? It boggles my mind every time I see this! Because searching perldoc

Re: about regex

2005-11-16 Thread Shawn Corey
Elie De Brauwer wrote: You could for example do that by buffering them. Following example reads from standard input. No that you should replace the regexp by something with more meaning in your context. This application also assumes that there will be at least three lines of input. my

Linked Lists in Perl

2005-11-16 Thread Shawn Corey
Handling linked lists in Perl is not the same as in C. You can emulate them with arrays and manipulate them by using Perl's array functions. Create a list: my @list = (); Clear the list: @list = (); Add an $item:push @list,

Re: What is $ (can´t find it in the Camelbook)

2005-11-10 Thread Shawn Corey
Elie De Brauwer wrote: Angerstein wrote: Hello there, I found the $ Scalar in some examples but I can´t figure out what they are for. Could someone tell me what $ is? perldoc perlvar $LIST_SEPARATOR $ This is like $, except that it applies to array and slice val- ues

Re: Is it possible with RegEx

2005-11-10 Thread Shawn Corey
Gilles wrote: Hi, I try do to a simple thing : Knowing If a string like 13 exist in a string like 123 Or if 37 exist in 12356789 I tried many solutions, but never found one good so I try to do it with loops which more difficult but not impossible I'd like to know if with RegExp it's more

Re: system command help

2005-11-10 Thread Shawn Corey
Marilyn Sander wrote: On Nov 9, 2005, at 4:52 PM, Pablo Wolter wrote: The system function call returns a boolean value as return value, I don't remember if 1 is for fail and 0 for success or viceversa. Actually it is not a boolean value. It is a two-byte value, and each byte is an

Re: Getopt::Long

2005-11-08 Thread Shawn Corey
Chris Knipe wrote: So, this is more of a block question I think, but how I can get the above example to show the help screen FIRST, and THEN complain about the missing value for -s Why? Here's an example of how to do it: #!/usr/bin/perl use strict; use warnings; use File::Basename;

Re: processing at preset times

2005-11-08 Thread Shawn Corey
Frank Bax wrote: I realise that my subject line might suggest use of cron, but this is not workable unless there is some way for two scripts to communicate with each other. If this could work, the processing script would probably still need a thread to do communication with timer script

Re: waitpid() and exitcode 8 ?

2005-11-07 Thread Shawn Corey
Elie De Brauwer wrote: Hello list, I recently encountered a small oddity. Suppose I have a process A: #!/usr/bin/perl use strict; print Hello \n; sleep 1; print Goodbye\n; exit 9; Simply shows some out and gives a certain exit code. A second process, simply calls fork, execs the child in

Re: array of hashrefs

2005-11-06 Thread Shawn Corey
Octavian Rasnita wrote: Hi, I have tried the following test program: my @array = ( {a = 'aaa', b = 'bbb',}, {a = 'ala', b = 'bala',}, ); my @array2 = @array; $array2[0]{a} = 'nanan'; push(@array2, 'test'); use Data::Dumper; print Dumper [EMAIL PROTECTED]; The result was: $VAR1 = [

Re: about cron and perl

2005-11-04 Thread Shawn Corey
ZHAO, BING wrote: Hi, I was advised to check out man cron for how to use cron. Set off do_it.pl using cron. But that's about it , all I can get from web help. I have no clue: 1. what should I include in the do_it.pl, say to delete certain old files? 2. this is a

Re: What kind of structure to choice

2005-11-03 Thread Shawn Corey
Gilles wrote: Hi, I would like to create a matrix 9x9 where the elements are list (array). (like a cube) These lists will decrease during processing and will normally contain one element, so to know if a list is definitely treated I need a flag. So 2 solutions seems to be good, but which

Re: max value of an integer scalar

2005-11-03 Thread Shawn Corey
Adriano Ferreira wrote: But the multiplication operator (*) is smarter and does an upgrade from integer to floating point when needed, (possibly) increasing the range of the correct results. Adriano. What JeeBee has stumbled across is a field of study called Numerical Analysis. For a brief

Re: XML Help

2005-11-03 Thread Shawn Corey
Scott Taylor wrote: if ($x-{VEHICLE}-{STREETNUM}){ print ... } else { print ; } but even that doesn't work. Cheers. -- Scott What do you mean when you say it doesn't work? Are you getting something like this? Use of uninitialized value in concatenation (.) or string ... If so, try:

Re: statistics of text

2005-11-02 Thread Shawn Corey
Ing. Branislav Gerzo wrote: I did this by hand...but anyone know how to this effectively in perl? I think I have to build hash of all possibilities of 2 words sentences (in input txt are allowed only [0-9a-z ]), in list I will have lines of input txt, and iterate every key in hash over array,

Re: statistics of text

2005-11-02 Thread Shawn Corey
Ing. Branislav Gerzo wrote: my $keyword = business; my %all2words = (); open TXT, words.txt or die $!; while (TXT) { chomp; next unless /\b$keyword\b/; # skip loop if no keyword while ( /(?=(\S+\s+\S+))\S+/g ) { my $temp = $1;

Re: uninitialized variable

2005-11-01 Thread Shawn Corey
Adedayo Adeyeye wrote: Hello, I'm getting an error when trying to run a script. Part of the scripts is Line 10 my $action = param('form_action'); . Line 14 Search_DB() if($action eq 'search'); The error I get is: [Tue Nov 1 16:28:41 2005] connect_script.cgi: Use of uninitialized

Re: How to change the Owner of a file

2005-10-31 Thread Shawn Corey
Rakesh Mishra wrote: Hi folks Can any body tell me how to change the owner of a file ?? I have written this script ... unless (chown $uid , $gid , $filename) { die chown failed :$!; } this code will give me the error you can't change permission denied can any body tell me , how to

Re: How to change the Owner of a file

2005-10-31 Thread Shawn Corey
Chris Devers wrote: What?? That's hardly why this constraint exists. If anyone can make changes to any other account's files, then there's no point in having ownership constraints at all. Of course. I was being facetious. The new version of chown prevents what? New is a relative term.