Re: how to copy elements into the next array

2009-01-29 Thread Mr. Shawn H. Corey
On Thu, 2009-01-29 at 14:39 +0800, itshardtogetone wrote: > Hi, > How do I copy the first 10 elements of @a into @b? > > The method that I use is long :- > my @a = 1..20; > my @b = (); > > my $ctr = 0; > foreach (@a){ > if ($ctr < 10){ > push @b,$_; > } > $ctr ++; > } See

RE: Subroutine getting its own path

2009-01-27 Thread Mr. Shawn H. Corey
On Tue, 2009-01-27 at 12:27 -0500, Malyj, Mark wrote: > Your code > > my ( $whoami ) = grep { m{ \b ServiceScript \. pl \b }msx } values % > INC; > print "$whoami\n"; > > works great!! If you have time, could you explain to a Windows guy > like > me what the grep is doing? See `perldoc -f grep`

Re: Subroutine getting its own path

2009-01-27 Thread Mr. Shawn H. Corey
On Mon, 2009-01-26 at 15:07 -0800, mark.ma...@gdit.com wrote: > My question is this – how can my ServiceRoutine in ServiceScript.pl > get its own path? I would like to record this to the database for > auditing purposes as well, to make sure no one is using a substitute > version of ServiceRoutine

Re: Simple regex problem has me baffled

2009-01-26 Thread Mr. Shawn H. Corey
On Mon, 2009-01-26 at 16:20 +0100, Bill Harpley wrote: > foreach $entry(@list) > { > > $entry =~ /\[([a-z0-9]{5})\]/; > > print "$1\n"; # print to screen > > # print FILE "$1\n";# print to file > } If there is no match, you are printing a uninitiali

Re: Loading results of pattern match into an array - help please

2009-01-23 Thread Mr. Shawn H. Corey
On Fri, 2009-01-23 at 11:57 -0800, jeffqt...@gmail.com wrote: > I am trying to split a very long fixed lenght record into its > constituents, and then load them into an array. I have patterns like '^ > (.{3})(.{24})(.{6})...' which gets teh fields into $1, $2, $3 etc. I > am stumped however as to h

Re: Perl UNIX shell PATH problem

2009-01-18 Thread Mr. Shawn H. Corey
On Sun, 2009-01-18 at 15:36 +, Andy Smith wrote: > Odd one, must be missing something basic! :P > The problem is that your servers were set up at different times. Or rather, your company does not have rigorous policies for setting up servers. Your development and test environments must be a

Re: String replacement involving special characters.

2009-01-18 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 10:56 -0800, Blue wrote: > $string = "aaa ' ccc "; > $string =~ s/'/bbb/eg; > > The above replaces the single-quotation mark with bbb. The result will > be: > aaa bbb ccc > > How do I modify it so that the single-quotation mark is replaced with > \' (a backslash and a single

Re: Perl UNIX shell PATH problem

2009-01-16 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 19:08 +, Andy Smith wrote: > Hi Thanks for the test code, yep the paths are different: > > working server: PATH > > /sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin > > not working server: PATH/bin:/usr/bin > > Im still sea

Re: Perl UNIX shell PATH problem

2009-01-16 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 17:51 +, Andy Smith wrote: >nope, its a binary executable. As I mention it works if placed in > (or a link is placed in) /usr/bin so there's definately a difference > of environment. The fact www doesnt have a shell or home dir makes > it > an odd one. Odd, anywa

Re: Perl UNIX shell PATH problem

2009-01-16 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 16:12 +, Andy Smith wrote: >yep, thats what Im saying, the profile is the same on each OS and > the www user has no homedir, so the www user should have the same > path > on both. Also PATH is set the same in /etc/rc on both systems. And, > sorry I didnt mention

Re: Perl UNIX shell PATH problem

2009-01-16 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 15:55 +, Andy Smith wrote: > Hi list, > >probably quite a basic question, but where does perl get its PATH > variable from when executig shell commands? > > My problem is running Tr.pm which is part of the open source tool > smokeping, it does some nice things wi

Re: launch process

2009-01-16 Thread Mr. Shawn H. Corey
On Fri, 2009-01-16 at 20:11 +0530, Sharan Basappa wrote: > Hi, > > What is the method to launch unix process from perl. I believe this is > going to be system call. > The additional requirement I have is that the calls should be non > blocking mainly as these > process execution should happen in p

Re: Passing info to a sub function

2009-01-12 Thread Mr. Shawn H. Corey
On Mon, 2009-01-12 at 18:40 -0600, Harry Putnam wrote: > I'm in the middle of some administrative type of scripting and my > skill level is pretty low. I ran up on a need to pass two different > kinds of chunks of into to a sub function. > > I'm familiar with the `func($thg1, thg2, thg3);' kind of

Re: help with format conversion

2009-01-11 Thread Mr. Shawn H. Corey
On Sun, 2009-01-11 at 13:41 -0500, ANJAN PURKAYASTHA wrote: > hi, > i have file of numbers in the format x.e+003, eg 2.133793e+001. > these numbers are not recognized by the perl multiplication operator > "*". > any idea of how i may convert these numbers to a format the operator > DOES > recog

Re: external program control

2009-01-11 Thread Mr. Shawn H. Corey
On Sat, 2009-01-10 at 12:06 -0700, bft wrote: > I am trying to launch an instance if Firefox, but I do not want my > Perl > script to stop while Firefox is open. > > I have tried: > print `firefox`; > > and > > print `firefox &`; > > Both hang my perl script until I close firefox. > > Any sug

Re: Regular Expression - exclude character from character class ?

2009-01-09 Thread Mr. Shawn H. Corey
On Thu, 2009-01-08 at 20:25 -0800, howa wrote: > Hello, > > > Consider the string: > > $s = '[[2003]] abc [[2008]] "def"'; > > > I want to extract 2008 and def, so using > > > \[\[([\w\W^\]]+?)\]\]\s"(.+?)" > > The regex match all string, even thought I have added to exclude: ^\] > inside t

Re: grep and substring then uc

2009-01-09 Thread Mr. Shawn H. Corey
On Thu, 2009-01-08 at 18:23 -0800, Erik Witkop wrote: > Here is what I am trying to do, > > I want to grep on a semicolon, and then upper case the next character. > > So if my input data is in the format of > > Witkop; erik > > I want to find the semicolon and then uppercase the 'e' in erik. >

Re: Neater way to declare variables

2009-01-08 Thread Mr. Shawn H. Corey
On Thu, 2009-01-08 at 11:56 +, Taylor, Andrew (ASPIRE) wrote: > This works OK, but I'm trying to avoid declaring variables seperately > from assigning them (wherever possible), and trying to keep the size > of > the script down without losing human legibility. > > Is there a neater/cleverer

Re: print on the same line

2009-01-06 Thread Mr. Shawn H. Corey
On Tue, 2009-01-06 at 06:23 -0800, h3xx wrote: > I find it's easier (and in this case totally doable) if you make > something like this: > > for my $count (10 .. 0) { > printf STDERR "%2d seconds remaining...\n", $count; > sleep 1; > print STDERR "\e[A"; > } > > ^ "\e[A" is the VT-100 code

Re: RegExp Searching within

2009-01-05 Thread Mr. Shawn H. Corey
On Mon, 2009-01-05 at 08:17 -0800, Paul M wrote: > If it were true XML, I would say all children's Node Names. > so: > > You mean all the descendants. The children of elem1 are elema and elemb. The descendants of elem1 are elema, elemb, and elemc. #!/usr/bin/perl use strict; use warnings

Re: RegExp Searching within

2009-01-05 Thread Mr. Shawn H. Corey
On Mon, 2009-01-05 at 08:02 -0800, Paul M wrote: > I want to know all the "elements" within elem1. (Note: It is > seriously MALFORMED XML, that is why I am attempting to use regexp). Do you want to know all the children or all the descendants? -- Just my 0.0002 million dollars worth, Sha

Re: print on the same line

2009-01-04 Thread Mr. Shawn H. Corey
On Sun, 2009-01-04 at 19:33 -0700, bft wrote: > Hello all, > I am on a windows box and I am trying to have a count down timer print > out the seconds remaining without new lining it. i.e. I do not want a > screen that looks like this... > > > 19 seconds remaining > 18 seconds remaining > 17 ...

Re: How to display the contents of (or open) a file

2009-01-02 Thread Mr. Shawn H. Corey
On Fri, 2009-01-02 at 05:35 -0800, Collaborate wrote: > I should have stated my question in a more general sense. I can send > the output to a text or an Excel file. Other file formats that I > haven't yet explored may be possible. Instead of double clicking with > the mouse on the created file's n

Re: JAPH program of my own

2009-01-02 Thread Mr. Shawn H. Corey
On Fri, 2009-01-02 at 11:32 -0500, Steven Rodriguez wrote: > Of course, Randal(a.k.a. "merlyn") is the original Perl hacker. He > is > the one who came up with the idea. I'd love to see some of his > gnarly > obfuscated versions.(BTW, I am a huge FLOSS weekly fan) I think > there > are some a

Re: How to display the contents of (or open) a file

2009-01-01 Thread Mr. Shawn H. Corey
On Thu, 2009-01-01 at 17:28 -0500, Chas. Owens wrote: > If the file is long and you want to do paging, well, that really isn't > Perl's job. Use whatever pager your OS provides (more, pg, less, > etc.). In *nix, traditionally the user's favourite pager is stored in the environment variable $PAGER

Re: Exit status of system commands

2009-01-01 Thread Mr. Shawn H. Corey
On Thu, 2009-01-01 at 04:38 -0800, Duck wrote: > I am writing a script to ping several systems and then to run nslookup > on those that fail the ping test. How do I capture the exit status of > the system commands. I tried something like: > > $status = system("nslookup xxx.xxx.xxx.xxx"); > print

Re: JAPH program of my own

2008-12-31 Thread Mr. Shawn H. Corey
On Wed, 2008-12-31 at 22:33 -0500, Chas. Owens wrote: > eval q.$..(uc).qq.='$_'.for split//, "JustanotherPerlhacker"; > print qq'$J$U$S$T$"$A$N$O$T$H$E$R$"$P$E$R$L$"$H$A$C$K$E$R$/'; > qq'...' That's just sick! -- Just my 0.0002 million dollars worth, Shawn Believe in the Gods but row a

Re: Is there some IDE dedicated to perl?

2008-12-30 Thread Mr. Shawn H. Corey
On Tue, 2008-12-30 at 11:50 -0500, Adam Jimerson wrote: > I played with Perl Express a bit and wasn't really happy with it, all > you really need is a text editor like others say and I have to put my > vote as +1 for VIM. > Both vim and gvim (gui-vim) work like vi. For a more modern version, use

Re: function call

2008-12-30 Thread Mr. Shawn H. Corey
On Tue, 2008-12-30 at 09:08 -0600, David Ehresmann wrote: > this works, thanks. I thought you had to declare the function before > you called it? That is not right? No, when you execute a Perl script, it is compiled before it is run. Therefore all subs are known before the script is run; they are

Re: function call

2008-12-30 Thread Mr. Shawn H. Corey
On Tue, 2008-12-30 at 07:10 -0600, David Ehresmann wrote: > I have a factorial script that calls a sub fact that does the > factorial and returns a value. But I get this error when I execute > the script: > > Use of uninitialized value in numeric gt (>) at fact.pl line 22. > > Here is the script

Re: Printing a constant array

2008-12-27 Thread Mr. Shawn H. Corey
On Sat, 2008-12-27 at 12:52 -0500, Chas. Owens wrote: > I too have worked at places that have these sorts of obnoxious > policies. Most often I have found that the policy has been created by > lazy sysadmins who don't want to take the time to install the modules > (or learn how, since often they d

Re: Printing a constant array

2008-12-27 Thread Mr. Shawn H. Corey
On Sat, 2008-12-27 at 11:51 -0500, Chas. Owens wrote: > * only if you have Readonly::XS installed, otherwise it uses a tied > variable that throws an error when STORE is called. The problem with Readonly et al. is that it is not a standard module. I have worked in places that do not allow anythin

Re: Printing a constant array

2008-12-27 Thread Mr. Shawn H. Corey
On Sat, 2008-12-27 at 03:10 -0800, bacoms wrote: > Ho, I wanted to declare an HTML list as a constant array and then > print it but cannot work out the stntax. > > This is what I've coded; > > use constant NAVTABSLIST => ["\n", > " > \n", >

Re: implementing algo

2008-12-25 Thread Mr. Shawn H. Corey
On Thu, 2008-12-25 at 19:15 +0530, Sharan Basappa wrote: > Hi Jenda, Rob, Shawn, > > I am attaching a sample flowchart figure. > > Step1 and Step2 are the process steps and D1 and D2 are the decisions. > > Will this code translate to the foll in perl? > > do > { > do > { > step1 >

Re: read line in, print each line to separate file

2008-12-24 Thread Mr. Shawn H. Corey
On Wed, 2008-12-24 at 13:16 -0500, Charlie Farinella wrote: > I need to read in a file of 200 lines and print each out to a separate > file. > > I've been stumbling with this, but I don't know how to name each outfile > individually. I was hoping to see 200 files named tx1 - tx200, but > inste

Re: Recursive regular expression not working !

2008-12-24 Thread Mr. Shawn H. Corey
On Wed, 2008-12-24 at 21:42 +0530, Amit Saxena wrote: > However when I try to execute it even with the proper text, I get the > different output than anticipated. > I'm not surprised that the results are not what you expected. Capture variables, $1, $2, $3, ... are globals and cannot be used in

Re: implementing algo

2008-12-24 Thread Mr. Shawn H. Corey
On Wed, 2008-12-24 at 20:10 +0530, Sharan Basappa wrote: > Hi, > > I am implementing an algorithm that I have worked out in theory. The > algorithm is in the form of a flowchart. > The area where I am having problem is where the flow passes from a > lower decision block to higher one. > I can impl

Re: Recursive regular expression not working !

2008-12-24 Thread Mr. Shawn H. Corey
On Wed, 2008-12-24 at 11:40 +0530, Amit Saxena wrote: > Hi all, > > I am trying to use recursive regular expression in Perl. > > I am using an example from http://www.perl.com/pub/a/2003/06/06/regexps.html. > > Whenever I try to execute the program, it hangs and I have to do a CNTRL-C > to break

Re: copying a webpage and pasting to a text file

2008-12-23 Thread Mr. Shawn H. Corey
On Tue, 2008-12-23 at 08:30 -0800, Collaborate wrote: > I am wondering if there is a way to copy a webpage to a text file > using Perl. All I need is to copy as unformatted text. > > I would like to match certain strings on pages written in javascript > and to my understanding, www::mechnize does

Re: Pod Usage Example

2008-12-23 Thread Mr. Shawn H. Corey
On Tue, 2008-12-23 at 20:16 +0530, Kelvin Philip wrote: > When I call pod2usage(verbose => 2); the terminal is getting stuck. > When I > press CTRL+4, it comes out and displays the whole man page. Would you > pls > suggest a solution for this issue? This sounds like a problem with your terminal em

Re: Pod Usage Example

2008-12-23 Thread Mr. Shawn H. Corey
On Tue, 2008-12-23 at 13:29 +0530, Kelvin Philip wrote: > Hi, > > Would someone guide me with a simple example for perl documentation using > Pod :: Usage? # Documentation levels my $DOC_USAGE = 0; my $DOC_HELP = 1; my $DOC_VER = 2; my $DOC_MAN = 3; # --

Re: HTML Stipper with an option for directories and multiple files

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 13:59 -0800, bdy wrote: > On Nov 18, 9:34 am, bdy120...@gmail.com (Bdy) wrote: > > Does any one know if there is a HTML stripper module that contains an > > option to strip multiple files across multiple directories. > > > > Having a helluva time finding one and getting the st

Re: 2 questions please, one on scope and one on regex

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 15:18 -0700, Eric Krause wrote: > Hello all, > I have two quick questions that I would love some help on. I have looked > at the manual (Programming Perl) and I didn't get it, hence my email. > > Question 1 - How can I make variables in a function (subroutine) global > (acc

Re: Perl garbage collector

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 15:02 -0500, Jay Savage wrote: > If you're really interested in Perl internals, you'll > probably want to check out the alt.lang.perl.misc newsgroup. Perl.org maintains a number of mailings list; one of the perl-porters http://lists.cpan.org/showlist.cgi?name=perl5-porters is

Re: Perl garbage collector

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 18:36 +0100, Patrick Kirsch wrote: > I'm using: Linux 2.6.27.6 #2 SMP x86_64; Distribution: OpenSUSE 11.0 . > In my opinion the Linux kernel is/should be able to rearrange freed > memory between processes (I think e.g. of the slab). > > But let me show another example: > $foo

Re: Perl garbage collector

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 18:10 +0100, Patrick Kirsch wrote: > Is there a possibility to influence it, to free memory (in the sense > of > give it back to the OS)? > Does your OS have a function that allows processes to return memory to it? Many do not. Most of the time, when a process frees memory

Re: trying to understand a line of perl cookbook

2008-12-22 Thread Mr. Shawn H. Corey
On Mon, 2008-12-22 at 03:49 -0800, RP wrote: > Question: I am not able to understand the statement -"@fake_array > { sort {$a <=> $b} keys %fake_array }". > I understood that we are sorting the keys of a hash %fake_array. But > what is the meaning of @fake_array here??? > > Appreciate your help to

Re: Windows - Perl - Cygwin - Basic Question

2008-12-19 Thread Mr. Shawn H. Corey
On Fri, 2008-12-19 at 11:45 -0500, Chas. Owens wrote: > If you get an error building a module from CPAN, either contact the > author or post the error to this list. > An additional note: some modules require you to install libraries. For example, GD.pm requires libgd.so These must be loaded an

RE: Trying to match window's path

2008-12-18 Thread Mr. Shawn H. Corey
On Thu, 2008-12-18 at 11:40 -0500, Gu, Han wrote: > Another question since I hit another snag on this, hopefully it's the last =) > > Sample --> > > $s2 = "c:\ise\conf\ise_eif_lvc.config"; You should always escape backslashes in literal strings: #!/usr/bin/perl use strict; use warnings; my $s

Re: Trying to match window's path

2008-12-18 Thread Mr. Shawn H. Corey
On Thu, 2008-12-18 at 10:50 -0500, Mr. Shawn H. Corey wrote: > On Thu, 2008-12-18 at 10:42 -0500, Gu, Han wrote: > > Hi, > > Still very noob when it comes to perl. Just have a quick question. I am > > trying to match a string that is window's path > > > >

Re: Trying to match window's path

2008-12-18 Thread Mr. Shawn H. Corey
On Thu, 2008-12-18 at 10:42 -0500, Gu, Han wrote: > Hi, > Still very noob when it comes to perl. Just have a quick question. I am > trying to match a string that is window's path > > Sample, > > $s1 = "c:\\log\s1.log"; > > $s2 = $s1; > > If ($s1 =~ m/$s2/i) { > print "matched\n"; >

Re: Sorting an array by a substring of its members

2008-12-15 Thread Mr. Shawn H. Corey
On Mon, 2008-12-15 at 20:33 -0500, Christopher Yee Mon wrote: > I have an array of strings whose members consist of a number followed by > a comma followed by a text string > > e.g. > 1,fresh > 2,testurl > > I want to sort by descending numerical order according to the number > part so I made t

Re: data and script in same location, how to write it down

2008-12-14 Thread Mr. Shawn H. Corey
On Sun, 2008-12-14 at 22:21 +0800, itshardtogetone wrote: > Hi, > I wish to open a file datafile.txt which is stored in the same location as > the perl script, so how do I write it down? > > open (FILE,'<'," ") || die "no such > files $!\n"; > > use F

Re: Processing Multiple Large Files

2008-12-12 Thread Mr. Shawn H. Corey
On Thu, 2008-12-11 at 12:28 -0800, friend...@gmail.com wrote: > Hi, > > I analyzing some netwokr log files. There are around 200-300 files and > each file has more than 2 million entries in it. > > Currently my script is reading each file line by line. So it will take > lot of time to process all

Re: convertion from a scalar to an array

2008-12-10 Thread Mr. Shawn H. Corey
On Wed, 2008-12-10 at 21:41 +0530, Anirban Adhikary wrote: > DEAR List > Is it possible what i am looking from the following code > > my @merge_err=("a","b","c","d","e"); > my @dup_err=("1","2","3","4","5"); > my @load_err=("aa","bb","cc","dd","ee"); > print "Enter Value:-[load/merge/dup]\t"; > >

Re: Split not acting the way I want it to

2008-12-09 Thread Mr. Shawn H. Corey
On Tue, 2008-12-09 at 22:20 -0500, Mr. Shawn H. Corey wrote: > On Wed, 2008-12-10 at 03:04 +, Rob Dixon wrote: > > Mr. Shawn H. Corey wrote: > > > > > > print '', (split( /\./, $ipAddress ))[-1]; > > > > Ugly, ugly, ugly. > > > OK,

Re: Split not acting the way I want it to

2008-12-09 Thread Mr. Shawn H. Corey
On Wed, 2008-12-10 at 03:04 +, Rob Dixon wrote: > Mr. Shawn H. Corey wrote: > > > > print '', (split( /\./, $ipAddress ))[-1]; > > Ugly, ugly, ugly. > OK, try: print substr($ipAddress,rindex($ipAddress,'.')+1); -- Just my 0.0002 million d

Re: how to release memory from a hash table or array

2008-12-09 Thread Mr. Shawn H. Corey
On Wed, 2008-12-10 at 13:15 +1030, org chen wrote: > I read a large file into a hash table. This hash table is used only > once in the subroutine. I am very concern the memory usage, So I plan > to realse the memory after used the hash table. The way I used is: > > my %hash = (); > > #read the

Re: Split not acting the way I want it to

2008-12-09 Thread Mr. Shawn H. Corey
On Tue, 2008-12-09 at 15:55 -0500, David Shere wrote: > On Tue, 2008-12-09 at 15:51 -0500, Mr. Shawn H. Corey wrote: > > print '', (split( /\./, $ipAddress ))[-1]; > > Thanks. I was searching for about an hour before I posted here; I found > an answer online a

Re: Split not acting the way I want it to

2008-12-09 Thread Mr. Shawn H. Corey
On Tue, 2008-12-09 at 15:35 -0500, David Shere wrote: > Hello. I'm not a new perl programmer, but I feel like one today. I > want to pull the last octet off of an IP address and print it to > standard output. I have this so far: > >@octets = split(/\./, $ipAddress); >print pop(@octets);

Re: Re:lawyer --- new to coding

2008-12-08 Thread Mr. Shawn H. Corey
On Mon, 2008-12-08 at 16:17 +0100, Jeff Pang wrote: > > Message du 08/12/08 16:12 > > De : "late_rabbit" > > A : beginners@perl.org > > Copie à : > > Objet : lawyer --- new to coding > > > > > > > I'm hoping for interesting beginner projects that may also have > > application to my work as a lawye

Re: Stupid question....

2008-12-06 Thread Mr. Shawn H. Corey
On Sat, 2008-12-06 at 23:09 +0900, Raymond Wan wrote: > The Perl documentation is "perldoc" and if you know you are > searching for something Perl-ish, you might as well use the search > function within perldoc (like that site I gave or as part of your > distribution) rather than Perl. To searc

Re: Starting with ::

2008-12-02 Thread Mr. Shawn H. Corey
On Tue, 2008-12-02 at 17:44 +0100, Martin Barth wrote: > > > $::Foo::a > > > > This is a shortcut for $main::Foo::a > > % perl -e 'package Foo; $a = 2; print $::Foo::a' > 2% > % perl -e 'package Foo; $a = 2; print $Foo::a' 2% > 2 > > so every package is a "subpackage" of main? Apparently

Re: Starting with ::

2008-12-02 Thread Mr. Shawn H. Corey
On Tue, 2008-12-02 at 16:42 +0100, Martin Barth wrote: > Hello, > > whats the difference if you start a variable with :: > > for example: > > $::a > $a > $main::a > > or: > > Package Foo; > $::a # <- this is still main?! Yes, the is a shortcut for $main::a > > $::Foo::a This is a shortcut

Re: "df -mg" system() -> $variable

2008-12-01 Thread Mr. Shawn H. Corey
On Mon, 2008-12-01 at 23:11 -0500, David wrote: > > > >The problem is the space character in the file name. Try: > > > >system "(df -mg;) >\"$fileLoc\" &"; > > > Shawn , that adjustment didn't work for me. > > sh: -c: line 1: syntax error near unexpected token > `">/Users/mini/diskSpaceLog/081

Re: "df -mg" system() -> $variable

2008-12-01 Thread Mr. Shawn H. Corey
On Mon, 2008-12-01 at 22:18 -0500, David wrote: > Thank you to all who helped me get a 6 digit date into perl. I > certainly heed warnings about not using outside system calls in perl > however, I have to make an outside call again. > > > > #!/usr/bin/perl -w > use strict; > > my $fileName =

Re: How to match HTML tag with RegExp

2008-11-30 Thread Mr. Shawn H. Corey
On Mon, 2008-12-01 at 02:57 +0100, Jenda Krynicky wrote: > OTOH, he can match the innermost [block]...[/block], remove it or > replace by something that doesn't contain either "tag", match the > next one ... It would not be pretty, but it would be doable. > > And actually if there really is jus

Re: Matching HTML tags with RegExp

2008-11-30 Thread Mr. Shawn H. Corey
On Sun, 2008-11-30 at 02:51 +0200, Canol Gökel wrote: > How can one write an expression to match always the most inner part? I > couldn't write an expression like "match a non-greedy .* which > does not have a inside. > You can't write a regular expression to do this. And no, I'm not going to w

Re: How to match HTML tag with RegExp

2008-11-30 Thread Mr. Shawn H. Corey
On Sat, 2008-11-29 at 20:56 -0800, ZuLuu wrote: > How can I match structures like > this: > > [block] > this is a block > [block] > this is another block > [/block] > first block ends > [/block] > You can't. In order to correctly interpret a s

Re: Not getting all the element.

2008-11-29 Thread Mr. Shawn H. Corey
On Fri, 2008-11-28 at 11:56 -0800, slow_leaner wrote: > Hello all, what am i missing!!! > #!/usr/bin/perl -w > @array_number =; > @new_array = half( @array_number ); > print "@new_array\n"; > > sub half { > @numbers = @_; > while (<@numbers>){ > @n = $_ / 2; > @new_a = pop(@n)

Re: wait for file creation and wait

2008-11-26 Thread Mr. Shawn H. Corey
On Wed, 2008-11-26 at 20:31 +0530, Sharan Basappa wrote: > Hi, > > I am writing a scheduler for some proprietary task. > There are two questions pertaining to this > > 1) I have to wait for creation of a file by some external process. How > do I do that in perl? > In other words, is it possible t

Re: system command

2008-11-26 Thread Mr. Shawn H. Corey
On Wed, 2008-11-26 at 20:43 +0530, Sharan Basappa wrote: > Hi, > > I am trying to launch a program using system command. > The program usually takes 20-30 minutes to complete. > I launch the programs in a loop. > Will the system command wait for first program to complete and then proceed > to the

Re: creating an HTML with images

2008-11-25 Thread Mr. Shawn H. Corey
On Tue, 2008-11-25 at 12:15 -0800, [EMAIL PROTECTED] wrote: > Hi, > I'm trying to write a simple script which reads some data from a file > and generates an HTML page with a graph in it describing the data from > the file. I know how to do all the processing, but I don't know which > packages to us

Re: random

2008-11-25 Thread Mr. Shawn H. Corey
On Tue, 2008-11-25 at 12:51 -0500, Telemachus wrote: > On Tue Nov 25 2008 @ 12:45, Telemachus wrote: > > If you want to check if you something Perl-ish > > Something clearly went wrong here. I got caught between "to check if you can > do something with Perl" and "to check something Perl-ish." Wha

Re: random

2008-11-25 Thread Mr. Shawn H. Corey
On Tue, 2008-11-25 at 21:29 +0530, Sharan Basappa wrote: > Hi, > > Would like to know if perl has native (without using special modules) > for generating random numbers? > > Regards > See `perldoc -f rand`. -- Just my 0.0002 million dollars worth, Shawn The key to success is being too

Re: Regarding conditional statement

2008-11-24 Thread Mr. Shawn H. Corey
On Mon, 2008-11-24 at 16:34 +0100, Jenda Krynicky wrote: > Is there any reason you want to do that? Other than that some > braindead languages work that way? Complete evaluation of conditions > is one of the most annoying features of any language. > > If rstBlah.EOF Then > bla bla bla > ElseIf

Re: Regarding conditional statement

2008-11-24 Thread Mr. Shawn H. Corey
On Mon, 2008-11-24 at 16:11 +0530, suresh kumar wrote: > Hi, > > Here is the sample code: > > sub a { > print "i am a\n"; > return 0; > } > > sub b { > print "i am b\n"; > return 1; > } > > if (a() && b()) { > print "yes\n"; > } else { > print "no\n"; > } > > > > I want both the subroutine t

Re: Uninitialized value in array

2008-11-24 Thread Mr. Shawn H. Corey
On Mon, 2008-11-24 at 15:57 +0530, sanket vaidya wrote: > my ($bi, $bn, @bchrs); > > my $boundry = ""; > > foreach $bn (48..57,65..90,97..122) { > > > > $bchrs[$bi++] = chr($bn); > > print "$bchrs[$bi]"; > > } > > Output: > > Use of unitialized value within @bchrs > You incr

Re: Regarding conditional statement

2008-11-24 Thread Mr. Shawn H. Corey
On Mon, 2008-11-24 at 18:41 +0530, suresh kumar wrote: > Thanks for the response. > > but is there anyother way to do this? > You just got three answer all essentially the same. What's wrong with them? -- Just my 0.0002 million dollars worth, Shawn The map is not the territory, the do

Re: global and local confusion

2008-11-23 Thread Mr. Shawn H. Corey
On Sun, 2008-11-23 at 16:55 -0600, Harry Putnam wrote: > The program I'll post below is really only a test of a subroutine I > want to use in a larger program. Trying to get the subroutine ironed > out in this test script below so there is a little extra bumping > around to get it executed as sub

Re: how to read file content into an array?

2008-11-23 Thread Mr. Shawn H. Corey
On Sun, 2008-11-23 at 05:47 -0800, John W. Krahn wrote: > Mr. Shawn H. Corey wrote: > > On Sun, 2008-11-23 at 05:34 -0800, John W. Krahn wrote: > >> You shouldn't "do something with $line" if $bytes_read is undefined: > >> > >>

Re: how to read file content into an array?

2008-11-23 Thread Mr. Shawn H. Corey
On Sun, 2008-11-23 at 05:34 -0800, John W. Krahn wrote: > You shouldn't "do something with $line" if $bytes_read is undefined: > > while ( my $bytes_read = read PATTERN, $line, 1920 ) { > unless ( defined $bytes_read ) { > die "error reading $filename: $!"; > } > # do s

Re: Greedy v non greedy regexps in lookahead.

2008-11-23 Thread Mr. Shawn H. Corey
On Sun, 2008-11-23 at 11:52 +, Andrew wrote: > I am tying to expand some camel case with spaces - but I want multiple > captitals to remain as one word. So > I want "PerlNotesOnXML" -> "Perl Notes On XML" > > My attempt is to use [A-Z]+ in a lookahead. > > my $text = "PerlNotesOnXML" ; >

Re: how to read file content into an array?

2008-11-23 Thread Mr. Shawn H. Corey
On Sun, 2008-11-23 at 15:52 +0800, loody wrote: > Dear all: > The prototype of read is > read FILEHANDLE,SCALAR,LENGTH > ex: > read PATTERN, $line, 1920; > > that means the $line will content 1920 bytes. It means it will attempt to read 1920 bytes. The actual number of bytes read is returned. Y

Re: Perl code shows high usage in "top" - why?

2008-11-22 Thread Mr. Shawn H. Corey
On Fri, 2008-11-21 at 23:51 -0800, sftriman wrote: > I have this code that looks through a series of files, and for each, > counts > the unique number of IP addresses over the past 20 minutes, then > rewrites > the file contents. > > It seems pretty simple - each of the 5 $site files has at most 1

Re: print $var =~ s/\s+\).$/)./g;

2008-11-21 Thread Mr. Shawn H. Corey
On Fri, 2008-11-21 at 15:13 -0800, [EMAIL PROTECTED] wrote: > Is there any way I can get rid of that pesky number and just have the > $var string printed? No. Substitution returns the number of substitutions made. Only match will return the matches. -- Just my 0.0002 million dollars worth

Re: Adding Very Large Numbers and Display

2008-11-21 Thread Mr. Shawn H. Corey
On Fri, 2008-11-21 at 11:02 -0800, [EMAIL PROTECTED] wrote: > Hello > > I have a perl script that is working fine. The script involves creating an > array of numbers. The values of these numbers in the is quite large (12 > integer digits or more). I can easily display the numbers with a simple p

Re: perl compilation issue - using global variable

2008-11-19 Thread Mr. Shawn H. Corey
On Thu, 2008-11-20 at 10:23 +0530, ashish nainwal wrote: > I want to compile a perl script because I want to run it on systems > which > dont have perl installed. > Does creating an executable solve this purpose? If yes, then how can I > do > that? All versions of Linux, BSD and UNIX come with Per

Re: Million hash comparisons

2008-11-19 Thread Mr. Shawn H. Corey
On Wed, 2008-11-19 at 18:30 +, Nitin Kalra wrote: > Hi Community, > > In a Perl script of mine I have to compare 2 8M-10M > files(each). Which mean 80-90M searches. As a normal > procedure (upto 1 M)I use hashes, but going beyond 1M > system performance degrades drastically. > > If anybody ha

Re: removing files in unix or linux using glob?

2008-11-19 Thread Mr. Shawn H. Corey
On Wed, 2008-11-19 at 12:12 -0500, Richard Lee wrote: > I thought I could do this, > > if ( -f q#/tmp/yahoo.* ) { > system("rm -rf /tmp/yahoo.*"); > } > > what am i missing? > for my $file ( glob( '/tmp/yahoo.*' ) ){ unlink $file if -f $file; } See: * perldoc -f unlink *

Re: perl compilation issue - using global variable

2008-11-19 Thread Mr. Shawn H. Corey
On Wed, 2008-11-19 at 04:03 -0800, ashish wrote: > Can someone please tell me how to compile a perl script which is > calling global variables and then how should the executable be used? > There is no need to compile a Perl script. To run it, call it with perl: perl ftp.pl Or you can make it

Re: Problem with parsing csv file and writing into two separate files

2008-11-18 Thread Mr. Shawn H. Corey
On Tue, 2008-11-18 at 10:16 -0500, Chas. Owens wrote: > Perl closes all file handles at the end of the program, so the only > reasons to close file handles early are > 1. the program doesn't end (it is a daemon) > 2. you have a limited number of file handles in your environment (or > you consume an

Re: Regular expression problem

2008-11-18 Thread Mr. Shawn H. Corey
On Tue, 2008-11-18 at 00:52 -0800, howa wrote: > Hello, > > I have two strings: > > 1. abc > 2. abc& > > > The line of string might end with "&" or not, so I use the expression: > > (.*)[$&] > > > Why it didn't work out? Inside the [] the meta-character loose their meaning. Only ^ and - ha

Re: perl module for graphs lines point

2008-11-18 Thread Mr. Shawn H. Corey
On Mon, 2008-11-17 at 23:07 -0800, ben perl wrote: > Hi , > > Is there a perl module to plot graphs with lines point. Yes, GD::Graph. You will need GD and GD::Text too. You can also try GD::Graph3d just for the fun of it. :) -- Just my 0.0002 million dollars worth, Shawn The map is n

Re: Array manipulation

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 08:35 -0800, hotkitty wrote: > How do I combine the arrays so that the the "newstuff" in array1 gets > appended only to an item in array2 if the dates match? Create a hash of lists with the dates as its keys. Go through Array2 and push each oldstuff on the list stored in the

Re: Need Help

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 13:23 -0500, Chas. Owens wrote: > On Sun, Nov 16, 2008 at 09:11, a b <[EMAIL PROTECTED]> wrote: > > Hi , > > Can any body tells me what do we mean by below code > > > > $ROUTE::COMM{NEWROUTE}{OS()} > > > > > > Thanks in Advance > > a b . > > > > No, there is not enough cont

Re: need help

2008-11-16 Thread Mr. Shawn H. Corey
On Sun, 2008-11-16 at 19:31 +0530, chillidba wrote: > Hi , > Can any body tells me what do we mean by below code > > $ROUTE::COMM{NEWROUTE}{OS()} > > > Thanks in Advance > a b . This is a deference of a hash of a hash in another package. ROUTE is the package name. COMM is the hash in ROUTE N

Re: search and replace

2008-11-13 Thread Mr. Shawn H. Corey
On Wed, 2008-11-12 at 13:00 -0800, [EMAIL PROTECTED] wrote: > I think I understand most of your suggestions but I'm not very clear > in this line: > > print $out $_;# in the while loop below. > > while (<$in>) { > s/\Q$search/$replace/g; > print $out $_; > > > What is the $_ variable? Th

Re: when to use variable vs. constant?

2008-11-13 Thread Mr. Shawn H. Corey
On Wed, 2008-11-12 at 21:17 -0500, Jay Savage wrote: > the only thing you are using the pragma to control is > whether the substitution happens at compile time or run time. In most > cases, it doesn't make a hill of beans. Yes, it does matter. If it happens at compile time, any error is reported

RE: String concatination.

2008-11-10 Thread Mr. Shawn H. Corey
On Mon, 2008-11-10 at 15:52 +, Taylor, Andrew (ASPIRE) wrote: > Try: > > print "abc${string}zyx\n"; > > or > > print "abc".$string."zyx\n"; > Also: printf "abc%sxyz\n", $string; -- Just my 0.0002 million dollars worth, Shawn The map is not the territory, the dossier is not the p

  1   2   3   4   5   6   7   >