Date: Thu, 27 Jan 2005 00:04:21 EST-10EDT,10,-1,0,7200,3,-1,0,7200,3600 Subject: [UnixOS2_Archive] No. 514 ************************************************** Wednesday 26 January 2005 Number 514 ************************************************** Subjects for today 1 Re: Perl help : Dave Saville" 2 The Book of Webmin : John Poltorak 3 Re: Perl help : Thomas Dickey 4 Re: Perl help : John Poltorak 5 Re: Perl help : Dave Saville" 6 Re: Perl help : Dave Saville" 7 Re: Perl help : Thomas Dickey 8 Re: Perl help : Dave Saville" 9 Re: Perl help : Thomas Dickey 10 Re: Perl help : John Poltorak 11 Re: Perl help : Thomas Dickey 12 Re: Perl help : Stefan.Neis at t-online.de 13 Re: Perl help : John Poltorak 14 Re: Perl help : John Poltorak 15 Re: Perl help : John Poltorak 16 Re: Perl help : John Poltorak 17 Re: Perl help : Dave Saville" 18 Re: Perl help : Dave Saville" 19 Patching from a 'here document' : John Poltorak **= Email 1 ==========================** Date: Tue, 25 Jan 2005 12:59:15 +0000 (GMT) From: "Dave Saville" Subject: Re: Perl help On Tue, 25 Jan 2005 11:44:33 +0000, John Poltorak wrote: >AFAICT at list is an array consisting lines from a file listing OS's >supported. Each line consists of these five elements: > ># The operating system name visible to the user. > ># The version number visible to the user. > ># Webmin's internal code for the operating system, which you can find by >looking at other entries in the file. This determines which actual config- >files are used at installation time, and which modules are visible. > ># Webmin's internal version number for the operating system. Again, this >is what actually determines which config- files to use when the OS is >chosen. > ># A fragment of Perl code that is run at installation time to check for >this operating system. If it evaluates to some some non-zero value, Webmin >will never ask the user to choose his OS from a list when setup.sh is run. >If you want the RPM version to be installable on this OS, this field must >be filled in so that the RPM installation script can detect it - otherwise >the install will fail. > > > >The code above must refer to the last of these elements. Assuming this was >that element:- > >$uname =~/OS\/2/i It returns true if the variable $uname contains os/2 in any case combination - the trailing i. The / of /2 is escaped with a backslash because the match operators are also / - Known as the "leaning toothpick syndrome" It could have been written $uname =~ m/OS\/2/i or $uname =~ m%os/2%/i With our without the m, ~ defaults to match. But using symbols other than / to delimit matches/substitutions usually don't get picked up by syntax highlighting editors. -- Regards Dave Saville **= Email 2 ==========================** Date: Tue, 25 Jan 2005 13:33:57 +0000 From: John Poltorak Subject: The Book of Webmin Anyone interested in reading about Webmin can read the online version of The Book of Webmin here:- http://www.swelltech.com/support/webminguide-1.0/index.html -- John **= Email 3 ==========================** Date: Tue, 25 Jan 2005 08:41:39 -0500 (EST) From: Thomas Dickey Subject: Re: Perl help On Tue, 25 Jan 2005, Dave Saville wrote: > With our without the m, ~ defaults to match. But using symbols other than / to > delimit matches/substitutions usually don't get picked up by syntax > highlighting editors. Perl isn't easy to parse. Most of the highlighters I've seen only do keywords. (vile and vim do more than that, but for vile I seem to be fixing a different bug every couple of months). Which ones are using '/'? -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net **= Email 4 ==========================** Date: Tue, 25 Jan 2005 14:05:06 +0000 From: John Poltorak Subject: Re: Perl help On Tue, Jan 25, 2005 at 12:59:15PM +0000, Dave Saville wrote: > On Tue, 25 Jan 2005 11:44:33 +0000, John Poltorak wrote: > > >The code above must refer to the last of these elements. Assuming this was > >that element:- > > > >$uname =~/OS\/2/i > > It returns true if the variable $uname contains os/2 in any case combination - > the trailing i. So, given that 'uname' returns 'OS/2' can I just code this as:- ? $uname =~ OS\/2 > The / of /2 is escaped with a backslash because the match > operators are also / - Known as the "leaning toothpick syndrome" It could have > been written > > $uname =~ m/OS\/2/i > > or > > $uname =~ m%os/2%/i > > With our without the m, ~ defaults to match. But using symbols other than / to > delimit matches/substitutions usually don't get picked up by syntax > highlighting editors. I can't say I like the look of Perl at all. It just does my head in looking at Perl code. Latest bit I'm trying to fathom is this:- while(1) { local ($os, $ver, $codes); if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { # OS/version{code} $os = $1; $ver = $2; $codes = $3; $oss = $4; } Is there any way to switch on verbose mode with Perl the way the '-x' flag works with shell scripts? > -- > Regards > > Dave Saville > -- John **= Email 5 ==========================** Date: Tue, 25 Jan 2005 15:23:37 +0000 (GMT) From: "Dave Saville" Subject: Re: Perl help On Tue, 25 Jan 2005 08:41:39 -0500 (EST), Thomas Dickey wrote: >On Tue, 25 Jan 2005, Dave Saville wrote: > >> With our without the m, ~ defaults to match. But using symbols other than / to >> delimit matches/substitutions usually don't get picked up by syntax >> highlighting editors. > >Perl isn't easy to parse. Most of the highlighters I've seen only do >keywords. (vile and vim do more than that, but for vile I seem to be >fixing a different bug every couple of months). > >Which ones are using '/'? vim on os/2 -- Regards Dave Saville **= Email 6 ==========================** Date: Tue, 25 Jan 2005 15:39:48 +0000 (GMT) From: "Dave Saville" Subject: Re: Perl help On Tue, 25 Jan 2005 14:05:06 +0000, John Poltorak wrote: >On Tue, Jan 25, 2005 at 12:59:15PM +0000, Dave Saville wrote: >> On Tue, 25 Jan 2005 11:44:33 +0000, John Poltorak wrote: >> >> >The code above must refer to the last of these elements. Assuming this was >> >that element:- >> > >> >$uname =~/OS\/2/i >> >> It returns true if the variable $uname contains os/2 in any case combination - >> the trailing i. > > >So, given that 'uname' returns 'OS/2' can I just code this as:- ? > >$uname =~ OS\/2 > No - You can't make up the syntax of a language as you go along. what is to the right of ~ is a "regular expression" (TM) It has very strict rules about how it is formatted. My O'Reilly book on the subject is an inch thick :-) >I can't say I like the look of Perl at all. It just does my head in >looking at Perl code. Latest bit I'm trying to fathom is this:- Nothing to do with perl and everything to do with regular expressions - Many program other than perl use them - grep, awk etc. > > >while(1) { > local ($os, $ver, $codes); > if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { > # OS/version{code} > $os = $1; $ver = $2; $codes = $3; $oss = $4; > } If what is in $oss matches the supplied patten - the nasty bit :-) then set some variables to the 1st, second, third and fourth bits of it. Denoted by () Starts, the ^, with at least one or more characters that are NOT / or white space, the \s - call this $1. The rest is left as an exercise for the reader :-) Think of it as a *really* hairy REXX PARSE combined with logic :-) >Is there any way to switch on verbose mode with Perl the way the '-x' flag >works with shell scripts? Not really - the closest is -w or use warnings; -- Regards Dave Saville **= Email 7 ==========================** Date: Tue, 25 Jan 2005 10:58:16 -0500 (EST) From: Thomas Dickey Subject: Re: Perl help On Tue, 25 Jan 2005, Dave Saville wrote: > Nothing to do with perl and everything to do with regular expressions - Many > program other than perl use them - grep, awk etc. But what makes perl hard to parse is that it doesn't bother to quote regular expressions, relying (too) heavily on context. ( ruby's supposed to be simpler, but it doesn't seem that way to me ;-) -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net **= Email 8 ==========================** Date: Tue, 25 Jan 2005 15:54:18 +0000 (GMT) From: "Dave Saville" Subject: Re: Perl help On Tue, 25 Jan 2005 14:05:06 +0000, John Poltorak wrote: > local ($os, $ver, $codes); > if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { > # OS/version{code} > $os = $1; $ver = $2; $codes = $3; $oss = $4; > } Just a bit more help - what he is parsing is that described in the comment: OS/version{code} So to rewrite that using the grouping brackets (OS)/(version){(code)}(any thing left over) $1 $2 $3 $4 HTH -- Regards Dave Saville **= Email 9 ==========================** Date: Tue, 25 Jan 2005 10:59:47 -0500 (EST) From: Thomas Dickey Subject: Re: Perl help On Tue, 25 Jan 2005, Dave Saville wrote: > On Tue, 25 Jan 2005 08:41:39 -0500 (EST), Thomas Dickey wrote: > >> On Tue, 25 Jan 2005, Dave Saville wrote: >> >>> With our without the m, ~ defaults to match. But using symbols other than / to >>> delimit matches/substitutions usually don't get picked up by syntax >>> highlighting editors. >> >> Perl isn't easy to parse. Most of the highlighters I've seen only do >> keywords. (vile and vim do more than that, but for vile I seem to be >> fixing a different bug every couple of months). >> >> Which ones are using '/'? > > vim on os/2 I hadn't noticed, but can see it in the syntax file now that you mention it, e.g., syn region perlMatch matchgroup=perlMatchStartEnd start=+[m!]/+ end=+/[cgimosx]*+ contains= at perlInterpSlash -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net **= Email 10 ==========================** Date: Tue, 25 Jan 2005 16:25:00 +0000 From: John Poltorak Subject: Re: Perl help On Tue, Jan 25, 2005 at 08:41:39AM -0500, Thomas Dickey wrote: > On Tue, 25 Jan 2005, Dave Saville wrote: > > > With our without the m, ~ defaults to match. But using symbols other than / to > > delimit matches/substitutions usually don't get picked up by syntax > > highlighting editors. > > Perl isn't easy to parse. Most of the highlighters I've seen only do > keywords. (vile and vim do more than that, but for vile I seem to be > fixing a different bug every couple of months). As you mention vile, I'm reminded that I managed to builf v9.4 the other day without any problems, but not so when it came to dialog where I got errors like this:- g:\ux2bs\posix2\include\sys/unistdx.h:149: warning: `struct _fd_set' declared inside parameter list g:\ux2bs\posix2\include\sys/unistdx.h:149: warning: its scope is only this definition or declaration, g:\ux2bs\posix2\include\sys/unistdx.h:149: warning: which is probably not what you want. ui_getc.c: In function `dlg_getc_ready': ui_getc.c:95: `fd_set' undeclared (first use in this function) ui_getc.c:95: (Each undeclared identifier is reported only once ui_getc.c:95: for each function it appears in.) ui_getc.c:95: parse error before `read_fds' ui_getc.c:99: `read_fds' undeclared (first use in this function) ui_getc.c:104: parse error before `)' make: *** [ui_getc.o] Error 1 I'm sure it built OK in the past... Maybe this is a newer version than I last tried. I also noticed you have added another patch to autoconf v2.13. Is that something I should incorporate into my setup? > -- > Thomas E. Dickey > http://invisible-island.net > ftp://invisible-island.net -- John **= Email 11 ==========================** Date: Tue, 25 Jan 2005 11:53:32 -0500 (EST) From: Thomas Dickey Subject: Re: Perl help On Tue, 25 Jan 2005, John Poltorak wrote: > On Tue, Jan 25, 2005 at 08:41:39AM -0500, Thomas Dickey wrote: >> On Tue, 25 Jan 2005, Dave Saville wrote: >> >>> With our without the m, ~ defaults to match. But using symbols other than / to >>> delimit matches/substitutions usually don't get picked up by syntax >>> highlighting editors. >> >> Perl isn't easy to parse. Most of the highlighters I've seen only do >> keywords. (vile and vim do more than that, but for vile I seem to be >> fixing a different bug every couple of months). > > As you mention vile, I'm reminded that I managed to builf v9.4 the other > day without any problems, but not so when it came to dialog where I got > errors like this:- I saw that, but my guess was that it was a recent problem with the ux2bs header files. The changes for select in dialog date back to 2001/08/11 (see http://dickey.his.com/dialog/CHANGES). Perhaps one of the unrelated changes (part of making dialog work with wide-characters), such as the #define for _XOPEN_SOURCE_EXTENDED, etc., is causing the problem. That's mostly done in the CF_POSIX_SOURCE macro, which as you may note (see aclocal.m4) contains a lot of special cases. I can add a special case for your configuration, but don't have a build environment setup for it. > I'm sure it built OK in the past... Maybe this is a newer version than I > last tried. > > I also noticed you have added another patch to autoconf v2.13. Is that > something I should incorporate into my setup? 20030927 probably isn't strictly necessary. This part: Modify the here-document used for help messages so it is quoted. This is consistent with autoconf 2.5x (and is a difference from autoconf 2.13). was to make expansion of variables within a "configure --help" message consistent (they're not expanded any more - long story). -- Thomas E. Dickey http://invisible-island.net ftp://invisible-island.net **= Email 12 ==========================** Date: Tue, 25 Jan 2005 18:32:53 +0100 (CET) From: Stefan.Neis at t-online.de Subject: Re: Perl help Thomas Dickey schrieb: > Perhaps one of the unrelated changes (part of making > dialog work with > wide-characters), such as the #define for > _XOPEN_SOURCE_EXTENDED, etc., > is causing the problem. Probably the right spot. Some such define (either POSIX or XOPEN related) is causing Posix/2 headers to _not_ include sys/select.h from unistd.h, but I'm not sure if that isn't rather a bug in said headers... If you have a look at http://cvs.sourceforge.net/viewcvs.py/posix2/posix2/libext/include/sys/unistdx.h?rev=1.27&view=markup you'll see what I mean within the top 15 lines of the file. Regards, Stefan **= Email 13 ==========================** Date: Tue, 25 Jan 2005 17:34:12 +0000 From: John Poltorak Subject: Re: Perl help On Tue, Jan 25, 2005 at 11:53:32AM -0500, Thomas Dickey wrote: > On Tue, 25 Jan 2005, John Poltorak wrote: > > > On Tue, Jan 25, 2005 at 08:41:39AM -0500, Thomas Dickey wrote: > >> On Tue, 25 Jan 2005, Dave Saville wrote: > >> > >>> With our without the m, ~ defaults to match. But using symbols other than / to > >>> delimit matches/substitutions usually don't get picked up by syntax > >>> highlighting editors. > >> > >> Perl isn't easy to parse. Most of the highlighters I've seen only do > >> keywords. (vile and vim do more than that, but for vile I seem to be > >> fixing a different bug every couple of months). > > > > As you mention vile, I'm reminded that I managed to builf v9.4 the other > > day without any problems, but not so when it came to dialog where I got > > errors like this:- > > I saw that, but my guess was that it was a recent problem with the ux2bs > header files. The changes for select in dialog date back to 2001/08/11 > (see http://dickey.his.com/dialog/CHANGES). Actually, I've just found the problem. Under UX2BS the default build uses Posix/2. When I exclude it, dialog build fine. The same happens with vile. > -- > Thomas E. Dickey > http://invisible-island.net > ftp://invisible-island.net -- John **= Email 14 ==========================** Date: Tue, 25 Jan 2005 18:37:38 +0000 From: John Poltorak Subject: Re: Perl help On Sun, Jan 23, 2005 at 08:59:00PM +0000, Lyn St George wrote: > On Sun, 23 Jan 2005 20:07:49 +0000, John Poltorak wrote: > > >I may have got that wrong but that is what it sounds like although I > >haven't figured out which bit of code does this... > > I've just revisited that on Linux, and on both a RH and an LFS system > if fails to do so automatically - it's a minor point so I'll leave it. > > ftp://ftp.zolotek.net/os2 has webmin-1.170.os2.diff and > run_update_os.pl, which should do the job. Apply the patch > and setup.sh will call run_update_os.pl. Setup still requires > human interaction, but it has a list of OS/2 and eCS versions to > pick from. I've managed to automatic selection of OS/2 now, although I'm still not sure about the pupose of the third and fourth elements in the OS table entry... > It also updates selected module.info files with > 'Warp 4 WSeB eCS' appended to any existing string so that these > platforms are allowed to use those modules. You will need to add > extra ones probably, but this file can be run by itself any time > after the main installation. This patch works on my WSeB system > in a clean installation directory. The CPAN module is still a PITA > though ... I can append things to the os_support line in module.info, but it is not being recognised by the installation program so I still don't get to see the Apache module in Webmin. > > > - > Lyn > -- John **= Email 15 ==========================** Date: Tue, 25 Jan 2005 18:49:24 +0000 From: John Poltorak Subject: Re: Perl help On Tue, Jan 25, 2005 at 03:39:48PM +0000, Dave Saville wrote: > On Tue, 25 Jan 2005 14:05:06 +0000, John Poltorak wrote: > > >> >The code above must refer to the last of these elements. Assuming this was > >> >that element:- > >> > > >> >$uname =~/OS\/2/i > >> > >> It returns true if the variable $uname contains os/2 in any case combination - > >> the trailing i. > > > > > >So, given that 'uname' returns 'OS/2' can I just code this as:- ? > > > >$uname =~ OS\/2 > > > > No - You can't make up the syntax of a language as you go along. what is to the > right of ~ is a "regular expression" (TM) It has very strict rules about how it > is formatted. My O'Reilly book on the subject is an inch thick :-) Well I've it to:- $uname =~OS/2 and that works fine. > > > >I can't say I like the look of Perl at all. It just does my head in > >looking at Perl code. Latest bit I'm trying to fathom is this:- > > Nothing to do with perl and everything to do with regular expressions - Many > program other than perl use them - grep, awk etc. > > > > > > >while(1) { > > local ($os, $ver, $codes); > > if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { > > # OS/version{code} > > $os = $1; $ver = $2; $codes = $3; $oss = $4; > > } > > If what is in $oss matches the supplied patten - the nasty bit :-) then set > some variables to the 1st, second, third and fourth bits of it. Denoted by () Should I be able to display the contents of $oss by adding:- ? print "$oss \n"; > Starts, the ^, with at least one or more characters that are NOT / or white > space, the \s - call this $1. The rest is left as an exercise for the reader > :-) Gee thanks! ;-).... > Think of it as a *really* hairy REXX PARSE combined with logic :-) Hmmmm... > -- > Regards > > Dave Saville > -- John **= Email 16 ==========================** Date: Tue, 25 Jan 2005 19:34:18 +0000 From: John Poltorak Subject: Re: Perl help On Tue, Jan 25, 2005 at 03:54:18PM +0000, Dave Saville wrote: > On Tue, 25 Jan 2005 14:05:06 +0000, John Poltorak wrote: > > > local ($os, $ver, $codes); > > if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { > > # OS/version{code} > > $os = $1; $ver = $2; $codes = $3; $oss = $4; > > } > > Just a bit more help - what he is parsing is that described in the comment: > > OS/version{code} > > So to rewrite that using the grouping brackets > (OS)/(version){(code)}(any thing left over) > $1 $2 $3 $4 > > HTH It's not really that simple... In one particular instance $oss is 'os2 OS/2'. I've included two values in the hope that one works but can't figure out which of these conditions is satisfied:- while(1) { local ($os, $ver, $codes); if ($oss =~ /^([^\/\s]+)\/([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { # OS/version{code} $os = $1; $ver = $2; $codes = $3; $oss = $4; } elsif ($oss =~ /^([^\/\s]+)\/([^\/\s]+)\s*(.*)$/) { # OS/version $os = $1; $ver = $2; $oss = $3; } elsif ($oss =~ /^([^\{\s]+)\{([^\}]*)\}\s*(.*)$/) { # OS/{code} $os = $1; $codes = $2; $oss = $3; } elsif ($oss =~ /^\{([^\}]*)\}\s*(.*)$/) { # {code} $codes = $1; $oss = $2; } elsif ($oss =~ /^(\S+)\s*(.*)$/) { # OS $os = $1; $oss = $2; } else { last; } next if ($os && !($os eq $ostype || $ostype =~ /^(\S+)-(\S+)$/ && $os eq "*-$2")); if ($ver =~ /^([0-9\.]+)\-([0-9\.]+)$/) { next if ($osver < $1 || $osver > $2); } elsif ($ver =~ /^([0-9\.]+)\-\*$/) { next if ($osver < $1); } elsif ($ver =~ /^\*\-([0-9\.]+)$/) { next if ($osver > $1); } elsif ($ver) { next if ($ver ne $osver); } next if ($codes && !eval $codes); return 1; } > -- > Regards > > Dave Saville > -- John **= Email 17 ==========================** Date: Tue, 25 Jan 2005 21:52:24 +0000 (GMT) From: "Dave Saville" Subject: Re: Perl help On Tue, 25 Jan 2005 18:49:24 +0000, John Poltorak wrote: >On Tue, Jan 25, 2005 at 03:39:48PM +0000, Dave Saville wrote: >> No - You can't make up the syntax of a language as you go along. what is to the >> right of ~ is a "regular expression" (TM) It has very strict rules about how it >> is formatted. My O'Reilly book on the subject is an inch thick :-) > >Well I've it to:- > >$uname =~OS/2 > >and that works fine. > But it's illegal syntax - Try with "use strict;" use strict; use warnings; my $uname; if( $uname =~OS/2 ) { printf "true\n"; } else { printf "false\n"; } running gives: Bareword "OS" not allowed while "strict subs" in use at try.pl line 5. Without "use strict" Use of uninitialized value in pattern match (m//) at try.pl line 5. Because I did not give it a value on the my line. So it is defaulting to a match. One should *always* use strict and warnings. Here you got away with it, but it *can* make a big difference to the results. -- Regards Dave Saville **= Email 18 ==========================** Date: Tue, 25 Jan 2005 21:58:18 +0000 (GMT) From: "Dave Saville" Subject: Re: Perl help On Tue, 25 Jan 2005 19:34:18 +0000, John Poltorak wrote: >It's not really that simple... > >In one particular instance $oss is 'os2 OS/2'. I've included two values in >the hope that one works but can't figure out which of these conditions is >satisfied:- > > > # OS/version{code} > # OS/version > # OS/{code} > # {code} > # OS My guess is the second one with an OS of "os2 OS" and a version of "2". Remember we are patten matching here. You don't need that initial os2 Linux/1.3{a} would match the first OS/2 matches the second OS2/{4.50} matches the third {123} matches the fourth Winblows XP the last -- Regards Dave Saville **= Email 19 ==========================** Date: Wed, 26 Jan 2005 09:16:55 +0000 From: John Poltorak Subject: Patching from a 'here document' I assume it is possible to apply a patch from a 'here document' ie inline from a shell script, but I can't figure out how. Does anyone else know? -- John