[19765] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1960 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 18 21:05:49 2001

Date: Thu, 18 Oct 2001 18:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <1003453509-v10-i1960@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 18 Oct 2001     Volume: 10 Number: 1960

Today's topics:
    Re: 20-line webserver in perl ? (Joe Smith)
    Re: Checking a line of string <krahnj@acm.org>
    Re: Checking the remote file (Charles DeRykus)
        Elegant Code - Indexing Letters (David Filmer)
    Re: Elegant Code - Indexing Letters (Tad McClellan)
    Re: Elegant Code - Indexing Letters (Randal L. Schwartz)
    Re: Elegant Code - Indexing Letters <andrew@erlenstar.demon.co.uk>
    Re: Elegant Code - Indexing Letters <bart.lateur@skynet.be>
    Re: Elegant Code - Indexing Letters <wyzelli@yahoo.com>
    Re: Elegant Code - Indexing Letters (Martien Verbruggen)
        HELP: Regular expression and grep (Paul Shinn)
    Re: HELP: Regular expression and grep <dtweed@acm.org>
    Re: how can i make perl retreive a web page and save it (Tad McClellan)
    Re: Looking for DOS equiv to pause <tintin@snowy.calculus>
    Re: Looking for DOS equiv to pause <jeff@vpservices.com>
    Re: Looking for DOS equiv to pause <mikesl@wrq.com>
    Re: need value of struct for system() (Tad McClellan)
        Perl remote communication - Is it tcp port, netbios or  <ra990866@ic.unicamp.br>
    Re: precedence question (Martien Verbruggen)
    Re: Regex: extracting repeating values like x=a,b,c,d (Tad McClellan)
    Re: Regular expression and grep <jurgenex@hotmail.com>
    Re: rename return value (Tad McClellan)
    Re: Scaling a DNA string (Martien Verbruggen)
        scripting File access problem (analyser)
    Re: sendmail not sending mail anymore (David Efflandt)
    Re: Splitting on value pairs <tintin@snowy.calculus>
    Re: Splitting on value pairs <mbudash@sonic.net>
    Re: SV: how can i make perl retreive a web page and sav (Martien Verbruggen)
        taint unique to Perl? (Miko O'Sullivan)
    Re: taint unique to Perl? (Tad McClellan)
    Re: taint unique to Perl? (Malcolm Dew-Jones)
    Re: taint unique to Perl? (Martien Verbruggen)
    Re: taint unique to Perl? (David Efflandt)
        What changes atime michael.e.grimes.nospam@fritolay.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 18 Oct 2001 22:48:01 +0000 (UTC)
From: inwap@best.com (Joe Smith)
Subject: Re: 20-line webserver in perl ?
Message-Id: <9qnm71$1fqk$1@nntp1.ba.best.com>

In article <3BCA4573.B879181E@acm.org>, Dave Tweed  <dtweed@acm.org> wrote:
>Joe Smith wrote:
>> Of course, no one should ever run that 4-line web server as it stands.
>> It treats the pathname part of the URL as a Unix absolute pathname,
>> allowing anyone to use "http://yourhostname/etc/passwd" to read your files.
>
>No, it concatenates it with $ARGV[0], assuming I understand it correctly.
>If you don't give an argument, of course, you get the behavior you describe.

You're right; I missed the part about making @ARGV non-empty.

perl -MO=Deparse temp
$v = 'HTTP/1.0';
$/ = "\r\n" x 2;
socket S, 2, 1, 6;
die unless bind S, pack('Snx12', 2, 80);
listen S, 8;
for (*STDOUT = *C; accept C, S; close) {
    print("$v 400" . $/), next unless $_ = <C> =~ /^GET\s+(\S+)/;
    $ENV{'QUERY_STRING'} = s/\?(.+)// ? $1 : '';
    s/%(..)/chr hex $1;/eg;
    foreach $_ ($ARGV[0] . $_) {
        -x $_ ? print("$v 200$/") && do $_ :
		(open(F, $_) ? print("$v 200$/", <F>) : print("$v 404$/"));
    }
}
temp syntax OK
--
See http://www.inwap.com/ for PDP-10 and "ReBoot" pages.


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

Date: Fri, 19 Oct 2001 00:50:33 GMT
From: "John W. Krahn" <krahnj@acm.org>
Subject: Re: Checking a line of string
Message-Id: <3BCF795B.140930C3@acm.org>

Sasha wrote:
> 
> I am writing a program which receives one line at a time. Each line may have
> some comment marked  # or data containing name and phone number, I was
> wodering if some one could tell me how can I skips or ignore the data
> started or after # skips a line if it starts with # or skips a line with
> more than two words and save the lines data if it has two words.
> 
>  The data in a line looks like this
> 
>  # Here is an example of  line data
> 
> Peter        2131111111   # correct data  it should be saved
> Andre      212112   333333  # Wrong data and it should be ignored
> Mark       212112   Angel    #  Wrong data and it should be ignored
> 
> My program looks like  :
> 
> If (open (MYFILE, "data.dat")){
> $line = <MYFILE>;
> while ($line ne "")  # Not end of file  {
> if (it_is_ a_comment ){ } #dont save it
> if (it_is_ a_wrong ){ } # dont save it
> if (it_is_correct){ #save it }
> }
> }


#!/usr/bin/perl -w
use strict;

open MYFILE, 'data.dat' or die "Cannot open data.dat: $!";
while ( <MYFILE> ) {
    s/#[^#]*$//;
    my @data = split;
    if ( @data == 2 ) {
        # save the data
        print "@data\n";
        }
    }




John
-- 
use Perl;
program
fulfillment


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

Date: Fri, 19 Oct 2001 00:03:11 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Checking the remote file
Message-Id: <GLFEtC.22A@news.boeing.com>

In article <fm6z7.109$1L8.187441152@news.frii.net>,
Chris Fedde <cfedde@fedde.littleton.co.us> wrote:
>In article <699c9db.0110161320.4b25f063@posting.google.com>,
>Peter Sun <sunpl@yahoo.com> wrote:
>>Hi,
>>
>> if (-e "servername:/home/peter/file.txt") { print "The file does
>>exist";}
>>
>
>Not much chance that is going to work. 
>Try instead something on the lines of 
>
>    system('rsh servername test -e /home/peter/file.txt');
>    if ($? == 0) {
>	print "The file does exist\n";
>    } 
>
>I tested this with ssh which exits with the exit code of the remote
>command. IIRC rsh does the same thing.

Actually I don't know of a rsh that'll propagate the remote 
exit code but "ersh" (author: Maarten Litmaath) does:

perl -le 'print system "rsh server test -e nosuchfile"'
0

perl -le 'print system "ersh server test -e nosuchfile"'
256


--
Charles DeRykus


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

Date: 18 Oct 2001 16:06:38 -0700
From: iNeverReadAnythingSentToMe@hotmail.com (David Filmer)
Subject: Elegant Code - Indexing Letters
Message-Id: <9a223a9d.0110181506.6372084b@posting.google.com>

In the prusuit of elegant code... Suppose I have a variable which
contains a single-character alphebitic.  I want to index it in a
circular fashion (A becomes B, B becomes C, etc, but Z becomes A).  I
can do this quite nicely and neatly with something like:

   $var =~ tr/A-Z/B-ZA/;

Sweet, huh?  But, now suppose that $var is a TWO-character alphabetic,
and it indexes like this:  AA >> AB, AB >> AC, etc, AZ >> BA (just as
if it were a base-26 numbering system with only alphabetic digits).  I
have NO IDEA what sort of syntax to use for a simple 'tr' command (or
if it's even possible).  I can do something like this:

   ($a, $b) = ($var =~ /(.)(.)/);
   if ($b =~ /Z/) {$a =~ tr/A-Z/B-ZA/}
   $b =~ tr/A-Z/B-ZA/;
   $var = "$a$b";

It works, but it's not elegant any more.  How could I do this
elegantly?


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

Date: Thu, 18 Oct 2001 23:38:09 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <slrn9sunag.qp2.tadmc@tadmc26.august.net>

David Filmer <iNeverReadAnythingSentToMe@hotmail.com> wrote:

>In the prusuit of elegant code... Suppose I have a variable which
>contains a single-character alphebitic.  I want to index it in a
>circular fashion (A becomes B, B becomes C, etc, but Z becomes A).  I
>can do this quite nicely and neatly with something like:
>
>   $var =~ tr/A-Z/B-ZA/;
>
>Sweet, huh?  But, now suppose that $var is a TWO-character alphabetic,
>and it indexes like this:  AA >> AB, AB >> AC, etc, AZ >> BA (just as
>if it were a base-26 numbering system with only alphabetic digits).  


What is to happen when you increment ZZ ?

Should it go to AAA or to AA (maintaining exactly two digits)?


>I
>have NO IDEA what sort of syntax to use 


See the "Auto-increment and Auto-decrement" section in perlop.pod.

ZZ => AAA in the below. Uncomment a line if you want ZZ => AA.

Sweet huh?  :-)

-------------------------
#!/usr/bin/perl
use warnings;
use strict;

$_ = 'AA';

for my $i ( 1..1000 ) {  # let's see a thousand increments
   print "$_\n";
   $_++;
#   $_ = 'AA' if $_ eq 'ZZ';
}
-------------------------


>for a simple 'tr' command (or
>if it's even possible).  


It is not possible with tr///. tr/// works on individual characters.

Going from one char to two chars changes it from operating on
characters to operating on substrings.

tr/// doesn't grok "substrings".


>It works, but it's not elegant any more.  How could I do this
>elegantly?


Magical autoincrement to the rescue.


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


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

Date: 18 Oct 2001 16:52:17 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <m1u1ww33ri.fsf@halfdome.holdit.com>

>>>>> "David" == David Filmer <iNeverReadAnythingSentToMe@hotmail.com> writes:

David> In the prusuit of elegant code... Suppose I have a variable which
David> contains a single-character alphebitic.  I want to index it in a
David> circular fashion (A becomes B, B becomes C, etc, but Z becomes A).  I
David> can do this quite nicely and neatly with something like:

David>    $var =~ tr/A-Z/B-ZA/;

David> Sweet, huh?  But, now suppose that $var is a TWO-character alphabetic,
David> and it indexes like this:  AA >> AB, AB >> AC, etc, AZ >> BA (just as
David> if it were a base-26 numbering system with only alphabetic digits).  I
David> have NO IDEA what sort of syntax to use for a simple 'tr' command (or
David> if it's even possible).  I can do something like this:

David>    ($a, $b) = ($var =~ /(.)(.)/);
David>    if ($b =~ /Z/) {$a =~ tr/A-Z/B-ZA/}
David>    $b =~ tr/A-Z/B-ZA/;
David>    $var = "$a$b";

David> It works, but it's not elegant any more.  How could I do this
David> elegantly?

Oddly enough:

$current = 'pl';
$current++;
print "next is $current\n";

prints "next is pm\n"

Even wraps around.  You have to catch it when it wraps to "aaa", of course.

perldoc perlop =>

       The auto-increment operator has a little extra builtin
       magic to it.  If you increment a variable that is numeric,
       or that has ever been used in a numeric context, you get a
       normal increment.  If, however, the variable has been used
       in only string contexts since it was set, and has a value
       that is not the empty string and matches the pattern /^[a-
       zA-Z]*[0-9]*$/, the increment is done as a string,
       preserving each character within its range, with carry:

           print ++($foo = '99');      # prints '100'
           print ++($foo = 'a0');      # prints 'a1'
           print ++($foo = 'Az');      # prints 'Ba'
           print ++($foo = 'zz');      # prints 'aaa'

       The auto-decrement operator is not magical.


-- 
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: 19 Oct 2001 00:58:39 +0100
From: Andrew Gierth <andrew@erlenstar.demon.co.uk>
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <87d73ko5zk.fsf@erlenstar.demon.co.uk>

>>>>> "David" == David Filmer <iNeverReadAnythingSentToMe@hotmail.com> writes:

 David> Sweet, huh?  But, now suppose that $var is a TWO-character
 David> alphabetic, and it indexes like this: AA >> AB, AB >> AC, etc,
 David> AZ >> BA (just as if it were a base-26 numbering system with
 David> only alphabetic digits).  I have NO IDEA what sort of syntax
 David> to use for a simple 'tr' command (or if it's even possible).
 David> I can do something like this:

 David>    ($a, $b) = ($var =~ /(.)(.)/);
 David>    if ($b =~ /Z/) {$a =~ tr/A-Z/B-ZA/}
 David>    $b =~ tr/A-Z/B-ZA/;
 David>    $var = "$a$b";

 David> It works, but it's not elegant any more.  How could I do this
 David> elegantly?

++$var;   # yes, it's that simple.

(unless you want to go back to "AA" after "ZZ", in which case you need
another step; the magic ++ applied to "ZZ" gives "AAA".)

-- 
Andrew.


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

Date: Fri, 19 Oct 2001 00:10:47 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <0orustg6stffpdip5nj5rj6nh812lfco3s@4ax.com>

David Filmer wrote:

>   ($a, $b) = ($var =~ /(.)(.)/);
>   if ($b =~ /Z/) {$a =~ tr/A-Z/B-ZA/}
>   $b =~ tr/A-Z/B-ZA/;
>   $var = "$a$b";
>
>It works, but it's not elegant any more.  How could I do this
>elegantly?

Everybody pointed you towards the magical ++. But they didn't offer a
compleet solution.

	$var = 'AB YZ';
	$var =~ s/([a-zA-Z]{2})/++(my $t = $1)/ge;
	print $var;
->
	AC ZA

-- 
	Bart.


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

Date: Fri, 19 Oct 2001 10:03:39 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <9pKz7.14$R12.640@wa.nnrp.telstra.net>

"Bart Lateur" <bart.lateur@skynet.be> wrote in message
news:0orustg6stffpdip5nj5rj6nh812lfco3s@4ax.com...
> David Filmer wrote:
>
> >   ($a, $b) = ($var =~ /(.)(.)/);
> >   if ($b =~ /Z/) {$a =~ tr/A-Z/B-ZA/}
> >   $b =~ tr/A-Z/B-ZA/;
> >   $var = "$a$b";
> >
> >It works, but it's not elegant any more.  How could I do this
> >elegantly?
>
> Everybody pointed you towards the magical ++. But they didn't offer a
> compleet solution.
>
> $var = 'AB YZ';
> $var =~ s/([a-zA-Z]{2})/++(my $t = $1)/ge;
> print $var;
> ->
> AC ZA

And to handle the ZZ -> AAA problem (if it is one) as ZZ -> AA :-

$var = 'AB ZZ';
$var =~ s/([a-zA-Z]{2})/substr(++(my $t = $1),-2)/ge;
print $var;



Wyzelli
--
push@x,$_ for(a..z);push@x,' ';
@z='092018192600131419070417261504171126070002100417'=~/(..)/g;
foreach $y(@z){$_.=$x[$y]}y/jp/JP/;print;





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

Date: Fri, 19 Oct 2001 01:01:16 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Elegant Code - Indexing Letters
Message-Id: <slrn9suuqs.e62.mgjv@verbruggen.comdyn.com.au>

On Fri, 19 Oct 2001 10:03:39 +0930,
	Wyzelli <wyzelli@yahoo.com> wrote:
> "Bart Lateur" <bart.lateur@skynet.be> wrote in message
> news:0orustg6stffpdip5nj5rj6nh812lfco3s@4ax.com...
>> David Filmer wrote:
>>
>> >   ($a, $b) = ($var =~ /(.)(.)/);
>> >   if ($b =~ /Z/) {$a =~ tr/A-Z/B-ZA/}
>> >   $b =~ tr/A-Z/B-ZA/;
>> >   $var = "$a$b";
>> >
>> >It works, but it's not elegant any more.  How could I do this
>> >elegantly?
>>
>> Everybody pointed you towards the magical ++. But they didn't offer a
>> compleet solution.
>>
>> $var = 'AB YZ';
>> $var =~ s/([a-zA-Z]{2})/++(my $t = $1)/ge;
>> print $var;
>> ->
>> AC ZA
> 
> And to handle the ZZ -> AAA problem (if it is one) as ZZ -> AA :-
> 
> $var = 'AB ZZ';
> $var =~ s/([a-zA-Z]{2})/substr(++(my $t = $1),-2)/ge;
> print $var;

The original never mentioned lowercase letters, but if you do want to
include those, you might as well write:

$var =~ s/([A-Z]{2})/substr(++(my $t = $1),-2)/gie;

If you don't, get rid of the i option. If you do, however, it brings
up the question how the OP wants this all handled. Perl's
auto-increment will do the following:

az -> ba
aZ -> bA

if you include lower and uppercase, is that what's wanted? Or would we
rather have

az -> bA
aZ -> aA

\begin{digression}

The magic auto-increment does nice things, but they can be surprising.
it works on any string [note 1] matching /^[a-zA-Z]*[0-9]*\z/ [note 2].  
However, the increment works on individual characters (with carry),
but in three distinct rotating groups  A-Z, a-z, and 0-9. Z rolls over
to A, z rolls over to a, and 9 rolls over to 0, and the increment is
carried to the left [note 3]. This behaviour is intended, but rather
clumsily documented:

                               the increment is done as a string,
       preserving each character within its range, with carry:
                                 ^^^^^^^^^^^^^^^^
The problem is of course, that the underlined bit above has never
really been defined. What is "a character's range", and where are the
boundaries of these "ranges"? It also doesn't define how the carry
works on the left side of the string.

[note 1] this means that the string cannot have been used in a numeric
context.

[note 2] Note that auto-increment does _not_ work for strings like
"a1a" or "1aa". It only works for strings like "aAaA", "aAa1", or
"123".

[note 3] if there's nothing there, the left-most character determines what
the new character becomes. e.g z9 -> aa0, Z9 -> AA0, and 99 -> 100, of
course. What is more surprising in this context, but perfectly
well-defined and documented, is that 99A also goes to 100.

\end{digression}

Martien
-- 
Martien Verbruggen              | 
                                | Little girls, like butterflies, need
Trading Post Australia Pty Ltd  | no excuse - Lazarus Long
                                | 


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

Date: 18 Oct 2001 22:55:21 GMT
From: pshinn@mail1.sas.upenn.edu (Paul Shinn)
Subject: HELP: Regular expression and grep
Message-Id: <9qnmkp$a7h$1@netnews.upenn.edu>

   I am driving myself crazy trying to figure out why this regular
expression will not work.  Maybe I've been looking at it too long.  I know
there has to be a very simple answer. 

Here's what I'm trying to accomplish:

I have a file of DNA sequences that looks like this:

>076C10-76A01.xa 847 0 847 ABI
ACGAAGTTATGGATCAGGCCAAATCGGCCGAGCTCGAATTCGTCCAGTTA
ATTAAATTAATCCCCCCCCCCCCCCCCGAGCTCCTTTTTTCTCTATCTCG
>076C10-76C02.ya 818 0 818 ABI 
GAACATAGAAACGTTAGAAAACCTAATTAAGAACAATCATCACTACTTTT
ACCCTCGATTTCCCATTCTTCTCATTTCTCTCCACTCTACTTCTCAAATC
>076C10-76D01.xa 770 0 770 ABI 
TCGTATAGCATACATTATACGAAGTTATGGATCAGGCCAAATCGGCCGAG
CTCGAATTCGTCGAGTTAATTAAATTAATCCCCCCCCCCCCCCCCCGGAG

Each ">" denotes a new sequence and the information following it is the 
sequence name and its length.  I have another file that looks like this:

76D01
76C02

 In a new file, I want to exclude any DNA sequences in file1 that match the 
name in file2.  It's like grepping but getting everything else that 
you're grepping for.  Thanks ahead of time.

My output should just be the sequence for 076C10-76A01.xa in this case.  
Instead of excluding the sequences in the list, my output contains all 
the sequences in file1.  I have put print statements inside the if 
statement for the pattern matching but it never comes up true.

Here's what I have:

#!/usr/bin/perl
#pulls the sequences that match the names in the file

($seqs, $list)=@ARGV;

open LIST, "$list";
open SEQS, "$seqs" or die;

@search=<LIST>;

$/=">";
<SEQS>;

while (<SEQS>) {
   chomp;
   ($header, @sequence)=split "\n";
   $match=1;
   foreach $item (@search) {
      $pattern=$item;
      chop $pattern;
      if ($pattern =~ /$header/) {  #there is something wrong here
         $match=0;
         last
      }
   }
   if ($match==1) {
      $sequence=join "\n", @sequence;
      print join("\n", ">".$header,"$sequence\n");
   }
}
close SEQS;



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

Date: Fri, 19 Oct 2001 00:44:24 GMT
From: Dave Tweed <dtweed@acm.org>
Subject: Re: HELP: Regular expression and grep
Message-Id: <3BCF7600.80E3EC1F@acm.org>

Paul Shinn wrote:
>       if ($pattern =~ /$header/) {  #there is something wrong here

Sure is. Try this:

        if ($header =~ /$pattern/) {

Also, several things can be simplified and/or made more robust:
* chomp the patterns once at the beginning, rather than on each pass
  through the loop
* check both opens for errors, close LIST when done with it
* remove extraneous quotes
* don't strip the newline from the sequence if you're just going to
  put it back on when you print it
* don't split the sequence at all, in fact

#!perl -w
#pulls the sequences that match the names in the file

($seqs, $list)=@ARGV;

open LIST, $list or die;
chomp (@search = <LIST>);
close LIST;

open SEQS, $seqs or die;
$/ = ">";
<SEQS>;
while (<SEQS>) {
   my $header = (split "\n")[0];
   print ">$_" unless grep $header =~ /$_/, @search;
}
close SEQS;

-- Dave Tweed


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

Date: Thu, 18 Oct 2001 23:15:05 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: how can i make perl retreive a web page and save it to my website?
Message-Id: <slrn9suh45.qf2.tadmc@tadmc26.august.net>


[ Please put your text *following* the quoted text that you are
  commenting on.

  Please do not quote an entire article.

  Please do not quote .signatures

  Please see: http://www.geocities.com/nnqweb/nquote.html

  Thank you.

  Text rearranged into actual chronology.
]


']['rull <trullock@yahoo.com> wrote:
>"Tad McClellan" <tadmc@augustmail.com> wrote in message
>news:slrn9strnp.p4l.tadmc@tadmc26.august.net...
>> ']['rull <trullock@yahoo.com> wrote:
>>
>> >im absolutely fine when i have got the page saved, its just making perl
>> >fetch it.
>> >
>> >is this possible?
>>
>>
>> Sure:
>>
>>    use LWP::Simple;   # part of the libwww bundle on CPAN
>>    my $html_page = get 'http://www.perl.com';
>>    # do stuff with $html_page...

>can i use an array so that i can find each line?


A global pattern match in list context will fill an array with "lines":

      my @html_lines = $html_page =~ /(.*\n)/g;

But I caution you about thinking in terms of lines with HTML. Lines
don't mean much there. The entire file could be on one "line"...


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


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

Date: Fri, 19 Oct 2001 08:27:38 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Looking for DOS equiv to pause
Message-Id: <CIIz7.1$r83.44076@news.interact.net.au>


"Lou Moran" <lmoran@wtsg.com> wrote in message
news:9mrtstkh1e2n22vua69am3mbltsb3vprt9@4ax.com...
> On Thu, 18 Oct 2001 08:26:15 +1000, "Tintin" <tintin@snowy.calculus>
> wrote wonderful things about sparkplugs:
>
> SNIP
> >
> >And your limited Perl knowledge is not sufficient to work out how to
change
> >the message?
> >
>
> yup that's the problem

Either I seriously misunderstood you or you're having me on.






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

Date: Thu, 18 Oct 2001 15:36:04 -0700
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: Looking for DOS equiv to pause
Message-Id: <3BCF5954.88B55A21@vpservices.com>

Tintin wrote:
> 
> "Lou Moran" <lmoran@wtsg.com> wrote in message
> news:2d6rstk6foh6ku2lvokkq6b3bbi38ipjqn@4ax.com...
> > On Wed, 17 Oct 2001 15:20:29 +0100, JMT <CCX138@coventry.ac.uk> wrote
> > wonderful things about sparkplugs:
> >
> > SNIP
> > >
> > >print qq(Press any key to continue . . .);
> > ><STDIN>;
> >
> > Good but it would have to print out "Press Enter to continue..."
> >
> > Thanks though.
> 
> And your limited Perl knowledge is not sufficient to work out how to change
> the message?

I think the deal here is not printing the characters "E n t e r" rather
than printing the characters "a n y k e y" but that <STDIN> waits for
the Enter key to be pressed and no other key will do.  So JMT's
suggestion above doesn't answer Lou's question since DOS pause will
accept any key.  The other answers in the thread (to use Term::ReadKey),
however, will work to do what Lou wants.

This all reminds me of the old (possibly apocryphal) story of the luser
who said to the trainer "But I don't see a key labeled 'Any', how can I
press it?"

-- 
Jeff



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

Date: Thu, 18 Oct 2001 22:42:48 GMT
From: Michael Slass <mikesl@wrq.com>
Subject: Re: Looking for DOS equiv to pause
Message-Id: <m3y9m8h8ns.fsf@thneed.na.wrq.com>

"Tintin" <tintin@snowy.calculus> writes:

>> >And your limited Perl knowledge is not sufficient to work out how to
>change
>> >the message?
>> >
>>
>> yup that's the problem
>
>Either I seriously misunderstood you or you're having me on.


From earlier in this thread:

,----
| On Wed, 17 Oct 2001 15:20:29 +0100, JMT <CCX138@coventry.ac.uk> wrote
| wonderful things about sparkplugs:
| 
| SNIP
| >
| >print qq(Press any key to continue . . .);
| ><STDIN>;
| 
| Good but it would have to print out "Press Enter to continue..." 
| 
| Thanks though.
`----


So I think the OP is pointing out that <STDIN> means you have to hit
Enter to continue, and he wants to hit _any key_ to continue.  I doubt
that he couldn't figure out how to change the text between the
quotation marks.

So "how do you do character at a time input?" seems to be the real
issue here.

-Mike


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

Date: Thu, 18 Oct 2001 23:15:07 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: need value of struct for system()
Message-Id: <slrn9sulnt.qf2.tadmc@tadmc26.august.net>

MJ <bogus@bogus.com> wrote:
>I have a structure:
>
>   struct vc_struct => {										
>	vm1     =>      '$',
>   };


That looks like the C language. Are you doing XS here?


>How do I refer vm1 to do a system call?  
>
>I try:
>
>	if ( system("rcp $RCCVAR/$vc->vm1 $system1:$RCCVAR/$vc->vm1") ) {
>             # code to print error
                     ^^^^^^^^^^^^^^

Code in this block executes when there is NO error!

You want either

   unless ( system...
or
   if ( ! system...
or
   if ( system... != 0 )


>             return 1;
>	}


That looks like the Perl language.

We can't help you much though because you didn't show what is in
$RCCVAR or $vc...


>But I get an error:
>
>sh: syntax error at line 1: `(' unexpected
 ^^
 ^^

But you are getting errors from the _shell_.


>Any suggestions?

What are you doing? Are you programming in C or in Perl or in shell?

Do you want to "convert" the C into the equivalent Perl?

That can't be, because if it was, before posting you would have tried:

    perldoc -q struct

and would have already seen:

   "How can I make the Perl equivalent of a C structure/C++
    class/hash or array of hashes or arrays?"

So you must be asking something else, but what?

Even your Subject leaves me wondering what you are talking about.

There is no struct associated with Perl's system() function.

Please try explaining it again.


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


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

Date: Thu, 18 Oct 2001 20:04:16 -0200
From: Alessandro Augusto <ra990866@ic.unicamp.br>
Subject: Perl remote communication - Is it tcp port, netbios or what?
Message-Id: <Pine.GSO.4.10.10110182003530.11757-100000@tigre.dcc.unicamp.br>

I would like to know what kind of communication does Perl uses
to connect to remote computers?

I use Win32::TieRegistry. Does it uses TCP/IP? Netbios? what
port does it use? RPC?

I don't understant what kind of communication does it use, because
using the modules, you just have to specify the remote computers
names, and I don't know whats under it.

Can someone give me a brieth explanation about it?

Ps. I'm asking because, suppose it use some especify tcp port, i
can create a IPSec policy for the communication between my computers
when using the perl scripts.

Thank you,
Alessandro




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

Date: Thu, 18 Oct 2001 23:45:24 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: precedence question
Message-Id: <slrn9suqck.e62.mgjv@verbruggen.comdyn.com.au>

On Thu, 18 Oct 2001 12:33:58 GMT,
	Dave Tweed <dtweed@acm.org> wrote:
> Martien Verbruggen wrote:
>> You can't deduce perl's behaviour from how an 'equivalent' C program
>> behaves.
> 
> I know. I was merely pointing out another example of how you can't
> predict execution sequence from how you might think a parser works.

I know, and that was exactly why I jumped in :). Using another
language as an example doesn't work. 

As said already, in C and C++ expressions like the ones discussed are
undefined.

But, for example, the evaluation of these sorts of expressions in Java
is well-defined. When the language was designed, the fact that this
sort of thing was ambiguous in C and C++ prompted the language
designers to make sure that Java didn't have that problem. 

Neither of these two facts says anything about how this might be
handled in a fourth language. I always find it confusing when people
drag in other languages when discussing operator precedence,
associativity and evaluation order, because subtle differences in
either of these three may make any analogy totally invalid. Any
analogy will only serve to confuse.

Perl, unlike the languages above, has no formal specification. Until
Larry speaks out on this issue (and maybe he has), it isn't really
possible to say what is correct or isn't [1]. In situations like
these, I always find it wise to avoid these ambiguities.

Martien

[1] Even if he uses these constructions himself, that doesn't mean
anything. To use another analogy with another language designer: K&R2
contains code that casts malloc, which everyone agrees (including
Ritchie) is a bad thing).
-- 
Martien Verbruggen              | 
                                | The gene pool could use a little
Trading Post Australia Pty Ltd  | chlorine.
                                | 


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

Date: Thu, 18 Oct 2001 23:15:06 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Regex: extracting repeating values like x=a,b,c,d
Message-Id: <slrn9sukt7.qf2.tadmc@tadmc26.august.net>

Alexander Farber (EED) <eedalf@eed.ericsson.se> wrote:

>I'm trying to extract the hex addresses from strings like this:
>
>  PCORR:BLOCK=V5CCH,IA=H'22EF&H'2354&H'4BD4&H'4C4B&H'4D52&H'4DC9;

[ snip code and code adjustments ]

>But then it would also match "lonely" strings like BLAH&H'4BD4 
>also when they are not prepended by the assignment IA=...
>
>I wonder if there are some nice ways to solve this problem or 
>should I construct some (?<=IA=...) monster? 


Can there be more than one "IA=" or "IS=" on a line?

My solution assumes you do not have more than one per line.

I'd destroy the string (make a copy to destroy if you will need
it later):


   if ( s/(.*)\bI[AS]=/&/ ) {  # "trick" the edge case
      push @addr, /\G&H'([0-9A-F]{1,4})/g;
   }


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


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

Date: Thu, 18 Oct 2001 16:11:15 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Regular expression and grep
Message-Id: <3bcf618a@news.microsoft.com>

"Paul Shinn" <pshinn@mail1.sas.upenn.edu> wrote in message
news:9qnmkp$a7h$1@netnews.upenn.edu...
> [...]
> name in file2.  It's like grepping but getting everything else that
> you're grepping for.  Thanks ahead of time.

Maybe I'm thinking to simple but if I understand your correctly then the
result of your grep should return all items which are _not_ matched?
Well, that would be easy. Perl grep accepts expressions, not just REs only.
Therefore you can simply preceed the RE with a "not" (!) and be done.

Hope this helps

jue




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

Date: Thu, 18 Oct 2001 23:15:08 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: rename return value
Message-Id: <slrn9sulsf.qf2.tadmc@tadmc26.august.net>

Andrew Fry <arfry@lineone.net> wrote:

>What's
>going on ?


Show us the relevant part (the rename() calls) of your code 
and we will try and help you fix it.


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


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

Date: Thu, 18 Oct 2001 23:33:52 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Scaling a DNA string
Message-Id: <slrn9supn0.e62.mgjv@verbruggen.comdyn.com.au>

On Thu, 18 Oct 2001 20:52:05 -0000,
	David Wall <darkon@one.net> wrote:
> mgjv@tradingpost.com.au (Martien Verbruggen) wrote on 18 Oct 2001:
>> 
>> The more repetition there is, the more compression you get. You could
>> even consider not putting the minuses in.
>> 
>> 3 C4 1 G5 2 C7 2 G8 2 C4 2
> 
> Now I feel silly.  I like this idea better than what I did first, but with 
> a slight modification:

Looks good too. 

I just assumed that the original poster's main goal was to get some
decent compression, so that the data woiuldn't look as large anymore.
Your's is much more readable than mine, of course :)

I think it's probably time for the OP to speak up and make sure that
we don't go off on wild tangents that are unrelated to what is wanted.
There are quite a few ideas in this thread that they could use. Witha
bit of picking and choosing they should be able to get the better
idea.

From a clean readable reporting point of view, I think your solution
wins hands down :)

Martien
-- 
Martien Verbruggen              | 
                                | 
Trading Post Australia Pty Ltd  | Curiouser and curiouser, said Alice.
                                | 


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

Date: 18 Oct 2001 15:14:01 -0700
From: analysergreat@hotmail.com (analyser)
Subject: scripting File access problem
Message-Id: <72216665.0110181414.498c3afb@posting.google.com>

hi,
 
  i am having some problems with the script below.. purpose of the
script is to print out access dates of files with its owners from the
directory and the subdirectory WITHOUT CHANGING THE ACCESS DATES. but
after i added the perms module for accessing the dates somehow the
access dates get changed while checking. and i have no clue.. on to
what happened.. any clues or suggestions.




use File::Find;
use FileHandle;
use Win32::Perms;
$| = 1;

print ("Enter No.of days :");
$diff =<STDIN>;

get_time();
open(FD, ">C:\\sibifire.txt") || "Cannot open file\n";
printf FD ("Here is an output line.\n");
find(\&wanted, 'c:\');

close FD;  

sub wanted{
    return if ( /^\.{2}/ );
    return if ( /^\.{1}/ );
    return if -d $_;
    my @MyStat   = stat($_);
    return if ( $MyStat[8] > $DateDiff );
    my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime($MyStat[8]);
    $mon++;
    my $MyAccessDate = sprintf "%02d/%02d/%02d-%02d:%02d:%02d",
$mon,$mday,($year % 100),$hour,
                                                                      
             $min, $sec;
    my $perms = new Win32::Perms($File::Find::name);
	

            
    print  FD join ('@', $File::Find::name, $MyAccessDate ,
$perms->Owner() ), "\n" ;
    print  join ('@', $File::Find::name, $MyAccessDate ,
$perms->Owner() ), "\n" ;
    
 }
 
sub get_time {
    $diff = 86400 * $diff;
    ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) =
localtime(time - $diff);
    $mon++;
    $DateDiff = time;
    $DateDiff -= $diff;
    $diff = 0;
    
 }  # end of get_time


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

Date: Fri, 19 Oct 2001 00:36:43 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: sendmail not sending mail anymore
Message-Id: <slrn9sutcr.rar.efflandt@typhoon.xnet.com>

On Thu, 18 Oct 2001 09:52:09 GMT, No Idea <nospam@nospam.com> wrote:
> 
> I was trying out some new Form2Email scripts today and now all of
> a sudden sendmail doesnt want to send mail....
> $mail_flags     = '-oi -t -odq';

See 'man sendmail' and look for -q[time].  If you do not specify a time,
it processes queued mail _once_, and does not send any more queued mail
until the next time it gets a -q (or sendmail is restarted with normal
options that were working).  Totally unrelated to Perl.

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: Fri, 19 Oct 2001 08:34:13 +1000
From: "Tintin" <tintin@snowy.calculus>
Subject: Re: Splitting on value pairs
Message-Id: <NOIz7.2$ik3.185496@news.interact.net.au>


"Michael Budash" <mbudash@sonic.net> wrote in message
news:mbudash-3E96DA.11432418102001@news.sonic.net...

> yours will almost work for the example data you gave (it still leaves
> the double quotes on the datetime), but will break in more general
> cases, such as this:
>
> id=firewall fw=199.9.9.9 src3=199.9.9.9 time="2001-10-14 12:01:05"
>
> however, in situations like yours, you go for what works, and don't
> worry about a perfect solution, eh? 8^)

The WELF spec is well documented and the above example wouldn't occur.




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

Date: Thu, 18 Oct 2001 23:29:10 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Splitting on value pairs
Message-Id: <mbudash-595E1F.16291018102001@news.sonic.net>

In article <NOIz7.2$ik3.185496@news.interact.net.au>, "Tintin" 
<tintin@snowy.calculus> wrote:

> "Michael Budash" <mbudash@sonic.net> wrote in message
> news:mbudash-3E96DA.11432418102001@news.sonic.net...
> 
> > yours will almost work for the example data you gave (it still leaves
> > the double quotes on the datetime), but will break in more general
> > cases, such as this:
> >
> > id=firewall fw=199.9.9.9 src3=199.9.9.9 time="2001-10-14 12:01:05"
> >
> > however, in situations like yours, you go for what works, and don't
> > worry about a perfect solution, eh? 8^)
> 
> The WELF spec is well documented and the above example wouldn't occur.
> 

well, then, kewl!
-- 
Michael Budash ~~~~~~~~~~ mbudash@sonic.net


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

Date: Thu, 18 Oct 2001 23:47:22 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: SV: how can i make perl retreive a web page and save it to my website?
Message-Id: <slrn9suqga.e62.mgjv@verbruggen.comdyn.com.au>

On Thu, 18 Oct 2001 12:41:26 -0500,
	John J. Trammell <trammell@haqq.hypersloth.invalid> wrote:
> On Thu, 18 Oct 2001 18:16:28 +0200, Mr. Mostrom wrote:
>> This is why I like Perl! Its so nice one could cry! :-)
>> 
> 
> Sure, it makes me cry all the time.

It makes a grown man cry...

Now... Didn't someone buy the rights on that sentence from the Stones
a while ago? 

Martien
-- 
Martien Verbruggen              | 
                                | Unix is the answer, but only if you
Trading Post Australia Pty Ltd  | phrase the question very carefully
                                | 


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

Date: 18 Oct 2001 15:17:09 -0700
From: miko@idocs.com (Miko O'Sullivan)
Subject: taint unique to Perl?
Message-Id: <db27ea77.0110181417.261f2ffb@posting.google.com>

I hope this is considered on-topic.  I couldn't find an
everything_except_perl newsgroup.  :-)

Is tainting unique to Perl?  What other languages, if any, have this
cool built-in concept?   I'm writing a presentation about Perl and
I'll use tainting as one of the selling points for Perl, but it would
help to know if any other languages use tainting also.

-Miko
Just another marketer who hacks perl


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

Date: Thu, 18 Oct 2001 23:38:08 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: taint unique to Perl?
Message-Id: <slrn9sumjf.qp2.tadmc@tadmc26.august.net>

Miko O'Sullivan <miko@idocs.com> wrote:
>I hope this is considered on-topic.  I couldn't find an
>everything_except_perl newsgroup.  :-)


But there _is_ a Perl_has_something_no_other_language_has
mailing list  :-)

   http://lists.perl.org/showlist.cgi?name=advocacy


>Is tainting unique to Perl?  


Yes, AFAIK (but maybe I just don't know enough...).


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


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

Date: 18 Oct 2001 16:43:13 -0800
From: yf110@vtn1.victoria.tc.ca (Malcolm Dew-Jones)
Subject: Re: taint unique to Perl?
Message-Id: <3bcf6911@news.victoria.tc.ca>

Miko O'Sullivan (miko@idocs.com) wrote:
: I hope this is considered on-topic.  I couldn't find an
: everything_except_perl newsgroup.  :-)

: Is tainting unique to Perl?  What other languages, if any, have this
: cool built-in concept?   I'm writing a presentation about Perl and
: I'll use tainting as one of the selling points for Perl, but it would
: help to know if any other languages use tainting also.

Javascript used it for a while.  (1.1 ?)


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

Date: Fri, 19 Oct 2001 00:37:04 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: taint unique to Perl?
Message-Id: <slrn9sutdg.e62.mgjv@verbruggen.comdyn.com.au>

On 18 Oct 2001 15:17:09 -0700,
	Miko O'Sullivan <miko@idocs.com> wrote:
> 
> Is tainting unique to Perl?  What other languages, if any, have this
> cool built-in concept?   I'm writing a presentation about Perl and
> I'll use tainting as one of the selling points for Perl, but it would
> help to know if any other languages use tainting also.

The Java sandbox is a security feature that's part of the language,
although its implementation and what it does is very different from
Perl's tainting mechanism.

The idea behind it is also different. Perl's tainting mechanism was
originally created to make setuid programs more secure, while Java's
sandbox model was created to prevent you from accidentally running
malicious code that you download from an untrusted source.

JavaScript has a feature called 'data tainting', but this is slightly
different again.

I don't know of any other languages (or implementations of languages)
with a builtin, or standard set of security features, but that may be
just a shortcoming on my part :)

Martien
-- 
Martien Verbruggen              | 
                                | In a world without fences, who needs
Trading Post Australia Pty Ltd  | Gates?
                                | 


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

Date: Fri, 19 Oct 2001 00:42:51 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: taint unique to Perl?
Message-Id: <slrn9sutob.rar.efflandt@typhoon.xnet.com>

On 18 Oct 2001 15:17:09 -0700, Miko O'Sullivan <miko@idocs.com> wrote:
> I hope this is considered on-topic.  I couldn't find an
> everything_except_perl newsgroup.  :-)
> 
> Is tainting unique to Perl?  What other languages, if any, have this
> cool built-in concept?   I'm writing a presentation about Perl and
> I'll use tainting as one of the selling points for Perl, but it would
> help to know if any other languages use tainting also.

One reason that Perl has taint checking available is because it can 
potentially be run suid as another user (suidperl) and you want to be 
certain of the integrety of any input.  Most systems will not honor suid 
for any other type of scripting (just compiled binaries).

-- 
David Efflandt - All spam is ignored - http://www.de-srv.com/
http://www.autox.chicago.il.us/  http://www.berniesfloral.net/
http://cgi-help.virtualave.net/  http://hammer.prohosting.com/~cgi-wiz/


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

Date: 18 Oct 2001 23:50:20 GMT
From: michael.e.grimes.nospam@fritolay.com
Subject: What changes atime
Message-Id: <9qnprs$33s$1@news.netmar.com>

Howdy,

I am on an NT box and need to write a little script to perform some file
management. In particular, I have an FTP server and once a file has been
accessed, I would like to move it to another directory. I thought fine, I
will work with the stat function's atime variable. Trouble is , I can not
make the variable change unless I edit and save the file (this also changes
the mtime variable). After all, you have to access the file to modify it, but
I don't expect FTP clients to be editing my files!!! I have a test script to
watch what is happening:

#!d:\personal\perl\bin\perl.exe

opendir(DIR,".");
    foreach (readdir(DIR)) {
        next if $_ eq '.' || $_ eq '..' || (-d $_);
        $File=$_;
         if (-f $File) {
	       my ($Atime,$Mtime,$Ctime) = (stat ($File) )[8,9,10];
		if ($Atime == $Ctime) {
		        next;
		} else {
                        my $Now = time;
		        print "$Now - $File - $Atime -$Mtime - $Ctime\n";
			}

        }
    }
    closedir(DIR);

Is there a GURU out there who can tell me what constitutes an "access"
(something that will update the atime variable) or, maybe someone has done
this already and can point me in the right direction.

Thanks for any help,
Mike


 -----  Posted via NewsOne.Net: Free (anonymous) Usenet News via the Web  -----
  http://newsone.net/ -- Free reading and anonymous posting to 60,000+ groups
   NewsOne.Net prohibits users from posting spam.  If this or other posts
made through NewsOne.Net violate posting guidelines, email abuse@newsone.net


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

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.  

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


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