[18404] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 572 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Mar 27 03:05:45 2001

Date: Tue, 27 Mar 2001 00:05:18 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <985680317-v10-i572@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 27 Mar 2001     Volume: 10 Number: 572

Today's topics:
    Re: acceccing files on localhost ? <thomastk@prodigy.net>
        beginner's perl question <dwwang@uiuc.edu>
    Re: beginner's perl question (Chris Fedde)
    Re: CGI style - CGI vs "here is" vs ?? <bart.lateur@skynet.be>
    Re: Email do not show up in MYSQL <thomastk@prodigy.net>
    Re: find & replace question <thomastk@prodigy.net>
    Re: FOREACH little victory, I take a beating <thomastk@prodigy.net>
    Re: Help please. (Damian James)
    Re: Help please. <thomastk@prodigy.net>
        indent logging msgs by function call level? <mathias@koerber.org>
        More Help please :-) nospam@thank.you
    Re: one-liner assignment from regex <thomastk@prodigy.net>
    Re: Perl is much simpler than it looks! <gtoomey@usa.net>
    Re: Perl is much simpler than it looks! (Tim Hammerquist)
    Re: Regex to quote XML attributes? (Chris Fedde)
        require question; data structure for rules <dugan@leland.stanford.edu>
    Re: Sockets <acki@ivu.de>
    Re: Sort messes up? <jonni@ifm.liu.se>
    Re: Sub String <thomastk@prodigy.net>
    Re: system() return value <kellyboy@nospanner>
        Using Sunfreeware's perl in place of Sun's perl <och@nym.alias.net>
    Re: Using Sunfreeware's perl in place of Sun's perl (Mike Horwath)
    Re: WebCT help (David H. Adler)
        What way is 'better' ? <christoph.neubauer@siemens.at>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Mon, 26 Mar 2001 22:46:37 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: acceccing files on localhost ?
Message-Id: <99pcaf$6rs2$1@newssvr06-en0.news.prodigy.com>

You should be able to access files outside cgi-bin if permissions are set.
Check if your script runs and returns html headers. Also you may want to
trap errors and see what is going on. It could be a permission problem most
probably. The user a/c under http server runs should have the privileges.

"kellyboy" <kellyboy@nospanner> wrote in message
news:tc0666t4i57jc9@corp.supernews.com...
> My home network is behind firewall..
>
> Im writing script to list all image file in directory I supplied via
> form...but dont seem to work...got "Internal Server Error"
>
> is it because it limit the file access outside of cgi-bin?
>
> here's the script:
> #!/usr/local/bin/perl -w
>
> use CGI qw(:standard);
>
> print header, start_html("Graphic Explorer");
>
> if (param()) {
>  my $pathname = param("dir");
>  chomp($pathname);"
>  my @files = glob("$pathname/*.png");
>  foreach $pix (@files) {
>   print img(src=>$pix);
>   print p("$pix\n");
>  }
> else {
>  print p("Enter path to display .png files");
>  print hr();
>  print start_form();
>  print p("Pathname: ", textfield("dir"));
>  print p(submit("Get"). reset("Clear"));
>  print end_form(),hr();
> }
> print end_html;
>
> how do I get to that directory that is outside of /usr/local/apache?
>
> security is not much of a issue for me because im behind firewall and Im
the
> only person in this house using the computer
>
> kellyboy
> --
>
>
>




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

Date: Tue, 27 Mar 2001 01:03:42 -0600
From: David Wang <dwwang@uiuc.edu>
Subject: beginner's perl question
Message-Id: <Pine.GSO.4.10.10103262311270.9405-100000@ux13.cso.uiuc.edu>

I have a question about how to remove a block of code from a particular
file, the block of code would start with some string x and end with some
string y.

so the pseudocode would be open the file for update, then read each line
until x is found, then delete that line and lines that follow until y is
read, then delete that last line and then repeat the process. I know this
is very simple but I just can't figure it out despite having read the
lhama book and the cookbook. 

this is what i have so far for pseudocode, but I'm not sure how to search
for one string within a line, and iterate thru all the lines in a file.
Please help or try to translate into regular experession or proper Perl
syntax. thanks!

while (<FILEHANDLE>)	#when !EOF
{
 scannextline; 	#not sure how to do this, scan one line at a time
 if (anystring_on_the_line==$x) #starting delimiter for code block
    BOOLEAN strip = true;
 while (strip)
 {
   deleteline;  #again not sure how to delete the whole line
   scannextline;
   if (anystring_on_the_line == $y) #the closing delimiter
   { deleteline; strip = false;}
 }
}




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

Date: Tue, 27 Mar 2001 07:50:24 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: beginner's perl question
Message-Id: <4DXv6.326$T3.189565440@news.frii.net>

In article <Pine.GSO.4.10.10103262311270.9405-100000@ux13.cso.uiuc.edu>,
David Wang  <dwwang@uiuc.edu> wrote:
>I have a question about how to remove a block of code from a particular
>file, the block of code would start with some string x and end with some
>string y.
>

You could use a traditional algorithm like the one you posted or
you could use a couple of the notational conveniences of Perl to
work around lots of that CS-101 cruft.  

#!/usr/bin/perl 
#

(/^skip/../^_skip/) or print while (<DATA>)

__END__
       For ease of access, the Perl manual has been split up into
       several sections:

	   perl 	       Perl overview (this section)
	   perldelta	       Perl changes since previous version
	   perl5005delta       Perl changes in version 5.005
	   perl5004delta       Perl changes in version 5.004
	   perlfaq	       Perl frequently asked questions
	   perltoc	       Perl documentation table of contents
skip
	   perldata	       Perl data structures
	   perlsyn	       Perl syntax
	   perlop	       Perl operators and precedence
	   perlre	       Perl regular expressions
	   perlrun	       Perl execution and options
	   perlfunc	       Perl builtin functions
	   perlopentut	       Perl open() tutorial
	   perlvar	       Perl predefined variables
	   perlsub	       Perl subroutines
	   perlmod	       Perl modules: how they work
	   perlmodlib	       Perl modules: how to write and use
	   perlmodinstall      Perl modules: how to install from CPAN
	   perlform	       Perl formats
	   perlunicode	       Perl unicode support
	   perllocale	       Perl locale support
_skip
	   perlreftut	       Perl references short introduction
	   perlref	       Perl references, the rest of the story
	   perldsc	       Perl data structures intro
	   perllol	       Perl data structures: arrays of arrays
	   perlboot	       Perl OO tutorial for beginners
	   perltoot	       Perl OO tutorial, part 1
	   perltootc	       Perl OO tutorial, part 2
	   perlobj	       Perl objects
	   perltie	       Perl objects hidden behind simple variables
	   perlbot	       Perl OO tricks and examples
	   perlipc	       Perl interprocess communication
	   perlfork	       Perl fork() information
	   perlthrtut	       Perl threads tutorial
	   perllexwarn	       Perl warnings and their control
	   perlfilter	       Perl source filters
	   perldbmfilter       Perl DBM filters
-- 
    This space intentionally left blank


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

Date: Tue, 27 Mar 2001 08:00:42 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: CGI style - CGI vs "here is" vs ??
Message-Id: <fuh0ct4fpj9hvj3aourmnpgm9grdqpp66g@4ax.com>

pt <mnemotronic@mind\no-spam/spring.com> wrote:

>   A basic CGI style question : are there any Widely Accepted Practices
>for creating the "static" sections of a web page which don't require the
>services of a CGI?  It seems that lots of calls to CGI would be less
>efficient than a "here is" document with the HTML, or slurping an
>external file, or other methods (do tell).  Nothing in perlstyle, and
>the style section in CGI only discusses OO vs. function calls.

Are you talking about the module? Building the HTML from scratch using
the built-in tag-emulating (element-generating) functions?

Yuck.

That's my personal opinion about it.

But if you must use it, restrict it to the minimum. I wouldn't dream of
reconstructing a designer created HTML page into CGI function calls.
Limit it to the dynamic parts, those that are difficult to get correct
for all data cases without such helping functions.

For the rest, I always use here-docs. In fact, I use here-docs for
everything. But that's just my personal preference again.

-- 
	Bart.


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

Date: Mon, 26 Mar 2001 22:20:49 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Email do not show up in MYSQL
Message-Id: <99paq8$6r8k$1@newssvr06-en0.news.prodigy.com>

How do you parse the value in your Perl script? You get this due to encoding
and if you use param() method of CGI.pm module, you must get the values
decoded correctly (as you enter in the form).

"Victor Prasad" <vivekvp@spliced.com> wrote in message
news:3ABF2189.6DD2C803@spliced.com...
> Hello,
>
> I am trying to use an HTML form to a perl script to pass an email
> address in the form:
>
> test@test.com
>
> It shows up in the database and perl script as:  test%40test.com
>
> I am using the POST method - how do I get it to enter it correctly?
>
> Thanks,
>
> V
>




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

Date: Mon, 26 Mar 2001 22:54:15 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: find & replace question
Message-Id: <99pcom$17q0$1@newssvr06-en0.news.prodigy.com>

I think the s/\'//g construct effectively tests for ' and replace it. right?
So what is the point in you test and then replace? Both are same I guess. I
would go with first as it is elegant.

"B McDonald" <plz@righthere.com> wrote in message
news:1iQv6.63$224.88839@news.pacbell.net...
>
> Hi. What is better: to test for the presence of a character in a string
> before replacing it, or to just attempt the substitution without testing?
>
> For example, I have a string that can take on one of the following values:
>
>     Attorneys Eyes Only
>     Attorneys' Eyes Only
>
> The preferred XML encoding of the security level is without the
apostrophe.
>
> So, should I just do this...
>
>     $securitylev =~ s/\'//g;
>
> Or should I test it first?
>
> Brian
>
>




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

Date: Mon, 26 Mar 2001 22:14:07 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: FOREACH little victory, I take a beating
Message-Id: <99padm$6oma$1@newssvr06-en0.news.prodigy.com>

I wished you descried your problem clearly. Looks like you have some simple
problem, but hard to understand that from this description.

"Nancy" <pigpen@easynews.com> wrote in message
news:NcAv6.2677$dM.549831@news.easynews.com...
> I have the following foreach statement that I can't beat into submission.
It
> reads @orders just fine and prints each line of the output properly, but I
> also need to look at each line, and set a corresponding variable.  The
best
> I can come up with only seems to be reading the last line of @orders to
set
> the variables, but otherwise processes each line properly.  BTW, there
will
> never be more than 4 lines in @orders.  What basic concept am I failing to
> grasp here?
>
> my ($i)=0;
> foreach $line (@orders) {
>    ($qty, $item, $desc, $price, $ship, $taxit, $ship_boxes, $page_title,
> $plex, $originals) = split (/$delimit/, $line);
>
>          if ($item eq 'Cover Charges') {$msg_cov = 0;  } else {  $msg_cov
=
> 1;  }
>          if ($item eq 'Inserts') {$msg_ins = 0;  } else {  $msg_ins =
;  }
>          if ($item eq 'Finishing') {$msg_fin = 0;  } else {  $msg_fin =
> ;  }
>                 ++$i;
> print " A lot of the data in a pretty format. \n";
> }
>
> TIA!
> nan-
>
>




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

Date: 27 Mar 2001 05:35:38 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Help please.
Message-Id: <slrn9c09k6.cnu.damian@puma.qimr.edu.au>

nospam@thank.you chose Tue, 27 Mar 2001 04:46:08 GMT to say this:
>
>... This works fine at the moment but is
>it possible to locate the list file somewhere other than in the
>cgi-bin or a cgi-bin sub-directory - 

Of course, so long as you give your program write permission to that
directory. You just specify /absolute/path/to/directory. 

>In other words I'd like to
>store/host the list file in another domain. eg.
>www.somewhere.else.com/list/list.txt

This is another question entirely. When you use your favourite word
processor program, does it let you save your file to
www.somewhere.else.com/etc ? How would you, instead, set about putting your
file in that location? You are addressing the same situation here.

>I'm currently using;
>
>$file = "maillist/maillist.txt";
>
>to store the file name .
>

So that would be in /path/to/server/root/cgi-bin/mailist/
Did you try just putting it somewhere else on the same machine? 

>Thanks in advance :-)

You're welcome.

HTH

Cheers,
Damian
-- 
@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
Just another Perl Hacker


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

Date: Mon, 26 Mar 2001 22:40:53 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Help please.
Message-Id: <99pbvn$50h4$1@newssvr06-en0.news.prodigy.com>

You must be able to read it thru HTTP calls (using UserAgent or something).
But updating may not be possible.

<nospam@thank.you> wrote in message
news:3ac018ec.34395177@news.freeserve.co.uk...
> Hi,
>
> I've written a simple Perl script which creates an emailing list ie, a
> user enters their email address into a html form, the script adds
> their email address to the list. This works fine at the moment but is
> it possible to locate the list file somewhere other than in the
> cgi-bin or a cgi-bin sub-directory - In other words I'd like to
> store/host the list file in another domain. eg.
> www.somewhere.else.com/list/list.txt
>
> I'm currently using;
>
> $file = "maillist/maillist.txt";
>
> to store the file name .
>
>
> Thanks in advance :-)




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

Date: Tue, 27 Mar 2001 15:22:58 +0800
From: Mathias Koerber <mathias@koerber.org>
Subject: indent logging msgs by function call level?
Message-Id: <kjb0ct4koapqlkqdenjbum8fs0ka6i1alq@4ax.com>

I need to debug a lengthy program with many nested function calls.

Is there any tool (module etc) which can assist in formatting
error/debug/log messages such that they are indented apropriately
to the evel of function (or loop etc) called?

thanks


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

Date: Tue, 27 Mar 2001 06:51:35 GMT
From: nospam@thank.you
Subject: More Help please :-)
Message-Id: <3ac037a3.42257783@news.freeserve.co.uk>

Thanks for the pointers :-) Much Appreciated

Another quick one,

I've sorted the list of email address with the script and the
resulting file has duplicates :-( Is there a quick way of removing the
duplicate lines? While the script is sorting the list? I'm using;

@newvalue = sort @value;

to sort the list.


Once again thanks in advance :-)



On 27 Mar 2001 05:35:38 GMT, damian@qimr.edu.au (Damian James) wrote:

>nospam@thank.you chose Tue, 27 Mar 2001 04:46:08 GMT to say this:
>>
>>... This works fine at the moment but is
>>it possible to locate the list file somewhere other than in the
>>cgi-bin or a cgi-bin sub-directory - 
>
>Of course, so long as you give your program write permission to that
>directory. You just specify /absolute/path/to/directory. 
>
>>In other words I'd like to
>>store/host the list file in another domain. eg.
>>www.somewhere.else.com/list/list.txt
>
>This is another question entirely. When you use your favourite word
>processor program, does it let you save your file to
>www.somewhere.else.com/etc ? How would you, instead, set about putting your
>file in that location? You are addressing the same situation here.
>
>>I'm currently using;
>>
>>$file = "maillist/maillist.txt";
>>
>>to store the file name .
>>
>
>So that would be in /path/to/server/root/cgi-bin/mailist/
>Did you try just putting it somewhere else on the same machine? 
>
>>Thanks in advance :-)
>
>You're welcome.
>
>HTH
>
>Cheers,
>Damian
>-- 
>@;=0..23;@;{@;}=split//,<DATA>;while(@;){for($;=@;;--$;;){next if($:=rand($;
>+1))==0+$;;@;[$;,$:]=@;[$:,$;]}print map{$;{$_}}(@| ,@;);push@|,shift@;if$;[
>0]==@|;$|=1;select$&,$&,$&,1/80;print"\b"x(@;+@|)}print"\n"__END__
>Just another Perl Hacker



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

Date: Mon, 26 Mar 2001 23:07:55 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: one-liner assignment from regex
Message-Id: <99pdi9$6a5a$1@newssvr06-en0.news.prodigy.com>

your approach is ok to get the matches into list. for the regexp to work,
add a .* in the middle-  (^.).*(.$)

"Kim C" <kimmfc@mydeja.com> wrote in message
news:thbvbt84fag81qbcsntacv5trp30p3c0h7@4ax.com...
> Hi,
>
> Is there a way to assign regex matches to a list without using $1, $2,
> etc?  Perhaps something like the following (which does not work):
>
> ##### <guesscode> #####
>
> @list = qw(one two three);
>
> foreach (@list){
> ($start , $end) = /(^.)(.$)/;
> }
>
> ##### </guesscode> #####
>
> Thanks,
>
> Kim




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

Date: Tue, 27 Mar 2001 16:28:08 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: Perl is much simpler than it looks!
Message-Id: <vdWv6.4028$45.20900@newsfeeds.bigpond.com>

I was amazed how fast I paicked up Perl too - I have a Unix background
and Perl is a revelation and revolution ;-).

As an aside, I have found out ASP and Cold Fusion run undex Linux-
why would anyone bother with IIS??

gtoomey
-----------------
"James Meade" <bones3d@charter.net> wrote in message
news:bones3d-50A432.23461725032001@corp.supernews.com...
> Hey all,
>
> I just got done putting together my first major perl script, with little
> more than a few snippets of code to learn from! I'm truely amazed at
> just how fast I picked up on it! It's only been 4 days since I started
> and I'm already using it for my websites!
>
> I only wish I would have known how easy it was long before now! :-)
>
> Anyway, if anyone's interested, check out the script in action over at:
>
> http://www.themarketspace.com/personal/base/
>
> The script is a script generator for that "all your base are belong to
> us" thing floating around on the internet. It's a project I ported from
> shockwave to perl to get around some copying problems with the shockwave
> playing in a browser.
>
> 8==8 Bones 8==8




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

Date: Tue, 27 Mar 2001 06:43:31 GMT
From: tim@vegeta.ath.cx (Tim Hammerquist)
Subject: Re: Perl is much simpler than it looks!
Message-Id: <slrn9c0dps.nk.tim@vegeta.ath.cx>

Gregory Toomey <gtoomey@usa.net> wrote:
> I was amazed how fast I paicked up Perl too - I have a Unix background
> and Perl is a revelation and revolution ;-).
> 
> As an aside, I have found out ASP and Cold Fusion run undex Linux-
> why would anyone bother with IIS??

<BASH type="shameless" target="Redmond">
Maybe their still content letting Mr. Gates decide what they want for
them?
</BASH>

To be totally fair, Apache::ASP doesn't support _all_ that the ASP
engine on Windoze does (which may not be a bad thing), and ChiliSoft had
no PerlScript support when I last checked, so I won't even bother
discussing it.  ;)

> gtoomey


-- 
-Tim Hammerquist <timmy@cpan.org>
Trust the computer industry to shorten the term "Year 2000" to Y2K. It
was this kind of thinking that got us in trouble in the first place.
	-- Adrian Tyvand


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

Date: Tue, 27 Mar 2001 06:47:39 GMT
From: cfedde@fedde.littleton.co.us (Chris Fedde)
Subject: Re: Regex to quote XML attributes?
Message-Id: <fIWv6.323$T3.189565440@news.frii.net>

In article <3AA8A349.E37161CF@bigfoot.com>,
Thorbjørn Ravn Andersen  <thunderbear@bigfoot.com> wrote:
>Matt Sergeant wrote:
>> 
>> Jesse Sheidlower wrote:
>> >
>> > I have a lot of data in a flavor of SGML that I need to convert
>> > to XML so I can process it with XML::Parser. Most of the
>> > discrepancies are trivial, and I've been able to deal with them
>> > (for instance, the original uses "." instead of ";" as the
>> > terminator for entity references, so I used "s/(&\w+)./\1;/g;").
>> >
>> > But I'm having some trouble with the attributes; the original
>> > doesn't ever quote them, so a tag could be:
>> > <e date=2001 changed=no id=2938223>, and I need this to be
>> > <e date="2001" changed="no" id="2938223"> or XML::Parser chokes
>> > on it.
>> >
>> > I've tried a few different things, and every one has either
>> > missed some attributes or has scattered quotation marks with
>> > abandon throughout my data. Can someone suggest a solution?
>> 
>> XML Tidy will let you convert SGML to XML. You can get it from the W3C.
>
>Certain?  I thought it just converted HTML to XHTML.
>

Looks like it works to me...

$ cat s.xml
<a a=b c=d e=f>
    <e>
	bcde
    </e>
    <f a=b c=d />
</a >
$tidy -xml s.xml
<?xml version="1.0"?>
<a a="b" c="d" e="f">
  <e>bcde</e>

  <f a="b" c="d" />
</a>



-- 
    This space intentionally left blank


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

Date: Mon, 26 Mar 2001 23:44:44 -0800
From: Jonathan Dugan <dugan@leland.stanford.edu>
Subject: require question; data structure for rules
Message-Id: <3AC044EC.8547C84F@leland.stanford.edu>

ok so this is a medium-to-easy question and a hard question.  Any help
you can give would be really appreciated.

====

I'm writing a simple rule-based system in perl.

I'd like the rule set to be alterable at run time without stopping the
script, so I've implemented the rule set as a module.  In the setup()
subroutine, I use require to load the modules and build the hashes
containing the rules.  I've put signal handlers in the main program to
catch HUP.

So the problem: how do I keep reloading a module?  (or for that
matter, any code in an external file) I want the function called on
HUP to simply run the setup() sub again (which it does) but the
'require' function only will load a module once.  I looked at the use
function, but it appears to apply the require function too, and that
will only load a module once.

any suggestions on the best way to do this?

I could just make the rules definitions a normal data file (like all
the other ones it re-reads) however, as you'll see in the next
question, the rules are a bit complicated, so it seems to make sense
to just write in perl to start with.

===

next question:

I'd like some help on the best way to format a data structure to hold
rules.  I'm sure there are lots of ways to do this -- and many of you
have much more perl experience than I....

This is what I'm thinking...  There will be a small number of distinct
rule sets.  One set will 'fire' on every datum, (in sequence order)
and other sets will fire under certain conditions.

I'm envisioning each rule set as a hash, keyed on a serial number:

###
package RULES;

my %rules1;
my %rules2;

%rules1 =  (

    1 =>  (blah,
                blah,
                  blah),


    2 => (  blah, etc. )

);

###

rules have conditions, effects, and a return value to fill in the blah
blah blah above (somehow).

I'd like both conditions and effects to be BLOCKS {} with perl code in
them.

So... can you put a BLOCK of perl code as an element of an list?  How
would you run it?

This way you could have a list of code segments that are the
conditions if they all evalualte to true, then the effects are
processed the return value is set appropriately.  Finally, the return
value is returned.

I'm imagining a separate function processes a rule to do all that
stuff above.

It doesn't appear that the eval function does what I want.  For Eval
I'd have to use die statements or throw expections within the
conditions code to see if it were true.

so...  any suggestions on a data structure that will hold perl code
that

can be evaulated at run time?



Any input would be most helpful.
Please CC dugan@bowser.stanford.edu with suggestions



Thanks,
Jon






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

Date: Tue, 27 Mar 2001 09:29:30 +0200
From: Ulrich Ackermann <acki@ivu.de>
Subject: Re: Sockets
Message-Id: <3AC0415A.4E9538E5@ivu.de>

Simon Stiefel wrote:

> Here are the scripts:
>
> --- server.pl ----
>
> #!/usr/bin/perl -w
>

use strict;

>
> use diagnostics;
>
> my $server_port = 1234; # Server-Port

 ^^^^

>
>
> use IO::Socket;
>
> my $server = IO::Socket::INET->new(LocalPort   => $server_port,

 ^^^^

>
>                                 Type            => SOCK_STREAM,
>                                 Reuse           => 1,
>                                 Listen          => 10 )
>         or die "Couldn't run server on port $server_port: $@\n";
>
> print "Server running at port $server_port...\n";
>
>
> while (my $client = $server->accept()) {

               ^^^

>
>
> $client->recv(my $receive_data, 10);

   ^^^^^^             ^^^

>
> print "Client connected...\n";
>
> print $receive_data;
> }
>
> close($server);
>

client.pl needs also some changes to keep '-w' happy. I think you can do
this on your own.

>
> ----- client.pl -----
>
> #!/usr/bin/perl -w
>
> use IO::Socket;
> use diagnostics;
>
> $socket = IO::Socket::INET->new(PeerAddr        => "server.stiefel.priv",
>                                 PeerPort        => 1234,
>                                 Proto           => "tcp",
>                                 Type            => SOCK_STREAM,
>                                 Timeout         => "1000")
>         or die "Couldn't etablish connection: $@\n";
>
> $socket->send("Hallo", 10) or die "Couldn't send data...$@\n";
>
> $answer = <$socket>;
>
> print $answer;
>
> close($socket);
>
> ---- END ----
>

HTH, Ulrich




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

Date: Tue, 27 Mar 2001 08:27:59 +0200
From: "Jonas Nilsson" <jonni@ifm.liu.se>
Subject: Re: Sort messes up?
Message-Id: <99pbpk$38r$1@newsy.ifm.liu.se>

> OTOH, all OP needs to do is break sort()'s strong prototyping behavior
> with "+":
>
>
>   % perl -wle 'print sort +foo("bar"); sub foo {"hello ", shift}'
>   barhello

Yeah, I found that out after posting.

These works as supposed to.

print sort +foo("bar");
print sort &foo("bar");

Some additional questions:
Does the + do anything at all, accept to tell the parser what I want?
More explicit: Does the parsed code differ when I change.
print foo("bar");
to
print +foo("bar");
?

And howcome the & works?
/jN

--
_______________________________
Jonas Nilsson




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

Date: Mon, 26 Mar 2001 22:31:09 -0800
From: "Thomas Theakanath" <thomastk@prodigy.net>
Subject: Re: Sub String
Message-Id: <99pbdg$3106$1@newssvr06-en0.news.prodigy.com>

$str = "checkbox2(-flags)";
($str1,$str2) = ($str =~ /(\w*)\((.*?)\)/);
will get the strings into str1 and str2.
Is that you are trying to do?

"Carl Lindsay" <carllindsay1978@nospam.hotmail.com> wrote in message
news:3ABF43F3.A615BFD4@nospam.hotmail.com...
> hi,
>
> I was hopping that someone could help me I want to extract a string from
> another string is there a way to do this in perl
>
> i.e. checkbox2(-flags)
>
> I need to be able to have access to the -flags so the string in the
> brackets I have tried:
>
>  $name[$i]=~ s/(\w+)/<$1>/;
>  $name[$i]=~ s/\(/ /;
>  $name[$i]=~ s/\)/ /;
>
> which works put does not allow me to compare the result to another
> string, even though both strings are the same there must be an easy
> solution to this.  I could use substr() but then how do I count the
> chars in the brackets?
>
> Please help,
>
>
>




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

Date: Tue, 27 Mar 2001 00:28:52 -0600
From: "kellyboy" <kellyboy@nospanner>
Subject: Re: system() return value
Message-Id: <tc0cjtlpet2761@corp.supernews.com>



--


> [Please, in the future, put your reply _after_ the suitably trimmed
> text you reply to. It's the generally accepted quoting style on this
> group, and Usenet in general]

I understand and I will make it a habit. I noticed that its more sensible
that way.
| being a damn fool about it.

>
>   [rest of the reply]
>

Thanks, I now have a better understanding about system () from your
explaination .

Sometime I have hard time understanding explaination from man page or
perldoc. some people on newsgroup has a better way of explaining things for
me.

thanks,kellyboy




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

Date: 27 Mar 2001 05:50:26 -0000
From: Och <och@nym.alias.net>
Subject: Using Sunfreeware's perl in place of Sun's perl
Message-Id: <20010327055026.19579.qmail@nym.alias.net>





In a SolarisIA 8 environment, the perl that Sun distributes displays
the following errors when I invoke inn's mailpost


Can't locate syslog.ph in @INC (did you run h2ph?) (@INC contains: /usr/perl5/5.
00503/i86pc-solaris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/i86pc-solaris
/usr/perl5/site_perl/5.005 .) at /usr/perl5/5.00503/Sys/Syslog.pm line 117.
BEGIN failed--compilation aborted at /usr/news/bin/mailpost line 15.


Apparently perl displays this error because Sun used its proprietary
C compiler to create its perl distribution, but my host uses gcc.

It also seems that a pkgrm SUNWpl5? fails because the Solaris 8
kernel now depends upon perl.

How the heck can I install Sunfreeware's perl, compiled with gcc,
if Sun's perl refuses to remove itself?

I changed cc to gcc in /usr/perl5/5.00503/i86pc-solaris/Config.pm,
but the error still occurs.

TIA.

_______________________________________________________________________

Och                             finger och@nym.alias.net for public key


Version: 2.6.2

iQCVAwUBOsAlnIk2xl+M24IFAQG6zAP/fHeGCRPUZnJRNgeAE6DzbYLcv4sk0ap8
umu9Kl9SDMGIc5i+iAmVS+S0M3RK8E0ljP20yfJg3cnaXYZj/LBuxUnz8NVWiytn
amAMRHZLxweysyyi8Um49Cmsr1b4cSbW/ECa7yYna5PfWgn4QWo2xOX0+jR5mkc7
pMkxkVSDl2w=
=F05q
-----END PGP SIGNATURE-----


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

Date: Tue, 27 Mar 2001 06:05:14 GMT
From: drechsau+usenet@yuck.net (Mike Horwath)
Subject: Re: Using Sunfreeware's perl in place of Sun's perl
Message-Id: <u4Wv6.3304$SB2.577088@ruti.visi.com>

Followups Trimmed.

In news.software.nntp Och <och@nym.alias.net> wrote:
: In a SolarisIA 8 environment, the perl that Sun distributes displays
: the following errors when I invoke inn's mailpost


: Can't locate syslog.ph in @INC (did you run h2ph?) (@INC contains: /usr/perl5/5.
: 00503/i86pc-solaris /usr/perl5/5.00503 /usr/perl5/site_perl/5.005/i86pc-solaris
: /usr/perl5/site_perl/5.005 .) at /usr/perl5/5.00503/Sys/Syslog.pm line 117.
: BEGIN failed--compilation aborted at /usr/news/bin/mailpost line 15.


: Apparently perl displays this error because Sun used its proprietary
: C compiler to create its perl distribution, but my host uses gcc.

Are you smoking drugs?

THe error is so clear!

type, as root:

	# h2ph /usr/include/syslog.h

and try your comand again.

In fact, it even asks yo uif you have run h2ph yet!

: I changed cc to gcc in /usr/perl5/5.00503/i86pc-solaris/Config.pm,
: but the error still occurs.

That has nothing to do with it.

-- 
Mike Horwath  Admin & Manager @ VISI.com   WORK: drechsau@visi.com
IRC: Drechsau     http://www.visi.com/     HOME: drechsau@geeks.org
The only Minnesota ISP with public statistics: http://noc.visi.com/
         Garbage In -- Gospel Out. - berkeley fortune(6)


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

Date: 27 Mar 2001 05:35:55 GMT
From: dha@panix6.panix.com (David H. Adler)
Subject: Re: WebCT help
Message-Id: <slrn9c09lr.1l7.dha@panix6.panix.com>

On Sat, 24 Mar 2001 13:41:51 +0900, Jane Longhurst wrote:
>We are looking for programmers/scripters

You have posted a job posting or a resume in a technical group.

And cross-posted it excessively, in fact.

Longstanding Usenet tradition dictates that such postings go into
groups with names that contain "jobs", like "misc.jobs.offered", not
technical discussion groups like the ones to which you posted.

Had you read and understood the Usenet user manual posted frequently to
"news.announce.newusers", you might have already known this. :)  (If
n.a.n is quieter than it should be, the relevent FAQs are available at
http://www.faqs.org/faqs/by-newsgroup/news/news.announce.newusers.html)
Another good source of information on how Usenet functions is
news.newusers.questions (information from which is also available at
http://www.geocities.com/nnqweb/).

Please do not explain your posting by saying "but I saw other job
postings here".  Just because one person jumps off a bridge, doesn't
mean everyone does.  Those postings are also in error, and I've
probably already notified them as well.

If you have questions about this policy, take it up with the news
administrators in the newsgroup news.admin.misc.

http://jobs.perl.org may be of more use to you

Yours for a better usenet,

dha

-- 
David H. Adler - <dha@panix.com> - http://www.panix.com/~dha/
Dealing with problems is only for people too weak to run away from
them.	- Phillip, www.goats.com/comix/0002/goats000211.gif


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

Date: Tue, 27 Mar 2001 09:56:55 +0200
From: Christoph Neubauer <christoph.neubauer@siemens.at>
Subject: What way is 'better' ?
Message-Id: <3AC047C6.3DEE064A@siemens.at>

Hi All !

Let script1.pl be a Perl script, calling another script2.pl.
Assume script2.pl is supplied with some arguments
and does not produce any output to STDOUT.

As far as I know, there are 2 ways of calling script2.pl within
script1.pl

1.) `script2.pl @args`;
      (if $? != 0) {die "..."};

2.) ((system "script2.pl @args") == 0) or (die "...");

What way is faster, 'better perl style', recommended, ...

Many thanks for answers !
Christoph

PS:  Seldom I write,
       Often I read,
       Much I learn.
       Many thanks to everybody !



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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
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: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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


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