[23864] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 6067 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Feb 2 14:06:02 2004

Date: Mon, 2 Feb 2004 11:05:07 -0800 (PST)
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, 2 Feb 2004     Volume: 10 Number: 6067

Today's topics:
    Re: Capture stderr stdout using system call with commas <tadmc@augustmail.com>
    Re: Clarifications <bik.mido@tiscalinet.it>
    Re: Clarifications <tadmc@augustmail.com>
    Re: Clarifications <jwkenne@attglobal.net>
    Re: Clarifications <jwkenne@attglobal.net>
    Re: Clarifications <bmb@ginger.libs.uga.edu>
        Help with sleep and file open (Bob)
    Re: Help with sleep and file open <nobull@mail.com>
    Re: Help with sleep and file open <bmb@ginger.libs.uga.edu>
    Re: How can I read file from end to first ? <trf@teamlog.com>
    Re: How to add a user to /etc/passwd using CGI? <jurgenex@hotmail.com>
    Re: How to add a user to /etc/passwd using CGI? <josef.moellers@fujitsu-siemens.com>
    Re: How to add a user to /etc/passwd using CGI? <admin@asarian-host.net>
    Re: How to match some characters different to each othe <pinyaj@rpi.edu>
    Re: How to match some characters different to each othe <nobull@mail.com>
    Re: Net::FTP and "mput" issue...cannot change local cur (John Davis)
    Re: Net::FTP and "mput" issue...cannot change local cur <tadmc@augustmail.com>
    Re: network card <javier@t-online.de>
    Re: network card <javier@t-online.de>
        One liner: "&&" all elements of array <irving_kimura@lycos.com>
    Re: open a ascii file and rotate the content 90 deg... <syscjm@gwu.edu>
    Re: open a ascii file and rotate the content 90 deg... <lallip@dishwasher.cs.rpi.edu>
    Re: open a ascii file and rotate the content 90 deg... <syscjm@gwu.edu>
    Re: perl v-drive/webfolder program <tadmc@augustmail.com>
        Two regular expression questions <noemail@noemail4u.com>
    Re: Two regular expression questions <pinyaj@rpi.edu>
    Re: Two regular expression questions (Walter Roberson)
        When to "use strict" when teaching? <simon.andrews@bbsrc.ac.uk>
    Re: When to "use strict" when teaching? <nobull@mail.com>
    Re: When to "use strict" when teaching? <Juha.Laiho@iki.fi>
    Re: When to "use strict" when teaching? <ittyspam@yahoo.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 2 Feb 2004 08:51:29 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Capture stderr stdout using system call with commas?
Message-Id: <slrnc1sovh.b8i.tadmc@magna.augustmail.com>

Chris Mattern <syscjm@gwu.edu> wrote:
> Marv wrote:

>>                 system (
>>                         "mount",
>>                         "-r",
>>                         "-t",
>>                         "smbfs",
>> 
>> "-o","username=$adminuser,password=$adminpass",
>>                         "//$ip/$ashare",
>>                         "/share/$nbname/$ashare",
>>                         "2>&1 tmp.errors"
>>                 );
>> 
>> This method doesn't work because it takes the '2>&1 tmp.errors' as
>> another option of mount and bombs out. 


> Your problem is that you are providing the parameters to system() in a list
> context.  


The arguments to system() are _always_ in list context.

It isn't context at work here, it is calling system() with more
than one argument.


> When you do this, system() calls the program directly, passing the
> rest of the list to the program as parameters.  mount can't do output
> redirection; that's a function of the command shell.

[ snip rest of good answer ]


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Tue, 03 Feb 2004 15:45:06 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: Clarifications
Message-Id: <l06v10tuu99r4p95fkvb4g8m5u1ik77um6@4ax.com>

On Mon, 02 Feb 2004 04:04:36 GMT, "John W. Kennedy"
<jwkenne@attglobal.net> wrote:

>> you surely know that there is not such a thing called 'PERL', don't
>> you?!?
>
>When I first learned the language, I was told in no uncertain terms that 
>the name was an acronym.  Acronyms are capitalized in English.

BTW: just to be fussy as much as possible, I *think* that (also in
English) the correct term should be "abbreviation" and not "acronym"
(it is definitely so in Italian, where one finds a sharp distinction
between "acronimo" and "sigla"), but in fact one most often finds
"acronym" in that acceptation...


Michele
-- 
you'll see that it shouldn't be so. AND, the writting as usuall is
fantastic incompetent. To illustrate, i quote:
- Xah Lee trolling on clpmisc,
  "perl bug File::Basename and Perl's nature"


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

Date: Mon, 2 Feb 2004 09:12:16 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Clarifications
Message-Id: <slrnc1sq6g.bc3.tadmc@magna.augustmail.com>

Michele Dondi <bik.mido@tiscalinet.it> wrote:
> On Mon, 02 Feb 2004 04:04:36 GMT, "John W. Kennedy"
><jwkenne@attglobal.net> wrote:
> 
>>> you surely know that there is not such a thing called 'PERL', don't
>>> you?!?
>>
>>When I first learned the language, I was told in no uncertain terms that 
>>the name was an acronym.  Acronyms are capitalized in English.
> 
> BTW: just to be fussy as much as possible, I *think* that (also in
> English) the correct term should be "abbreviation" and not "acronym"
> (it is definitely so in Italian, where one finds a sharp distinction
> between "acronimo" and "sigla"), but in fact one most often finds
> "acronym" in that acceptation...


Actually, "PERL" might be called a "bacronym", ie: a backwards acronym.

The name came first, the coming up with words for each letter came
_after_ choosing the name.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 02 Feb 2004 15:32:59 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Clarifications
Message-Id: <L4uTb.40686$gw3.16319685@news4.srv.hcvlny.cv.net>

Tad McClellan wrote:
> John W. Kennedy <jwkenne@attglobal.net> wrote:
>>When I first learned the language, I was told in no uncertain terms that 
>>the name was an acronym.

> You were told wrong then, eh?

> Who told you?

It's been a while (this was '95-'96) -- some textbook or other.  (Not 
the Camel, because I didn't get that until later.)  But I'm fairly sure 
that other sources confirmed it.

And I notice that the perl man page, on Cygwin, at least, still presents 
it on the NAME line.

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


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

Date: Mon, 02 Feb 2004 15:40:25 GMT
From: "John W. Kennedy" <jwkenne@attglobal.net>
Subject: Re: Clarifications
Message-Id: <JbuTb.40689$gw3.16341826@news4.srv.hcvlny.cv.net>

Michele Dondi wrote:
> On Mon, 02 Feb 2004 04:04:36 GMT, "John W. Kennedy"
> <jwkenne@attglobal.net> wrote:

>>>you surely know that there is not such a thing called 'PERL', don't
>>>you?!?

>>When I first learned the language, I was told in no uncertain terms that 
>>the name was an acronym.  Acronyms are capitalized in English.

> BTW: just to be fussy as much as possible, I *think* that (also in
> English) the correct term should be "abbreviation" and not "acronym"
> (it is definitely so in Italian, where one finds a sharp distinction
> between "acronimo" and "sigla"), but in fact one most often finds
> "acronym" in that acceptation...

No, "acronym" is correct in English if it makes a pronouncable word. 
I'm afraid my Italian dictionaries don't even list "acronimo", so I 
can't speak to that (of course, I have them more for Arrigo Boito than 
for computers).  But "sigla" would certainly be wrong.

-- 
John W. Kennedy
"But now is a new thing which is very old--
that the rich make themselves richer and not poorer,
which is the true Gospel, for the poor's sake."
   -- Charles Williams.  "Judgement at Chelmsford"


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

Date: Mon, 2 Feb 2004 13:33:31 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Clarifications
Message-Id: <Pine.A41.4.58.0402021311110.21724@ginger.libs.uga.edu>

On Sun, 1 Feb 2004, edgrsprj wrote:

> If you are not a professional computer programmer and you would like to
> see if Perl might be useful for your purposes then as far as I can see
> you are out of luck. It is so complex that you will never be able to
> even test it. You would have to either take a class on it or spend weeks
> or more going through the documentation.  And probably relatively few
> people are going to do that.

Balderdash.


> What that Web page presently does is provide people with groups of
> instructions which will let them try the program.  If they download and
> install it and then use those codes exactly as I have written them,
> substituting their own file names etc., in as little as 10 to 30 minutes
> they should be able to create a program which will open a file, read
> information from it, do some calculations on the information, store the
> results in another file, close all the files, and then open the output file
> with some Windows program such as Notepad or whatever and work with it.

Not if you give them "codes" that are syntax errors:

    open FILENAME &#8220;&gt; c:/textfile.txt&#8221;;

Not if you state things that simply aren't true:

    print "Text message\n";
    print 'Text message',"\n";

    Both of those commands produce the same result.  They cause the string
    "Text message" to immediately print.  If the \n is not present the
    Perl program will wait until it is done with all of its calculations
    etc. before it prints anything.


> Once they are able to do that they can then make a decision regarding
> whether or not they wish to learn how to use Perl or instead choose some
> other program.  Without that Web page they have no options at all as far as
> I can see.  I believe that it is virtually impossible for someone who is not
> a computer programming expert to get the program to do enough things that
> they can decide if they want to use it.

Balderdash.


> Experienced computer programmers might not like the style or content.  But
> they already have documentation which they can use with their Perl work.  I
> do not think that this is presently the case for many and perhaps most
> scientists.

Anyone who has Perl or has Web access has the documentation to Perl.  You
should take a look at it.


> As I said, it is largely intended to simply open the door for people who
> want to see if Perl is a language they might want to use. Without the
> information on that Web page they might never be able to give it a try.

I think you think too highly of your page and too little of your audience.
"They might never be able to ..."?  Pulleez.

Or are you just trolling ...

Regards,

Brad


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

Date: 2 Feb 2004 08:38:24 -0800
From: horseyride@hotmail.com (Bob)
Subject: Help with sleep and file open
Message-Id: <79df890b.0402020838.12ca268@posting.google.com>

I would have expected the code below to sleep for 10 seconds, up to 15
tries, in attempting to open the data file before continuing. Instead
it *always* seems sleep 15 tries before continuing. Can someone please
tell what what I did wrong?

Thanks



 .
 .
 .
$trycount=0;
main:
open(SAV, ">>$filename") || die (&wait_and_try_again);
 .
 .
 .
 .
print "Complete";
exit;

sub wait_and_try_again {
	$trycount++;
	if($trycount<16) { sleep (1); print "Slept: $trycount\n"; goto main;
}
	exit;
}


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

Date: 02 Feb 2004 18:07:12 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: Help with sleep and file open
Message-Id: <u9vfmpcq3z.fsf@wcl-l.bham.ac.uk>

horseyride@hotmail.com (Bob) writes:

> I would have expected the code below to sleep for 10 seconds,

Please post real minimal complete code.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Mon, 2 Feb 2004 13:59:29 -0500
From: Brad Baxter <bmb@ginger.libs.uga.edu>
Subject: Re: Help with sleep and file open
Message-Id: <Pine.A41.4.58.0402021357490.21724@ginger.libs.uga.edu>

On Mon, 2 Feb 2004, Bob wrote:

> I would have expected the code below to sleep for 10 seconds, up to 15
> tries, in attempting to open the data file before continuing. Instead
> it *always* seems sleep 15 tries before continuing. Can someone please
> tell what what I did wrong?

I suspect you do not have permission to write to $filename. With that
code, if you can't open it the first time, waiting is unlikely to help.

Regards,

Brad


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

Date: Mon,  2 Feb 2004 09:57:07 -0600
From: "TRF" <trf@teamlog.com>
Subject: Re: How can I read file from end to first ?
Message-Id: <195a9b26be2bc1a338f8cb1aa8d2a737@localhost.talkaboutprogramming.com>

or maybe sort the file before to proceed ???



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

Date: Mon, 02 Feb 2004 14:52:49 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How to add a user to /etc/passwd using CGI?
Message-Id: <5vtTb.38$Lj5.29@nwrddc02.gnilink.net>

Kempniu wrote:
> I was wondering how do all the "free web space" services etc. work -
> when one fills in a form, he/she is automatically added to the
> system's userlist. How does this work? I mean, how is it possible for
> a CGI script to access /etc/passwd without executing `chmod 666
> /etc/passwd` first? ;)

You may want to ask in Newsgroup that actually deals with CGI.

jue




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

Date: Mon, 02 Feb 2004 16:06:18 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to add a user to /etc/passwd using CGI?
Message-Id: <401E676A.B04D273C@fujitsu-siemens.com>

Kempniu wrote:
> =

> Hi there,
> =

> I was wondering how do all the "free web space" services etc. work -
> when one fills in a form, he/she is automatically added to the
> system's userlist. How does this work? I mean, how is it possible for
> a CGI script to access /etc/passwd without executing `chmod 666
> /etc/passwd` first? ;)

What about
system("useradd",
	"-d /home/$USERNAME",
	"-g freewebusers",
	"-m -k /etc/freeweb.skel",
	"-p $PASSWORD",
	"-s /bin/false",
	$USERNAME);
?

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Mon, 2 Feb 2004 20:02:52 +0100
From: "Mark" <admin@asarian-host.net>
Subject: Re: How to add a user to /etc/passwd using CGI?
Message-Id: <x_qdneytW9tpA4Pd4p2dnA@giganews.com>

"Kempniu" <lordpopcorn@[cut-this-out]poczta.onet.pl> wrote in message
news:mgjs10d99shnem6a2ftu8lefbdnjs706a5@4ax.com...

> Hi there,
>
> I was wondering how do all the "free web space" services etc. work -
> when one fills in a form, he/she is automatically added to the
> system's userlist. How does this work?

It doesn't; and if it does, it is broken.

> I mean, how is it possible for
> a CGI script to access /etc/passwd without executing `chmod 666
> /etc/passwd` first? ;)

A few observations:

1): With shadow passwords, it is doubtful /etc/passwd is what you want to
edit even.

2): If you can successfully do a "chmod 666 /etc/passwd" within your CGI,
then this is either a setuid script, or your entire web daemon runs as root.
In both cases, consider your setup broken.

3): Theoretically, I suppose you could use a tiny c wrapper, which does
setuid (0) and seteuid (0), and then an execv to start your privileged
program (like "/usr/sbin/pw useradd"). This is a VERY BAD idea, though.
Nothing running via a public accessible web-form should be able to
manipulate your user-database directly.

> And if the users are NOT added to /etc/passwd, then how can they
> log in through FTP (e.g. to upload their websites)?

4): If your web-form is really meant to create users on your system (which
is really not a good idea without at least some type of prior inspection of
the form-data), just do it the safe way: store the form-data onto disk
first; and then temporarily, via cron, have a privileged queue-runner (alla
sendmail) process the batch.

If none of the above makes sense, then you're probably not ready to start a
"free web space" service yet.

- Mark




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

Date: Mon, 2 Feb 2004 11:39:36 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
To: Georg Wittig <Georg.Wittig@zv.Fraunhofer.de>
Subject: Re: How to match some characters different to each other?
Message-Id: <Pine.SGI.3.96.1040202112849.72448A-100000@vcmr-64.server.rpi.edu>

[posted & mailed]

On 2 Feb 2004, Georg Wittig wrote:

>In perl 5.8.3 I need to match a sequence of 7 to 11 characters that
>are different to each other. The best solution I came up with is the
>following,

>sub find711 {
>  my ($arg) = shift;
>  my ($string);
>  my (%chars) = ();
>  if ($arg =~ /([a-z]{7,11})/) {
>    $string = $1;
>    @chars{split(//,$string)}++;
>    return 1 if keys (%chars) == length ($string);
>  }
>  return 0;
>}
>
>Is there a shorter or faster or more elegant solution, especially one
>that uses just a single regexp, i.e. without that intermediate hash
>array?

You can do it by making sure you can't match a character, followed by
other characters, followed by that character again.

  sub unique_7_11 {
    my $str = shift;
    return $str =~ /^(?!.*([a-z]).*\1)[a-z]{7,11}$/;
  }

That function returns true if the string is 7 to 11 lowercase letters,
with no letter used more than once.  It returns false if the string
contains characters that are NOT lowercase letters, if it contains less
than 7 or more than 11 lowercase characters, or if any lowercase letter is
used more than once.  (It DOES allow for a newline at the end of the
string, though, just in case.)

First, notice that I added ^ and $ anchors to the regex.  These anchor to
the beginning and end of the string.  Your regex didn't have them, so it
allowed strings of lengths GREATER than 11 to make it through.

Second, I've added something to the beginning of the regex.  It's a
"negative look-ahead assertion".  Here it is:

  (?!.*([a-z]).*\1)

It looks complex, but let's break it down:

  .*       # match any number of characters
  ([a-z])  # match (and capture to $1) a lowercase letter
  .*       # match any number of characters
  \1       # match what was captured into $1

What this is doing is trying to match a character, and then seeing if it
can match that character again later in the string.  This is ALL wrapped
inside a (?!...), which I said is a negative look-ahead.  This means two
things:  first, if the pattern inside it SUCCEEDS, the look-ahead FAILS
(because it's a "negative" look-ahead).  Second, it only LOOKS AHEAD, it
doesn't actually consume anything in the string.  It's like sending a
scout ahead of you to see if the coast is clear, and then having the scout
return.  It doesn't end up changing your position in the string.

You could reorder the regex a bit to make it more efficient:

  sub unique_7_11 {
    my $str = shift;
    return $str =~ /^(?=[a-z]{7,11}$)(?!.*([a-z]).*\1)/;
  }

This time, we use a positive look-ahead at the front, to make sure FIRST
that the string matches our 7-11 lowercase character requisite.  THEN we
use the negative look-ahead to make sure no character is repeated.

Or, you could use two regexes:

  sub unique_7_11 {
    my $str = shift;
    return $str =~ /^[a-z]{7,11}$/ and $str !~ /(.).*\1/;
  }

Here, we first make sure the string has 7-11 lowercase characters.  THEN,
we make sure the string CANNOT match a character twice.

For more information, please read the regex documentation that comes with
Perl, such as:

  perldoc perlre
  perldoc perlretut
  perldoc perlreref

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 02 Feb 2004 17:47:33 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: How to match some characters different to each other?
Message-Id: <u9oeshe5l6.fsf@wcl-l.bham.ac.uk>

Georg.Wittig@zv.Fraunhofer.de (Georg Wittig) writes:

> In perl 5.8.3 I need to match a sequence of 7 to 11 characters that
> are different to each other.

Well the way to text that a string has no repeated characters is

!/(.).*\1/

The way to get a sequence of 7 to 11 characters is 

/(.{7,11})/

What is annoying is that the (?{ code }) assertion always succedes
even if code evalutes to false.

I'd like to know what bright spark decided it should work this way
rather than doing the intuatively obvious and much more useful thing
of succeding iff code returns a true value.

So we can't just do:

/(.{7,11})(?{ $1 !~ m{(.).*\1} })/

In priciple I believe you can do:

/(.{7,11})(??{ $1 !~ m{(.).*\1} ? '' : '^' })/

(We know that '' will always match and '^' never ). 

But that segfaults on 5.8.0 - I've not tried it on a later version.

> The best solution I came up with is the following,
> 
> sub find711 {
> 	my ($arg) = shift;
> 	my ($string);
> 	my (%chars) = ();
> 	if ($arg =~ /([a-z]{7,11})/) {
> 		$string = $1;
> 		@chars{split(//,$string)}++;
> 		return 1 if keys (%chars) == length ($string);
> 	}
> 	return 0;
> }

That inner bit can be replaced with 

  return 1 if $1 !~ /(.).*\1/;

But your "solution" considers the first string of 7 to 11 lowercase
letters in $arg.  That does not match your problem definition (which
says nothing about letters) and also misses 'abcdefg' in 'fooabcdefg'
and in 'abcdefgfoo'.

Also you forgot to mention that you are only looking for true false!
You don't want to extract the match. Your problem simplifies to
looking for a string of exactly 7 characters all different since any
string of 11 non-repeated characters must start with a string of 7
non-repeated characters.
 
> Is there a shorter or faster or more elegant solution,

for ( $arg =~ /(?=(.{7}))/g ) {
    return 1 if $1 !~ /(.).*\1/;
}
return 0;

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: 2 Feb 2004 07:04:36 -0800
From: tudmuf2b@onebox.com (John Davis)
Subject: Re: Net::FTP and "mput" issue...cannot change local currently directory
Message-Id: <7167a8d.0402020704.31c1799f@posting.google.com>

Hmm..thanks for the replies folks.

I think the last thing is, I cannot seem to do an "lcd" like when you
do that from the ftp prompt. I am trying to emulate "lcd /tmp/dbinfo".

The cwd module helped me to see that I was still in the current
directory where and I run my script "~/bin"), but I want to go to
/tmp/dbinfo. It seems my

chdir (/tmp/dbinfo);

is ignored. Printing out the cwd still says "~/bin" - no matter
what....

How do I go about getting into that directory (on my local box),
because it's there that I want to "mput" my files.

Thanks guys!

Ben Morrow <usenet@morrow.me.uk> wrote in message news:<bvfjlj$1hg$1@wisteria.csv.warwick.ac.uk>...
> Sisyphus <kalinaubears@iinet.net.au> wrote:
> > #'.' has special significance in regex. I think you want:
> >      next if ! ($file=~/db\.out/) ;
> 
> And *I* think you want
> 
>     next if $file !~ /db\.out$/;
> 
> or
> 
>     next unless $file =~ /db\.out$/;
> 
> Ben


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

Date: Mon, 2 Feb 2004 09:17:00 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: Net::FTP and "mput" issue...cannot change local currently directory
Message-Id: <slrnc1sqfc.bc3.tadmc@magna.augustmail.com>

John Davis <tudmuf2b@onebox.com> wrote:

> It seems my
> 
> chdir (/tmp/dbinfo);


That is not Perl code, it will not compile.

You should put quotes around strings.


> is ignored.


Then you should ask perl to tell you _why_ it failed by 
checking the return value and showing the contents of $! :

   
   chdir '/tmp/dbinfo' or die "could not cd to '/tmp/dbinfo'  $!";

   

[snip TOFU. Please do not post upside-down like that]

-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 02 Feb 2004 15:12:58 +0100
From: Xaver Biton <javier@t-online.de>
Subject: Re: network card
Message-Id: <bvllrb$p2j$00$1@news.t-online.com>

Bill wrote:

> 
> Well...
> The problem with your question is that the term 'network connection' can 
> trefer to many things, many but not all of which can be done with Perl. 
> Can you explain what you want to do with the network connection once you 
> have it? That might allow people here to better understand what kind on 
> 'connection' you mean...

Ok, sorry if was unclear.  In windows, wenn you go in dial-up and network
connection, you can click on new connection and create it manually with the
wizard, what I want to do is actually automating the whole process with a
perl script. Now, if a connection exist I can manipulate it with IPHeper and
IPConfig module, but if does't exist, how do I create a new one?

many thks.

Xaver



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

Date: Mon, 2 Feb 2004 15:06:43 +0100
From: "Xaver Biton" <javier@t-online.de>
Subject: Re: network card
Message-Id: <bvm300$kuo$07$1@news.t-online.com>

> trefer to many things, many but not all of which can be done with Perl.
> Can you explain what you want to do with the network connection once you
> have it? That might allow people here to better understand what kind on
> 'connection' you mean...

Ok, sorry if was unclear.  In windows, wenn you go in dial-up and network
connection, you can click on new connection and create it manually with the
wizard, what I want to do is actually automating the whole process with a
perl script. Now, if a connection exist I can manipulate it with IPHeper and
IPConfig, but if does't exist, how do I create a new one?

many thks.

Xaver





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

Date: Mon, 2 Feb 2004 18:33:54 +0000 (UTC)
From: Irving Kimura <irving_kimura@lycos.com>
Subject: One liner: "&&" all elements of array
Message-Id: <bvm56i$ndd$1@reader2.panix.com>



I must admit that one of the things I enjoy most about programming
Perl is also one of the most infamous: the possibility of compact
expressions that get a lot done with very few keystrokes.  I'm
referring to gems like this one:

  # removes duplicates from an array, preserving original order
  @no_repeats = do { my %h; grep !$h{$_}++, @has_repeats };

 ...which I found recently in an old c.l.p.m. post, and which make
Pythonites clutch their heads and run out of the room screaming.

OK, so call such opaque compactness a guilty pleasure, to be enjoyed
only by consenting adults...

I'm looking for the most compact way in Perl to take the logical
and of all the elements of an array or list.  The best I can come
up with is this:

!grep !$_, @array;

(The corresponding logical or is equally long: 

!!grep $_, @array;

The initial !! ensures a scalar result even in a list context.)

I've also run into stuff like this

eval join '&', map $_ ? 1 : 0, @array;

 ...which is a bit klugey but functional, and generalizable to other
infix operators such as '|' and '+'.  Then again, generalizability
earns one no points in the compactness derby.  (The map is required
to take care of cases in which @array contains elements, such as
the empty string or undef or whitespace, that would mess up the
Perl string to be eval'd.  And since we are now dealing with 1s
and 0s we can take the bit-wise and.)

I wonder if there's anything better, or I should say badder, out
there.  >:-)

Irv



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

Date: Mon, 02 Feb 2004 12:07:04 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: open a ascii file and rotate the content 90 deg...
Message-Id: <401E83B8.1010400@gwu.edu>

Brian McCauley wrote:
> lyoute <lyoute@softhome.net> writes:
> 
> 
>>i got a set of files all looks like: (with fixed dimension 8x8)
>>.X..XO..
>>X...XO..
>>OXX.XO..
>>OOOXXO..
>>...OO.O.
>>..O.....
>>........
>>........
>>
>>how can i produce output with 90 deg rotated:
>>.XOO....
>>X.XO....
>>..XO.O..
>>...XO...
>>XXXXO...
>>OOOO....
>>....O...
>>........
> 
> 
> That is not rotation, that is reflection.
> 

No, it's not even reflection.  Danged if I can figure out *what*
it's supposed to be.  Any rotation or reflection would move
those two Xs in the top left away, because there isn't anything
like them anywhere else in the matrix.  Nowhere else is there

 .X
X.

or

X.
 .X

             Chris Mattern



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

Date: Mon, 2 Feb 2004 12:27:39 -0500
From: Paul Lalli <lallip@dishwasher.cs.rpi.edu>
Subject: Re: open a ascii file and rotate the content 90 deg...
Message-Id: <20040202122625.I483@dishwasher.cs.rpi.edu>

On Mon, 2 Feb 2004, Chris Mattern wrote:

> Brian McCauley wrote:
> > lyoute <lyoute@softhome.net> writes:
> >
> >
> >>i got a set of files all looks like: (with fixed dimension 8x8)
> >>.X..XO..
> >>X...XO..
> >>OXX.XO..
> >>OOOXXO..
> >>...OO.O.
> >>..O.....
> >>........
> >>........
> >>
> >>how can i produce output with 90 deg rotated:
> >>.XOO....
> >>X.XO....
> >>..XO.O..
> >>...XO...
> >>XXXXO...
> >>OOOO....
> >>....O...
> >>........
> >
> >
> > That is not rotation, that is reflection.
> >
>
> No, it's not even reflection.  Danged if I can figure out *what*
> it's supposed to be.  Any rotation or reflection would move
> those two Xs in the top left away, because there isn't anything
> like them anywhere else in the matrix.  Nowhere else is there
>
> .X
> X.
>
> or
>
> X.
> .X
>

It is reflection, but it's not reflection about the X or Y axis.  Rather,
it's reflection about the line x=y, which is just odd...


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

Date: Mon, 02 Feb 2004 13:13:16 -0500
From: Chris Mattern <syscjm@gwu.edu>
Subject: Re: open a ascii file and rotate the content 90 deg...
Message-Id: <401E933C.9030103@gwu.edu>

Paul Lalli wrote:
> On Mon, 2 Feb 2004, Chris Mattern wrote:
> 
> 
>>Brian McCauley wrote:
>>
>>>lyoute <lyoute@softhome.net> writes:
>>>
>>>
>>>
>>>>i got a set of files all looks like: (with fixed dimension 8x8)
>>>>.X..XO..
>>>>X...XO..
>>>>OXX.XO..
>>>>OOOXXO..
>>>>...OO.O.
>>>>..O.....
>>>>........
>>>>........
>>>>
>>>>how can i produce output with 90 deg rotated:
>>>>.XOO....
>>>>X.XO....
>>>>..XO.O..
>>>>...XO...
>>>>XXXXO...
>>>>OOOO....
>>>>....O...
>>>>........
>>>
>>>
>>>That is not rotation, that is reflection.
>>>
>>
>>No, it's not even reflection.  Danged if I can figure out *what*
>>it's supposed to be.  Any rotation or reflection would move
>>those two Xs in the top left away, because there isn't anything
>>like them anywhere else in the matrix.  Nowhere else is there
>>
>>.X
>>X.
>>
>>or
>>
>>X.
>>.X
>>
> 
> 
> It is reflection, but it's not reflection about the X or Y axis.  Rather,
> it's reflection about the line x=y, which is just odd...

Yes, Brian pointed it out to me in email.  I see it now.  Actually,
with standard Cartesian coordinates (positive being up and right),
it's the line y = -x.

             Chris Mattern



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

Date: Mon, 2 Feb 2004 09:04:56 -0600
From: Tad McClellan <tadmc@augustmail.com>
Subject: Re: perl v-drive/webfolder program
Message-Id: <slrnc1spoo.b8i.tadmc@magna.augustmail.com>

seansan <sean103@reeve.nl> wrote:

> would like to know if
> there are some great scripts/programs out there that someone could
> recommend.

> Any advice would be appreciated


Use a search engine for searching.

Post to a programming newsgroup for asking questions about programming.


-- 
    Tad McClellan                          SGML consulting
    tadmc@augustmail.com                   Perl programming
    Fort Worth, Texas


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

Date: Mon, 02 Feb 2004 16:48:02 GMT
From: Dang Griffith <noemail@noemail4u.com>
Subject: Two regular expression questions
Message-Id: <7da69a9190d78a234a11c316feaf9eb4@news.teranews.com>

1. Is there a more appropriate newsgroup to post questions regarding
regular expressions?  I know many languages now support them, but Perl
is generally considered the de facto standard.  (Yes?)

2. Are there plans to add syntax to support matched-nesting, for
things such as balanced parenthesis, angle-brackets, and quote marks?
It's my understanding that there currently is not support for this,
which is why you can't parse xhtml-like text with simply a regular
expression.  I.e., you need to go to the next level and write a parser
to maintain the state of the nesting.

Thanks,
    --dang


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

Date: Mon, 2 Feb 2004 12:56:41 -0500
From: Jeff 'japhy' Pinyan <pinyaj@rpi.edu>
Subject: Re: Two regular expression questions
Message-Id: <Pine.SGI.3.96.1040202125545.74202A-100000@vcmr-64.server.rpi.edu>

On Mon, 2 Feb 2004, Dang Griffith wrote:

>1. Is there a more appropriate newsgroup to post questions regarding
>regular expressions?  I know many languages now support them, but Perl
>is generally considered the de facto standard.  (Yes?)

This is the place to ask questions about Perl's regexes.

>2. Are there plans to add syntax to support matched-nesting, for
>things such as balanced parenthesis, angle-brackets, and quote marks?
>It's my understanding that there currently is not support for this,
>which is why you can't parse xhtml-like text with simply a regular
>expression.  I.e., you need to go to the next level and write a parser
>to maintain the state of the nesting.

You can match nested things with Perl's regexes, because Perl's regexes
aren't... well... regular.  You can execute arbitary code.  You can
dynamically generate the regex as it's being matched.

-- 
Jeff Pinyan            RPI Acacia Brother #734            2003 Rush Chairman
"And I vos head of Gestapo for ten     | Michael Palin (as Heinrich Bimmler)
 years.  Ah!  Five years!  Nein!  No!  | in: The North Minehead Bye-Election
 Oh.  Was NOT head of Gestapo AT ALL!" | (Monty Python's Flying Circus)



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

Date: 2 Feb 2004 17:59:28 GMT
From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)
Subject: Re: Two regular expression questions
Message-Id: <bvm360$602$1@canopus.cc.umanitoba.ca>

In article <7da69a9190d78a234a11c316feaf9eb4@news.teranews.com>,
Dang Griffith  <noemail@noemail4u.com> wrote:
:1. Is there a more appropriate newsgroup to post questions regarding
:regular expressions?  I know many languages now support them, but Perl
:is generally considered the de facto standard.  (Yes?)

What perl supports are not really regular expressions; it supports
a superset of regular expressions that can match things that
regular expressions cannot. Thus, if you are trying to study
true regular expressions, you might be better off looking elsewhere.


:2. Are there plans to add syntax to support matched-nesting, for
:things such as balanced parenthesis, angle-brackets, and quote marks?

It isn't just a matter of syntax: it fundamentally affects the
search strategy. True regular expressions *cannot* do balancing
no matter what syntax you use.

-- 
Positrons can be described as electrons traveling backwards in time.
Certainly many Usenet arguments about the past become clearer when they
are re-interpreted as uncertainty about the future.
   -- Walter Roberson


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

Date: Mon, 02 Feb 2004 16:59:15 +0000
From: Simon Andrews <simon.andrews@bbsrc.ac.uk>
Subject: When to "use strict" when teaching?
Message-Id: <bvlvj6$36g$1@south.jnrs.ja.net>

I'm thinking about putting together a a series of evening classes at 
work for a group of people who are interested in learning Perl.  I'm 
just thinking about how to split things up and the best approaches to 
take.  A couple of quetions presented themselves and I though I'd 
solicit opinions from others who have done this sort of thing before.

1) When do you think it's best to introduce strictures into the programs 
people write.  Many moons back I learnt Perl using Learning Perl, which 
I found to be excellent, but looking back I see that it doesn't 
introduce the concept of strictures into any of the basic exercises.  I 
remember that adapting my programming to using strictures was one of the 
harder things I had to get my head around, and I wonder if it would have 
been easier to have started off by writing all programs under warnings 
(+diagnostics) and strict?

2) How much Perl do you reckon people can comfortably take in one 
sitting?  I'm in the nice position of being able to spread the training 
in short sesssions over several weeks so that people don't get 
overloaded (most will never have done any programming before at all). 
Most technical courses I've seen suffer from throwing too much 
information at people which results in them not retaining much of it.  I 
was thinking of 1.5 hours at a stretch and maybe 10 sessions in total 
(with exercises in between), to give them a good introduction to the 
language.

Any thoughts / advice appreciated.

	TTFN

	Simon.


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

Date: 02 Feb 2004 18:01:04 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: When to "use strict" when teaching?
Message-Id: <u94qu9e4yn.fsf@wcl-l.bham.ac.uk>

Simon Andrews <simon.andrews@bbsrc.ac.uk> writes:

> I'm thinking about putting together a a series of evening classes at
> work for a group of people who are interested in learning Perl.  I'm
> just thinking about how to split things up and the best approaches to
> take.  A couple of quetions presented themselves and I though I'd
> solicit opinions from others who have done this sort of thing before.
> 
> 1) When do you think it's best to introduce strictures into the
> programs people write.

From the outset put the shebang line, "use strict" and "use warnings"
at the top of all your programs.  Mention in passing that use strict
"disables some feature that are mostly for Perl4 backward
compatability" and maybe add that "in the advanced course you will
encounter a few situations when you still want to use some of these
features".

> Many moons back I learnt Perl [...] I wonder if it would have been
> easier to have started off by writing all programs under warnings
> (+diagnostics) and strict?

It would.


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

Date: Mon, 02 Feb 2004 18:22:00 GMT
From: Juha Laiho <Juha.Laiho@iki.fi>
Subject: Re: When to "use strict" when teaching?
Message-Id: <bvm4a5$qis$1@ichaos.ichaos-int>

Simon Andrews <simon.andrews@bbsrc.ac.uk> said:
>I'm thinking about putting together a a series of evening classes at 
>work for a group of people who are interested in learning Perl.  I'm 
>just thinking about how to split things up and the best approaches to 
>take.  A couple of quetions presented themselves and I though I'd 
>solicit opinions from others who have done this sort of thing before.

I haven't (been teaching Perl, that is), so don't put too much weight
on my words.

>1) When do you think it's best to introduce strictures into the programs 
>people write.  Many moons back I learnt Perl using Learning Perl, which 
>I found to be excellent, but looking back I see that it doesn't 
>introduce the concept of strictures into any of the basic exercises.  I 
>remember that adapting my programming to using strictures was one of the 
>harder things I had to get my head around, and I wonder if it would have 
>been easier to have started off by writing all programs under warnings 
>(+diagnostics) and strict?

I think I'd try to get the students use warnings and strictures from the
start. But this depends on how much things your students allow as "just
do it this way", without questioning and/or requiring in-depth explanation.

I also had hard time when I moved to use strictures - and Perl wasn't
my first language.

>2) How much Perl do you reckon people can comfortably take in one 
>sitting?  I'm in the nice position of being able to spread the training 
>in short sesssions over several weeks so that people don't get 
>overloaded (most will never have done any programming before at all). 

Here you have another challenge -- introducing people to the idea of
programming. This'll be the hard one, because you'll need to teach
at least some of the base abstractions:
- variables
- flow control (branching and looping)
- boolean logic (for controlling the above)
- modularity, reuse (subroutines)
- structured data (arrays, hashes)

>Most technical courses I've seen suffer from throwing too much 
>information at people which results in them not retaining much of it.  I 
>was thinking of 1.5 hours at a stretch and maybe 10 sessions in total 
>(with exercises in between), to give them a good introduction to the 
>language.

That's not too much, but could be enough for basics.
-- 
Wolf  a.k.a.  Juha Laiho     Espoo, Finland
(GC 3.0) GIT d- s+: a C++ ULSH++++$ P++@ L+++ E- W+$@ N++ !K w !O !M V
         PS(+) PE Y+ PGP(+) t- 5 !X R !tv b+ !DI D G e+ h---- r+++ y++++
"...cancel my subscription to the resurrection!" (Jim Morrison)


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

Date: Mon, 2 Feb 2004 13:47:07 -0500
From: Paul Lalli <ittyspam@yahoo.com>
Subject: Re: When to "use strict" when teaching?
Message-Id: <20040202133607.N483@dishwasher.cs.rpi.edu>

On Mon, 2 Feb 2004, Simon Andrews wrote:

> I'm thinking about putting together a a series of evening classes at
> work for a group of people who are interested in learning Perl.  I'm
> just thinking about how to split things up and the best approaches to
> take.  A couple of quetions presented themselves and I though I'd
> solicit opinions from others who have done this sort of thing before.
>

I taught Perl for 4 semesters at Rensselaer Polytechnic Institute, so take
that for what it's worth...

> 1) When do you think it's best to introduce strictures into the programs
> people write.  Many moons back I learnt Perl using Learning Perl, which
> I found to be excellent, but looking back I see that it doesn't
> introduce the concept of strictures into any of the basic exercises.  I
> remember that adapting my programming to using strictures was one of the
> harder things I had to get my head around, and I wonder if it would have
> been easier to have started off by writing all programs under warnings
> (+diagnostics) and strict?

I taught use warnings; and use strict; on the first first day, I believe
within the first five slides.  I told all the students that they were both
technically optional "but extraordinarily recommended".  For my
programming assignments in class, I tried to always use strict; in the
solutions, but occasionally forgot (because like many, *I* was not taught
strictures to begin with either).

>
> 2) How much Perl do you reckon people can comfortably take in one
> sitting?  I'm in the nice position of being able to spread the training
> in short sesssions over several weeks so that people don't get
> overloaded (most will never have done any programming before at all).
> Most technical courses I've seen suffer from throwing too much
> information at people which results in them not retaining much of it.  I
> was thinking of 1.5 hours at a stretch and maybe 10 sessions in total
> (with exercises in between), to give them a good introduction to the
> language.

Our classes were scheduled for 2 hours a day, one day a week, for the
entire semester (about 13 weeks).  About half the time, the class let out
within 90 minutes.

If you're insanely curious, the course webpage from the last semester I
taught can still be found at http://www.cs.rpi.edu/~lallip/perl/spring03

Paul Lalli


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

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 6067
***************************************


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