[28122] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 9486 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 17 06:05:50 2006

Date: Mon, 17 Jul 2006 03:05:04 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 17 Jul 2006     Volume: 10 Number: 9486

Today's topics:
        CGI: Running a forked background process <hal@thresholddigital.com>
    Re: CGI: Running a forked background process <1usa@llenroc.ude.invalid>
    Re: CPANPLUS on debian headache <mumia.w.18.spam+nospam.usenet@earthlink.net>
    Re: How get UTF-8 from urlencoded web form <john@castleamber.com>
    Re: Module::Build / version / cpan / tail chasing <attn.steven.kuo@gmail.com>
    Re: Net::Telnet - Library Application <sgt19@tid.es>
        new CPAN modules on Mon Jul 17 2006 (Randal Schwartz)
    Re: RegEx: odd number of slashes? and too many slashes? <1usa@llenroc.ude.invalid>
    Re: What is a type error? <zs@students.cs.mu.OZ.AU>
    Re: What is a type error? <jo@durchholz.org>
    Re: What is a type error? (Rob Warnock)
    Re: What is a type error? <jo@durchholz.org>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Mon, 17 Jul 2006 02:00:55 -0400
From: Hal Vaughan <hal@thresholddigital.com>
Subject: CGI: Running a forked background process
Message-Id: <BLGdndCez5kUuibZnZ2dnUVZ_vadnZ2d@comcast.com>

I have a web page (served up by Apache 2) where a user click a link to
download a file.  The link calls my Perl CGI script which takes the
parameters and generates a file to download.  It takes time to generate the
file, so my idea was to fork like this:

if (!fork()) {
        system("$ifile person=$id location=$loc");
        exit();
}

And while the forked program is generating the download file, another web
page pops up saying, "Please wait..." and includes a Javascript countdown
until the next time it'll check and see if the download is ready.  That
way, when the user clicks a link, they don't have to wait and get a new
page immediately.  The new page has a countdown to let them know they're
not forgotten.

I've found, though, that the fork is not working.  When I click on the link,
I get a LONG pause and eventually the countdown page appears, but only
after the forked program is done with it's work.

How can I fork so the download file is generated in the background, without
delaying displaying the other page?

Thanks!

Hal



------------------------------

Date: Mon, 17 Jul 2006 06:03:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: CGI: Running a forked background process
Message-Id: <Xns98031503F8E24asu1cornelledu@127.0.0.1>

Hal Vaughan <hal@thresholddigital.com> wrote in
news:BLGdndCez5kUuibZnZ2dnUVZ_vadnZ2d@comcast.com: 

> I have a web page (served up by Apache 2) where a user click a link to
> download a file.  The link calls my Perl CGI script which takes the
> parameters and generates a file to download.  It takes time to
> generate the file, so my idea was to fork like this:
> 
> if (!fork()) {
>         system("$ifile person=$id location=$loc");
>         exit();
> }

http://www.stonehenge.com/merlyn/LinuxMag/col39.html

Sinan
-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Mon, 17 Jul 2006 07:06:48 GMT
From: "Mumia W." <mumia.w.18.spam+nospam.usenet@earthlink.net>
Subject: Re: CPANPLUS on debian headache
Message-Id: <cGGug.5475$vO.4439@newsread4.news.pas.earthlink.net>

On 07/16/2006 10:27 PM, Hobo Salesman wrote:
> BZ wrote:
>> Hobo Salesman wrote in comp.lang.perl.misc:
>>> Default debian distribution doesn't seem to give any
>>> way to search for perl modules, the best it does is
>>> (sometimes) mention modules in the description of a
>>> package.
>> Uhm, Debian packages of perl modules are just
>> consistently named; there's therefor no need to search. 
>> Just use dpkg -l lib\*-perl or so to list all available
>> modules.
> 
> Maybe I'm not understanding, but I can't see how that tells
> me what package I need if I want to use, say,
> Config::General. I'd also like to use one system for
> managing perl modules, and I don't think I could find a
> debian package for, say... Petal. 

~$ aptitude search '~nconfig~ngeneral'
p   libconfig-general-perl          - generic configuration
module
~$
~$ aptitude search '~npetal'
p   libpetal-perl                   - Perl Template Attribute
Language - TAL fo
~$

Debian 3.1

 > Maybe I could if I used
> the CPAN debian packages (maybe, dont know how complete it
> is), but I'd imagine it would be like the CPANPLUS package
> they have - outdated, buggy, and 100 times more trouble
> than it's worth.
> 

~$ aptitude search '~n^lib.*-perl$' > outp
~$ wc -l outp
878 outp

Why use the largest collection of free software ever compiled 
if you're not going to use the largest collection of free 
software ever compiled? Stop pulling your hair out and get 
computing :)




------------------------------

Date: 17 Jul 2006 06:41:17 GMT
From: John Bokma <john@castleamber.com>
Subject: Re: How get UTF-8 from urlencoded web form
Message-Id: <Xns9803112B7ED00castleamber@130.133.1.4>

"John W. Kennedy" <jwkenne@attglobal.net> wrote:

> Bart Van der Donck wrote:
>> Dr.Ruud wrote:
>> 
>>> Bart Van der Donck schreef:
>>>
>>>> You can't compare (n vs. \n) to (é vs. %E9).
>>> You can compare (<LF> vs. "\n") to (<é> vs. "%E9"). Often, such
>>> translations use a table in memory.
>> 
>> Yes, exactly, like:
>>  LF -> %0A
>>  é  -> %E9
>> 
>> <LF> refers to hex 0A by definition, but I'm not sure whether "\n"
>> always refers to hex 0A on various operating systems.
> 
> "\n" is 0x0A on all systems.

According to the table on p 161-162 of Programming Perl:

"Match the newline character (usually NL, but CR on Macs)."

I doubt that the book talks about file level here, but I have no Mac to 
test this :-D.

-- 
John Bokma          Freelance software developer
                                &
                    Experienced Perl programmer: http://castleamber.com/


------------------------------

Date: 16 Jul 2006 21:39:41 -0700
From: "attn.steven.kuo@gmail.com" <attn.steven.kuo@gmail.com>
Subject: Re: Module::Build / version / cpan / tail chasing
Message-Id: <1153111181.775009.92900@m79g2000cwm.googlegroups.com>

sbk wrote:
> hi,
>
> i've compiled perl-5.8.8 from scratch (my favorite approach) ...
> installed it ... and now i'm installing the modules which my in-house
> collection of code requires ... and i've run into a 'loop' between
> 'version' and 'Module::Build' ... each requires the other ... and
> 'cpan' doesn't seem to know how to work around this:
>

(snipped)

>
> at this point, i'm chasing my tail ... any tips on how to break out and
> make progress?
>


Circular dependency?

Maybe you can first install a slightly older version of
Module::Build -- one that doesn't require version.pm:

http://search.cpan.org/src/KWILLIAMS/Module-Build-0.2801/Build.PL

You can get the source from the CPAN website; download the tarball
found here:

http://search.cpan.org/~kwilliams/Module-Build-0.2801/

Manually install this module.

Then install version with the CPAN shell utility.

Then reinstall the (latest) Module::Build.

It does seem quite bothersome...

-- 
Hope this helps,
Steven



------------------------------

Date: Mon, 17 Jul 2006 09:47:57 +0200
From: Stephan Titard <sgt19@tid.es>
Subject: Re: Net::Telnet - Library Application
Message-Id: <e9ffbb$suf8@news.hi.inet>

robic0 escribió:
> On Sun, 16 Jul 2006 19:03:43 -0400, Carl Lafferty <laff7430@bellsouth.net> wrote:
> 
>> I have a problem with something I am doing using net::telnet in perl.
>> I am trying to write a script that will access an automated library 
>> system via telnet and basically mimic what the company that sold us the 
>> system did in VB.  I am basically reverse engineering their code only in 
>> perl..  anyway...  My problem is that I am having to search for 
>> different flags using waitfor.  sometimes it is the word Description, 
>> sometimes it is \x8f (I have no idea why but they seem to use that as a 
>> delimiter quite often)  My problem is that when I get to a particular 
>> piece of data, I am not getting everything from the stream in my waitfor 
>> variable.
>>
>> This is a snippit of the code
>>
>> #cleaning out the buffer
>>      ($info) = $galaxy->waitfor("/\x8f/");
>>      print "1    $info\n";
>>
>>      ($info) = $galaxy->waitfor("/\x8f/");
>>      print "2    $info\n";
>>
>>
>>      $galaxy->print("5000 5018 30 0 0 ");
>>
>>      ($info) = $galaxy->waitfor("/\x8f/");
>>      $info =~ s/\\b/\n/g;
>>      $info =~ s/\\B/\<b\>/g;
>>      $info =~ s/\n/\<\/b\>\n/g;
>>      print "$info\n";
>>
>>
>>      ($info) = $galaxy->waitfor("/Description/");
>>      $info =~ s/\\b/\n/g;
>>      $info =~ s/\\B/\<b\>/g;
>>      $info =~ s/\n/\<\/b\>\n/g;
>>      print "$info\n";
>>
>> #got stuff up to description now
>>      ($info) = $galaxy->waitfor("/\x5C\x62/");
>>      $info =~ s/\\b/\n/g;
>>      $info =~ s/\\B/\<b\>/g;
>>      $info =~ s/\n/\<\/b\>\n/g;
>>      print "Description: $info\n";
>>
>>
>> print "\nLogging out of galaxy\n";
>> #$ok = $galaxy->waitfor("/\x8f/");
>> $ok = $galaxy->print("999");
>> $ok = $galaxy->print("0005 GALAXY||20");
>> $ok = $galaxy->print("0010 ");
>>
>> $galaxy->close;
>> -----------------------------------
>> 0x000e0: 20 20 20 20  20 20 20 20  20 20 20 20  20 20 20 20
>> 0x000f0: 20 5c 62 20  20 54 79 70  65 2f 6c 61  6e 67 75 61   \b 
>> Type/langua
>> 0x00100: 67 65 3a 20  5c 42 42 6f  6f 6b 2f 65  6e 67 5c 62  ge: 
>> \BBook/eng\b
>> 0x00110: 0d 20 20 20  49 53 42 4e  2f 49 53 53  4e 3a 20 5c  . 
>> ISBN/ISSN: \
>> 0x00120: 42 2f 5c 62  0d 20 44 65  73 63 72 69  70 74 69 6f  B/\b. 
>> Descriptio
>> 0x00130: 6e 3a 20 5c  42 31 37 38  20 70 2e 2c  20 32 30 20  n: \B178 p.. 20
>> 0x00140: 63 6d 2e 20  20 20 20 20  20 20 20 20  5c 62        cm.         \b
>>
>> 0x00000: 39 39 39 0d                                         999.
>>
>> 0x00000: 30 30 30 35  20 47 41 4c  41 58 59 7c  7c 32 30 0d  0005 
>> GALAXY||20.
>>
>> 0x00000: 30 30 31 30  20 0d                                  0010 .
>>
>> ----------------------------------------------
>> above is the dump file (a little difficult to read :( )
>>
>>
>> it SEES the word description and gives me the info up to that..  BUT 
>> after description the delimiter is \b (\x5c\x62) which is what I do a 
>> waitfor on.  all I get is a \
>>
>> Everything after 0x00140: is my program signing out of the telnet session..
>>
>> Any way to get that information into my variable??  Ive been beating my 
>> head for 4 days now...  any help is appreciated.
>>
>>
>> Carl Lafferty
>> System Admin
>> Floyd County Public Library
>> Prestonsburg, KY
> 
> 
> Net::Telnet is a just an ok module. The fact is that no module can 
> correct the inherrant flaws of Telnet in general. For what it does,
> I give the author a thumbs up. He trully has written a awsome piece of code.
> 
> The flaws of Telnet across OS's compounds the problem. The translation of 
> newlines (and other control codes) alone in these terminal emulators
> (across OS's) is the death nail. Other nails are there, the big one is
> discovery handshaking and progrmability (mode setting). So implementation
> was the big deathnail to Telnet. That is of course on the level that you
> need to use it at because, there are plenty of smooth running Telnet
> automations out there, be it in C or Perl modules.
> 
> In general, to design a piece of code for the Telnet module, you will have
> to know, to be able to anchor with certainty. This involves alot of work by
> hand ahead of time. Using the module capture "all" in several attempts for
> a statistical overview of your objective.
> 
> What you reliably "waitfor" may not be the EOT (end of transmission).
> And the eot may not be a static thing.
> 
> Whatever your waiting for it doesen't matter. What matters is that you want
> to capture some data, be it binary (not control) or printable. You don't want 
> to capture the data of interest directly! You want some assurance that "it" 
> can be gleened later on and you want to be immediatly ready to repeat the
> sequence.
> 
> So many folks try to capture that "single" piece of data on the fly, but never
> get framed for it as the boxcars roll down the track (possibly several times).
> 
> In actuality (this is the truth), some Telnet servers don't even send
> a frame down for a single data change. What you have to know is that when the handshaking
> is done what the full outcome of a frame request will be.
> 
> You can force Telnet servers to re-send all the info in the frame however.
> I had written a wrapper module a very long time ago, that covers Win<->win, Nx<->Win.
> You can imbedd binary in the waitfor string (but its not necessary).
> 
> I am posting it here  (again) from along time ago. When I wrote this, I only had like 
> 1 year of Perl and 16 years of C/C++. What is here is stuff that works. I can take no
> cudo's for the code and I am not in the biz of re-writing code (for free).
> So here it is, a pm and pl file that "can" get what you wan't. If you don't use it
> its ok with me. It has worked for me in several Telnet automations within/across platform.
> 
> Any usage questions, let me know.
> Just glanceing at the old examples, read through the lines on the intent, I don't want to
> revisit or modify this crap, even though it works. You will get the jist.
> 
> robic0
> 
> 
> ==================================================
> TlnSvr.pm
> ==================================================
> package TlnSrv;
> use strict;
> #my $console_mode = 1;
> 
> use Net::Telnet ();
> use Cwd;
> my $VERSION = 1.00;
> 
> my $tln = undef;
> $|=1;
> 
> # CONSOLE MODE ????? Info --
> # We need line-mode or stream!!
> # In console mode, the screen is treated
> # as a buffer X by Y where the display is
> # controlloed by ansi escape sequences.
> # This is bad when expecting specific output (prompts)
> # that may never come because those chars are already
> # in screen buffer.
> # Always make the server NON-Console, ie: use stream!!
> # If not, as a workaround, between real commands,
> # we can clear screen, then send return.
> # -------------------------------------------------------
> # Note that all 'Prompts' strings are single quote Regex
> # parameters.
> 
> # Global variables
> sub new ($$$$$)
> {
> 	my $class		= shift;
> 	my $self		= {};
> 	$self->{'TlnServer'}	= shift;	# Telnet server address. IP or computer name
> 	$self->{'TlnUser'}	= shift;	# User name
> 	$self->{'TlnUser'}	= "administrator" unless (defined $self->{'TlnUser'});
> 	$self->{'TlnPass'}	= shift;	# Password
> 	$self->{'TlnPass'}	= "password" unless (defined $self->{'TlnPass'});
> 	$self->{'LogDir'}	= shift;
> 	$self->{'LogDir'}	= cwd() unless (defined $self->{'LogDir'});
> 	$self->{'Debug'}	= 0;
> 	$self->{'Show_Prematch'} = 'no';	# Show reply up to 'match' (used in SendCommand only)
> 	$self->{'Port'}		= 23;
> 	$self->{'Prompt'}	= '/[\$%#>] $/'; # or '/c:\\\\>/i for dos
> 	$self->{'Timeout'}	= 10;
> 	$self->{'ClearCmd'}	= '';		# Clear screen shell command (or "" if not used)
> 	$self->{'Waitsecs'}	= 10;		# (see SendCommand)
> 	$self->{'Show_Wait'}	= 'yes';	# Print line that counts off 'Waitsecs'
> 	$self->{'Error'}	= '';
> 	bless ($self, $class);
> 	return $self;
> }
> 
> #######################################
> # SetVal 
> #######################################
> sub SetVal
> {
> 	my ($self, @args) = @_;
> 	my $val;
> 	if (@args > 0)
> 	{
> 		while (($_, $val) = splice @args, 0, 2) {
> 			if (/^Debug$/i) {
> 				$self->{'Debug'} = $val;
> 			}
> 			elsif (/^Show_Prematch$/i) {
> 				$self->{'Show_Prematch'} = $val;
> 			}
> 			elsif (/^Port$/i) {
> 				$self->{'Port'} = $val;
> 			}
> 			elsif (/^Prompt$/i) {
> 				$self->{'Prompt'} = $val;
> 			}
> 			elsif (/^Timeout$/i) {
> 				$self->{'Timeout'} = $val;
> 			}
> 			elsif (/^ClearCmd$/i) {
> 				$self->{'ClearCmd'} = $val;
> 			}
> 			elsif (/^Waitsecs$/i) {
> 				$self->{'Waitsecs'} = $val;
> 			}
> 			elsif (/^Show_Wait$/i) {
> 				$self->{'Show_Wait'} = $val;
> 			}
> 		}
> 	}
> 	$self->{'Error'} = '';
> 	return 1;
> }
> 
> #######################################
> # Open telnet session
> #######################################
> sub OpenSession($$)
> {
> 	my $self = shift;
> 	my $logging = shift;
> 
> 	## default prompt and timeout for this session
> 	my $timeout = $self->{'Timeout'};
> 	my $prompt  = $self->{'Prompt'};
> 	my $logging = 1 unless (defined $logging);
> 
> 	if (defined $tln) {$tln->close;}
> 	$tln = undef;
> 	$tln = new Net::Telnet (Timeout => $self->{'Timeout'}, Prompt => $self->{'Prompt'});
> 
> 	$tln->errmode ('return');
> 	## logging is turned off by default
> 	## if enabled, a new log is created each time
> 	if ($logging) {
> 		$tln->option_log ("$self->{'LogDir'}/option.log");
> 		$tln->dump_log   ("$self->{'LogDir'}/dump.log");
> 		$tln->input_log  ("$self->{'LogDir'}/input.log");
> 	}
> 	$tln->buffer_empty;
> 	$tln->cmd_remove_mode (0);
> 
> 	if (!$tln->open(Host => $self->{'TlnServer'}, Port => $self->{'Port'})) {
> 		$self->{'Error'} = "Could not connect to: $self->{'TlnServer'}";
> 		$tln = undef;
> 		return 0;
> 	}
> 	if (!$tln->login ($self->{'TlnUser'}, $self->{'TlnPass'})) {
> 		$self->{'Error'} = "Login failed on $self->{'TlnServer'} (name|password):  $self->{'TlnUser'}, $self->{'TlnPass'}";
> 		$tln = undef;
> 		return 0;
> 	}
> 	$self->{'Error'} = '';
> 	return 1;
> }
> 
> #######################################
> # Close telnet session
> #######################################
> sub CloseSession($)
> {
> 	my $self = shift;
> 	if (defined $tln) {$tln->close;}
> 	$tln = undef;
> 	$self->{'Error'} = '';
> 	return 1;
> }
> 
> #######################################
> # Clear screen 
> # use as console mode workaround
> #######################################
> sub ClearScreen ($$$$)
> {
> 	my ($self, $cmd, $timeout, $prompt) = @_;
> 	my ($pre, $match);
> 
> 	if (!defined $tln) {
> 		$self->{'Error'} = "Session not open";
> 		return 0;
> 	}
> 	$cmd = $self->{'ClearCmd'} unless defined $cmd;
> 	$timeout = $self->{'Timeout'} unless defined $timeout;
> 	$prompt  = $self->{'Prompt'} unless defined $prompt;
> 	$tln->print ($cmd);
> 	$tln->waitfor (Match => $prompt, Timeout => $timeout);
> 	$tln->print ("");
> 	($pre, $match) = $tln->waitfor (Match => $prompt, Timeout => $timeout);
> 	print "Sent clear screen ... recieved:  $match\n" if ($self->{'Debug'});
> 	$tln->buffer_empty; # empty recieve buffer after clear
> 	$self->{'Error'} = '';
> 	return 1;
> }
> 
> #######################################
> # Empty recieve buffer
> #######################################
> sub EmptyBuffer($)
> {
> 	my $self = shift;
> 	if (!defined $tln) {
> 		$self->{'Error'} = "Session not open";
> 		return 0;
> 	}
> 	$tln->buffer_empty;
> 	$self->{'Error'} = '';
> 	return 1;
> }
> 
> #####################################################
> # Send command and wait for reply
> # - May wait for one of many reply regxs' passed in
> #   via the 'Reply' array. Each MUST be single
> #   quoted regex expressions. ie: '/any/i'
> # IN:
> #  cmd       - the shell command or program 
> #  waitsecs  - total secs willing to wait (up to)
> #  show_wait - 'yes' shows the seconds while waiting
> #  Reply     - list of matches will wait for
> # OUT:
> #  Returns index+1 into the 'Reply' list passed in,
> #  of the first match found in reply stream.
> #  Otherwise returns 0, meaning timeout or other
> #  error (check $self->{'Error'})
> #####################################################
> sub SendCommand
> {
> 	my ($self, $cmd, $waitsecs, $show_wait, @Reply) = @_;
> 	my ($pre, $match);
> 
> 	if (!defined $tln) {
> 		$self->{'Error'} = "Session not open";
> 		return 0;
> 	}
> 	$waitsecs = $self->{'Waitsecs'} unless (defined $waitsecs);
> 	$show_wait = $self->{'Show_Wait'} unless (defined $show_wait);
> 
> 	my @args = ('Timeout', 0);
> 	if (@Reply == 0) { push (@Reply, $self->{'Prompt'}) }
> 	for (@Reply) {
> 		push (@args, 'Match');
> 		push (@args, $_);
> 	}
> 	my $savedtimeout = $tln->timeout(0);
> 	$tln->print ($cmd);
> 	print "Sent:  $cmd\n" if ($self->{'Debug'});
> 
> 	for (my $i = 0; $i < $waitsecs; $i++) {
> 		($pre, $match) = $tln->waitfor(@args);
> 		if (!$tln->timed_out) {
> 			print "\rRecieved ($i seconds):   $match               \n" if ($self->{'Debug'});
> 			print "\n$pre\n" if (lc($self->{'Show_Prematch'}) eq 'yes');
> 			last;
> 		}
> 		sleep (1);
> 		if ($show_wait eq lc('yes')) {
> 			print "\rWait progress:  ".($i+1)." seconds           " ;
> 			print "\n" if ($i == ($waitsecs-1));
> 		}
> 	}
> 	$tln->timeout($savedtimeout);
> 
> 	## check if timed out
> 	if ($tln->timed_out) {
> 		print "\r** WAIT EXPIRED - $waitsecs seconds **                           \n" if ($self->{'Debug'});
> 		$self->{'Error'} = "Timed out ($waitsecs) executing command:  $cmd";
> 		return 0;
> 	}
> 	## return the index of the matched @Reply
> 	#return 1 if (!@Reply);
> 	my $pos = 0;
> 	for (@Reply) {
> 		$pos++;
> 		my $patcheck = "last if (\$match =~ $_);"; # pattern match check
> 		#print "$patcheck\n";
> 		eval $patcheck;
> 	}
> 	$self->{'Error'} = '';
> 	return $pos;
> }
> 1;
> 
> ==================================================
> tln.pl
> ==================================================
> use strict;
> 
> use Net::Telnet;
> use sort 'stable';
> my $current = sort::current();      
> 
> use Net::Telnet qw(TELOPT_TTYPE);
> 
> if (1)
> {
> 	my $Term = "ascii";
> 	my $Telopt_ttype_ok = '';
> 	my ($outline, $inline);
> 
> 	my $tln = new Net::Telnet (Timeout => 1, Prompt => '/C:\\\\>/');
> 	my $savederrmode = $tln->errmode ('return');
> 
> 	$tln->option_log('option.log');
> 
> 	## Set up callbacks to negotiate terminal type.
> 	if ($tln->open("155.64.151.193"))
> 	{
> 		$tln->login("administrator", "password");
> 		#print "$savederrmode\n";
> 		#my @aOut = $tln->cmd ( "help\n" );
> 		#print (join "\n", @aOut);
> 		#print "\n\n\ndid u see it?\n\n\n\n";
> 		#<>;
> 
> 		$outline = "";
> 		while ($outline !~ /quit/i)
> 		{
> 			do {
> 				$inline = $tln->get();
> 				#chomp ($inline);
> 				print "$inline";
> 			} while (defined $inline);
> 
> 			$outline = <STDIN>;
> 			chomp ($outline);
> 			# print $outline;
> 			$tln->print ($outline);
> 		}
> 	} else {
> 		print "Could not connect to host\n";
> 	}
> 	$tln->close;
> 
> 	print "done!\n";
> 
> 	###################################
> 	# Option negotation callbacks
> 	####################################
> 	sub opt_callback
> 	{
> 		my ($obj, $option, $is_remote,
> 	    	$is_enabled, $was_enabled, $buf_position) = @_;
>     
> 		if ($option == TELOPT_TTYPE and $is_enabled and !$is_remote) {
> 			$Telopt_ttype_ok = 1;
> 		}
> 		1;
> 	}
> 	sub subopt_callback
> 	{
> 		my ($obj, $option, $parameters) = @_;
> 		my $ors_old;
> 
> 		if ($option == TELOPT_TTYPE) {
> 			$ors_old = $obj->output_record_separator("");
> 
> 			$obj->print("\xff\xfa", pack("CC", $option, 0), $Term, "\xff\xf0");
> 
> 			$obj->output_record_separator($ors_old);
> 		}
> 		1;
> 	} 
> }
> 
> if (0)
> {
> ## Module import.
>     use Net::Telnet qw(TELOPT_TTYPE);
>     
>     ## Global variables.
>     my $Term = "vt100";
>     my $Telopt_ttype_ok = '';
>     
>     ## Main program.
>     {
>         my $t;
>         my ($host, $username, $passwd) = @ARGV;
>         die "usage: $0 host username passwd\n" unless @ARGV == 3;
>     
>         $t = new Net::Telnet (Prompt => '/\$ $/',
>                               Dump_log => "/tmp/dump.log",
>                               Option_log => "/tmp/option.log");
>     
>         ## Set up callbacks to negotiate terminal type.
>         $t->option_callback(\&opt_callback);
>         $t->option_accept(Do => TELOPT_TTYPE);
>         $t->suboption_callback(\&subopt_callback);
>     
>         $t->open($host);
>         $t->login($username, $passwd);
>         print "TERM=", $t->cmd("printenv TERM");
>         $t->close;
>     
>         exit;
>     } # end main program
>     
>     sub opt_callback {
>         my ($obj, $option, $is_remote,
>             $is_enabled, $was_enabled, $buf_position) = @_;
>     
>         if ($option == TELOPT_TTYPE and $is_enabled and !$is_remote) {
>             $Telopt_ttype_ok = 1;
>         }
>     
>         1;
>     }
>     
>     sub subopt_callback {
>         my ($obj, $option, $parameters) = @_;
>         my $ors_old;
>     
>         if ($option == TELOPT_TTYPE) {
>             $ors_old = $obj->output_record_separator("");
>     
>             $obj->print("\xff\xfa", pack("CC", $option, 0), $Term, "\xff\xf0");
>     
>             $obj->output_record_separator($ors_old);
>         }
>         
>         1;
>     } 
> }
> 
> =============================================
> tln2.pl
> =============================================
> use strict;
> 
> use Net::Telnet;
> use sort 'stable';
> 
> my $VERSION = 1.00;
> 
> my $current = sort::current();      
> #print "\n==> sort : $current\n\n";
> 
> use Net::Telnet ();
> 
> my $tln = undef;
> 
> my $debug = 1;
> my $console_mode = 1;
> 
> # CONSOLE MODE ????? Info --
> # We need line-mode or stream!!
> # In console mode, the screen is treated
> # as a buffer X by Y where the display is
> # controlloed by ansi escape sequences.
> # This is bad when expecting specific output (prompts)
> # that may never come because those chars are already
> # in your screen buffer.
> # Always make the server NON-Console, ie: use stream!!
> # If not, as a workaround we will clear screen cmd,
> # then return cmd,  between real commands.
> 
> if (1)
> {
> 	$tln = new Net::Telnet (Timeout => 2, Prompt => '/c:\\\\>/i');
> 
> 	$tln->errmode    ('return');
> 	$tln->option_log ('option.log');
> 	$tln->dump_log   ('dump.log');
> 	$tln->input_log  ('input.log');
> 
> 	$tln->buffer_empty;
> 	$tln->cmd_remove_mode (0);
> 
> 	my $prompt = '/c:\\\\>/i';
> 
> 	if ($tln->open("155.64.151.193"))
> 	{
> 		$tln->prompt ($prompt);
> 		$tln->login ("administrator", "password");
> 		$tln->cmd_remove_mode (0);
> 
> 
> 		## test loop
> 
> 		for (my $t = 0; $t < 3; $t++) 
> 		{
> 			$tln->timeout(2);
> 
> 			my $ret;
> 
> 			TlNet_ClearScreen ('cls', $prompt, 2);
> 
> 			$ret = TlNet_Send ( "ping 155.64.151.193", 10, 'yes', '/asfdgbasdfgas/i', '/c:\\\\>/i'); 
> 			#print "send returned prompt #:  $ret\n";
> 
> 			TlNet_ClearScreen ('cls', $prompt, 2);
> 
> 			$ret = TlNet_Send ( "dir", 10, 'yes', '/c:\\\\>/i', '/asfdgbasdfgas/i'); 
> 			#print "send returned prompt #:  $ret\n";
> 
> 			TlNet_ClearScreen ('cls', $prompt, 2);
> 
> 			$ret = TlNet_Send ( "help\n\n\n\n\n\n", 5, 'yes', '/c:\\\\>/i', '/MORE ---/i'); 
>      
> 			my $retry = 5;
> 			while ($ret != 1 && $retry-- > 0)
> 			{
> 				$ret = TlNet_Send ( "", 1, 'yes', '/c:\\\\>/i', '/MORE ---/i'); 
> 				#print "send returned prompt #:  $ret\n";
> 			}
> 			$ret = TlNet_Send ( "echo hi\necho and\necho hello\necho there\n", 15, 'yes', '/c:\\\\>/i', '/MORE ---/i'); 
> 			TlNet_ClearScreen ('cls', $prompt, 2);
> 			TlNet_ClearScreen ('cls', $prompt, 2);
> 
> 		}
> 
> 	} else {
> 		print "Could not connect to host\n";
> 	}
> 	$tln->close;
> 
> 	print "\nPress return. ";<>;
> 	print "done!\n";
> }
> 
> ## send
> sub TlNet_Send
> {
> 	my ($cmd, $waitsecs, $showsecs, @prompt) = @_;
> 	my ($pre, $match);
> 
> 	return 0 if (!defined $tln or !defined $cmd);
> 
> 	$waitsecs = 2  unless (defined $waitsecs);
> 	$showsecs = 'yes' unless (defined $showsecs);
> 
> 	my @args = ();
> 	@args = ('Match', '') if (@prompt == 0);
> 
> 	for (@prompt) {
> 		push (@args, 'Match');
> 		push (@args, $_);
> 	}
> 
> 	$tln->timeout(0); # save old timeout ??
> 	$tln->print ($cmd);
> 	print "Sent:  $cmd\n" if (defined $debug);
> 
> 	for (my $i = 0; $i < $waitsecs; $i++) {
> 		($pre, $match) = $tln->waitfor(@args);
> 		if (!$tln->timed_out) {
> 			print "\rRecieved ($i seconds):   $match               \n" if (defined $debug);
> 			#print "\n$prematch\n";
> 			last;
> 		}
> 		sleep (1);
> 		print "\rWait progress:  ".($i+1)." second           " if ($showsecs eq lc ('yes'));
> 		
> 	}
> 	## check time out
> 	if ($tln->timed_out) {
> 		print "\r** TIMED OUT **  after $waitsecs seconds -- add more time or change prompt ?       \n" if (defined $debug);
> 		return 0;
> 	}
> 	## return the index of the matched @prompt
> 	return 1 if (!@prompt); # no prompt entered, assume first returned
> 
> 	my $pos = 0;
> 	for (@prompt) {
> 		$pos++;
> 		my $patcheck = "last if (\$match =~ $_);"; # pattern match check
> 		#print "$patcheck\n";
> 		eval $patcheck;
> 	}
> 	return $pos;
> }
> 
> ## clear screen 
> sub TlNet_ClearScreen
> {
> 	my ($cmd, $prompt, $timeout) = @_;
> 	my ($pre, $match);
> 
> 	return 0 if (!defined $tln or !defined $cmd);
> 
> 	$prompt  = '' unless (defined $prompt);
> 	$timeout = 2  unless (defined $timeout);
> 
> 	$tln->timeout($timeout);
> 	$tln->print ($cmd);
> 	$tln->waitfor ($prompt);
> 	$tln->print("");
> 	($pre, $match) = $tln->waitfor ($prompt);
> 	print "Sent clear screen ... recieved:  $match\n" if (defined $debug);
> 	$tln->buffer_empty; # empty recieve buffer between commands
> 	return $match;
> }
> 
> ====================================================
> tln_unix.pl
> ====================================================
> use strict;
> 
> #########################################
> # unixrun.pl - tests the TlnSrv module
> # R. Chalaire  -  10/21/04
> #########################################
> 
> require TlnSrv;
> $|=1;
> 
> #############################################
> # CONSOLE MODE ????? Info --
> # We need line-mode or stream!!
> # In console mode, the screen is treated
> # as a buffer X by Y where the display is
> # controlloed by ansi escape sequences.
> # This is bad when expecting specific output (prompts)
> # that may never come because those chars are already
> # in screen buffer.
> # Always make the server NON-Console, ie: use stream!!
> # If not, as a workaround, between real commands,
> # we can clear screen, then send return.
> # -------------------------------------------------------
> # Note that all 'Prompts' strings are single quote Regex
> # parameters.
> #############################################
> # Default parameters on some methods are take from the class variables
> # if those parameters are not passed in with the call.
> # Set the class variables with  SetVal() function.
> # Values passed into the functions are not assigned to class variables.
> # ----------------------------------
> # SetVal() will find these keys:
> # ----------------------------------
> # Debug           1/0      (default: 0)
> # Show_Prematch   yes/no   (default: no)
> # Port            #        (default: 23)
> # Prompt          /regex/  (default: /[\$%#>] $/) 
> # Timeout         #        (default: 10 secs)
> # ClearCmd                 (default: '')
> # Waitsecs        #        (default: 10 secs)
> # Show_Wait       yes/no   (default: yes)
> 
> 
> #############################################
> # TlnSrv::new (server, user, pwd, logdir); 
> #############################################
> my $prompt = '/# $/i';
> my @p_cls = ("", 3, $prompt);
> my $ret;
> 
> my $tln = new TlnSrv ("172.0.15.1", "x098", "sys2"); 
> 
> $tln->SetVal (
>  Port     =>  1023,
>  Debug    =>  1,
>  Waitsecs =>  15,
>  ClearCmd =>  '',
>  Prompt   =>  $prompt,
>  Timeout  =>  10
> );
> 
> if ($tln->OpenSession(1))	# 1 = enable logging, 0 = disable
> {
> 	$tln->EmptyBuffer();
> 	$tln->ClearScreen (@p_cls);
> 
> 	$ret = $tln->SendCommand ( "cd /share/here");	# the values from above are used when nothing passed in
> 	print "$tln->{'Error'}\n" if (!$ret);
> 
> 	$ret = $tln->SendCommand ("ls");
> 	print "$tln->{'Error'}\n" if (!$ret);
> 
> 	$ret = $tln->SendCommand ( "cd /share/there");	# 1 will be returned here, if 0, its either timeout or some other error
> 	print "$tln->{'Error'}\n" if (!$ret);
> 
> 	$ret = $tln->SendCommand ("ls");
> 	print "$tln->{'Error'}\n" if (!$ret);
> 
> 	$ret = $tln->SendCommand ( "cd /share/and_here", 10, 'yes', '/asfdgbasdfgas/i', '/c:\\\\>/i', $prompt);	# 3 will be returned here
> 	print "$tln->{'Error'}\n" if (!$ret);
> 
> 	$ret = $tln->SendCommand ("ls");
> 	print "$tln->{'Error'}\n" if (!$ret);
> 
> 	$tln->CloseSession();
> }
> else
> {
> 	print "Open Session error: $tln->{'Error'}\n";
> }
> 
> print "\nPress return. ";<>;
> print "done!\n";
> 

I have used for years the telnet module and never experienced any 
problem (except with a broken version of a windows server). I even used 
cat on the other end to get files; probably it is a good idea to choose 
a good prompt (something unlikely to collide with data and easy to find...)

anyway, if you believe your wrapper may serve others you could contact 
the author to have your code added in the example section for example
just a thought
hth
--stephan



------------------------------

Date: Mon, 17 Jul 2006 04:42:06 GMT
From: merlyn@stonehenge.com (Randal Schwartz)
Subject: new CPAN modules on Mon Jul 17 2006
Message-Id: <J2J6E7.1F6F@zorch.sf-bay.org>

The following modules have recently been added to or updated in the
Comprehensive Perl Archive Network (CPAN).  You can install them using the
instructions in the 'perlmodinstall' page included with your Perl
distribution.

Alien-wxWidgets-0.19
http://search.cpan.org/~mbarbon/Alien-wxWidgets-0.19/
building, finding and using wxWidgets binaries
----
CGI-Ajax-0.697
http://search.cpan.org/~bct/CGI-Ajax-0.697/
a perl-specific system for writing Asynchronous web applications
----
Clutter-0.110
http://search.cpan.org/~ebassi/Clutter-0.110/
Simple GL-based canvas library
----
Data-Reuse-0.04
http://search.cpan.org/~elizabeth/Data-Reuse-0.04/
share constant values with Data::Alias
----
DateTime-Util-Calc-0.11
http://search.cpan.org/~dmaki/DateTime-Util-Calc-0.11/
DateTime Calculation Utilities
----
File-StatCache-0.02
http://search.cpan.org/~pevans/File-StatCache-0.02/
a caching wrapper around the stat() function
----
Graph-0.78
http://search.cpan.org/~jhi/Graph-0.78/
graph data structures and algorithms
----
IPC-Mmap-Share-0.03
http://search.cpan.org/~aduitsis/IPC-Mmap-Share-0.03/
Safely share structures among processes using anonymous mmap.
----
Image-Info-1.22
http://search.cpan.org/~tels/Image-Info-1.22/
Extract meta information from image files
----
Mail-Audit-2.201
http://search.cpan.org/~rjbs/Mail-Audit-2.201/
Library for creating easy mail filters
----
Mail-LocalDelivery-0.22
http://search.cpan.org/~rjbs/Mail-LocalDelivery-0.22/
Deliver mail to a local mailbox
----
Method-Declarative-0.03
http://search.cpan.org/~jschneid/Method-Declarative-0.03/
Create methods with declarative syntax
----
Module-Build-0.2804
http://search.cpan.org/~kwilliams/Module-Build-0.2804/
Build and install Perl modules
----
Module-ScanDeps-0.62
http://search.cpan.org/~smueller/Module-ScanDeps-0.62/
Recursively scan Perl code for dependencies
----
Net-IRC3-0.2
http://search.cpan.org/~elmex/Net-IRC3-0.2/
An IRC Protocol module which is event system independend
----
PDL-Fit-Levmar-0.008
http://search.cpan.org/~jlapeyre/PDL-Fit-Levmar-0.008/
Levenberg-Marquardt fit/optimization routines
----
POE-Component-IRC-4.96
http://search.cpan.org/~bingos/POE-Component-IRC-4.96/
a fully event-driven IRC client module.
----
Sub-Install-0.921
http://search.cpan.org/~rjbs/Sub-Install-0.921/
install subroutines into packages easily
----
Sub-Multi-0.002
http://search.cpan.org/~clkao/Sub-Multi-0.002/
Data::Bind-based multi-sub dispatch
----
Test-Simple-0.64
http://search.cpan.org/~mschwern/Test-Simple-0.64/
Basic utilities for writing tests.
----
Wx-0.54
http://search.cpan.org/~mbarbon/Wx-0.54/
interface to the wxWidgets cross-platform GUI toolkit
----
ack-1.24
http://search.cpan.org/~petdance/ack-1.24/
grep-like text finder for large trees of text


If you're an author of one of these modules, please submit a detailed
announcement to comp.lang.perl.announce, and we'll pass it along.

This message was generated by a Perl program described in my Linux
Magazine column, which can be found on-line (along with more than
200 other freely available past column articles) at
  http://www.stonehenge.com/merlyn/LinuxMag/col82.html

print "Just another Perl hacker," # the original

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


------------------------------

Date: Mon, 17 Jul 2006 05:44:24 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: RegEx: odd number of slashes? and too many slashes?
Message-Id: <Xns980311CB1303Dasu1cornelledu@127.0.0.1>

Dan Wilkin <nibbles.bits@verizon.net> wrote in news:gmDug.3008$rT6.56
@trnddc03:

> It looks like the regex engine is gobbling up slashes!!  Perl 5.x
> 

 ... 

> #my $altPath = '\\\\websrv\\VMServer\\cvs\\SAMS\\archives';
> my $rootPath = '\\\\\\\websrv\\\VMServer\\\cvs\\\SAMS\\\archives';
> 
>          /$rootPath(.+?)-arc - (.+)/o;

#!/usr/bin/perl

use strict;
use warnings;

use Data::Dumper;

my $path = '\\\\websrv\VMServer\cvs\SAMS\archives';
my $fn = "$path\\test.txt";

print "YES!\n" if $fn =~ /\Q$path\E/;

__END__

See perldoc perlop.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html



------------------------------

Date: Mon, 17 Jul 2006 04:45:45 GMT
From: Zoltan Somogyi <zs@students.cs.mu.OZ.AU>
Subject: Re: What is a type error?
Message-Id: <44bb15f7$1@news.unimelb.edu.au>

Andreas Rossberg <rossberg@ps.uni-sb.de> writes:
>Uh, aliasing all over the place! Actually, I think that logic 
>programming, usually based on deep unification, brings by far the worst 
>incarnation of aliasing issues to the table.

I agree that deep unification, as implemented in Prolog, brings with it
lots of aliasing problems. However, these problems have been recognized
from the seventies, and people have tried to solve them. There have
been a huge variety of mode systems added to various dialects of Prolog
over the years, which each attempt to tackle (various parts of) the aliasing
problem, none of them fully successfully in my view, since their designers
usually actually *wanted* to retain at least *some* of the expressive power
of the logic variable.

Some non-Prolog logic languages have departed from this approach, the earliest
being the Relational Language. To tie this message to another thread, the
Relational Language had a strict mode system that is as identical as possible
to the notion of typestate in NIL and Hermes given the limitations of
comparing declarative apples with imperative oranges, but significantly
earlier, 1979 vs 1986 IIRC.

Marshall wrote:
>I have explored the OO path to its bitter end and am
>convinced it is not the way. So what is left? Uniqueness
>types and logic programming, I suppose. I enjoy logic
>programming but it doesn't seem quite right. But notice:
>no pointers there!  And it doesn't seem to suffer from the
>lack.

Of course, the main logic programming language today that disallows the use
of unification for arbitrary aliasing is Mercury. It enforces this through
a strong mode system. Our motivation for the design of this mode system
was precisely to eliminate the problems Andreas identified above. However
it has also turned out to be an excellent foundation for Mercury's notion of
unique modes, its equivalent of uniqueness types, which Mercury uses to
express I/O.

Zoltan Somogyi <zs@cs.mu.OZ.AU> http://www.cs.mu.oz.au/~zs/
Department of Computer Science and Software Engineering, Univ. of Melbourne


------------------------------

Date: Mon, 17 Jul 2006 10:17:13 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is a type error?
Message-Id: <e9fhbf$vg2$1@online.de>

Marshall schrieb:
> Joachim Durchholz wrote:
>> Marshall schrieb:
>>> Good point. Perhaps I should have said "relational algebra +
>>> variables with assignment." It is interesting to consider
>>> assignment vs. the more restricted update operators: insert,
>>> update, delete.
>> Actually I see it the other way round: assignment is strictly less
>> powerful than DML since it doesn't allow creating or destroying
>> variables, while UPDATE does cover assignment to fields.
> 
> Oh, my.
> 
> Well, for all table variables T, there exists some pair of
> values v and v', such that we can transition the value of
> T from v to v' via assignment, but not by any single
> insert, update or delete.

I fail to see an example that would support such a claim.

On the other hand, UPDATE can assign any value to any field of any 
record, so it's doing exactly what an assignment does. INSERT/DELETE can 
create resp. destroy records, which is what new and delete operators 
would do.

I must really be missing the point.

 > Further, it is my understanding
> that your claim of row identity *depends* on the restricted
> nature of DML; if the only mutator operation is assignment,
> then there is definitely no record identity.

Again, I fail to connect.

I and others have given aliasing examples that use just SELECT and UPDATE.

>> (However, it's usually new+assignment+delete vs. INSERT+UPDATE+DELETE,
>> at which point there is not much of a difference.)
> 
> I am not sure what this means. Delete can be expressed in
> terms of assignment. (As can insert and update.)

INSERT cannot be expressed in terms of assignment. INSERT creates a new 
record; there's no way that assignment in a language like C can create a 
new data structure!
The same goes for DELETE.

 > (Assignment can also be expressed in terms of insert and delete.)

Agreed.

I also realize that this makes it a bit more difficult to nail down the 
nature of identity in a database. It's certainly not storage location: 
if you DELETE a record and then INSERT it with the same values, it may 
be allocated somewhere entirely else, and our intuition would say it's 
not "the same" (i.e. not identical). (In a system with OID, it would 
even be impossible to recreate such a record, since it would have a 
different OID. I'm not sure whether this makes OID systems better or 
worse at preserving identity, but that's just a side track.)

Since intuition gives me ambivalent results here, I'll go back to my 
semiformal definition (and take the opportunity to make it a bit more 
precise):
Two path expressions (lvalues, ...) are aliases if and only if the 
referred-to values compare equal, and if they stay equal after applying 
any operation to the referred-to value through either of the path 
expressions.

In the context of SQL, this means that identity isn't the location where 
the data is stored. It's also not the values stored in the record - 
these may change, including key data. SQL record identity is local, it 
can be defined from one operation to the next, but there is no such 
thing as a global identity that one can memorize and look up years 
later, without looking at the intermediate states of the store.

It's a gross concept, now that I think about it. Well, or at least 
rather alien for us programmers, who are used to taking the address of a 
variable to get a tangible identity that will stay stable over time.

On the other hand, variable addresses as tangible identities don't hold 
much water anyway.
Imagine data that's written out to disk at program end, and read back 
in. Further imagine that while the data is read into main memory, 
there's a mechanism that redirects all further reads and writes to the 
file into the read-in copy in memory, i.e. whenever any program changes 
the data, all other programs see the change, too.
Alternatively, think about software agents that move from machine to 
machine, carrying their data with them. They might be communicating with 
each other, so they need some means of establishing identity 
("addressing") the memory buffers that they use for communication.

 > I don't know what "new" would be in a value-semantics, relational
> world.

It would be INSERT.

Um, my idea of "value semantics" is associated with immutable values. 
SQL with INSERT/DELETE/UPDATE certainly doesn't match that definition.

So by my definition, SQL doesn't have value semantics, by your 
definition, it would have value semantics but updates which are enough 
to create aliasing problems, so I'm not sure what point you're making 
here...

>> Filters are just like array indexing: both select a subset of variables
>> from a collection.
> 
> I can't agree with this wording. A filter produces a collection
> value from a collection value. I don't see how variables
> enter in to it.

A collection can consist of values or variables.

And yes, I do think that WHERE is a selection over a bunch of variables 
- you can update records after all, so they are variables! They don't 
have a name, at least none which is guaranteed to be constant over their 
lifetime, but they can be mutated!

 > One can filter either a collection constant or
> a collection variable; if one speaks of filtering a collection
> variable, on is really speaking of filtering the collection value
> that the variable currently contains; filtering is not an operation
> on the variable as such, the way the "address of" operator is.
> Note you can't update the result of a filter.

If that's your definition of a filter, then WHERE is not a filter, 
simple as that.

>> In SQL, you select a subset of a table, in a
>> programming language, you select a subset of an array.
>>
>> (The SQL selection mechanism is far more flexible in the kinds of
>> filtering you can apply, while array indexing allows filtering just by
>> ordinal position. However, the relevant point is that both select things
>> that can be updated.)
> 
> When you have been saying "select things that can be updated"
> I have been assuming you meant that one can derive values
> from variables, and that some other operation can update that
> variable, causing the expression, if re-evaluated, to produce
> a different value.

That's what I meant.

 > However the phrase also suggests that
> you mean that the *result* of the select can *itself* be
> updated.

The "that" in "things that can be updated" refers to the selected 
things. I'm not sure how this "that" could be interpreted to refer to 
the selection as a whole (is my understanding of English really that bad?)

 > Which one do you mean? (Or is there a third
> possibility?)

I couldn't tell - I wouldn't have thought that there are even two 
possibilities.

Regards,
Jo


------------------------------

Date: Mon, 17 Jul 2006 03:39:44 -0500
From: rpw3@rpw3.org (Rob Warnock)
Subject: Re: What is a type error?
Message-Id: <EJydnZRij7pN0SbZnZ2dnUVZ_sKdnZ2d@speakeasy.net>

Joachim Durchholz  <jo@durchholz.org> wrote:
+---------------
| INSERT cannot be expressed in terms of assignment. INSERT creates a new 
| record; there's no way that assignment in a language like C can create a 
| new data structure!  The same goes for DELETE.
+---------------

Well, what about "malloc()" & "free()"? I mean, if your
"database" is a simple linked list, then INSERT is just:

    ROW *p = malloc(sizeof *p);
    p->field1 = value1;
    p->field2 = value2;
    ...
    p->fieldN = valueN;
    database = cons(p, database);		/* Common Lisp's CONS */

and DELETE is just:

    ROW *p = find_if(predicate_function, database); /* CL's FIND-IF */
    database = delete(p, database);		/* CL's DELETE */
    free(p);

[There are single-pass methods, of course, but...]


-Rob

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607



------------------------------

Date: Mon, 17 Jul 2006 10:46:36 +0200
From: Joachim Durchholz <jo@durchholz.org>
Subject: Re: What is a type error?
Message-Id: <e9fj2i$2mq$1@online.de>

Chris Smith schrieb:
> David Hopwood <david.nospam.hopwood@blueyonder.co.uk> wrote:
>> Chris Smith wrote:
>>> If checked by execution, yes.  In which case, I am trying to get my head 
>>> around how it's any more true to say that functional languages are 
>>> compilable postconditions than to say the same of imperative languages.
 >>
>> A postcondition must, by definition [*], be a (pure) assertion about the
>> values that relevant variables will take after the execution of a subprogram.
> 
> Okay, my objection was misplaced, then, as I misunderstood the original 
> statement.  I had understood it to mean that programs written in pure 
> functional languages carry no additional information except for their 
> postconditions.

Oh, but that's indeed correct for pure functional languages. (Well, they 
*might* carry additional information anyway, but it's not a requirement 
to make it a programming language.)

The answer that I have for your original objection may be partial, but 
here goes anyway:

Postconditions cannot easily capture all side effects.
E.g. assume there's a file-open routine but no way to test whether a 
given file handle was ever opened (callers are supposed to test the 
return code from the open() call).
In an imperative language, that's a perfectly valid (though possibly not 
very good) library design.
Now the postcondition would have to say something like "from now on, 
read() and write() are valid on the filehandle that I returned". I know 
of no assertion language that can express such temporal relationships, 
and even if there is (I'm pretty sure there is), I'm rather sceptical 
that programmers would be able to write correct assertions, or correctly 
interpret them - temporal logic offers several traps for the unwary. 
(The informal postcondition above certainly isn't complete, since it 
doesn't cover close(); I shunned the effort to get a wording that would 
correctly cover sequences like open()-close()-open(), or 
open()-close()-close()-open().)

Regards,
Jo


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 9486
***************************************


home help back first fref pref prev next nref lref last post