[19843] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2038 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Oct 30 18:06:06 2001

Date: Tue, 30 Oct 2001 15:05:09 -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: <1004483108-v10-i2038@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Tue, 30 Oct 2001     Volume: 10 Number: 2038

Today's topics:
        [ANNOUNCE] ApacheBench 0.61 released (Adi Fairbank)
    Re: Array initialization, what am I doing wrong? <jennifer.frank@ericsson.com>
    Re: Configuring the Serial Ports <stuart@otenet.gr>
    Re: DBI MySQL problems (martinblack)
    Re: DBI MySQL problems <jeff@vpservices.com>
    Re: DBI MySQL problems (Dat Nguyen)
    Re: Encrypting in one program and Decrypting in another <stuart@otenet.gr>
        Help with Error (Kelly)
    Re: Help with Error (John J. Trammell)
        How can I fix this? (AVL)
    Re: How can I fix this? (Tad McClellan)
    Re: Newbie. <exodus@thisaintreal.com>
        output of qx to standard out (Rick)
    Re: output of qx to standard out <Tassilo.Parseval@post.rwth-aachen.de>
    Re: output of qx to standard out <stuart@otenet.gr>
    Re: Perl from NT OS to Linux/Unix <stuart@otenet.gr>
        Please help with simple script <tdupuis@omafra.gov.on.ca>
    Re: Please help with simple script <Tassilo.Parseval@post.rwth-aachen.de>
        Unsigned 8 bit math (addition and subtraction) (J.B. Moreno)
    Re: Unsigned 8 bit math (addition and subtraction) <stuart@otenet.gr>
    Re: Useless use of private hash in void context (Clinton A. Pierce)
    Re: XML parsing <bart.lateur@skynet.be>
        Yet another regexp question <baughmankr@appstate.edu>
    Re: Yet another regexp question <Laocoon@eudoramail.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 28 Oct 2001 13:31:10 -0800
From: adi@certsite.com (Adi Fairbank)
Subject: [ANNOUNCE] ApacheBench 0.61 released
Message-Id: <tttvq3ef3np997@corp.supernews.com>

I've released a new version of ApacheBench, the Perl API to Apache's ab
tool with added features that make it usable for regression testing as
well as benchmarking.

I am trying to keep up (catch up) with Apache's work on ab, so expect more
releases soon.

changes since 0.60:

 * bugfixes:
  - fixed a segmentation faults that occurred when custom Content-type:
    headers were used
  - fixed bug that prevented Host: lines to be read by server,
    which broke requests to virtual hosts
 * better error checking to eliminate configuration related segfaults
 * arbitrary headers can now be added to HTTP requests
 * removed 512 byte hard-coded maximum size of HTTP requests;
   now requests can be arbitrarily large
 * all HTTP requests are now stored and accessible via regression methods
 * improved documentation

Have fun!

Adi

--

The uploaded file

    ApacheBench-0.61.tar.gz

has entered CPAN as

  file: $CPAN/authors/id/A/AD/ADIRAJ/ApacheBench-0.61.tar.gz
  size: 54512 bytes
   md5: ea5c2e1ff8c1c455917bcad8b5d725e6

No action is required on your part
Request entered by: ADIRAJ (Adi Fairbank)
Request entered on: Tue, 23 Oct 2001 04:20:01 GMT
Request completed:  Tue, 23 Oct 2001 04:21:15 GMT

        Virtually Yours,
        Id: paused,v 1.74 2001/05/20 14:59:52 k Exp k




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

Date: Tue, 30 Oct 2001 12:13:53 -0800
From: "Jennifer Frank" <jennifer.frank@ericsson.com>
Subject: Re: Array initialization, what am I doing wrong?
Message-Id: <9rn1m4$qbs$1@aken.eed.ericsson.se>


Tassilo von Parseval wrote in message
<3BD9E209.10705@post.rwth-aachen.de>...
>Jennifer Frank wrote:
>
>> Hi,
>>
>> I always get the message:
>>
>> Use of uninitialized value at NOIS2XML.pl line 601.
>>
>> When compiling the following code (only partial):
>>
>>    @temp = (" ") x @temp;
>
>
>When springing to life, @temp has zero elements. Hence you initialize
>zero elements with a whitespace which will keep the whole array
>uninitialized.
>
>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->{$_}))))};
>
Hi Tassilo,

Thanks for your answer this got me definitely into the right direction.
I think the easiest way to avoid the warning is to introduce a check of the
array length before trying to access the element.

Jennifer




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

Date: Tue, 30 Oct 2001 21:35:37 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Configuring the Serial Ports
Message-Id: <9rmvna$57i$4@usenet.otenet.gr>

"Misty" <tee_noone@yahoo.com> wrote in message
news:de5432d.0110300221.84ab650@posting.google.com...
> Hi,
> I need to write to the serial port on a Unix machine but before I do I
> need to set some parameters like the bit rate etc.
> can anyone tell me how to do this.
> I know you write to the serial port you simply open the file and write
> to it, but I am required to set these parameters first.
> Any ideas.

You just need to be carefull. The thing that caught me out was echo, you try
and send a command if echo is on then the two machines go into a frenzy
echoing the echo of the echo of the echo ......


#Initalise serial port
open(S4,"</dev/ttyd4") or die("Could not open ttyd4 (r)");
select((select(S4), $| = 1)[0]);        #set S4 to non blocking
system('stty 19200 -echo </dev/ttyd4'); #set baudrate and no echo

while(<S4>) {
do stuff
}

Then if you want to send a command you must open out on another handle
VIZ
        open(W4,">/dev/ttyd4") or die("Could not open ttyd4 (w)");
        select((select(W4), $| = 1)[0]);        #set S4 to non blocking
        system('stty 19200 -echo </dev/ttyd4'); #set baudrate and no echo

        print W4 "\n\n";                        #Attention
        sleep 2;
        print W4 "filer\n";             #Set each time because
        sleep 2;                        #Editbox might have rebooted
        if ($V) {print "Requesting Directory\n"; };
        print W4 "fl #3 t 605,606\n";   #Directory of MO
        close(W4);



--

Stuart Gall
------------------------------------------------
This message is not provable.



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

Date: 30 Oct 2001 11:27:09 -0800
From: martinblack26@yahoo.com (martinblack)
Subject: Re: DBI MySQL problems
Message-Id: <c025943b.0110301127.5e4911af@posting.google.com>

Hi, sorry about that. I forgot to include the lines in question. Below
is a copy of the script with commented line numbers 29 and 107:

#!/usr/bin/perl

BEGIN {
open (STDERR, ">html/error.txt");
}

### add.cgi

	use DBI;
	use CGI::Carp qw(fatalsToBrowser carpout);
	use CGI;
	$q=new CGI;


	# input..................................

	$io{'company_id'} = $company_id = $q->param('company_id');
	$io{'product_id'} = $product_id = $q->param('product_id');
	$io{'title'} = $title = $q->param('title');
	$io{'description'} = $description  = $q->param('description');
	$io{'spex'} = $spex  = $q->param('spex');
	$io{'price'} = $price  = $q->param('price');
	$io{'sex'} = $sex  = $q->param('sex');
	

	# mainline...............................


	print header; ############ line 29 ###########################

	$DBname= "dbi:mysql:minmin";
        $DBhost = "localhost";
        $DBusername = "minmin";
        $DBpassword = "fFUZsFtD";

	$dbh = DBI->connect("$DBname:$DBhost", $DBusername, $DBpassword ||   
  die "connection problem: ", $DBI::errstr;
	$dbh->{'RaiseError'} = 1;

	&kaboom;

	&print_output || die "we've got a problem: ";

  # Disconnect from the database
	$dbh->disconnect || die "disconnection problem: ", $DBI::errstr;
	exit;


 
	# the subs...............................


sub print_output{
   print<<HTML;
    <HTML><BODY>   
    <CENTER><FONT SIZE=5>
     Record added to database
      <P>
     he he he ha ha
      </P>
    </FONT></CENTER>
   </BODY></HTML>
HTML

} 

sub kaboom() { 


	$sth = $dbh->prepare( q[
		SELECT company_id, product_id
		FROM product
		WHERE company_id = ? and 
		product_id= ?
	] ) || die "prep problem: ", $DBI::errstr;
	$sth->execute( $company_id, $product_id ) || die "execution problem:
", $DBI::errstr;

	&fetch_results;
	
		
	if ($newid) {

	$dbh->do(do { local $" = ", "; qq[
		UPDATE product
		SET @{[map "$_ = ?", keys %io]}
		WHERE company_id = ? AND product_id = ?
	] }, undef,
	values %io,
	@io{qw(company_id product_id)} );

	} else {

	$dbh->do(do { local $" = ", "; qq[
		INSERT INTO product (@{[ keys %io ]})
		VALUES (@{[ ('?') x values %io ]})
	] }, undef, values %io );
		   
	}
}


sub fetch_results {
  
    while ($x = $sth->fetchrow_hashref) {
     $com = $x->{'company_id'};
     $pro = $x->{'product_id'};
   } $newid = $com ."-".$pro;  ##### line 107 #########
}


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

Date: Tue, 30 Oct 2001 11:41:40 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI MySQL problems
Message-Id: <3BDF0274.DD11846@vpservices.com>

martinblack wrote:
> 
>         use CGI;
>         $q=new CGI;

You are specifying that you want to use the object interface to CGI.pm,
rather than the function oriented interface.

>         print header; ############ line 29 ###########################

But "header" is part of the function oriented interface, so you need to
change that to $q->header.

>      $com = $x->{'company_id'};
>      $pro = $x->{'product_id'};
>    } $newid = $com ."-".$pro;  ##### line 107 #########

If the form does not contain information for either company_id or
product_id, then you will get an uninitialized value warning on line
107.  So, if lack of those is fatal, do something like this for both
variables:

  $com = $x->{'company_id'};
  die "No company_id supplied!" unless defined $com;

If this is a non-fatal condition, then you might want to use an empty
string (or some other default value) to avoid the uninitialized warning:

  $com = $x->{'company_id'};
  $com = '' unless defined $com;

-- 
Jeff



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

Date: 30 Oct 2001 14:23:00 -0800
From: thucdat@hotmail.com (Dat Nguyen)
Subject: Re: DBI MySQL problems
Message-Id: <6b1f50ac.0110301422.247092a3@posting.google.com>

andrew.hutchinson@mcmail.vanderbilt.edu (Andrew Hutchinson) wrote in message news:<3bddbf84.528897078@news.vanderbilt.edu>...
> I can only count to 29 without line numbers, so I'll only answer the
> first part of your question.
> 
> At line 29, you say 
> 
> print header;
> 
> which would be valid of header were a filehandle.  However, I think
> that what you mean is:
> 
> print $q->header();
> 
> You failed to reference the CGI object that you created, which makes
> Perl think that you're referring to an unopened handle.
> 
> Hope this helps,
> 
> Andrew
> 
> On 29 Oct 2001 10:22:12 -0800, martinblack26@yahoo.com (martinblack)
> wrote:
> 
> >Hi, I've been having trouble with this script from day one. I'm not
> >sure what the problem is, but I'm trying to query the database with
> >the form parameters ie: $product_id = $q->param('product_id');. If the
> >item in question is already in the database, the script should UPDATE.
> >If not, the script should INSERT. Instead, I get a 500 error. If I
> >turn the warn flag on, I get:
> >"Filehandle main::header never opened at add.cgi line 29". and
> >"Use of uninitialized value at add.cgi line 107". I have totaly
> >revamped this script about four times, nothing seems to work. Any help
> >on this would be greatly apprecieated. Thanks in advance.
> >Cheers. Martinblack. 
> >
> >Below is a copy of the script:
> >
> >#!/usr/bin/perl
> >
> >BEGIN {
> >open (STDERR, ">html/error.txt");
> >}
> >
> >### add.cgi
> >
> >	use DBI;
> >	use CGI::Carp qw(fatalsToBrowser carpout);
> >	use CGI;
> >	$q=new CGI;
> >
> >
> >	# input..................................
> >
> >	$io{'company_id'} = $company_id = $q->param('company_id');
> >	$io{'product_id'} = $product_id = $q->param('product_id');
> >	$io{'title'} = $title = $q->param('title');
> >	$io{'description'} = $description  = $q->param('description');
> >	$io{'spex'} = $spex  = $q->param('spex');
> >	$io{'price'} = $price  = $q->param('price');
> >	$io{'sex'} = $sex  = $q->param('sex');
> >	
> >
> >	# mainline...............................
> >
> >
> >	print header;
> >
> >	$DBname= "dbi:mysql:minmin";
> >        $DBhost = "localhost";
> >        $DBusername = "minmin";
> >        $DBpassword = "fFUZsFtD";
> >
> >	$dbh = DBI->connect("$DBname:$DBhost", $DBusername, $DBpassword ||   


===> Where is the closing paren ?
/Dat


> >  die "connection problem: ", $DBI::errstr;
> >	$dbh->{'RaiseError'} = 1;
> >
> >	&kaboom;
> >
> >	&print_output || die "we've got a problem: ";
> >
> >  # Disconnect from the database
> >	$dbh->disconnect || die "disconnection problem: ", $DBI::errstr;
> >	exit;
> >
> >
> > 
> >	# the subs...............................
> >
> >
> >sub print_output{
> >   print<<HTML;
> >    <HTML><BODY>   
> >    <CENTER><FONT SIZE=5>
> >     Record added to database
> >      <P>
> >     he he he ha ha
> >      </P>
> >    </FONT></CENTER>
> >   </BODY></HTML>
> >HTML
> >
> >} 
> >
> >sub kaboom() { 
> >
> >
> >	$sth = $dbh->prepare( q[
> >		SELECT company_id, product_id
> >		FROM product
> >		WHERE company_id = ? and 
> >		product_id= ?
> >	] ) || die "prep problem: ", $DBI::errstr;
> >	$sth->execute( $company_id, $product_id ) || die "execution problem:
> >", $DBI::errstr;
> >
> >	&fetch_results;
> >	
> >		
> >	if ($newid) {
> >
> >	$dbh->do(do { local $" = ", "; qq[
> >		UPDATE product
> >		SET @{[map "$_ = ?", keys %io]}
> >		WHERE company_id = ? AND product_id = ?
> >	] }, undef,
> >	values %io,
> >	@io{qw(company_id product_id)} );
> >
> >	} else {
> >
> >	$dbh->do(do { local $" = ", "; qq[
> >		INSERT INTO product (@{[ keys %io ]})
> >		VALUES (@{[ ('?') x values %io ]})
> >	] }, undef, values %io );
> >		   
> >	}
> >}
> >
> >
> >sub fetch_results {
> >  
> >    while ($x = $sth->fetchrow_hashref) {
> >     $com = $x->{'company_id'};
> >     $pro = $x->{'product_id'};
> >   }
>  $newid = $com ."-".$pro;   
> >}


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

Date: Tue, 30 Oct 2001 21:13:45 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Encrypting in one program and Decrypting in another program
Message-Id: <9rmvn9$57i$3@usenet.otenet.gr>

"Andrew Hamm" <ahamm@programmer.net> wrote in message
news:3bddfa37@news.iprimus.com.au...
> Anand Ramamurthy wrote in message
> <761041e6.0110231606.77f15731@posting.google.com>...
> >I need help with encrypt & decrypt
> >
> >1. I encrypt a text string (passwd) in one program (xx.pl) and store it
> >   in a config file (this this possible).
> >2. I read the config file in another program (yy.pl) later and decrypt
> >   the text string.
> >
> >What is the best method I can use? Any specific Crypt module that will
> >help me to achieve this?
> >
> Normal practice with passwords is to encrypt the supplied password and
store
> it. So you have step 1 correct. Step two (confirming the password later)
is
> not normally done the way you are suggesting however. The normal trick is
to
> prompt the user for a password, encrypt that and compare the crypted
> strings. If they are the same then the source password is assumed to be
the
> same - which works extremely will in practice - don't be afraid of someone
> entering a completely different password and getting the same encrypted
> string.

This is not just "practice" the strength of DES and MD5 (which you mention)
is precicely that there is no decryption possible. So even if someone has
access to the encrypted passwords and the source code of the application
they would still not be able gain access.




--

Stuart Gall
------------------------------------------------
This message is not provable.



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

Date: 30 Oct 2001 12:57:23 -0800
From: kjmckay@mac.com (Kelly)
Subject: Help with Error
Message-Id: <a52cb0b0.0110301257.45d8964e@posting.google.com>

I'm new to this and I'm trying to simply edit some pages for an
affiliate program.  The page is a form that when submitted, runs a
script to determine if the user is accepted.  When I click submit
though, it gives me this error:

ERROR 1007: Illegal HTML syntax: Missing Body Tag

But all my html files appear to have the body tag in it.  Any help?


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

Date: Tue, 30 Oct 2001 14:33:13 -0600
From: trammell@haqq.hypersloth.invalid (John J. Trammell)
Subject: Re: Help with Error
Message-Id: <slrn9tu6ej.8c2.trammell@haqq.el-swifto.com>

On 30 Oct 2001 12:57:23 -0800, Kelly <kjmckay@mac.com> wrote:
> I'm new to this and I'm trying to simply edit some pages for an
> affiliate program.  The page is a form that when submitted, runs a
> script to determine if the user is accepted.  When I click submit
> though, it gives me this error:
> 
> ERROR 1007: Illegal HTML syntax: Missing Body Tag
> 
> But all my html files appear to have the body tag in it.  Any help?

I don't see a Perl question in your post.  Followups set.

-- 
If you don't look at the fnord, it can't get you.


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

Date: 30 Oct 2001 12:03:53 -0800
From: xotrm@yahoo.com (AVL)
Subject: How can I fix this?
Message-Id: <b80a47eb.0110301203.1d96b5d2@posting.google.com>

Hello, I have a problem with this code. I am using
this code in one of my scripts (frames.cgi). The
problem is that one of the values I have to parse,
an URL, contains the character '=', and it looks
that the routine does not work. The URL that calls
the script is this style:

http://www.domain.com/cgi-
bin/frames.cgi?id=12798&url=http://www.server.com/index.asp?page=183

I get only 'http://www.server.com/index.asp?page', but not '=183',
through the frames.cgi script, that contains the code below:


#!/usr/bin/perl

$bannerurl = "banner.cgi";

	if ($ENV{'REQUEST_METHOD'} eq 'GET') {
        	$buffer = $ENV{'QUERY_STRING'};
	}	
	else {
        	read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
	}

# Break em up into a format the script can read

	@pairs = split(/&/, $buffer);
	foreach $pair (@pairs) {
        	($name, $value) = split(/=/, $pair);
        	$value =~ tr/+/ /;
        	$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
        	$FORM{$name} = $value;
	}

$referer = $ENV{HTTP_REFERER};
$title = $FORM{title};
$id = $FORM{id};
$url = $FORM{url};
print "Content-type: text/html\n\n";
print qq|
<html>
<head>
<title>$title</title>
</head>
<frameset framespacing="0" border="0" rows="64,*" frameborder="0">
  <frame name="top" src="$bannerurl?id=$id&title=$title&referer=$referer&url=$url"
scrolling="no" resize="no">
  <frame name="main" src="$url" resize="no">
  <noframes>
  <body>.....


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

Date: Tue, 30 Oct 2001 22:19:47 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How can I fix this?
Message-Id: <slrn9tu4gu.vhj.tadmc@tadmc26.august.net>

AVL <xotrm@yahoo.com> wrote:

> Subject: How can I fix this?


   use CGI;


for parsing form data.


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


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

Date: Tue, 30 Oct 2001 19:07:30 -0000
From: "Exodus" <exodus@thisaintreal.com>
Subject: Re: Newbie.
Message-Id: <iTCD7.31194$GA.4263053@news2-win.server.ntlworld.com>


<nobull@mail.com> wrote in message news:u9elno7o21.fsf@wcl-l.bham.ac.uk...
> "Exodus" <exodus@thisaintreal.com> writes:
>
> You appear to be asking about the posting guidelines for this group.
> The posting guidelines were recently posted.

I've read through most of the FAQs, but didn't see any posting guidelines,
I'll keep my eyes open.

>
> > Even if they are really obivious to some of you more experience
programmers?
>
> I don't know if you are two lazy to read manuals - quite possibly you
> are not, but you risk giving the wrong impression by using the word
> "newbie" in he subject line - most people who use the word in their
> subject lines use to mean "I've not RTFM".

Thanks for you comments, I'll always start with the manual as first port of
call, followed by 3 books, 2 techs, Google Groups and a 'find' on this
newsgroup - after that - I'll think about posting :o)

The only reason I stated newbie was (a) to introduce myself, and (b) so that
people might be a little more forthcoming with explanations as well as raw
facts.

Thanks again.

Ex.




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

Date: 30 Oct 2001 13:30:21 -0800
From: akirapc@hotmail.com (Rick)
Subject: output of qx to standard out
Message-Id: <3c7e70b8.0110301330.3fdcff43@posting.google.com>

Hi,

How can I make the output of a qx command go to standard out?

For example:

---
#!/usr/bin/perl

qx(tail -f /usr/local/apache/logs/access_log);
---

when I run this, I don't see the results of tail -f.  I would like qx
to direct output to standard out.  I was hoping to do this without
using the File::Tail module.

Thanks,
Rick


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

Date: Tue, 30 Oct 2001 22:39:03 +0100
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: output of qx to standard out
Message-Id: <3BDF1DF7.5030108@post.rwth-aachen.de>

Rick wrote:

> Hi,
> 
> How can I make the output of a qx command go to standard out?


By print()ing it?


> 
> For example:
> 
> ---
> #!/usr/bin/perl
> 
> qx(tail -f /usr/local/apache/logs/access_log);


qx// does not do what you think it does. Read it up with 'perldoc perlop'.

In short:

$output = qx(tail -f /usr/local/apache/logs/access_log);
# stdout of tail now stored in $output, hence:
print $output;

or just:

system "tail -f /usr/locaL/apache/logs/access_log";

since you don't seem to post-prozess the output created by tail.

[...]

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: Tue, 30 Oct 2001 23:45:12 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: output of qx to standard out
Message-Id: <9rn7bv$ajd$2@usenet.otenet.gr>

"Rick" <akirapc@hotmail.com> wrote in message
news:3c7e70b8.0110301330.3fdcff43@posting.google.com...
> Hi,
>
> How can I make the output of a qx command go to standard out?
>
> For example:
>
> ---
> #!/usr/bin/perl
>
> qx(tail -f /usr/local/apache/logs/access_log);

Errrrr
print qx(tail -f /usr/local/apache/logs/access_log);

BUT tail -f will never terminate, so control will never return to perl
Perhaps system("tail","-f","/usr/local/apache/logs/access_log");
is a better way to go.
--

Stuart Gall
------------------------------------------------
This message is not provable.



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

Date: Tue, 30 Oct 2001 20:37:30 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Perl from NT OS to Linux/Unix
Message-Id: <9rmvn9$57i$2@usenet.otenet.gr>

> I even FTP downloaded a perl script that do run on the Unix box and
> then upload it again with and without running the remove control-M's
> perl script on it before uploading but always get the error included
> in the bottom of this message.
>
> Is it maybe that i miss something so basic that I'm supposed to run
> the remove control-M's script on the Unix server?

Have you made the script executable?
Shell in and do chmod uog+x NAMEOFCGI

I dont think ^M will bother the perl interpreter it should just treat it as
whitespace.

--

Stuart Gall
------------------------------------------------
This message is not provable.



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

Date: Tue, 30 Oct 2001 15:33:10 -0500
From: Terry <tdupuis@omafra.gov.on.ca>
Subject: Please help with simple script
Message-Id: <3BDF0E86.DB5467D6@omafra.gov.on.ca>

Hello,

Could someone help converting this to perlscript?

Thanks in advance,
Terry

==========================================
Dim domain1, domain2, domain3, domain4, refDomain

refDomain = Request.ServerVariables("HTTP_REFERER")
domain1 = inStr(refDomain,"http://www.domain1.com")
domain2 = inStr(refDomain,"http://www.domain2.com")
domain3 = inStr(refDomain,"http://www.domain3.com")
domain4 = inStr(refDomain,"http://www.domain4.com")

If domain1 <> True And domain2 <> True And domain3 <> True And domain4
<> True Then
 Response.Write("Error.<br><br>This script cannot be run from this
domain.")
 Response.End
End If



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

Date: Tue, 30 Oct 2001 22:08:43 +0100
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: Please help with simple script
Message-Id: <3BDF16DB.7080705@post.rwth-aachen.de>

Terry wrote:

> Hello,
> 
> Could someone help converting this to perlscript?
> 
> Thanks in advance,
> Terry
> 
> ==========================================
> Dim domain1, domain2, domain3, domain4, refDomain
> 
> refDomain = Request.ServerVariables("HTTP_REFERER")
> domain1 = inStr(refDomain,"http://www.domain1.com")
> domain2 = inStr(refDomain,"http://www.domain2.com")
> domain3 = inStr(refDomain,"http://www.domain3.com")
> domain4 = inStr(refDomain,"http://www.domain4.com")
> 
> If domain1 <> True And domain2 <> True And domain3 <> True And domain4
> <> True Then
>  Response.Write("Error.<br><br>This script cannot be run from this
> domain.")
>  Response.End
> End If


I am not really a VB-hacker but from what I think: [untested]

#! /usr/bin/perl -wT

use strict;
print "text/html\n\n";
if ($ENV{HTTP_REFERER} !~ /http:\/\/www\.domain[1-4]\.com/) {
	print <<EOHTML;
Error.
<br><br>
This script cannot be run from this domain.
EOHTML
}

Hmmh, how much nicer this is!


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: Tue, 30 Oct 2001 16:06:36 -0500
From: planb@newsreaders.com (J.B. Moreno)
Subject: Unsigned 8 bit math (addition and subtraction)
Message-Id: <1f23lmv.1b93aucxkoxgsN%planb@newsreaders.com>

Is there an easy way to do unsigned one byte addition and subtraction?
I.e. I want 0-1 to equal 255 and 250+7 to equal 1.

-- 
JBM
"Your depression will be added to my own" --  Marvin of Borg


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

Date: Tue, 30 Oct 2001 23:41:53 +0200
From: "Stuart Gall" <stuart@otenet.gr>
Subject: Re: Unsigned 8 bit math (addition and subtraction)
Message-Id: <9rn7bv$ajd$1@usenet.otenet.gr>

"J.B. Moreno" <planb@newsreaders.com> wrote in message
news:1f23lmv.1b93aucxkoxgsN%planb@newsreaders.com...
> Is there an easy way to do unsigned one byte addition and subtraction?
> I.e. I want 0-1 to equal 255 and 250+7 to equal 1.
>
Avoiding an if ?
$a = ((0-1) % 256)+ 256) %256
$b =((250+7) % 256)+ 256) %256

Or
$a = (0-1) % 256; $a+=256 if $a<0;
$b = (250-7) % 256; $b+=256 if $b<0;


> --
> JBM
> "Your depression will be added to my own" --  Marvin of Borg

--

Stuart Gall
------------------------------------------------
This message is not provable.



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

Date: Tue, 30 Oct 2001 22:25:51 GMT
From: clintp@geeksalad.org (Clinton A. Pierce)
Subject: Re: Useless use of private hash in void context
Message-Id: <PNFD7.212444$K6.104041398@news2>

[Posted and mailed]

In article <ca9aa2d8.0110300846.6d58b914@posting.google.com>,
	mwangu@yahoo.com (Mike Wangu) writes:
> [Lots and lots of stuff deleted]
>      #XX# Problem line below
>     $projtree->{$spdata[0]} = ( %binfo, $self->gettree($spdata[3], 
>								$recurse) );
>
> This all works fine on the whole. The problem I am having is the error:
> 
> Useless use of private hash in void context at
>         /opt/customer/home/pmutyam/release/bin/Vignette/Vignette.pm line 120
> (#1)
> 
>             [LINE 120 IS THE LINE AFTER #XX# IN THE SNIPPET ABOVE]

Let's simplify what you've said above:

	$p->{foo}=(%h, .....)

What context is %h in?  The thing on the left of the assignment is a scalar value.   
The parens on the right therefore are in a scalar context.  In a scalar context

	(a, b, c)

Evaluates "a", "b" and "c" in void or scalar context and returns c.  It does not 
do any kind of amalgamation in scalar context.  Your hash there is a useless 
appendage.  It's evaluated in a void context, it's value isn't used or needed and 
you're ignoring it.

What I suspect you wanted to say was one of:

	$p->{foo}={ %h, $s->g(...) };  

or

	$p->{foo}=[ %h, $s->g(...) };

Which has scalar things on the right and the left of the assignment.

[And DO NOT fall into the trap of:

	$p->{foo}=\(%h, ...);

 either.  It doesn't do what you want at all.]


-- 
    Clinton A. Pierce            Teach Yourself Perl in 24 Hours  *and*
  clintp@geeksalad.org                Perl Developer's Dictionary
"If you rush a Miracle Man,     for details, see http://geeksalad.org     
	you get rotten Miracles." --Miracle Max, The Princess Bride


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

Date: Tue, 30 Oct 2001 22:48:37 GMT
From: Bart Lateur <bart.lateur@skynet.be>
Subject: Re: XML parsing
Message-Id: <heautt081vefuvamfckhoa0g5d8iifamut@4ax.com>

Spike wrote:

>Hi. I am new to XML parsing and have enherited some code which uses
>XMl::Simple.
>This reads in the entire XML file and parses it into a data structure.
>However, when a large file is encountered the machine runs out of
>memory.
>
>Is there some other way to deal with these XML files rather than the
>way outlined above? Perhaps a module which deals with the file in a
>step-wise fashion?

I'm currently facing the same problem. I have a database saved as XML in
the following structure:

	<?xml version="1.0"?>
	<database>
	   <record id="a123">
	       ...
	   </record>
	   <record id="b456">
	       ...
	   </record>
	   <record id="c789">
	       ...
	   </record>
	</database>

Since this can contain up to tens of thousands of records, I'd like to
process them one at a time. I do prefer a tree-like appoach.

Anyway, after some looking around, I found this module which looks
promising: XML::Twig. It is on CPAN.

	XML::Twig - A perl module for processing huge XML documents in
	tree mode.

If your problem is similar to mine, at least check out "ex_fm2" in the
examples archive that is available through
<http://standards.ieee.org/resources/spasystem/twig/>. In my case, I'd
have to set a handler for the "record" element, and this one would be
called when a whole record has been read. You can access the whole
subtree under that element in that handler.

-- 
	Bart.


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

Date: Tue, 30 Oct 2001 17:05:39 -0500
From: Kinney Baughman <baughmankr@appstate.edu>
Subject: Yet another regexp question
Message-Id: <3BDF2433.94E94D81@appstate.edu>

OK, I give! 

I've been working on this for a couple of hours now. 

I'm trying to work out a regular expression that will do the following:

1) I have strings of names in a database.  

For ex., "BAUGHMAN, KINNEY GRAGG, JACK A GRAGG, MARY LEA W".

2) Users will search on last names, "Gragg", for example.

3) The database will return the string above but ...
4) All I want to return is the first occurence of the search term plus the
next word.

So in my example above, if someone searches on "GRAGG", then I want to
return "GRAGG, JACK".

I've tried grouping and all sorts of techniques but I'm not even getting
close.

So how do I do this?

Thanks.
-- 
+-----------------------------------------------------------------------+
| Kinney Baughman                          Appalachian State University |
| Appalachian Regional Development Institute            Boone, NC 28608 |
| Email:   baughmankr@appstate.edu               Phone:  (828) 262-6523 |
+-----------------------------------------------------------------------+


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

Date: Tue, 30 Oct 2001 23:31:46 +0100
From: Laocoon <Laocoon@eudoramail.com>
Subject: Re: Yet another regexp question
Message-Id: <Xns914AEF5CD563DLaocooneudoramailcom@62.153.159.134>

Kinney Baughman <baughmankr@appstate.edu> wrote in
news:3BDF2433.94E94D81@appstate.edu: 

> OK, I give! 
> 
> I've been working on this for a couple of hours now. 
> 
> I'm trying to work out a regular expression that will do the following:
> 
> 1) I have strings of names in a database.  
> 
> For ex., "BAUGHMAN, KINNEY GRAGG, JACK A GRAGG, MARY LEA W".
> 
> 2) Users will search on last names, "Gragg", for example.
> 
> 3) The database will return the string above but ...
> 4) All I want to return is the first occurence of the search term plus
> the next word.
> 
> So in my example above, if someone searches on "GRAGG", then I want to
> return "GRAGG, JACK".

$names =~ /($searchterm, \w+)/ and $match = $1;

Hope this helps you..

Lao



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

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


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