Re: FORMAT question

2006-07-04 Thread Jeff Peng
Here a script that illustrates my current workaround: #! /usr/bin/env perl use strict; use warnings; my $outfile = "file_with_tables.txt"; open(OUT,">$outfile") or die "Couldn't open $outfile for writing: $!\n"; print OUT "Table 1:\n"; _print_format1(1,15,"foo"); _print_format1(2,8,"bar"); clos

Re: FORMAT question

2006-07-04 Thread Offer Kaye
On 7/5/06, Jeff Peng wrote: Hello, I think there are not relation between your implement and the filehandle. As far as I can tell, a format must have the same name as the filehandle to which you want to print it, and once you define a format you cannot change it. So these 2 facts mean you can'

RE: FORMAT question

2006-07-04 Thread Jeff Peng
The reason I am asking is that I want to print 2 different tables to the same text file and I don't want to use printf statements. For me at least, code that uses printf to print something as complex as a text table is hard to both write and read, hard to understand and hard to debug. It's also

FORMAT question

2006-07-04 Thread Offer Kaye
Hi, Can anyone tell me if it is possible to define 2 different formats for the same filehandle? The reason I am asking is that I want to print 2 different tables to the same text file and I don't want to use printf statements. For me at least, code that uses printf to print something as complex a

RE: Want to start remote desktop thru the CGI script

2006-07-04 Thread Nath, Alok (STSD)
Thanx Tom, for clarification. ~Alok. -Original Message- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Tom Phoenix Sent: Tuesday, July 04, 2006 10:34 PM To: Nath, Alok (STSD) Cc: beginners@perl.org Subject: Re: Want to start remote desktop thru the CGI script On

RE: Want to start remote desktop thru the CGI script

2006-07-04 Thread Nath, Alok (STSD)
Thanx bs for clarification. ~alok -Original Message- From: Bjørge Solli [mailto:[EMAIL PROTECTED] Sent: Tuesday, July 04, 2006 10:27 PM To: beginners@perl.org Subject: Re: Want to start remote desktop thru the CGI script Please reply below the text you are answering, it makes the who

Re: using CTRL-C to abort a routine?

2006-07-04 Thread John W. Krahn
Jorge Almeida wrote: > I want to use CTRL-C to abort execution of a routine (but not of the > main program). Something like this: > > # main program > $SIG{'INT'}='IGNORE'; > (...) > &myroutine() > (...) > sub myroutine{ > # do something > (...) > $S

Re: Resolved: passing by value ...

2006-07-04 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: > It was chop and not chomp that I need, I'm removing the last "/" on a > directory path, not newlines > Then it might be safer to do a substitute, chop is very aggressive. ( my $x = $_[0] ) =~ s(/$)(); -- __END__ Just my 0.0002 million dollars worth, --- S

Re: Resolved: passing by value ...

2006-07-04 Thread Dr.Ruud
[EMAIL PROTECTED] schreef: > Anyways, this how my subroutine now looks: > > sub xyz { > $x = $_[0]; Make that my $x = $_[0] ; Alternatives: my $x = shift ; my ($x) = @_ ; (that last one if you only expect 1 parameter) Put use strict ; use warnings ; on top of ev

Re: using CTRL-C to abort a routine?

2006-07-04 Thread Mr. Shawn H. Corey
Jorge Almeida wrote: > I want to use CTRL-C to abort execution of a routine (but not of the > main program). Something like this: > > # main program > $SIG{'INT'}='IGNORE'; > (...) > &myroutine() > (...) > sub myroutine{ > # do something > (...) > $S

Resolved: passing by value ...

2006-07-04 Thread Jhst463
Thanks everyone for your help, I found the problem was with (1) my understanding of how Perl functions act on variables in general and (2) with how chop in particular behaved. My subroutine originally contained this: sub xyz { $x = chop $_[0]; ... do stuff with $x } which demonstrates

using CTRL-C to abort a routine?

2006-07-04 Thread Jorge Almeida
I want to use CTRL-C to abort execution of a routine (but not of the main program). Something like this: # main program $SIG{'INT'}='IGNORE'; (...) &myroutine() (...) sub myroutine{ # do something (...)

Re: Searching for a word in a file ....... need a faster way.

2006-07-04 Thread Mr. Shawn H. Corey
Jeff Peng wrote: > Because the latter (grep) is essentially a loop,so grep() is not better > than using 'while(<>)'.Specially,when the file's size is large,reading > all the contents of this file into an array would consume your memory > quickly. > Another way to speed things up is to pre-filter t

RE: Searching for a word in a file ....... need a faster way.

2006-07-04 Thread Jeff Peng
Because the latter (grep) is essentially a loop,so grep() is not better than using 'while(<>)'.Specially,when the file's size is large,reading all the contents of this file into an array would consume your memory quickly. If your /search_pattern/ is changing frequently,I would give another exampl

Re: passing by value vs. passing by reference

2006-07-04 Thread D. Bolliger
[EMAIL PROTECTED] am Dienstag, 4. Juli 2006 19:17: > I have a subroutine that, amongst other things, chops a scalar variable, > $dir, passed to it as an argument. The problem is that I need $dir intact > (ie unchopped) after calling said subroutine, but it has been altered by > the chop. I can't

Re: passing by value vs. passing by reference

2006-07-04 Thread Mr. Shawn H. Corey
Aaron Priven wrote: > You should show us some code. > > Normally you would do this in the subroutine: > > sub routine { > >my $mydir = shift; ># which puts the value of $_[0] into $mydir ># and then removes that from the argument list >chop $mydir; ># do stuff with $mydir >

Re: passing by value vs. passing by reference

2006-07-04 Thread Aaron Priven
On Jul 4, 2006, at 10:46 AM, Aaron Priven wrote: you could pass it an expression that returns the value of $a. Sorry, I should have said "your variable" instead of "$a" here. -- Aaron Priven, [EMAIL PROTECTED], http://www.priven.com/aaron -- To unsubscribe, e-mail: [EMAIL PROTECTED] For a

Re: passing by value vs. passing by reference

2006-07-04 Thread Aaron Priven
You should show us some code. Normally you would do this in the subroutine: sub routine { my $mydir = shift; # which puts the value of $_[0] into $mydir # and then removes that from the argument list chop $mydir; # do stuff with $mydir } That makes a copy of the value. It sound

Re: passing by value vs. passing by reference

2006-07-04 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: > I have a subroutine that, amongst other things, chops a scalar variable, > $dir, passed to it as an argument. The problem is that I need $dir intact > (ie > unchopped) after calling said subroutine, but it has been altered by the > chop. I > can't figure out how to

Searching for a word in a file ....... need a faster way.

2006-07-04 Thread kilaru rajeev
Hi all, I'm searching for a word in a file. I wrote the code like this. while ( ) { if ( /search_pattern/ ) { executebale. } } or Can I use like, @list = ; grep();# using grep on list Let me know a faster way to search. Regards, Rajeev

passing by value vs. passing by reference

2006-07-04 Thread Jhst463
I have a subroutine that, amongst other things, chops a scalar variable, $dir, passed to it as an argument. The problem is that I need $dir intact (ie unchopped) after calling said subroutine, but it has been altered by the chop. I can't figure out how to pass the value (or more precisely, a

Re: Want to start remote desktop thru the CGI script

2006-07-04 Thread Tom Phoenix
On 7/4/06, Nath, Alok (STSD) <[EMAIL PROTECTED]> wrote: What I want to provide is a page with some machine Id's. So once somebody clicks the hyperlinks , it should remote desktop instead of telnet. If the machine understands the telnet: protocol, you can use clickable telnet: U

Re: Want to start remote desktop thru the CGI script

2006-07-04 Thread Bjørge Solli
Please reply below the text you are answering, it makes the whole thing easier to follow. On Tuesday 04 July 2006 18:38, Nath, Alok (STSD) wrote: > What I want to provide is a page with some machine Id's. > So once somebody clicks the hyperlinks , it should remote > desktop instead of

RE: Want to start remote desktop thru the CGI script

2006-07-04 Thread Nath, Alok (STSD)
Tom, Sorry if I am not able to explain it. What I want to provide is a page with some machine Id's. So once somebody clicks the hyperlinks , it should remote desktop instead of telnet. Is it not possible ? The current script is triggering a telnet session.

Re: Want to start remote desktop thru the CGI script

2006-07-04 Thread Tom Phoenix
On 7/4/06, Nath, Alok (STSD) <[EMAIL PROTECTED]> wrote: What I want is when I click the hyperlink it should run the command 'mstsc IP Address'(instead of telnet) so that I can remote desktop to that machine. So, you want to run a program on the computer at the browser's end of the conn

Want to start remote desktop thru the CGI script

2006-07-04 Thread Nath, Alok (STSD)
Hi, Here's a script which has some two cells in the table.I want to make a change here. What I want is when I click the hyperlink it should run the command 'mstsc IP Address'(instead of telnet) so that I can remote desktop to that machine. Can anybody help me how