Hang with Use Warnings and a Subroutine

2005-01-27 Thread Graeme St. Clair
I just solved a (to me) curious hang with Windows XP, ActiveState 5.8.6, Apache 1.3.27. On Submit, an HTML page calls a Perl script into a new page. The Perl script runs fine with use strict but not warnings. Add -w to the shebang line, or add 'use warnings', and it hangs without ever presentin

Re: How get folder size?

2005-01-27 Thread JupiterHost.Net
Giangaetano Vituzzi wrote: Hi everyone, Hello, How could I go about having perl to get the size of a folder? perldoc -f stat $ perl -mstrict -we 'my $ds = (stat ".")[7];print "$ds\n";' 5474 $ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: How to find the Index of an element in array?

2005-01-27 Thread Alfred Vahau
You can use regular expression Eh? You mean a regular construct? alfred, [EMAIL PROTECTED] wrote: Hi Mallik You can use regular expression - $i=0; foreach $temp (@arr) { if ( $temp eq 'pqr' ) { print "index is == $i \n"; last; } $i++; }

How get folder size?

2005-01-27 Thread Giangaetano Vituzzi
Hi everyone, How could I go about having perl to get the size of a folder? thanks -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

Re: [OT - maybe] cgi-bin script being run three times?

2005-01-27 Thread Gavin Henry
-- Just getting into the best language ever... Fancy a [EMAIL PROTECTED] Just ask!!! > On Thu, 27 Jan 2005, Gavin Henry wrote: > >> my rsync.cgi script that I was taking about earlier, when run via >> cgi-bin, >> ps- aux soshow three copies of the same command. >> >> Does a cgi process fork 3 t

Re: [OT - maybe] cgi-bin script being run three times?

2005-01-27 Thread Chris Devers
On Thu, 27 Jan 2005, Gavin Henry wrote: > my rsync.cgi script that I was taking about earlier, when run via cgi-bin, > ps- aux soshow three copies of the same command. > > Does a cgi process fork 3 times, or is this an apache feature? No, and no. Of course, there must be a reason that it's hap

[OT - maybe] cgi-bin script being run three times?

2005-01-27 Thread Gavin Henry
Dear all, my rsync.cgi script that I was taking about earlier, when run via cgi-bin, ps- aux soshow three copies of the same command. Does a cgi process fork 3 times, or is this an apache feature? A bit OT I know. -- Kind Regards, Gavin Henry. Managing Director. T +44 (0) 1467 624141 M +44 (

Re: How to find the Index of an element in array?

2005-01-27 Thread Richard Chycoski
Another problem occurs if the keys are not unique, depending on whether you want the first, last or all occurrences of the string. A linear search can find all occurrences, and will be faster for single lookup, but using a hash will consume less CPU (at the expense of memory) for large numbers

Re: RegExp equivalencies

2005-01-27 Thread Chris Devers
On Thu, 27 Jan 2005, Jay wrote: > Most free put an add at the bottom, too. Yes. A terse, easy to ignore one. This is reasonable. Multi-paragraph legalese is not reasonable. > What annoys me are the crazy disclaimers. But they are corporate > policy in a lot of places, and it's crazy to thin

RE: RegExp equivalencies

2005-01-27 Thread Jason Balicki
Jay wrote: > just for this list. Let's face it, this isn't about spam: this is > about violating some people's sesibility regarding a completely > arbitrary customary 4-line sig limit developed in a completely > different forum (usenet) 20 years ago when (80 x 4 = 320) b

Re: Bareword "INPUT" not allowed while "strict subs"

2005-01-27 Thread Jay
On Thu, 27 Jan 2005 16:11:15 +0530, Ankur Gupta <[EMAIL PROTECTED]> wrote: > I think you can't pass filehandles directly to a sub. > You need to use typeglob. > > Just add this after opening the file. > my $file = *INPUT; > > $message = &processTextMails($file); > sub processTextMails > { >

Re: RegExp equivalencies

2005-01-27 Thread Jay
On Thu, 27 Jan 2005 07:15:10 -0500 (EST), Chris Devers <[EMAIL PROTECTED]> wrote: > On Thu, 27 Jan 2005, Michael Kraus wrote: > > > Yes, I've noticed. Unfortunately if I leave off my .sig (as I did in > > the original message of this thread), the mail server decides to > > append an even longer si

RE: How to find the Index of an element in array?

2005-01-27 Thread Matthew Corby-Eaglen \(mcorby\)
Nah makes perfect sense !! ;) Grep Power(tm) -Original Message- From: Ankur Gupta [mailto:[EMAIL PROTECTED] Sent: 27 January 2005 13:15 To: Manav Mathur Cc: Rob Napier (rnapier); Richard Chycoski (rac); Mallikarjun Kodicherla (mkodiche); perl-trolls (mailer list); beginners@perl.org Sub

Re: How to find the Index of an element in array?

2005-01-27 Thread Ankur Gupta
I have another solution using grep but its kinda weird @array = (..); #your array here $i=1; eval{ grep { (/$element/o && die ) or ++$i } @array; }; print "index of $element = $i\n"; #prints the index of $element.. If $i > scalar(@array), element not found. -- Ankur Manav Math

RE: How to find the Index of an element in array?

2005-01-27 Thread Manav Mathur
Rob, In your solution $hash{'pqr'} will return 3. - iniitalize $i with 1 or - %hash=map{$_=>[EMAIL PROTECTED]; Manav |-Original Message- |From: Rob Napier [mailto:[EMAIL PROTECTED] |Sent: Thursday, January 27, 2005 2:06 PM |To: Richard Chycoski |Cc: Mallik; Perl-Trolls; beginners@perl.o

Re: CGI Rsync script to show backup in realtime for end user

2005-01-27 Thread Gavin Henry
>>> Is it possible for me to write a perl cgi script that will echo the >>> output from an rsync backup? >> >> Sure, why not :) >> >> Sorry, had to be done ;p >> >> More info needed, code you've tried, how you're doing rsync, etc >> >> Start with: >> >> #!/usr/bin/perl >> >> use strict; >> use war

Re: How to find the Index of an element in array?

2005-01-27 Thread Rob Napier
In terms of time efficiency, if you only need one lookup, the linear walk is almost certainly faster, since you don't have to hash the entire list. You can stop as soon as you find the answer (which you expect to be half-way down the list). But the speed difference is almost certainly negligabl

Re: How to find the Index of an element in array?

2005-01-27 Thread Richard Chycoski
You would have to 'walk' the whole array, which is rather inefficient. However, depending on what else you need to do with your data, a hash could do better than an array: %myhash = ('abc'=>1, 'xyz'=>2, 'mno'=>3, 'pqr'=>4, 'stu'=>5, 'sdfd'=>6); and then $myhash{ 'pqr') wiil return 4. - Richard

RE: RegExp equivalencies

2005-01-27 Thread Chris Devers
On Thu, 27 Jan 2005, Michael Kraus wrote: > Yes, I've noticed. Unfortunately if I leave off my .sig (as I did in > the original message of this thread), the mail server decides to > append an even longer signature to my email messages. :( > > Sorry, it's my company's policy - and I'm tired of t

Re: using namespace

2005-01-27 Thread Marcello
Ramprasad A Padmanabhan ha scritto: Hi Manav, But still import does not work across multiple files. for eg, main.pl- #!/usr/bin/perl # use Some::Module qw(someFunction1); require MyLibModule; # This function will now work someFunction1(); MyLibModule::someOth

Re: using namespace

2005-01-27 Thread Randy W. Sims
Ramprasad A Padmanabhan wrote: Is there anyway I can do a using namespace for a particular loop like in c++; ( for functions not exported ) Below are a few dirty little tricks that can get you something similar, but I've never used them, and I'm not sure they are good practice... Use at your own

Re: Bareword "INPUT" not allowed while "strict subs"

2005-01-27 Thread Ankur Gupta
I think you can't pass filehandles directly to a sub. You need to use typeglob. Just add this after opening the file. my $file = *INPUT; $message = &processTextMails($file); sub processTextMails { my $file = shift; while(<$file>) { $returnMessage=$returnMessage.$_; } close($file);

Re: Bareword "INPUT" not allowed while "strict subs"

2005-01-27 Thread Ing. Branislav Gerzo
Anish Kumar K. [AKK], on Thursday, January 27, 2005 at 15:53 (+0530) wrote these comments: AKK> open (INPUT , "a.txt") II die "Cannot open this file"; do you mean II is || AKK> $message = &processTextMails(INPUT); = Error in this line AKK> Bareword "INPUT" not allowed while "strict subs" in use a

Bareword "INPUT" not allowed while "strict subs"

2005-01-27 Thread Anish Kumar K.
Hi I open a file and pass the file handle to the sub routine. I have used "Use Strict" I am getting the error in the filehandle. Why is this caused.. Is it because I need to pass any other information with this sub processTextMails { while() { $returnMessage=$returnMessage.$_; }

Re: How to find the Index of an element in array?

2005-01-27 Thread John W. Krahn
Mallik wrote: I need to find the index of a particular element in array. For eg., @arr = ('abc', 'xyz', 'mno','pqr','stu','sdfd'); I want to find the index of the element 'pqr' which is 4. Any function/code to achieve this. for my $i ( 0 .. $#arr ) { if ( $arr[ $i ] eq 'pqr' ) { $inde

RE: using namespace

2005-01-27 Thread Ramprasad A Padmanabhan
On Thu, 2005-01-27 at 15:11, Manav Mathur wrote: > use semantics internally do an import. > By multiple files, do you mean multiple packages?? > see perldoc -f use > > for the code that you have listed below, you'll have to 'use' Some::Module > inside package MyLibModule. > > for perldoc > > The

Re: How to read this array?

2005-01-27 Thread Ing. Branislav Gerzo
Chris Devers [CD], on Wednesday, January 26, 2005 at 11:11 (-0500 (EST)) thoughtfully wrote the following: >> http://${host name deleted}/orelly/perl/prog3/ch09_03.htm CD> That looks like a pirated copy of one of O'Reilly's bookshelf CDs. uff, I am sorry for that, didn't know, misslooked .ua :( S

RE: using namespace

2005-01-27 Thread Ramprasad A Padmanabhan
Hi Manav, But still import does not work across multiple files. for eg, main.pl- #!/usr/bin/perl # use Some::Module qw(someFunction1); require MyLibModule; # This function will now work someFunction1(); MyLibModule::someOtherFunction(); ---END--

RE: using namespace

2005-01-27 Thread Manav Mathur
see perldoc -f import perldoc -f use and what happens when you use Some::Module (qw/somefunction1 somefunction2/) ; Manav |-Original Message- |From: Ramprasad A Padmanabhan [mailto:[EMAIL PROTECTED] |Sent: Thursday, January 27, 2005 2:33 PM |To: perl beginners |Subject: using namespace

Re: converting from CP1250 to ASCII

2005-01-27 Thread Ing. Branislav Gerzo
Ing. Branislav Gerzo [IBG], on Thursday, January 27, 2005 at 09:47 (+0100) made these points: IBG> Convert the string to UTF-8, then iterate over the characters, get IBG> their names using Unicode::CharName::uname, strip the accent using IBG> regular expression from the name, like LATIN CAPITAL L

using namespace

2005-01-27 Thread Ramprasad A Padmanabhan
Is there anyway I can do a using namespace for a particular loop like in c++; ( for functions not exported ) FOr eg in a perl script use Some::Module { using namespace Some::Module; # Is this possible ? someFuntion1(); # Instead of Some::Module::someFunction1() someF

Re: converting from CP1250 to ASCII

2005-01-27 Thread Ing. Branislav Gerzo
Jay [J], on Wednesday, January 26, 2005 at 16:51 (-0500) typed: J> Are you sure? There's no newline, so make sure you're terminal isn't J> putting "aez" before your prompt. Also, are you sure that the input I am sure, because, if I put there "aez" (no accents), it prints "aez" J> is what you t

RE: How to find the Index of an element in array?

2005-01-27 Thread Ramprasad A Padmanabhan
On Thu, 2005-01-27 at 13:10, Mallik wrote: > Hi, > > Thanks for ur reply. > > Is there any function instead of looping thru entire array. > > Mallik. > You can do fancy stuff like below, but this may not be necessarily better. Can you post where you are trying to use this ? What is there is m

Re: CGI Rsync script to show backup in realtime for end user

2005-01-27 Thread Gavin Henry
On Thursday 27 Jan 2005 02:01, JupiterHost.Net wrote: > >> Is it possible for me to write a perl cgi script that will echo the > >> output from an rsync backup? > > > > Sure, why not :) > > > > Sorry, had to be done ;p > > > > More info needed, code you've tried, how you're doing rsync, etc > > > >