[23395] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5613 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Oct 4 00:05:49 2003

Date: Fri, 3 Oct 2003 21:05:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 3 Oct 2003     Volume: 10 Number: 5613

Today's topics:
    Re: hack a telnet server? <ddunham@redwood.taos.com>
    Re: need to go back three lines after a match  (Tad McClellan)
    Re: need to go back three lines after a match <kuujinbo@hotmail.com>
    Re: REGEX  (Not allowing file extenstions) or the dot <sts@news.sts>
    Re: REGEX  (Not allowing file extenstions) or the dot <sts@news.sts>
    Re: Unexpected alteration of array's content (Charles DeRykus)
    Re: Unexpected alteration of array's content (Charles DeRykus)
    Re: where am my()? <gpatnude@adelphia.net>
    Re:  <bwalton@rochester.rr.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sat, 04 Oct 2003 01:13:50 GMT
From: Darren Dunham <ddunham@redwood.taos.com>
Subject: Re: hack a telnet server?
Message-Id: <i9pfb.288$652.43720898@newssvr21.news.prodigy.com>

smackdab <smackdab1@hotmail.com> wrote:

> Oh, I thought if you used a Telnet client, then the server side of
> your application (IO::Socket, accept(), etc.) needed to understand
> and negotiate binary "stuff" to sync up.  Is this not necessary?

To some extent, no.

I've tested simple ASCII "servers" with a generic telnet client.  The
only real problem I've run into is that without the binary negotiation,
most clients will default to "line mode" and only deliver a line of data
to the server.  A telnet man page might mention that.

In your case, that might be just fine.  However if you were looking for
the user to type 'g' (and not return), you'd never see the data.  Some
telnet clients may be able to modify that behavior locally.  

Don't let that behavior make you lazy on the server side.  Be sure to
read data with the possibility of reading only partial lines at a time
in mind.

-- 
Darren Dunham                                           ddunham@taos.com
Unix System Administrator                    Taos - The SysAdmin Company
Got some Dr Pepper?                           San Francisco, CA bay area
         < This line left intentionally blank to confuse you. >


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

Date: Fri, 3 Oct 2003 19:52:48 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: need to go back three lines after a match 
Message-Id: <slrnbns6f0.27u.tadmc@magna.augustmail.com>

Andrew Rich <vk4tec@hotmail.com> wrote:

> I was thinking of sampling three rows at a time


Then read three rows each time:

   while ( my $line1 = <> ) {
      my $line2 = <>;
      my $line3 = <>;

      # do stuff with the 3 lines
   }


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


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

Date: Sat, 04 Oct 2003 10:01:17 +0900
From: ko <kuujinbo@hotmail.com>
Subject: Re: need to go back three lines after a match
Message-Id: <bll68e$8do$1@pin3.tky.plala.or.jp>

Eric Schwartz wrote:

> ko <kuujinbo@hotmail.com> writes:
> 
>>Andrew Rich wrote:
>>
>>>Howdy,
>>>I have a need to do this :-
>>>1. find a match
>>>2. go back three lines
>>>3. read out lines 1 2 3
>>
>>You could read the file into an array and reverse() the array (read
>>the file backwards). When you find your match, print it and the next
>>two lines. Since the array (lines in the file) is already reversed,
>>you don't have to backtrack
> 
> 
> But that would print them out backwards.  You could save the three
> lines in an array, reverse it, and then print it out, I suppose.  I'd
> rather just keep a two-line buffer. :)
> 
> -=Eric

I was thinking of something (not that its better/more efficient than 
keeping the two-line buffer, just different) like :

my @reversed = reverse <FH>;
my $index = 0;
foreach (@reversed) {
   if (/PATTERN/) {
     print reverse(@reversed[$index .. ($index + 2)]);
     last;
   }
   ++$index;
}

Thanks for pointing out what I should have in my explanation :)



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

Date: Sat, 04 Oct 2003 03:38:38 GMT
From: "sts" <sts@news.sts>
Subject: Re: REGEX  (Not allowing file extenstions) or the dot
Message-Id: <2hrfb.9913$bp.6813@newssvr32.news.prodigy.com>

Yes as a matter of fact it does. I am in the proecess of compiling PERL into
Quake to help with web statistical reporting of the server
and of games.

"Eric J. Roode" <REMOVEsdnCAPS@comcast.net> wrote in message
news:Xns9409D2CECE05Fsdn.comcast@206.127.4.25...
> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
>
> <sts@news.sts> wrote in
> news:dcnfb.5595$sn1.2155@newssvr16.news.prodigy.com:
>
> > REGULAR EXPRESSION
> >
> > PROGRAM: Quake2
> > CODE: C+
> ...
> > anyhelp with this is very much appreciated.
> >
> > vynum
>
> Does your problem have anything at all to do with Perl?  Not so far as I
> could tell.
>
> - -- 
> Eric
> $_ = reverse sort $ /. r , qw p ekca lre uJ reh
> ts p , map $ _. $ " , qw e p h tona e and print
>
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
>
> iQA/AwUBP34XqWPeouIeTNHoEQIS+gCg0lvKYbOuis6TbMDRb8yqBKmXPFUAoPyL
> hZbmPqi53Ug26MOdKb2HIYkA
> =bGcP
> -----END PGP SIGNATURE-----




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

Date: Sat, 04 Oct 2003 04:01:38 GMT
From: "sts" <sts@news.sts>
Subject: Re: REGEX  (Not allowing file extenstions) or the dot
Message-Id: <CCrfb.9916$Wo.6582@newssvr32.news.prodigy.com>


"Darren Dunham" <ddunham@redwood.taos.com> wrote in message
news:DOnfb.270$%S1.42855670@newssvr21.news.prodigy.com...
> sts@news.sts wrote:
> > ;RE:^say.*
>
> > I DO NOT WANT TO ALLOW THIS: ".bsp" QUAKE SERVER ONLY NEEDS THE MAP NAME
WHICH IS THE NAME OF THE FILE AND
> > NOT THE '.' NOR THE 'BSP'. I WANT TO TOTALLY BAN, ".BSP" part of the
client's command sent to the server.
>
> > lrcon map map q2dm1.bsp
>
> The question I have is whether you have any command where a period
> should appear.

No. Only the filename of the map without any extenstion or period attached
to the string.


> If you don't, then just ban all periods.
This is almost exactly what I want to do. I want to ban or should I say
ignore by regular expression , the period, and anything that follows after
the period.
The only thing I want allowed is, [a-z/A-Z] and all numbers 1 thru 0's are
allowed. Another words, at this point, guys who connect to play the game
are allowed to pass any string command, EXECEPT in this very special
scenerio were lrcon is used.

Maybe I should explain what exactly is taking place. John Doe connects and
types the following:

lrcon map map q2dm1

I will break the above down.

lrcon = tells the quake2admin .dll that an rcon is used and the dll is now
wating for what command?

map = map tells the quake2admin dll that the "map" command to change maps is
to be used.

map = the last "map" is the public password. Now the quake2admin is now
waiting for one more peice of information. What map should it change to?
          this is were I want the regular expresion to start filtering , if
you will, what is allowed and what should be ignored.

So, this is going to be kinda of a weird way to explain it but once you see
it I think you will get the idea.

Everything outside the ( ) is allowed. Anything within the parenthasis
should be disallowed, ignored.

lrcon map map q2dm1(.bsp)  The dot and the file extention or ANY extension
should be banned by regular expression. q2dm1 is just a name of a map.


  The problem is
> that periods are usually special in regular expressions, and I can only
> guess that this module and perl use similar syntax.
>
> RE:\.        # Ban any command with a period.
>
> If that's too limiting, then this (might) ban anything starting with
> lrcon that has a period elsewhere on the line.
>
> RE:^lrcon.*\.
>
> Again, syntax issues for RE are very dependent on what engine is in
> use.  Hopefully a backslash escapes the period here, but it might not.
>
> It is possible that
> RE:^lrcon.*[.]
> would work if the above did not..
>
Does the above mean that they can type anything starting with lrcon and
anything there after, but if a dot is used any were inside the string
oranything after the dot
is disallowed? IF so,  then this is exactly what I want.
> -- 
> Darren Dunham                                           ddunham@taos.com
> Unix System Administrator                    Taos - The SysAdmin Company
> Got some Dr Pepper?                           San Francisco, CA bay area
>          < This line left intentionally blank to confuse you. >




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

Date: Sat, 4 Oct 2003 00:36:48 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Unexpected alteration of array's content
Message-Id: <HM7J1C.C72@news.boeing.com>

In article <u9oewydvo3.fsf@wcl-l.bham.ac.uk>,
Brian McCauley  <nobull@mail.com> wrote:
>...
  >> for (@array) {
  >>     local $_ = $_;
  >>     $_++;
  >> print "Affected $_\n";
  >> }
  >> print join('', @array), "\n";
>
>By rights that should modify each of the elements of @array in turn
>but put them back afterwards.  That's not what it does in current
>versions of Perl but maybe one day it will.
>

Hm, I'm not sure I understand "modify each of the elements of @array in 
turn but put them back afterwards"  ...?  
 
Are you suggesting that, even if $_ is localized, any changes
will still affect @array within that scope..?  (I thought that
localization was intended to prevent such modification altogether...)   

Or were you saying something entirely different?


--
Charles DeRykus


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

Date: Sat, 4 Oct 2003 00:49:44 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: Unexpected alteration of array's content
Message-Id: <HM7JMw.CMn@news.boeing.com>

In article <HM7J1C.C72@news.boeing.com>,
Charles DeRykus <ced@bcstec.ca.boeing.com> wrote:
>In article <u9oewydvo3.fsf@wcl-l.bham.ac.uk>,
>Brian McCauley  <nobull@mail.com> wrote:
>>...
>  >> for (@array) {
>  >>     local $_ = $_;
>  >>     $_++;
>  >> print "Affected $_\n";
>  >> }
>  >> print join('', @array), "\n";
>>
>>By rights that should modify each of the elements of @array in turn
>>but put them back afterwards.  That's not what it does in current
>>versions of Perl but maybe one day it will.
>>
>
>Hm, I'm not sure I understand "modify each of the elements of @array in 
>turn but put them back afterwards"  ...?  
> 
>Are you suggesting that, even if $_ is localized, any changes
>will still affect @array within that scope..?  (I thought that
>localization was intended to prevent such modification altogether...)   
>
>Or were you saying something entirely different?
>

Sorry, to follow my own post but I think now I see the logic. 
Since $_ is an alias, any alternations within that scope should 
affect the original array (although that's not the current practice)...  

--
Charles DeRykus


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

Date: Sat, 04 Oct 2003 02:37:04 GMT
From: "Greg Patnude" <gpatnude@adelphia.net>
Subject: Re: where am my()?
Message-Id: <knqfb.1744$qj6.1356099@news1.news.adelphia.net>

Its because you declare my $var WITHIN a subroutine.... read a book....

-- 
Greg Patnude / The Digital Demention
2916 East Upper Hayden Lake Road
Hayden Lake, ID 83835
(208) 762-0762

"Ben Dover - Mental Patient 0057"
<Ben_Dover@psychiatric-center.Bellevue-Hospital.com> wrote in message
news:3F7C4A6E.24C29214@psychiatric-center.Bellevue-Hospital.com...
> where am my()?
>
> @db=some db file;
> sub test {
>     foreach $list ($file1,$file2,$file3){
> foreach (@db){
>     my($var); <--if my defined here
>     if ($countTD > $linesPerColumn){
> if ($countTR > $columnsPerPage){
>                      $var=1234; <---and used here
> }
> print "<td valign=\"top\"><u><b>$var</b></u>\n"; <--why won't it show
> up here?
>     }
>     if ($_ =~ m/category:/){
>     }
>     if ($_ =~ m/;;/){
>     }
>
> }
>     }
> }
>
> isn't my defined at a broad enough location?




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

Date: Sat, 19 Jul 2003 01:59:56 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: 
Message-Id: <3F18A600.3040306@rochester.rr.com>

Ron wrote:

> Tried this code get a server 500 error.
> 
> Anyone know what's wrong with it?
> 
> if $DayName eq "Select a Day" or $RouteName eq "Select A Route") {

(---^


>     dienice("Please use the back button on your browser to fill out the Day
> & Route fields.");
> }
 ...
> Ron

 ...
-- 
Bob Walton



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

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


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