[19736] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1931 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Oct 15 06:07:35 2001

Date: Mon, 15 Oct 2001 03: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: <1003140308-v10-i1931@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Mon, 15 Oct 2001     Volume: 10 Number: 1931

Today's topics:
    Re: #!/usr/bin/perl net being pased properly <wyzelli@yahoo.com>
    Re: #!/usr/bin/perl not being parsed properly <jllachan@interlink.net>
    Re: #!/usr/bin/perl not being parsed properly <wyzelli@yahoo.com>
    Re: #!/usr/bin/perl not being parsed properly (Villy Kruse)
    Re: 20-line webserver in perl ? <joe+usenet@sunstarsys.com>
        about special chars when split() <divetolife@yahoo.com>
    Re: backgrounding a system call <goldbb2@earthlink.net>
        Balanced RegExp Pattern? <davin@cablespeed.com.ns>
    Re: Change Last Modified for all files in a directory <whataman@home.com>
    Re: Check Syntax (Martien Verbruggen)
    Re: filehandle : localized typeglob - local $_ <pilsl_@goldfisch.at>
    Re: filehandle : localized typeglob - local $_ <goldbb2@earthlink.net>
        HELP:  #!/usr/bin/perl net being pased properly <jllachan@interlink.net>
    Re: How do you get paid for Perl work over the Internet <aperlprogrammer@yahoo.com>
    Re: How do you get paid for Perl work over the Internet <tim@vegeta.ath.cx>
    Re: How to make a script put itself into background? <Tassilo.Parseval@post.rwth-aachen.de>
        html parsing <hugo@fractalgraphics.com.au>
    Re: Parsing complex data structure <goldbb2@earthlink.net>
    Re: Parsing complex data structure <Thomas@Baetzler.de>
    Re: Search engine script needs to run for Mac & PC on a <bart.lateur@skynet.be>
        sort an array and print out biggest number (Tim)
    Re: sort an array and print out biggest number <ilya@martynov.org>
    Re: sort an array and print out biggest number <jurgenex@hotmail.com>
    Re: Specifying a range of values <bart.lateur@skynet.be>
        Spliting string to an array of word <sasha_lui@yahoo.com>
    Re: Spliting string to an array of word (Rafael Garcia-Suarez)
    Re: Spliting string to an array of word <sasha_lui@yahoo.com>
    Re: Spliting string to an array of word <s.warhurst@rl.ac.uk>
    Re: Working with Bit Vectors <goldbb2@earthlink.net>
    Re: Working with Bit Vectors <bart.lateur@skynet.be>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 15 Oct 2001 14:11:38 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: #!/usr/bin/perl net being pased properly
Message-Id: <GFty7.56$791.959@wa.nnrp.telstra.net>

"Jean-Luc Lachance" <jllachan@interlink.net> wrote in message
news:3BCA6419.DC5EDF3@interlink.net...
> HELP!  :)
>
> Well, ever since I upgraded my Redhat Linux 7.1 with the latest patches,
my perl
> scripts won't run unless I use #!/usr/bin/perl -w at the start of each
file.  :(
>
> For the past two days I have been trying to find which library would be
> responsible for this without success.
>
> Any help would be appreciated.

If you mean you had to add the -w, then it means that all your line endings
are wrong, probably because you transferred in the wrong mode.

Otherwise, if you mean the shebang is different than it used to be, it could
be because your perl is not where you think it is.  Adding a symbolic link
may help, or change the shebang to point to your correct location.

On linux the shebang is required, so I suspect the first is likely to be
your problem.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: Mon, 15 Oct 2001 01:36:53 -0400
From: Jean-Luc Lachance <jllachan@interlink.net>
Subject: Re: #!/usr/bin/perl not being parsed properly
Message-Id: <3BCA75F5.3D1BE576@interlink.net>

#!/usr/bin/perl not being parsed properly

If only I typed it properly it would be easier to understand.  :)


The problem is that none of the existing script will run without
#!/usr/bin/perl -w

Even something as simple as

#!/usr/bin/perl
print "Hello world\n";

won't work without -w

I get 

No such file or directory.


Maybe the problem is with bash or whatever system call is responsible for
interpreting #!

Jean-Luc





Wyzelli wrote:
> 
> "Jean-Luc Lachance" <jllachan@interlink.net> wrote in message
> news:3BCA6419.DC5EDF3@interlink.net...
> > HELP!  :)
> >
> > Well, ever since I upgraded my Redhat Linux 7.1 with the latest patches,
> my perl
> > scripts won't run unless I use #!/usr/bin/perl -w at the start of each
> file.  :(
> >
> > For the past two days I have been trying to find which library would be
> > responsible for this without success.
> >
> > Any help would be appreciated.
> 
> If you mean you had to add the -w, then it means that all your line endings
> are wrong, probably because you transferred in the wrong mode.
> 
> Otherwise, if you mean the shebang is different than it used to be, it could
> be because your perl is not where you think it is.  Adding a symbolic link
> may help, or change the shebang to point to your correct location.
> 
> On linux the shebang is required, so I suspect the first is likely to be
> your problem.
> 
> Wyzelli
> --


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

Date: Mon, 15 Oct 2001 15:22:39 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: #!/usr/bin/perl not being parsed properly
Message-Id: <fIuy7.59$791.967@wa.nnrp.telstra.net>

"Jean-Luc Lachance" <jllachan@interlink.net> wrote in message
news:3BCA75F5.3D1BE576@interlink.net...
> #!/usr/bin/perl not being parsed properly
>
> If only I typed it properly it would be easier to understand.  :)
>
>
> The problem is that none of the existing script will run without
> #!/usr/bin/perl -w
>
> Even something as simple as
>
> #!/usr/bin/perl
> print "Hello world\n";
>
> won't work without -w
>

See point 1 in my previous post.  Your line endings are probably wrong.

When you have the -w after the #!/usr/bin/perl, then bash can read as far as
perl and knows what interpreter to process, though it may not understand
the -w properly because of the faulty line ending.

With #!/usr/bin/perl the last character is wrong and so there is no file.

Correct the line ending by either editing on unix (with pico or vi or
similar) or ensure that you transfer in ascii mode.

Wyzelli
--
($a,$b,$w,$t)=(' bottle',' of beer',' on the wall','Take one down, pass it
around');
for(reverse(1..100)){$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n$_$a$s$b\n$t\n";
$_--;$s=($_!=1)?'s':'';$c.="$_$a$s$b$w\n\n";}print"$c*hic*";





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

Date: 15 Oct 2001 07:15:22 GMT
From: vek@pharmnl.ohout.pharmapartners.nl (Villy Kruse)
Subject: Re: #!/usr/bin/perl not being parsed properly
Message-Id: <slrn9sl389.7if.vek@pharmnl.ohout.pharmapartners.nl>

On Mon, 15 Oct 2001 15:22:39 +0930,
    Wyzelli <wyzelli@yahoo.com> wrote:


>"Jean-Luc Lachance" <jllachan@interlink.net> wrote in message
>news:3BCA75F5.3D1BE576@interlink.net...
>> #!/usr/bin/perl not being parsed properly
>>
>> If only I typed it properly it would be easier to understand.  :)
>>
>>
>> The problem is that none of the existing script will run without
>> #!/usr/bin/perl -w
>>
>> Even something as simple as
>>
>> #!/usr/bin/perl
>> print "Hello world\n";
>>
>> won't work without -w
>>
>
>See point 1 in my previous post.  Your line endings are probably wrong.
>
>When you have the -w after the #!/usr/bin/perl, then bash can read as far as
>perl and knows what interpreter to process, though it may not understand
>the -w properly because of the faulty line ending.
>
>With #!/usr/bin/perl the last character is wrong and so there is no file.
>
>Correct the line ending by either editing on unix (with pico or vi or
>similar) or ensure that you transfer in ascii mode.
>



Notem that the vi(m) on linux you can use the command :set ff=unix to 
set the proper line ending.  Also, when openining a file with vim it
will display the file mode (DOS or UNIX) on the last line, and that
will be the only indication that your line endings may be CRLF rather
than plain NL.  Other editiors will probably display ^M at the end
of each line.

Villy


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

Date: 15 Oct 2001 00:37:35 -0400
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: 20-line webserver in perl ?
Message-Id: <m3bsj9ecxc.fsf@mumonkan.sunstarsys.com>

inwap@best.com (Joe Smith) writes:

> The first 16 characters of the last line should be
> "v 200\n")&&do$_
> so that the CGI's headers will be processed as headers.

"$v 200\r\n" would probably be better (but still not quite RFC-1945 
compliant :).

> 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. 

Not necessarily, the docroot is $ARGV[0] (but as Dave Tweed mentioned 
that's circumventable with a sufficient number of "../"'s.)
 
> So, yes, it is possible to write an HTTP server in less than 20 lines
> of perl, but such simple-minded servers have no security at all.

As written, that code is only runnable on a *nix box as root (and
perhaps with some modification, since it's obviously non-portable).
One would hope that such a person is responsible enough to run it in 
a reasonably secure environment (a chroot(1) jail would alleviate the
security problems you raised).  Besides other minor bugs (e.g. -x is 
true for most directories), IMO the real problem with it is that the 
code doesn't drop privileges after binding to port 80, so it runs CGI 
programs as root and circumvents all Unix file permissions. I considered 
making room for something like $<=$>=99 by dropping the %(..)
decoder, but decided against it because I was pretty confident people 
here would point out the more obvious security issues anyway :)

-- 
Joe Schaefer                 "Language is the dress of thought."
                                               -- Samuel Johnson



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

Date: Fri, 12 Oct 2001 15:00:48 +0800
From: Cliver Yang <divetolife@yahoo.com>
Subject: about special chars when split()
Message-Id: <MPG.163115f7a7240a3989683@news.cuhk.edu.hk>

Hi,all
I am doing a log analyzer on Winroute log. But I donot know how to 
process special characters when split().Such as the following line:
"192.168.1.25 - muwei [03/Sep/2001:14:23:45 +0800] "GET 
http://www.microsoft.com/isapi/redir.dll?Prd=ie&Pver=5.0&Ar=ie5update&O1
=b1 HTTP/1.0" 302 296"

@test=split(/\s+/,$_);

Many chars need to be escaped. Is there any method to substitute? 


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

Date: Mon, 15 Oct 2001 00:44:33 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: backgrounding a system call
Message-Id: <3BCA69B1.F45DD82A@earthlink.net>

Logan Shaw wrote:
> 
[snip]
>     if ($pid = fork)
>     {
>         die "Can't fork()\n" if $pid == -1;

You are thinking in C, not in perl.  fork returns undef if it fails,
rather than the -1 which you expect.

$SIG{CHLD} = sub{wait};
defined( $pid = fork ) or die "Can't fork()\n";
if( $pid ) {
   *END = sub { kill SIGINT => $pid };
   # eval qq[END: { kill SIGINT => $pid }];
} else {
   exec ('mpg123', '-vw', "$track.$i.wav", $_);
   die "Couldn't exec mpg123: $!";
}

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Mon, 15 Oct 2001 02:29:29 -0400
From: Davin Shearer <davin@cablespeed.com.ns>
Subject: Balanced RegExp Pattern?
Message-Id: <MPG.16344c5147ba4f50989680@news.cablespeed.com>

Greetings,

I'm using Java oro to use Perl regular expressions in a servlet I'm 
writing. I've come across an obstacle that I'm hoping someone here can 
assist me in overcoming.

What I want to do is parse a set of macros. Call them [list][/list]. 
These list macros, like HTML lists, can be nested, and like HTML lists, 
they are required to be balanced.

Consider this example:
[LIST]
	[ITEM]1 Level Deep[/ITEM]
	[LIST]
		[ITEM]2 Levels Deep[/ITEM]
		[LIST]
			[ITEM]3 Levels Deep[/ITEM]
		[/LIST]
	[/LIST]
[/LIST]

A greedy regexp like...

s|\[LIST\](.+)\[/LIST\]|<ul>$1</ul>|isg

 ...will only match the "outter-most" shell.
So we match:
[LIST]-Greedy Match Start
	[ITEM]1 Level Deep[/ITEM]
	[LIST]
		[ITEM]2 Levels Deep[/ITEM]
		[LIST]
			[ITEM]3 Levels Deep[/ITEM]
		[/LIST]
	[/LIST]
--Greedy Match End[/LIST]


A non-greedy regexp like...

s|\[LIST\](.+?)\[/LIST\]|<ul>$1</ul>|isg

 ...will only match [list] to the closest [/list] which is even worse.
So we match:
[LIST]-Non-greedy Match Start
	[ITEM]1 Level Deep[/ITEM]
	[LIST]
		[ITEM]2 Levels Deep[/ITEM]
		[LIST]
			[ITEM]3 Levels Deep[/ITEM]
--Non-greedy Match End[/LIST]
	[/LIST]
[/LIST]

Is there a way to recursively match balanced text using Perl's regular 
expression parser or do I need to do something cheesy like put the 
greedy version into a for loop and set a maximal nesting level?

TIA,
Davin

---------
Publisher -- http://www.storagereview.com/


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

Date: Mon, 15 Oct 2001 04:32:46 GMT
From: "What A Man !" <whataman@home.com>
Subject: Re: Change Last Modified for all files in a directory
Message-Id: <3BCA66FE.DA997286@home.com>

Garry Williams wrote:
> 
> On Sun, 14 Oct 2001 23:50:55 GMT, What A Man ! <whataman@home.com> wrote:
> > My script below does not change the last modified date.
> 
> I don't believe you.
> 
See below.

> > The error
> > message says there is no such file. What am I doing wrong?
> >
> > # Change last mod date for all files in "test" directory
> >
> > chdir "test";
> > opendir THISDIR, "." or die "Can't Open Directory: $!";
> > @files = grep !/^\.\.?$/, readdir THISDIR;
> >    foreach $file(@files) {
> >      $now=time;
> >       utime $now, $now, @files;
> >     };
> >     die "Cannot change utime: $!";
> > closedir THISDIR;
> 
> As a matter of fact, the code above changes the times on all of the
> files in the directory as many times as there are files in the
> directory.
> 

Sorry, it didn't change them until I restarted my browser so I didn't
notice the date change.

> In spite of your bizarre indentation, the call to die() will happen
> every time the script is run -- after all of the files have had their
> mtime changed (more than once!).  The value of $! is residual -- not
> as a result of a check for an error.
> 
> It turns out that utime() will not return a false value, if *any* file
> in the list has been successfully changed.  (See the utime() section
> of the perlfunc manual page.)
> 
> The thing you probably want to do is:
> 
>   #!/usr/bin/perl -w
>   use strict;
>   chdir "test"         or die "can't chdir to test: $!\n";;
>   opendir THISDIR, "." or die "can't open test: $!\n";
> 
>   my $err;
>   my $now = time;
>   foreach ( grep !/^\.\.?$/, readdir THISDIR ) {
>     utime $now, $now, $_
>     or warn "can't touch test/$_: $!\n" and $err = 1;
>   }
> 
>   closedir THISDIR;
>   exit(1) if $err;
> 
Thank You.

Regards,
--Dennis


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

Date: Mon, 15 Oct 2001 19:02:27 +1000
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: Check Syntax
Message-Id: <slrn9sl9h3.di2.mgjv@martien.heliotrope.home>

On Sun, 14 Oct 2001 23:05:43 GMT,
	Geoff Clark <gclark@wavetel.com> wrote:
> Could someone please check my syntax when they get a moment.  Thank you,

Let Perl do it for you first. To get help from humans, you should

Enable warnings

Enable strict (which you did, good)

Make sure you check EVERY call that can be checked.

Decently format your code
    When people need to read your code, you should make it as easy as
    possible for them to actually read it. Formatting and indenting the
    code is a must.

Tell us what the code is supposed to do, what it doesn't do, and
accompany it with any output you get, INCLUDING error codes. All of this
should be cut and pasted, not retyped.

Then, when you have a problem, you reduce your code to the barest and
smallest possible amount that shows the problem, and you post that here.

And then you can probably expect people to look at it.


The reason for this is that most people here have jobs to do, and they
really can't afford to do the work that Perl could do automatically for
you. They also can't afford to try to untangle your code to figure out
where blocks start and end. They also can't afford to try to figure out
what might be going wrong with your code, especially if they can't run
it themselves. 

UNLESS you have gone through all the steps above, and you actually state
WHAT the problem is, you can't even begin to expect people to do the
work of a computer for you.

http://tuxedo.org/~esr/faqs/smart-questions.html
http://mail.augustmail.com/~tadmc/clpmisc.shtml

Martien
-- 
Martien Verbruggen              | 
Interactive Media Division      | If at first you don't succeed, try
Commercial Dynamics Pty. Ltd.   | again. Then quit; there's no use
NSW, Australia                  | being a damn fool about it.


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

Date: Mon, 15 Oct 2001 11:34:00 +0200
From: peter pilsl <pilsl_@goldfisch.at>
Subject: Re: filehandle : localized typeglob - local $_
Message-Id: <3bcaad93@e-post.inode.at>

Bart Lateur wrote:

>>
>>Do I need the line and if - why ?
> 
> It has nothing to do with localized filehandles. 

This was exactely my problem. I was not sure if this line is needed for the 
localized typeglob *FH. 
In my script I dont need the line then cause $_ is processed before and the 
result stored in different local variables then.

thnx to you and all the others that replied to my message,
peter

-- 
peter pilsl
pilsl_@goldfisch.at
http://www.goldfisch.at



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

Date: Mon, 15 Oct 2001 06:07:07 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: filehandle : localized typeglob - local $_
Message-Id: <3BCAB54B.B3D06BC@earthlink.net>

peter pilsl wrote:
> 
> a recursive subroutine needs to open a file and keep it opened while
> it calls itself again and opens the next file ...
> 
> So I use something like this:
> 
> sub rec
> {
>   my $name=shift;
>   local *FH;
>   open(FH,'< $name) or die 'shit';

If you are using an advanced enough perl, you can change the above two
lines to:
   open( my($fh), "<$name" ) or die "Could not open $name: $!";
If you are using an older perl which does not allow the above, consider
using:
   open( local(*FH), "<$name" ) or die "Could not open $name: $!";

>   while (<FH>)

The above line is semantically equivilant to:
    while( defined( $_ = <FH> ) )

$_ is a global variable.  See further comment below.

>   {
>      ...
>      rec($1) if $line=~/^INSERT\((.*)\)$/;

You've read your data into $_.

/^INSERT..../ does a match against $line.

How does $line get $_ ?

rec($1) will end up opening and reading a file, and putting new stuff
into $_.  This may be bad, if the code after this does anything to/with
$_, like more // matching.

You need to do one of two things: either localize $_, or use some other
variable, one which is either localized itself, or which is lexical.

>      ...
>    }
>    close FH;
> }

sub rec {
    my ($name) = @_;
    open( my($fh), "<", $name )
        or die "Couldn't open $name for reading: $!";
    while( defined(my $line = <$fh>) ) {
        my $foo;
        ........
        } elsif( ($foo) = $line =~ /^INSERT\((.*)\)$/ ) {
            rec($foo);
        } elsif( ($foo) = $line =~ /^bar(baz)quux$/ ) {
        ........
    }
}

> 
> you got the idea ..
> 
> now I've a questions:
> 
> perldoc -q filehandle  reveals the faq 'How can I make filehandles
> local to a subroutine' and states an example with a line 'local $_'
> and the comment that this is a very important line. Unfortunately
> there is no further explanation why this line is important and in the
> following examples there is no such line ...
> 
> Do I need the line and if - why ?

I explained up above why you need it.  Also, not explained, is that
localizing it also affects $1, $2, etc. [I think.]

Anyway, since $1, $2, etc, do get localized, I think, you oughtn't pass
$1 as an argument to rec directly, and should instead either store it in
a lexical and pass that, or pass it as "$1", which also makes a copy.

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Mon, 15 Oct 2001 00:20:41 -0400
From: Jean-Luc Lachance <jllachan@interlink.net>
Subject: HELP:  #!/usr/bin/perl net being pased properly
Message-Id: <3BCA6419.DC5EDF3@interlink.net>

HELP!  :)

Well, ever since I upgraded my Redhat Linux 7.1 with the latest patches, my perl
scripts won't run unless I use #!/usr/bin/perl -w at the start of each file.  :(

For the past two days I have been trying to find which library would be
responsible for this without success.

Any help would be appreciated.

--
Jean-Luc


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

Date: Mon, 15 Oct 2001 07:49:53 GMT
From: Carlos C. Gonzalez <aperlprogrammer@yahoo.com>
Subject: Re: How do you get paid for Perl work over the Internet??
Message-Id: <MPG.16344236fa338bfd9897b3@news.edmonton.telusplanet.net>

Matt Garrish at matthew.garrish@sympatico.ca said...

> And as a final point, it's really quite rude to publicly solicit help for
> such an ill-conceived venture in this newsgroup. You have announced to the
> Perl community that you are not adverse to providing clients with shoddy
> work, but I suppose the only consolation is that you cannot delete these
> messages from the newsgroup archives, so hopefully any potential clients who
> do a background check of you on the internet will come across these posts
> and think twice.

You know I didn't want to say anything else but I feel I must here.  It 
absolutely astounds me how I am being misread here.  I really don't know 
why you think I am not "adverse to providing clients with shoddy work" 
Matt?  I never said anything of the sort.  

Just so you know Matt I will not and do not encourage anyone to provide 
shoddy work to anyone.  All I am saying is that in certain areas of Perl 
programming, beginning programmers can provide a much needed service to 
people who cannot afford high rates.  And they can do a very good job 
indeed if they stick to things they already know how to do.  Install CGI 
scripts, process form data, read info from a database and populate a form 
with it, save data to a database and such.  I realize that there are some 
aspects of this type of "simple" work that might be made complicated but 
what I am talking about Matt is doing the work in a way that is better 
than a great deal of what is already out on the Internet.  A lot of which 
is indeed shoddy.  

No way would I want any client anywhere to pay for shoddy work.  No way!  
For you to say that is to totally and completely 100% misread me.  

I would want potential clients to know that they can save themselves some 
money and get excellent quality work for less from beginning programmers 
who can do certain things very well.  Leaving the truly difficult things 
to the more experienced ones among us who deserve the $100.00 an hour 
rates.  If they want work done very quickly they should also go to 
experienced programmers but if the difference between getting things done 
in 1 day verses 4 (I'm really stretching it here) is no big deal to them 
why not save themselves some money?  

I personally will gladly pay $20.00 per hour to an electrician who is new 
and wants to prove themselves than $70.00 to an experienced journeyman.  
As I see it the same thing applies to saving money on programming 
projects Matt.  In so far as beginners are eager to please and 
enthusiastic about doing the best they can do. In things that they can 
do.  

Maybe my ideas will not work.  That's okay.  I have other income streams.  
I am just trying to provide a needed service to those who want it and to 
start another income stream.  If the market doesn't support this no 
biggy.  

The way some have responded to my ideas one would think I had committed 
an unpardonable sin just by mentioning them.  I find that hard to 
swallow.  

Did I say something offensive to you or others?  I am truly and sincerely 
sorry if I did.  I did not mean to.  Take my statements as the ramblings 
of a naive beginner if you must but please know that I did not mean to 
offend you or anyone else.  

I was looking for some constructive criticism and input and though I have 
gotten some to be sure these last posts have seemed more like being given 
a whipping.  That's okay I guess since I can still learn from such 
whippings but it sure would be nice if my statements didn't end up 
getting so misread and misunderstood.  

It feels as though I have accidentally stepped on a holy grail of some 
sort and am now feeling the heat of a bath in hot oil.  

Out of respect for this newsgroup I will again attempt to go back into 
the silence of unresponsiveness unless someone emails me.  This is one 
thread I wish I had started elsewhere but at the time I didn't know where 
and seeing that I was interested in making an income in part through Perl 
programming, I turned to this newsgroup.  

Thanks for your input Matt. 

---
Carlos 
www.internetsuccess.ca (not operational yet)


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

Date: Mon, 15 Oct 2001 08:57:22 GMT
From: Tim Hammerquist <tim@vegeta.ath.cx>
Subject: Re: How do you get paid for Perl work over the Internet??
Message-Id: <slrn9sla2f.ack.tim@vegeta.ath.cx>

Me parece que Carlos C Gonzalez <aperlprogrammer@yahoo.com> dijo:
[ snip ]
>  why you think I am not "adverse to providing clients with shoddy work" 
>  Matt?  I never said anything of the sort.  
>
>  Just so you know Matt I will not and do not encourage anyone to provide 
[ snip ]
>  what I am talking about Matt is doing the work in a way that is better 
[ snip ]
>  As I see it the same thing applies to saving money on programming 
>  projects Matt.
[ snip ]
>  Thanks for your input Matt. 
[ snip ]

Carlos, look, out of my sincerest concern for your well-being, Carlos,
and sanity, Carlos, please accept my humble, humble suggestion, Carlos,
that you refrain from posting in the vernacular of the salesman, Carlos.

What may sound good to your "mom and pop" clients sounds contrived and
false to others (to me, for one).  Or are you just afraid we'll forget
who you're talking about/to?

And some more "constructive criticism," Carlos...  We may never
have met you, but many of us have worked for you, done work for you, had
to listen to your ideas, ideals, lines, promises, and excuses.  You may
have a different face, wardrobe, home, and life than those we've worked
for, but the impression remains the same.  It's only Pavlovian
psychology that we react against the incarnation of our adversaries.

Ask your subcontractors the following question.  If they can't answer
it, don't even bother.  If you can't figure out what's wrong with it,
well, maybe you could hire a Perl programmer...

Hypothetical question: "I just moved from an Apache web server to IIS.
Everything's fine except for somescript.cgi; it worked fine on the other
server, and I made sure that the first line pointed to the location of
perl on the new machine. What's wrong?"

Sometimes I think, "Well, no, that's _too_ easy."  But then I see that
same question show up in the newsgroup the next day...and the next.

An actual manager (that I actually worked for) once said "It says
dot-C-G-I, so the server should know it's perl."  He was making a
statement, not asking a question.  He fancied himself an amateur
programmer as well.

Indeed.
Tim
-- 
Hiroshima '45, Tschernobyl '86, Windows '98


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

Date: Mon, 15 Oct 2001 08:40:43 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How to make a script put itself into background?
Message-Id: <3BCA84EB.9010807@post.rwth-aachen.de>

Benjamin Goldberg wrote:

> Just remember that you probably want to restore the terminal settings
> just before you suspend yourself, and 'raw' them after you get
> unsuspended.


Yes, after finding myself in a scrambled terminal and having to blindly 
type 'reset', same idea occured to me as well. ;-)


Tassilo


-- 
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};



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

Date: Mon, 15 Oct 2001 17:42:22 +0800
From: hugo <hugo@fractalgraphics.com.au>
Subject: html parsing
Message-Id: <3BCAAF7E.C16D6742@fractalgraphics.com.au>

Hi 

I was wondering if someone could help me with a bit of code: I would
like to extract data from HTML files, but the tags that precede the data
may vary, although most often they are likely to be table tags i.e.
<table>,tr><td>get this (often a number)</td></td>get that (another
number)</td></tr></table. I was thinking of using the perl HTML:Parsing
module, but I am a bit unsure as how to tackle it. I would like to: 

1. Import the contents of a html file.

2. Display to the user the text (html contents) between tags (I think
this equates to the tag attributes), each time asking the user whether
he/she wants to preserve that text. 

3. Store the text.

4. Output the text in another file in tabular format. 

Could anyone help me out with a bit of code that sets me on my way? I am
not so sure how to go about it. 

Any help will be greatly appreciated. 

Thanks

Hugo 

-- 
Dr Hugo Bouckaert
R&D Support Engineer, Fractal Graphics 
57 Havelock Street, West Perth 6005
Western Australia 6009
Tel: +618 9211 6000
Email:hugo@fractalgraphics.com.au
Web: http://www.fractalgraphics.com.au


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

Date: Mon, 15 Oct 2001 00:18:20 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Parsing complex data structure
Message-Id: <3BCA638C.C7695E8@earthlink.net>

[reordered slightly for improved readability]

Thelma Lubkin wrote:
> 
> Benjamin Goldberg <goldbb2@earthlink.net> wrote:
[snip]
> :   my ($server, $flavor) = split /,/;
> :   $flavor = "default" if !exists $flavors{$flavor};
>
>        The code above will never see $flavor eq "aix", aix having
>        been replaced by "default".
>
>     my ($server, $truflavor) = split /,/;
>     my $flavor = (exists $flavors{$truflavor})?$truflavor:"default";

In my code, it will only be replaced by "default" if and only if it
doesn't exist in the %flavors hash.  Yours is semantically equivilant.

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Mon, 15 Oct 2001 11:48:25 +0200
From: =?ISO-8859-1?Q?Thomas_B=E4tzler?= <Thomas@Baetzler.de>
Subject: Re: Parsing complex data structure
Message-Id: <65clstookjd8jo8orvpufaon964u3581pm@4ax.com>

On Sat, 13 Oct 2001, Dave Tweed <dtweed@acm.org> wrote:

>Thomas Bätzler wrote:
>> split(',',); will split <undef>. Hint: one comma too many.
>
>You didn't try it, did you?

Oh, I did try. I just forgot to set $_ :-)

*ducks*
-- 
use strict;my($i,$t,@r)=(0,'5 -.@BHJPT4acd6e2hk2lmn2o4r2s3tuz',map{ord}
split//,unpack('u*','L#`T&)QD5#0`#!!`#%1D)#08`#P05!!(3``$$"``#"0L&``('.
'"`P<!`````0$`'));$t=~s/(\d)(.)/$2x$1/eg;map{$t.=substr$t,$i,1,''while
$_--;$i++}@r;print"$t\n";# Thomas@Baetzler.de - http://baetzler.de/perl


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

Date: Mon, 15 Oct 2001 07:26:10 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Search engine script needs to run for Mac & PC on a cd
Message-Id: <i23lststjku7aijt472r4bncpl52cqs80t@4ax.com>

Mina Naguib wrote:

> I'm sure someone wrote a module to facilitate HTTP daemon
>needs.

It's called... HTTP::Daemon.

Randal Schwartz uses it quite a bit, so perhaps you can find good sample
code in his WebTechniques columns.

	<http://www.stonehenge.com/merlyn/WebTechniques/>

A search using the script on his site shows that columns 11, 23+24, 34,
56 and 62 make use of this module.

As for the Mac, I have some doubts if you can have much luck when using
MacPerl5.4.0r2 (if that's the correct current version number). Perhaps
it will be better feasable using the new 5.6.x, which is now in beta.

-- 
	Bart.


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

Date: 14 Oct 2001 22:49:55 -0700
From: tvn007@hotmail.com (Tim)
Subject: sort an array and print out biggest number
Message-Id: <21724be2.0110142149.5381406e@posting.google.com>

Hi,

Could someone please help me on this ?

Problem:

I would like to print out the largest number in any array.

For example: 
@array (1,2,5,7,9);
As, you can see, the largest number is 9.

Here is my solution:

@array (1,2,5,7,9);
@array = sort (@array);
print "The largest number is $array[4];

This is not very good solution since I hardcoded the script.

Please offer me with better solution.

Thanks,


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

Date: 15 Oct 2001 10:17:59 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: sort an array and print out biggest number
Message-Id: <87n12tjujs.fsf@abra.ru>

>>>>> On 14 Oct 2001 22:49:55 -0700, tvn007@hotmail.com (Tim) said:

T> Hi,
T> Could someone please help me on this ?

T> Problem:

T> I would like to print out the largest number in any array.

T> For example: 
T> @array (1,2,5,7,9);
T> As, you can see, the largest number is 9.

T> Here is my solution:

T> @array (1,2,5,7,9);
T> @array = sort (@array);
T> print "The largest number is $array[4];

T> This is not very good solution since I hardcoded the script.

T> Please offer me with better solution.

print "The largest number is $array[-1];

or 

@array = reverse sort (@array);
print "The largest number is $array[0];

BTW there is a problem with you sort. But default sort() compares list
elements as strings. So if you have (2, 10, 1) sort will order this
list as (1, 10, 2). I suppose it is not what you want. You should use

    sort { $a <=> $b } (@array)

instead of 

    sort (@array)

-- 
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/)                                    |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80  E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/)                          |
 -=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-


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

Date: Sun, 14 Oct 2001 23:42:11 -0700
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: sort an array and print out biggest number
Message-Id: <3bca8545@news.microsoft.com>

"Ilya Martynov" <ilya@martynov.org> wrote in message
news:87n12tjujs.fsf@abra.ru...
> T> I would like to print out the largest number in any array.
>
> T> For example:
> T> @array (1,2,5,7,9);
>
> print "The largest number is $array[-1];
>
> or
>
> @array = reverse sort (@array);
> print "The largest number is $array[0];
>
> BTW there is a problem with you sort. But default sort() compares list
> elements as strings. So if you have (2, 10, 1) sort will order this
> list as (1, 10, 2). I suppose it is not what you want. You should use

There is also another problem with 'sort': sort is O(n * log n) while a
trivial linear search would be only O(n), i.e. quite a bit faster for large
n.

    my $max = $a[0];
    foreach (@a) {
        if ($_ > $max) {$max = $_;);
    }
    print $max;

jue




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

Date: Mon, 15 Oct 2001 06:55:23 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Specifying a range of values
Message-Id: <7l1lstshhvnvjq22207sjemqs4ll15btij@4ax.com>

Logan Shaw wrote:

>In article <3BCA4850.7060500@home.com>,
>Michael Carman  <mjcarman@home.com> wrote:
>
>>Logan Shaw wrote:
>
>>> Philip Newton  <nospam.newton@gmx.li> wrote:
>>>> Perl6 will let you do the 'maths' thing and go straight for
>>>>
>>>>   if( $X < $score < $Y) { ... }
>
>>> Say it ain't so!
>
>>Yep. Larry talks about this in the most recent Apocalyspe:
>>
>>http://www.perl.com/pub/a/2001/10/02/apocalypse3.html
>
>So since it's an RFC, is there any way I can contribute C's that
>they've R'ed F people to make[1]?

Though you're a year late for responding to the RFC itself, I guess you
can still mention your reservations on the appropriate mailing list,
especially since this RFC is mentioned in the latest Apocalypse what
makes it current. See <http://dev.perl.org/perl6/lists/> for the
complete list, I think the most approriate list would be perl6-language,
which is, together with perl6-internals, the most active list anyway.

-- 
	Bart.


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

Date: Mon, 15 Oct 2001 11:07:41 +0200
From: "Sasha" <sasha_lui@yahoo.com>
Subject: Spliting string to an array of word
Message-Id: <9qe7qn$qq4$1@newstoo.ericsson.se>

This is a multi-part message in MIME format.

------=_NextPart_000_000A_01C15569.9BF31250
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi all,

I was wondering if some one could help me, i have a string containes =
".", which i want to split it to an array of words, when i  run my =
program i am getting error. Here is my program:


$_ =3D "this.is.my_test";
my @array =3D split(/./);
print "Array 1 is  is $array[0]\n";


Thanks in advance   Sasha


------=_NextPart_000_000A_01C15569.9BF31250
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META content=3D"text/html; charset=3Diso-8859-1" =
http-equiv=3DContent-Type>
<META content=3D"MSHTML 5.00.3315.2870" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hi all,</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I was wondering if some one could help =
me, i have a=20
string containes ".", which i want to split it to&nbsp;an array of =
words, when=20
i&nbsp; run my program i am getting error. Here is my =
program:</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>$_ =3D "this.is.my_test";</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>my @array =3D split(/./);</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>print "Array 1 is&nbsp; is=20
$array[0]\n";</FONT></DIV>
<DIV>&nbsp;</DIV>
<DIV>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>Thanks in advance&nbsp;&nbsp; =
Sasha</FONT></DIV>
<DIV>&nbsp;</DIV></BODY></HTML>

------=_NextPart_000_000A_01C15569.9BF31250--



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

Date: 15 Oct 2001 09:17:23 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: Spliting string to an array of word
Message-Id: <slrn9slad3.bgb.rgarciasuarez@rafael.kazibao.net>

Sasha wrote in comp.lang.perl.misc:
} This is a multi-part message in MIME format.
} 
} ------=_NextPart_000_000A_01C15569.9BF31250
} Content-Type: text/plain;
} 	charset="iso-8859-1"
} Content-Transfer-Encoding: quoted-printable

Please DO NOT post MIME-encoded and/or quoted-printable stuff to newsgroups.

} Hi all,
} 
} I was wondering if some one could help me, i have a string containes =
} ".", which i want to split it to an array of words, when i  run my =
} program i am getting error. Here is my program:

When you ask a question, it's better to describe the error you getting:
this helps answerers.

} $_ =3D "this.is.my_test";
} my @array =3D split(/./);
} print "Array 1 is  is $array[0]\n";

'.' is special in regular expressions: it means 'any character except
newline'. (see the perlre page for more info). You should write
	my @array = split /\./;
to escape the dot.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/


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

Date: Mon, 15 Oct 2001 11:34:22 +0200
From: "Sasha" <sasha_lui@yahoo.com>
Subject: Re: Spliting string to an array of word
Message-Id: <9qe9co$bg8$1@newstoo.ericsson.se>

Thank you Rafael for your reply. I am sorry if my message was in wrong
format. But how could i send my message in right format, or in what format
should my message be ?

Thanks igain   Sasha



"Rafael Garcia-Suarez" <rgarciasuarez@free.fr> wrote in message
news:slrn9slad3.bgb.rgarciasuarez@rafael.kazibao.net...
> Sasha wrote in comp.lang.perl.misc:
> } This is a multi-part message in MIME format.
> }
> } ------=_NextPart_000_000A_01C15569.9BF31250
> } Content-Type: text/plain;
> } charset="iso-8859-1"
> } Content-Transfer-Encoding: quoted-printable
>
> Please DO NOT post MIME-encoded and/or quoted-printable stuff to
newsgroups.





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

Date: Mon, 15 Oct 2001 10:31:29 +0100
From: "S Warhurst" <s.warhurst@rl.ac.uk>
Subject: Re: Spliting string to an array of word
Message-Id: <9qeadi$u88@newton.cc.rl.ac.uk>

> "Sasha" <sasha_lui@yahoo.com> wrote in message
news:9qe7qn$qq4$1@newstoo.ericsson.se...
>
> I was wondering if some one could help me, i have a string containes ".",
which i want to split it to an array of words,
> when i  run my program i am getting error. Here is my program:
>
> $_ = "this.is.my_test";
> my @array = split(/./);
> print "Array 1 is  is $array[0]\n";

Escape the dot & it'll work. ie: change the second line as follows:

my @array = split(/\./);

Spencer




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

Date: Mon, 15 Oct 2001 00:26:10 -0400
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Working with Bit Vectors
Message-Id: <3BCA6562.DFD14FA8@earthlink.net>

Joel Caughran wrote:
> 
> I'm working on a short script that represents people's schedules and
> job's times as bit vectors.  It works but it seems to me that there
> must be a better way to see if there is a conflict between a person's
> schedule and a job's time.
> 
> Here is a sample script that shows the two ways I have to check the
> bit vectors
> 
> =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
> #!perl
> 
> use strict;
> 
> my $bitmap1;
> my $bitmap2;
> my $bitmap3;
> 
> vec($bitmap1, 1, 1) = 1;
> vec($bitmap1, 2, 1) = 1;
> print "bitmap1 : ", unpack("b*", $bitmap1), "\n";
> 
> vec($bitmap2, 3, 1) = 1;
> vec($bitmap2, 5, 1) = 1;
> print "bitmap2 : ", unpack("b*", $bitmap2), "\n";
> 
> print "b1 & b2 : ",unpack("b*", $bitmap1 & $bitmap2), "\n";
> 
> #       Method 1        ###################################
> if (unpack("b*", $bitmap1 & $bitmap2) =~ /^0+$/) {
>         print "No Conflict\n";
> } else {
>         print "Conflict\n";
> }

Method three:
my $zeros = "\0" x length( $bitmap1 ^ $bitmap2 );
$bitmap1 ^= $zeros;
$bitmap2 ^= $zeros;
if( $bitmap1 & $bitmap2 eq $zeros ) {
    print "No Conflict\n";
} else {
    print "Conflict.";
}

PS you should try to choose the granularity of your scheduling so that
one bit represents the shortest amount of time a thing can be scheduled
for... so if events can start on the hour or half hour, and are
multiples of 30 minutes long, then one bit should represent a half hour.

-- 
    "Just how stupid are you Kuno?"
    "Verily, Tatewaki Kuno knows no limits."


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

Date: Mon, 15 Oct 2001 07:54:50 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: Working with Bit Vectors
Message-Id: <oe5lstk2rno3qj316712kvbmpj5p8guuj3@4ax.com>

Joel Caughran wrote:

>$bitmap3 = $bitmap1 & $bitmap2;
>my $conflict = 0;
>for (my $i=0; $i<=length($bitmap3)*8; $i++) {
>	if (vec($bitmap3, $i, 1)) {
>     	$conflict = 1;
>     }
>}
>
>if ($conflict) {
>	print "Conflict\n";
>} else {
>	print "No Conflict\n";
>}

You're doing too much work. You just need to "and" these two strings
together, and if it contains any byte other than "\0", then there's a
conflict.

	if($bitmap3 =~ /[^\0]/) {
	     print "Conflict\n";
	} else {
	     print "No Conflict\n";
	}



-- 
	Bart.


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

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


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