script won't write to file ...
Hi I have a script that i'm working on, I want it to write info to a log file, but I can't get it to write to the file.. I run the script as root, and I also chmod 0777 the file but still no out put ... what have it missed .. ___script___ #!/usr/bin/perl print hello; use use strict; #package ifwatch; ### global vars my $primaryif = /dev/ttyACM0; my $secondaryif = /dev/ttyACM1; my $primaryconfig = /etc/ifwatch/ACM0; my $secondayconfig = /etc/ifwatch/ACM1; my $currentif; my $mainloopsleep = 10; my $LOG_DIR = /var/log; daemonize(); main(); process handeling kill and restart call $SIG{INT} = sub { print STATUS_LOG localtime() . Exiting...\n; close (DEBUG_LOG); close (ERROR_LOG); exit; }; $SIG{HUP} = sub { print STATUS_LOG localtime() . Restarting...\n; exec ($0, @ARGV) or die Could not restart: $!\n; close (STATUS_LOG); close (STATUS_LOG); exit; }; sub ifcheck{ #my $files = /dev/xtty0; #Bunless (open(TESTFILE, $files)){ #die (File does not exist); #} } # daemonize sub daemonize { # use POSIX qw(setsid); open (STDIN, /dev/null); open (STATUS_LOG, /var/log/ifwatch); # defined(my $pid = fork) or die Can't fork: $!; # exit if $pid; } main loop sub main { print STATUS_LOG localtime() . hello ; my $loop = 1; while ($loop = -1) { print STATUS_LOG localtime() . sleeping\n; sleep $mainloopsleep; } print STATUS_LOG localtime() . ifwatch exiting; close (STATUS_LOG); } 1 ; -- Gregory Machin [EMAIL PROTECTED] www.linuxpro.co.za -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
testing if hardware is avalible
Hi can you advise on the best way test if a usb modem is plugged in ? I though about checking if the file/node /dev/ttyACM0 is present, as it's created when the device is plugged in using open (TEST, /dev/tty/ACM0); but just concecned if i do this while the device is acitive it will cause it to drop the connection... What is the best methode for this ?? -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: script won't write to file ...
On 7/20/07, Gregory Machin [EMAIL PROTECTED] wrote: Hi I have a script that i'm working on, I want it to write info to a log file, but I can't get it to write to the file.. I run the script as root, and I also chmod 0777 the file but still no out put ... what have it missed .. snip Simplify, simplify, simplify. #!/usr/bin/perl use strict; use warnings; use IO::File; my $wait = 10; my $logfile = /var/log/ifwatch; my $continue = 1; open my $log, , $logfile or die could not open $logfile:$!; $log-autoflush(1); process handeling kill and restart call $SIG{INT} = $SIG{TERM} = sub { print $log localtime() . Exiting...\n; $continue = 0; }; $SIG{HUP} = sub { print $log localtime() . Restarting...\n; exec ($0, @ARGV) or die Could not restart: $!\n; }; open STDIN, , /dev/null or die could not redirect stdin: $!; print $log localtime() . ifwatch starting\n; while ($continue) { #do stuff print $log localtime() . sleeping\n; sleep $wait; } print $log localtime() . ifwatch exiting\n; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: script won't write to file ...
Ok thanks, for the advise, 2 questions - what did i do wrong in my original code, cause it's based on a working example, and is IO::File included in the default perl package ? is this script has to go on an embedded device with as min dependencies as possible ? Many Thanks On 7/20/07, Chas Owens [EMAIL PROTECTED] wrote: On 7/20/07, Gregory Machin [EMAIL PROTECTED] wrote: Hi I have a script that i'm working on, I want it to write info to a log file, but I can't get it to write to the file.. I run the script as root, and I also chmod 0777 the file but still no out put ... what have it missed .. snip Simplify, simplify, simplify. #!/usr/bin/perl use strict; use warnings; use IO::File; my $wait = 10; my $logfile = /var/log/ifwatch; my $continue = 1; open my $log, , $logfile or die could not open $logfile:$!; $log-autoflush(1); process handeling kill and restart call $SIG{INT} = $SIG{TERM} = sub { print $log localtime() . Exiting...\n; $continue = 0; }; $SIG{HUP} = sub { print $log localtime() . Restarting...\n; exec ($0, @ARGV) or die Could not restart: $!\n; }; open STDIN, , /dev/null or die could not redirect stdin: $!; print $log localtime() . ifwatch starting\n; while ($continue) { #do stuff print $log localtime() . sleeping\n; sleep $wait; } print $log localtime() . ifwatch exiting\n; -- Gregory Machin [EMAIL PROTECTED] www.linuxpro.co.za -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: script won't write to file ...
On 7/20/07, Gregory Machin [EMAIL PROTECTED] wrote: Ok thanks, for the advise, 2 questions - what did i do wrong in my original code, cause it's based on a working example, and is IO::File included in the default perl package ? is this script has to go on an embedded device with as min dependencies as possible ? snip I don't know what you did wrong, there were far to many commented out lines and other complexities in your original code. That is why I simplified. You could try comparing the two sets of code. Most likely you are trying to write to the file before opening it, you are never reaching the code the prints to the file (you seem to have called main() too early), or the open is failing (you aren't printing the error message, so you have no way of knowing). IO::File is part of IO which has been in core Perl since 5.003_07 or earlier (that is the earliest release I could find in CPAN). -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
RE: Multiple file perl program
[EMAIL PROTECTED] asked: How do I write a multiple file perl program? I dont want to conflict with any real module names that were built in or are on CPAN. I just want to spread some subs onto some other files. Just choose a suitable namespace prefix like Local:: or your company Name for your modules and you'll be fine. HTH, Thomas -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Writing a Program
On 7/17/07, CJ [EMAIL PROTECTED] wrote: To all you who know: I'm trying to write a program, granted it's going to be a large one, that will keep track of people's computers when they're in my shop being repaired. I want to assign a number to each computer system, and that number will stay with that machine throughout the program. I want to be able to see when the computer is taken in, where it is at the time, etc... My question is this: How would I go about writing this program in perl, and is perl the language to write it in? I'll use MySQL to store the data. The reason I chose perl is because I like linux, and perl runs excellently in linux, and I'd like to do my developing on a linux box. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ And for your reading pleasure and enjoyment, this should help as well: http://www.perl.org/books/beginning-perl/ Regards, Jeff
Re: testing if hardware is avalible
On 7/19/07, Gregory Machin [EMAIL PROTECTED] wrote: can you advise on the best way test if a usb modem is plugged in ? I'd look at the socket. But if you're trying to do this via Perl, the best answer is the same way you'd do it via C, INTERCAL, or any other language. In other words, you may need to ask in a forum about usb devices, instead of one about Perl. Once you know what low-level operation will give you your answer, we can help you find a way to do that from Perl. I though about checking if the file/node /dev/ttyACM0 is present, as it's created when the device is plugged in using open (TEST, /dev/tty/ACM0); but just concecned if i do this while the device is acitive it will cause it to drop the connection... Maybe you could use a filetest to do what you want? Perhaps -e or even -c? my $modem_port = '/dev/tty/ACM0'; die Modem not found on '$modem_port' unless -c $modem_port; Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: testing if hardware is avalible
On 7/20/07, Gregory Machin [EMAIL PROTECTED] wrote: Hi can you advise on the best way test if a usb modem is plugged in ? I though about checking if the file/node /dev/ttyACM0 is present, as it's created when the device is plugged in using open (TEST, /dev/tty/ACM0); but just concecned if i do this while the device is acitive it will cause it to drop the connection... What is the best methode for this ?? This is highly OS dependent; however, most OSes provide a utility like ifconfig that can report on the status of network interfaces. Another option (at least under many UNIX flavors) is to use lsof (list open files) to check to see if the file is already open: #!/usr/bin/perl use strict; use warnings; $! = 0; if (my $out = `lsof $ARGV[0]`) { die $out if $?; print $ARGV[0] is open\n; } else { print $ARGV[0] is closed\n; } -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: script won't write to file ...
Gregory Machin wrote: Hi Hello, I have a script that i'm working on, I want it to write info to a log file, but I can't get it to write to the file.. I run the script as root, and I also chmod 0777 the file but still no out put ... what have it missed .. ___script___ #!/usr/bin/perl print hello; use use strict; You should also use the pragma: use warnings; #package ifwatch; ### global vars my $primaryif = /dev/ttyACM0; my $secondaryif = /dev/ttyACM1; my $primaryconfig = /etc/ifwatch/ACM0; my $secondayconfig = /etc/ifwatch/ACM1; my $currentif; my $mainloopsleep = 10; my $LOG_DIR = /var/log; daemonize(); main(); process handeling kill and restart call $SIG{INT} = sub { print STATUS_LOG localtime() . Exiting...\n; You should probably print an error message to determine why it isn't printing to the log file: print STATUS_LOG localtime() . Exiting...\n or warn Cannot print to the log file: $!; close (DEBUG_LOG); close (ERROR_LOG); exit; }; $SIG{HUP} = sub { print STATUS_LOG localtime() . Restarting...\n; exec ($0, @ARGV) or die Could not restart: $!\n; close (STATUS_LOG); close (STATUS_LOG); exit; exec() ends the current process and starts a new one so the two closes and the exit will never execute. }; sub ifcheck{ #my $files = /dev/xtty0; #Bunless (open(TESTFILE, $files)){ #die (File does not exist); #} } # daemonize sub daemonize { # use POSIX qw(setsid); open (STDIN, /dev/null); open (STATUS_LOG, /var/log/ifwatch); You should *ALWAYS* verify that the files opened correctly: open STDIN, '', '/dev/null' or die Cannot open '/dev/null' $!; open STATUS_LOG, '', $LOG_DIR/ifwatch or die Cannot open '$LOG_DIR/ifwatch' $!; # defined(my $pid = fork) or die Can't fork: $!; # exit if $pid; } John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Unable to post to https
Is there anything special need to post to https sites? The page has a few lines of java script and the following html -- html form form name=loginForm action=j_security_check method=post ... ... tr td class=loginLabellabel for=tUser accesskey=Uspan class=underlineU/spanser Name:nbsp;/label/td td class=loginValueinput type=text id=tUser name=j_username/td /tr tr td class=loginLabellabel for=tPassword accesskey=Pspan class=underlineP/spanassword:nbsp;/label/td td class=loginValueinput type=password id=tPassword name=j_password maxlength=50/td /tr --- end use strict; use warnings; use Data::Dumper; use LWP 5.64; my $browser = LWP::UserAgent-new; my $user = 'username'; my $pass = 'password'; My $url = 'https://secure-site/j_security_check'; my $response = $browser-post( $url, [ j_username = $user, j_password = $pass ] ); die $url error: , $response-status_line unless $response-is_success; die Weird content type at $url -- , $response-content_type unless $response-content_type eq 'text/html'; if( $response-content =~ m{(Incorrect user name or password)}) { print $1,\n; } elsif( $response-content =~ m{(My Customers)} ) { print login successfull returning data:\n; sleep 2; print $response-content; } else { print problem trying to access $url: $!\n; } No matter what I keep getting the following: https://secure-site/j_security_check error: 408 Request Timeout at foo.pl line 17 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - This message is intended only for the personal and confidential use of the designated recipient(s) named above. If you are not the intended recipient of this message you are hereby notified that any review, dissemination, distribution or copying of this message is strictly prohibited. This communication is for information purposes only and should not be regarded as an offer to sell or as a solicitation of an offer to buy any financial product, an official confirmation of any transaction, or as an official statement of Lehman Brothers. Email transmission cannot be guaranteed to be secure or error-free. Therefore, we do not represent that this information is complete or accurate and it should not be relied upon as such. All information is subject to change without notice. IRS Circular 230 Disclosure: Please be advised that any discussion of U.S. tax matters contained within this communication (including any attachments) is not intended or written to be used and cannot be used for the purpose of (i) avoiding U.S. tax related penalties or (ii) promoting, marketing or recommending to another party any transaction or matter addressed herein. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
how to launch perl
Hey Guys, I am working on linux (redhat) 1999 version without the xwindows. I have configured my dns server on this linux box and it works fine for my test lab network at home. Apache and sendmail are also working fine without any problem. I have this huge book called the camel about perl which i have read over ten times before even touching the program perl itself to get the theory of the whole thing. now when i went to the shell as root trying to launch perl from #!/usr/bin/perl -wT nothing seems tobe working, it hangs and doesn't go any further on the next line for ever till i kill the process and then it tells me stopped perl. what is it that i am ding wrong , i need somebody to help me understand how to launch this program perl. i know it is installed because the program tells me everything is o.k when i rpm -q perl. i even typed in all the example perl cgi scripts that i learned still nothing, i like working upwards that is why i am using a lower version of linux and then try to move on to the latest kernels. please let me know what to do . thanks in advance john conteh africanuniversityonline.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
[EMAIL PROTECTED] wrote: Hey Guys, Hello, I am working on linux (redhat) 1999 version without the xwindows. It's either X or the X Window System. http://en.wikipedia.org/wiki/X_Window_System I have configured my dns server on this linux box and it works fine for my test lab network at home. Apache and sendmail are also working fine without any problem. I have this huge book called the camel about perl which i have read over ten times before even touching the program perl itself to get the theory of the whole thing. now when i went to the shell as root You shouldn't normally login as root, especially if you are connected to the internet. trying to launch perl from #!/usr/bin/perl -wT nothing seems tobe working, it hangs and doesn't go any further on the next line for ever till i kill the process and then it tells me stopped perl. what is it that i am ding wrong , i need somebody to help me understand how to launch this program perl. i know it is installed because the program tells me everything is o.k when i rpm -q perl. i even typed in all the example perl cgi scripts that i learned still nothing, i like working upwards that is why i am using a lower version of linux and then try to move on to the latest kernels. please let me know what to do . If you are working in a shell from the command line then type 'perl ' and then the program name or type 'perl -e' and then valid Perl code, for example: $ cat myprogram print Hello John\n; $ perl myprogram Hello John $ perl -e'print Hello John\n;' Hello John $ And if you have your Perl program in a file you can put '#!/usr/bin/perl' on the *first* line: $ cat myprogram #!/usr/bin/perl print Hello John\n; $ ./myprogram Hello John There is some more information in the man page: perldoc perlrun And also at the web site: http://learn.perl.org/ John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short order.-- Larry Wall -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hey Guys, I am working on linux (redhat) 1999 version without the xwindows. I have configured my dns server on this linux box and it works fine for my test lab network at home. Apache and sendmail are also working fine without any problem. I have this huge book called the camel about perl which i have read over ten times before even touching the program perl itself to get the theory of the whole thing. now when i went to the shell as root trying to launch perl from #!/usr/bin/perl -wT nothing seems tobe working, it hangs and doesn't go any further on the next line for ever till i kill the process and then it tells me stopped perl. what is it that i am ding wrong , i need somebody to help me understand how to launch this program perl. i know it is installed because the program tells me everything is o.k when i rpm -q perl. Just adding to what John already said, it hangs because, when used without arguments like script file names or -e 'print qq{Hello, world\n}' , it expects the script is coming from the standard input. So you can do $ perl -wT print Hello, world!\n; for (1..10) { print STDOUT ('one','two','three')[$_ % 3]; } Hello, world! ^D (or something that tells your system the stream is over) twothreeonetwothreeonetwothreeonetwo i even typed in all the example perl cgi scripts that i learned still nothing, i like working upwards that is why i am using a lower version of linux and then try to move on to the latest kernels. please let me know what to do . thanks in advance john conteh africanuniversityonline.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, Adriano Ferreira [EMAIL PROTECTED] wrote: snip Just adding to what John already said, it hangs because, when used without arguments like script file names or -e 'print qq{Hello, world\n}' , it expects the script is coming from the standard input. So you can do $ perl -wT print Hello, world!\n; for (1..10) { print STDOUT ('one','two','three')[$_ % 3]; } Hello, world! ^D (or something that tells your system the stream is over) twothreeonetwothreeonetwothreeonetwo snip There are also some Perl REPLs* out there that allow you to use a Perl interpreter interactively. zoidberg, a Perl shell: http://search.cpan.org/~pardus/Zoidberg-0.95/lib/Zoidberg.pm psh, another Perl shell: http://sourceforge.net/projects/psh/ Devel::REPL, a modern Perl REPL: http://search.cpan.org/~mstrout/Devel-REPL-1.001000/lib/Devel/REPL.pm There are probably others out there. * REPL stands for Read, Eval, Print, Loop. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
Adriano Ferreira wrote: Just adding to what John already said, it hangs because, when used without arguments like script file names or -e 'print qq{Hello, world\n}' , it expects the script is coming from the standard input. Well, actually the OP said he was using '#!/usr/bin/perl -wT' A shell should interpret this a comment, ignore it, and come back immediately. I don't understand his comment about the shell hanging. Nothing should happen. -- Just my 0.0002 million dollars worth, Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
Chas Owens wrote: There are also some Perl REPLs* out there that allow you to use a Perl interpreter interactively. zoidberg, a Perl shell: http://search.cpan.org/~pardus/Zoidberg-0.95/lib/Zoidberg.pm psh, another Perl shell: http://sourceforge.net/projects/psh/ Devel::REPL, a modern Perl REPL: http://search.cpan.org/~mstrout/Devel-REPL-1.001000/lib/Devel/REPL.pm There are probably others out there. * REPL stands for Read, Eval, Print, Loop. Oh, you mean: perl -ple '$_=eval' Or on DOS: perl -ple $_=eval -- Just my 0.0002 million dollars worth, Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote: Chas Owens wrote: There are also some Perl REPLs* out there that allow you to use a Perl interpreter interactively. zoidberg, a Perl shell: http://search.cpan.org/~pardus/Zoidberg-0.95/lib/Zoidberg.pm psh, another Perl shell: http://sourceforge.net/projects/psh/ Devel::REPL, a modern Perl REPL: http://search.cpan.org/~mstrout/Devel-REPL-1.001000/lib/Devel/REPL.pm There are probably others out there. * REPL stands for Read, Eval, Print, Loop. Oh, you mean: perl -ple '$_=eval' Or on DOS: perl -ple $_=eval snip Nope, take a look at this: [EMAIL PROTECTED]:~$ perl -ple '$_=eval' my $c = 5 5 $c+1 1 Now this: pugs my $c = 5 5 pugs $c + 1 6 The problem is that my $c = 5 creates a lexical inside the while loop created by -p and it goes out of scope immediately. Also, REPLs tend to provide more services (such as command line completion, command history, ability to save the current buffer, etc.). As you can see, Perl 6 already has a REPL. Of course, Pugs* is a lot more than just a REPL, it is also a compiler for the Parrot virtual machine** and it can interpret the code directly (like perl does currently). * http://www.pugscode.com ** http://www.parrotcode.org -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, Chas Owens [EMAIL PROTECTED] wrote: On 7/20/07, Adriano Ferreira [EMAIL PROTECTED] wrote: snip Just adding to what John already said, it hangs because, when used without arguments like script file names or -e 'print qq{Hello, world\n}' , it expects the script is coming from the standard input. So you can do $ perl -wT print Hello, world!\n; for (1..10) { print STDOUT ('one','two','three')[$_ % 3]; } Hello, world! ^D (or something that tells your system the stream is over) twothreeonetwothreeonetwothreeonetwo snip There are also some Perl REPLs* out there that allow you to use a Perl interpreter interactively. zoidberg, a Perl shell: http://search.cpan.org/~pardus/Zoidberg-0.95/lib/Zoidberg.pm zoidberg is intented to be a shell (like bash, zsh) only that the command language is Perl. Not exactly a simple REPL. psh, another Perl shell: http://sourceforge.net/projects/psh/ Devel::REPL, a modern Perl REPL: http://search.cpan.org/~mstrout/Devel-REPL-1.001000/lib/Devel/REPL.pm The modernity of Devel::REPL is at using state-of-art Perl OO like Moose and being extendable. Beyond that, this modernity means today some 5 seconds to start the interactive interpreter ;-) $ re.pl (5 seconds later, your prompt:) $ There are probably others out there. I am one of the contenders here, having written Shell::Perl http://search.cpan.org/dist/Shell-Perl/ which needs severely more work to be a really decent REPL. But for now, it works (if you accept its limitations) * REPL stands for Read, Eval, Print, Loop. Cheers, Adriano Ferreira -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: Unable to post to https
On 7/20/07, Brown, Rodrick [EMAIL PROTECTED] wrote: No matter what I keep getting the following: https://secure-site/j_security_check error: 408 Request Timeout at foo.pl line 17 If a browser can reach the site, but your LWP code can't, you almost certainly need to change your LWP code to do the same thing the browser is doing. The best way may be if you can set up a middleman program (such as a proxy) which can track the details of the transaction and see what the browser is doing that your code doesn't do. That can be difficult when using https protocol, though. Another way is to use LWP's debugging facilities to monitor the transaction at a lower level. Good luck with it! --Tom Phoenix Stonehenge Perl Training -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
Chas Owens wrote: The problem is that my $c = 5 creates a lexical inside the while loop created by -p and it goes out of scope immediately. Yes, that's what 'my' means. If you do it without the 'my', it works. And it has a lot of security problems. But it's also quick and easy to remember. Like any tool, it cannot be used to solve all your problems. -- Just my 0.0002 million dollars worth, Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote: Chas Owens wrote: The problem is that my $c = 5 creates a lexical inside the while loop created by -p and it goes out of scope immediately. Yes, that's what 'my' means. If you do it without the 'my', it works. And it has a lot of security problems. But it's also quick and easy to remember. Like any tool, it cannot be used to solve all your problems. Yes, but that is not what a good REPL should do with it. Take a look at the pugs example again. The problem is that you are executing my code in your context. My code should be evaluated in a separate context. There should be no difference between perl -e ' my $n = 5; $n++; print $n\n; ' and mythical_perl_repl my $n = 5 5 $n++ 5 print $n\n 6 1 (note: 1 is what print would return). In fact, here is an example using pugs: [EMAIL PROTECTED]:~$ cat t.p6 my $c = 5; $c++; say $c; [EMAIL PROTECTED]:~$ pugs t.p6 6 [EMAIL PROTECTED]:~$ pugs __ /\ __ \ \ \ \/\ \ __ __ __ __ (P)erl6 \ \ __//\ \/\ \/\ __ \/\ ___\(U)ser's \ \ \/ \ \ \_\ \ \ \/\ \ \___ \ (G)olfing \ \__\ \ \/\ \ \/\_\ (S)ystem \/__/ \/___/ \/___/\ \// /\/ Version: 6.2.13 \/___/Copyright 2005-2006, The Pugs Contributors Web: http://pugscode.org/ Email: [EMAIL PROTECTED] Welcome to Pugs -- Perl6 User's Golfing System Type :h for help. Loading Prelude... done. pugs my $c = 5 5 pugs $c++ 5 pugs say $c 6 Bool::True pugs -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
Chas Owens wrote: Yes, but that is not what a good REPL should do with it. Take a look at the pugs example again. The problem is that you are executing my code in your context. My code should be evaluated in a separate context. There should be no difference between No, I am executing my code in my context. Neither your REPL or my little Perl command can replace a well thought out Perl program. -- Just my 0.0002 million dollars worth, Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote: Chas Owens wrote: Yes, but that is not what a good REPL should do with it. Take a look at the pugs example again. The problem is that you are executing my code in your context. My code should be evaluated in a separate context. There should be no difference between snip No, I am executing my code in my context. Neither your REPL or my little Perl command can replace a well thought out Perl program. snip You fail to understand what a REPL is for. A REPL is for learning and playing with a language. Some people also use them as a debugging or prototyping environment*. It isn't supposed to be a well thought out program, well the REPL is, but the stuff the user types into it isn't. *Lisp and Scheme people actually use them as editors. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
Chas Owens wrote: *Lisp and Scheme people actually use them as editors. OK, you just scare the Hel out of me. You're one of those people who think everyone should write programs that write programs that do real work. Do not want. -- Just my 0.0002 million dollars worth, Shawn For the things we have to learn before we can do them, we learn by doing them. Aristotle -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/
Re: how to launch perl
On 7/20/07, Mr. Shawn H. Corey [EMAIL PROTECTED] wrote: Chas Owens wrote: *Lisp and Scheme people actually use them as editors. OK, you just scare the Hel out of me. You're one of those people who think everyone should write programs that write programs that do real work. Do not want. snip I think that but north-north-west: when the wind is southerly I know a hawk from a handsaw. In general, I write programs that do stuff directly, and I like Perl more than I like Lisp, but the lure of writing programs to write programs and DSLs* is strong. * Domain Specific Languages -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/