[8907] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2524 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 7 03:07:20 1998

Date: Thu, 7 May 98 00:01:02 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 7 May 1998     Volume: 8 Number: 2524

Today's topics:
        "if" statement help <johns_r@cs.odu.edu>
        2 columns, one blank, need to repeat col 1 in col 2 <mhammer@execpc.com>
    Re: 2 columns, one blank, need to repeat col 1 in col 2 <lr@hpl.hp.com>
    Re: case sensitive of a search engine <rootbeer@teleport.com>
    Re: Dylan Song Title Generator (was Re: Rainy Day Women <lr@hpl.hp.com>
    Re: Ever Wonder Why Not Everyone Uses Modules? (Ilya Zakharevich)
    Re: Ever Wonder Why Not Everyone Uses Modules? (Martien Verbruggen)
    Re: Field Checking in NT <rootbeer@teleport.com>
    Re: Hash value length limit? (Martien Verbruggen)
    Re: How old is Perl? (Kevin Reid)
    Re: How to add a space to a variable after 'x' many cha <rra@stanford.edu>
    Re: How to add a space to a variable after 'x' many cha <lr@hpl.hp.com>
    Re: How to add a space to a variable after 'x' many cha <rootbeer@teleport.com>
    Re: I need to delete temp files after 24 hours... <ljz@asfast.com>
    Re: newbie question about system call (Martien Verbruggen)
    Re: perl script for zone files <rootbeer@teleport.com>
    Re: Perl Socket and proxy Server (Martien Verbruggen)
    Re: PLEASE HELP -ASCII file saved <rootbeer@teleport.com>
    Re: PLEASE HELP -ASCII file saved (Martien Verbruggen)
        Problem when using the LWP module. <snay@primenet.com>
    Re: qq method calls (Tom Mornini)
    Re: Setsuid and PERL5LIB <rootbeer@teleport.com>
    Re: settime <rootbeer@teleport.com>
    Re: What is wrong with this? <rootbeer@teleport.com>
    Re: Win95 Perl scripts DONT WORK on UNIX (Martien Verbruggen)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Wed, 6 May 1998 22:35:18 -0400
From: Reginald Johnson <johns_r@cs.odu.edu>
Subject: "if" statement help
Message-Id: <Pine.GSO.3.96.980506223258.10502A-100000@wave.cs.odu.edu>

Hello,
I'm trying to write an if statement based on an element in an array using
the following code.  Unfortunately the if statement doesn't seem to care
what the element is and goes with whatever is in the first statement
everytime.

I would appreciate any help given.


#!/usr/local/bin/perlold/perl
use Msql;
use CGI;
#print "Content-type:text/html\n\n";
$query = new CGI;
print $query->header;
if ($dbh = Msql->Connect(defiant,"cs495")){
    print "<body bgcolor=#3300cc text=white link=yellow vlink=green>"; 
    print("<h2><center>Connected to host and database for
listing<center></h2> <BR><hr><BR>");
} else {
    die "Unable to connect to host or database: $Msql::db_errstr\n";
}


#print"<br>hi<br>";

	$sth = $dbh->Query("select angie1.prod_num, angie1.description,
angie1.price, angie1.manufacturer,
	  angie2.sale,  angie2.number 
	  from angie1, angie2 where angie1.prod_num = angie2.prod_num
order by angie1.prod_num
	  " ) 
	  or die "Could not find query :$Msql::db_errstr \n";
#print"<br>this is hell<br>";

print"<center>";
print "<table border=1>";
print "<tr align=center><td>Product Number</td>";
print "<td>Description</td>";
print "<td>Manufacturer</td>";
print "<td>Sales Price</td>";
print "<td>Regular Price</td>";
print "<td>Number in Stock</td></tr>";


	foreach ($i=1; $i <= ($sth->numrows); $i++) {
		@row = $sth->FetchRow;
		print"<tr align=center>";
		print "<td>" . @row[0] . "</td>";
		print "<td>" . @row[1] . "</td>";
		if(@row[3]=='intel')
		{
			print "<td><a href=http://www.intel.com>" .
@row[3] . "</a></td>";
		}
		elsif(@row[3]=='IBM')
		{
			print "<td><a href=http://www.ibm.com>" . @row[3]
 . "</a></td>";
		}
		elsif(@row[3]=='toshiba')
		{
			print "<td><a href=http://www.toshiba.com>" .
@row[3] . "</a></td>";
		}
		elsif(@row[3]=='maxtor')
		{
			print "<td><a href=http://www.maxtor.com>" .
@row[3] . "</a></td>";
		}
		else 
		{
			print "<td>" . @row[3] . "</td>";
		}
		print "<td>" . @row[2] . "</td>";
		print "<td>" . @row[4] . "</td>";
		print "<td>" . @row[5] . "</td>";
		
	
		undef( @row );
		print "</tr>";
	}
print"</table>";

print"<br><hr><br>";



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

Date: Wed, 06 May 1998 23:04:08 -0500
From: Mike Hammernik <mhammer@execpc.com>
Subject: 2 columns, one blank, need to repeat col 1 in col 2
Message-Id: <6irbpg$1qa@newsops.execpc.com>

I have a fike that started iut looking like

----------------------------------------------
|             216453 |                        |
-----------------------------------------------
|             219405 |                 219406 |
-----------------------------------------------
|             219410 |                        |
-----------------------------------------------
|             219697 |                        |
-----------------------------------------------
|             315414 |                 315418 |
-----------------------------------------------
and so on and so on
 ...

I can strip it down to

216453|
219405|219406
219410|
219697|
315414|315410

Now I nee to duplicate column 1 in column 2 if it is empty. But I want
to leave the line alone if it has two columns.

216453|216453
219405|219406
219410|219410
219697|219697
315414|315410

  I'm stuck because I can;t find any examples and I haven't been able to
make the leap in programming skills by reading my perl books.  Probably
because I'n not a good programmer but I like to try.

Could someone please show me how to perform this task?  

Thanks in advance

Hammer


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

Date: Wed, 6 May 1998 22:59:26 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: 2 columns, one blank, need to repeat col 1 in col 2
Message-Id: <6iriks$367@hplntx.hpl.hp.com>

[posted and mailed]

Mike Hammernik wrote in message <6irbpg$1qa@newsops.execpc.com>...
 ...
>I can strip it down to
>
>216453|
>219405|219406
>219410|
>219697|
>315414|315410
>
>Now I nee to duplicate column 1 in column 2 if it is empty. But I want
>to leave the line alone if it has two columns.
>
>216453|216453
>219405|219406
>219410|219410
>219697|219697
>315414|315410
 ...

Assuming the lines are in an array (or read them one at a time with
'while (<FILE>) {'):

foreach (@lines) {
    s/^(\d+)\|$/$1|$1/;
    print; # Or whatever you want to do with the result (in $_).
}

'Learning Perl' from O'Reilly & Associates should help you a great deal.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Thu, 07 May 1998 06:13:14 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: sg <info@atig.fr>
Subject: Re: case sensitive of a search engine
Message-Id: <Pine.GSO.3.96.980506231046.6329K-100000@user2.teleport.com>

On Wed, 6 May 1998, sg wrote:

> if ($cle eq (? or % or etc...) {
> return &not_found
> }
> 
> is it possible??

Yes, if you use the proper syntax. The FAQ has an entry entitled "How can
I tell whether an array contains a certain element?" which may be of some
use to you. Good luck! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Wed, 6 May 1998 22:20:26 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: Dylan Song Title Generator (was Re: Rainy Day Women #12 & 35 question)
Message-Id: <6irgbn$2ko@hplntx.hpl.hp.com>

David Faciane wrote in message <6ir8i6$fv6$1@news.fsu.edu>...
 ...
>#!/usr/local/bin/perl
>#
># bobify: absolutely dylan title generator
>#
>#
># usage: bobify <song title>
>#
>require 5.000;
>srand;
>
>my @words= qw/ obviously positively absolutely surely certainly amply
eerily
>familiarly fondly fully ghastly ghostly grizzly mercilessly ornately
>otherworldly pitilessly scraggly simply summarily superbly truly wholly
>pitifully obnoxiously/;
>
>print ucfirst($words[int(rand($#words))]), " @ARGV \n";


This will never print "Obnoxiously" (or does it print Obnoxiously all
the time? :-).  Replace $#words by @words. (BTW, the "int" function is
unnecessary -- the indexing operation truncates to integer.)

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: 7 May 1998 04:43:34 GMT
From: ilya@math.ohio-state.edu (Ilya Zakharevich)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <6ire5m$308$1@mathserv.mps.ohio-state.edu>

[A complimentary Cc of this posting was sent to Tom Christiansen 
<tchrist@mox.perl.com>],
who wrote in article <6ir80v$am6$1@csnews.cs.colorado.edu>:

> :Porting would be easier by *tons* if there were no *nix around.
> 
> Of course it would -- because Perl wouldn't exist.  Not merely because
> Larry wouldn't have written it, but rather because the very glory of
> the Unix philosophy is incarnated in Perl.

No, what is incarnated in Perl is (almost) exactly opposite to *nix
philosophy of orthogonality, highly specialized tools, and pipes.

Moreover, I would think that the reason Larry wrote Perl was not that
the system he worked on was majestic, but because it was so deficient
that it insulted his creativity to make is work done using the
existing (halfway-)broken tools.  I'm pretty sure that if he had REXX
(gasp!) or somesuch around he would find a better way to keep his mind
busy.

> Who wants to read poetry translated?  To what purpose?  To translate
> poetry carries with it the inevitable doom that its allusions and
> metaphors, its delicate aesthetics and pleasing symmetry, that shall be
> thus destroyed, reduced to a palimpsest--nay, a caricature--of true art.

Hmm, did you read any papers/books by E. Etkind?  Oh, I forgot that you
need a translator to read them.  ;-)

Ilya


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

Date: 7 May 1998 05:32:59 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Ever Wonder Why Not Everyone Uses Modules?
Message-Id: <6irh2b$icb$1@comdyn.comdyn.com.au>

In article <354E16EA.34EF25BA@kodak.com>,
	Brian Mathis <brianm@kodak.com> writes:
> Art Cohen wrote:
>> 
>> You know, it's very annoying to reply to an (unmarked) email cc only to
>> discover that the same message was also posted to the group. Doesn't your
>> newsreading software give you an option to put "posted and mailed" at the
>> top of the message?
> [...]
>> --Art
> 
> I'm sorry for the inconveinence.  I usually send an email reply, as well
> as a newsgroup one, for courtesy of the original poster.  Many people
> post questions, and often time an email response gets to them much
> faster than waiting for a usenet reponse to propagate through the
> system.  Quit your whining, it's not like you were spammed or anything.

The emphasis here was on 'unmarked'. If you email as well as post,
state so in the message, so that the person receiving the email knows
he is getting a copy, and not a personal communication. 

I always get very annoyed when I have just spent a while responding to
what I _think_ is a private email, only to find that it was also
posted to the newsgroup, in which case my response also belongs on the
newsgroup, which means that I have to go off and see if I maybe still
have a copy of what I sent etc. etc.

I have no problem with email copies, as long as they are _marked_ as
such.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | That's not a lie, it's a terminological
Commercial Dynamics Pty. Ltd.       | inexactitude.
NSW, Australia                      | 


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

Date: Thu, 07 May 1998 06:44:59 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: "Don H." <donh@solutions.mb.ca>
Subject: Re: Field Checking in NT
Message-Id: <Pine.GSO.3.96.980506233947.6329R-100000@user2.teleport.com>

On Thu, 7 May 1998, Don H. wrote:

> I coded a Perl program to check on text fields, radio buttons, and check
> boxes to make sure these fields are being filled in.  The Perl program
> works perfect with a UNIX server, but when I upload it onto a Windows NT
> 4.0 server, none of the checking code works. 

The Perl-for-Win32-FAQ explains some reasons why a program may not work on
such a system. Of course, you may not have the same version of Perl, or
your binary may have a bug, or many other possibilities.

>   if ($in{'fname'} eq "")
>       {
>            code to display error message
>        }

Of course, this isn't your real code, but if your real code is basically
as you say and $in{fname} is empty and this fails to display the error
message, then there's a bug in your perl binary. But I suspect that it's
not a perl bug.

> I've tried putting a space between the double quotes ( " " ), tried to
> say;  eq null, tried to move it into a variable and then check it's
> length;
>                 $name = $in{'fname'}
>                 if (lenght($name) == 0)
> and nothing works!

Well, it helps to spell the function names properly. :-)  And, of course,
null is not a perl built-in. 

In any case, if you're wanting to know whether a hash element exists,
there's a function for that. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 7 May 1998 05:34:01 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Hash value length limit?
Message-Id: <6irh49$icb$2@comdyn.comdyn.com.au>

In article <3550F518.813DA1CB@negia.net>,
	Dan Boorstein <danboo@negia.net> writes:

>> This application saves the data to a file in perl syntax (so it can be
>> sucked back in by a require).  This should not be limiting the length
>> of the records, right???
> 
> what kind of file? is it a DBM? if so, which?

Would be hard to suck in via a require :)

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | A Freudian slip is when you say one
Commercial Dynamics Pty. Ltd.       | thing but mean your mother.
NSW, Australia                      | 


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

Date: Thu, 7 May 1998 00:12:16 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: How old is Perl?
Message-Id: <1d8mpko.1afva4o58nmeyN@slip166-72-108-234.ny.us.ibm.net>

K. Viggers <kviggers@gulf.uvic.ca> wrote:

>   I was just hoping  that someone could tell me when Perl began its
> exsistence.

Sometime in 1986.

"Programming Perl" 2nd ed., chapter 8, page 554: "History Made
Practical".

-- 
  Kevin Reid.      |         Macintosh.
   "I'm me."       |      Think different.


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

Date: 06 May 1998 22:54:48 -0700
From: Russ Allbery <rra@stanford.edu>
To: bravo@bravodesign.com
Subject: Re: How to add a space to a variable after 'x' many characters??
Message-Id: <m3af8uvd5j.fsf@windlord.Stanford.EDU>

[ Posted and mailed. ]

Darrick Wolfe <bravo@bravodesign.com> writes:

> I'm wanting to add a space after, say 20 characters in a variable
> (inputed from a form: $IN{'stuff'} ), so that if someone submits
> something like:

> ttttttttttttthhhhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiiiiiissssssssssssssssssssssssssssss

> it will place a blank space after every 20th character.

$variable =~ s/(.{20})/$1 /g;

(Replace every string of 20 characters with that string of 20 characters
and a space.)

> Also, how do you count the actual characters in a variable?

$count = length $variable;

Hope this helps.

-- 
#!/usr/bin/perl -- Russ Allbery, Just Another Perl Hacker
$^=q;@!>~|{>krw>yn{u<$$<[~||<Juukn{=,<S~|}<Jwx}qn{<Yn{u<Qjltn{ > 0gFzD gD,
 00Fz, 0,,( 0hF 0g)F/=, 0> "L$/GEIFewe{,$/ 0C$~> "@=,m,|,(e 0.), 01,pnn,y{
rw} >;,$0=q,$,,($_=$^)=~y,$/ C-~><@=\n\r,-~$:-u/ #y,d,s,(\$.),$1,gee,print


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

Date: Wed, 6 May 1998 22:39:09 -0700
From: "Larry Rosler" <lr@hpl.hp.com>
Subject: Re: How to add a space to a variable after 'x' many characters??
Message-Id: <6irhev$2tv@hplntx.hpl.hp.com>

[posted and mailed]

Darrick Wolfe wrote in message <35512E27.7C1D@bravodesign.com>...
 ...
>I'm wanting to add a space after, say 20 characters in a variable
>(inputed from a form: $IN{'stuff'} ), so that if someone submits
>something like:
>
>ttttttttttttthhhhhhhhhhhhhhhhhhhhhhiiiiiiiiiiiiiiiiiiiiiiiissssssssssss
ssssssssssssssssss
>
>it will place a blank space after every 20th character.
>
>please help!!

Lots of ways.  Here's one:

$string =~ s/(.{20})/$1 /g;

>Also, how do you count the actual characters in a variable?


length $string

 ...

Read 'Learning Perl' from O'Reilly & Associates.

--
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com





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

Date: Thu, 07 May 1998 06:52:09 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Darrick Wolfe <bravo@bravodesign.com>
Subject: Re: How to add a space to a variable after 'x' many characters??
Message-Id: <Pine.GSO.3.96.980506234709.6329S-100000@user2.teleport.com>

On Wed, 6 May 1998, Darrick Wolfe wrote:

> I'm wanting to add a space after, say 20 characters in a variable

You may want to use substr as an lvalue:

    substr($string, 20, 0) = ' ';

But it sounds as if you want to break up extra-long words, which could be
a job for a pattern match, maybe something like this.

    $string =~ s/(\w{20})(?=\w)/$1 /g;

> Also, how do you count the actual characters in a variable?

That would be the length function, documented in perlfunc.

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 07 May 1998 00:10:52 -0400
From: Lloyd Zusman <ljz@asfast.com>
Subject: Re: I need to delete temp files after 24 hours...
Message-Id: <ltu372n2k3.fsf@asfast.com>

root.noharvest.\@not_even\here.com (-) writes:

> "David" <kupid@ecom.net> Said this:
> 
> >Firstly, you would post the time that the filename is created.
> >
> >time ()
> >
> > [ ... etc. ... ]
> 
> Your answer is fine and dandy, but (and I'm not trying to be rude) the
> question is "how do I find out if "file" is older than 24 hours?" -
> which is the step prior to your explanation ;)
> 
> Here's the easiest way to do it all.......
> 
> [ ... example that uses `stat' and date subtraction ... ]

Here's another way ...

   if (-M $file >= 1.0) {
      print "File was modified at least one day ago.\n";
   }

This uses the "modification time" of the file.  You can use `-C' or
`-A' instead of `-M' to use the "change time" or the "access time",
respectively.  Each of these operators returns its result as a
floating point number of days.

For example, if the current local time is 10:00:00 AM and the file was
last modified at 4:00:00 AM yesterday, local time, then the return
value for `-M $file' would be 1.25.

This is documented (although not in a whole lot of detail) in the
`perlfunc' man pages under the section `-X FILEHANDLE'.

-- 
 Lloyd Zusman   ljz@asfast.com
 perl -e '$n=170;for($d=2;($d*$d)<=$n;$d+=(1+($d%2))){for($t=0;($n%$d)==0;
 $t++){$n=int($n/$d);}while($t-->0){push(@r,$d);}}if($n>1){push(@r,$n);}
 $x=0;map{$x+=(($_>0)?(1<<log($_-0.5)/log(2.0)+1):1)}@r;print"$x\n"'


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

Date: 7 May 1998 05:46:02 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: newbie question about system call
Message-Id: <6irhqq$icb$4@comdyn.comdyn.com.au>

Please read the following information on how to choose a good subject
line:

http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post


In article <355111CE.2723DD9B@ttc-cmc.net>,
	Tim Hodges <7twh@ttc-cmc.net> writes:
> I am at a point in a perl program that I want to make a system call and 

Just to get the terminology right: You're not trying to make a system
call. You're trying to use system() to execute some program. A system
call is another thing entirely.

# perldoc -f syscall

> put the output it returns into an array. In particular, I want to go:
> system "/usr/bin/diff $file1 $file2"; 
> and then some how put what is returned into an array like @diffs

What is returned is the exit status of your command. No need to put
that in an array. Or do you mean that you want to capture the output
of diff?

Have you read the documentation? (What? You mean there's
documentation?)

# perldoc -f system
[snip]
This is I<NOT> what you want to use to capture the output from a
command, for that you should use merely backticks or qx//, as
described in L<perlop/"`STRING`">.
[snip]

> Can anyone point me the right direction. I read 'the camel' on system
> calls but still cant figure it out.

The camel has the same information. It's not in the section about
system calls. it's in the section about system().

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Thu, 07 May 1998 06:27:54 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Tommy Ho <tch@interport.net>
Subject: Re: perl script for zone files
Message-Id: <Pine.GSO.3.96.980506232558.6329M-100000@user2.teleport.com>

On Wed, 6 May 1998, Tommy Ho wrote:

> I'd like to run a script to modify lines in multiple DNS zone files.  So
> if I need to change an "A" record or "NS" records on 50 different zone
> files all at once, I would need a perl script to do that. 
> 
> Does anyone have any experience with this? 

Since you're asking about editing text files with Perl, the answer is
'yes'. :-)  If you are trying to make your own program to do thas and you
get stuck while writing it, please post again and let us know where you've
gotten stuck. If you're just looking to acquire DNS administration
software, people in a newsgroup about DNS may be of some assistance. Hope
this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 7 May 1998 03:48:58 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Perl Socket and proxy Server
Message-Id: <6irava$hks$2@comdyn.comdyn.com.au>

In article <35510602.41C67EA6@net.net>,
	ayl <test@net.net> writes:
> Martin,
> 
> Thank you for your advice.
> The reason that I do not want want to use CPAN package is I am not sure
> if I can install it as a local copy or I have to ask sys admin to do
> this.

The best thing to do would be to ask the sysadmin, especially since
the LWP package is quite extensive, etc. If you can't convince
her/him, you'll have to install it yourself.

> If I use a local copy, how can I use it?

This is described in the perl faq, part 8:

# perldoc perlfaq8
/How do I install a CPAN module?
/How do I keep my own module/library directory?

> BTW, I just want to get the html source file, not the full blown http
> implmentation, thus I guess I can do it myself, at least I know exactly
> what I am doing.

If you have lynx installed, you could use that, with the -source
option.

> I read the relevent RFC already, but it does not work the way I expect.

That is why other people have done the work for you, so you don't have to
re-invent the wheel.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | In a world without fences, who needs
Commercial Dynamics Pty. Ltd.       | Gates?
NSW, Australia                      | 


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

Date: Thu, 07 May 1998 06:32:19 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: DAVID CHEW <dcc1234@pacific.net.sg>
Subject: Re: PLEASE HELP -ASCII file saved
Message-Id: <Pine.GSO.3.96.980506233026.6329O-100000@user2.teleport.com>

On Thu, 7 May 1998, DAVID CHEW wrote:

> Subject: PLEASE HELP -ASCII file saved

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> Whenever I save file I use the following code:
>  open (FILE, ">logtxt.cgi");

Even when your script is "just an example" (and perhaps especially in that
case!) you should _always_ check the return value after opening a file.

>  print FILE $txt_to_be_save ;
>  close FILE;
> 
>  The problem is THAT the file saved
>  may contain unneccessary carriage return \015
>  which disturbs the cgi program. 

Well, you could take those characters out before printing. See the
discussion of tr/// in perlop.

> How do I save in ascii ?

That sounded like you were using ASCII to me. Are you running on an EBCDIC
system? 

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 7 May 1998 05:40:34 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: PLEASE HELP -ASCII file saved
Message-Id: <6irhgi$icb$3@comdyn.comdyn.com.au>

Please read the following information on how to choose a good subject
line:

http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post


In article <35510E23.204366F5@pacific.net.sg>,
	DAVID CHEW <dcc1234@pacific.net.sg> writes:
> Whenever I save file I use the following code:
>  open (FILE, ">logtxt.cgi");

You should check the return value of an open().

>  print FILE $txt_to_be_save ;
>  close FILE;
> 
>  The problem is THAT the file saved
>  may contain unneccessary carriage return \015
>  which disturbs the cgi program.

I don't get it. Whatever you save, you can read in in the same way. Or
are you maybe reading in code, and writing that to some file, and then
go off and try to execute that as a cgi script?

> How do I save in ascii ?

You were saving in ASCII, unless that $txt_to_be_save contained
anything else. 

Oh, you mean, how do I strip out the \015? Use the s/// stuff as
described in perlop. You could of course also make sure that when you
transfer text files between platforms that it arrives in the format
that that system expects. Specifically: If you use FTP, transfer in
ASCII mode.

> Please sent help reply to my email

Not a chance. We're not a helpdesk. We're not here to service you.

> as I do not often visit this newsgroup

Pity. You're going to miss a lot of useful information. If you had
only read a few messages on this group, you would have known the
answer to your query, as well as picked up a lot of other useful
things to know, for example: how to behave on Usenet.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | The gene pool could use a little
Commercial Dynamics Pty. Ltd.       | chlorine.
NSW, Australia                      | 


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

Date: 6 May 1998 21:35:01 -0700
From: snay <snay@primenet.com>
Subject: Problem when using the LWP module.
Message-Id: <355139D9.58705683@primenet.com>

I'm attempting to use the LWP module to get information from another CGI
program.  I have no problem when sending a request to the CGI program
via a method post, the problem comes in when I attempt to request more
than once in a single program... I know that sounds weird, but it keeps
happening. I use the identical code to call the other CGI program... but
it returns errors the second time I call it. Any suggestions would be
greatly appreciated.  Here's the code:

#!/usr/bin/perl
print "Content-type: text/html\n\n";

%form=(accept_UPS_license_agreement=>'yes',
'30_cod'=>'0','10_action'=>'3', '13_product'=>'GNDRES',
'15_origPostal'=>'90804', '19_destPostal'=>'90066',
'22_destCountry'=>'US', '23_weight'=>'20', '24_value'=>'320',
'39_response'=>'1');

use URI::URL;
use LWP::UserAgent;
$ua=new LWP::UserAgent;

my $req= new HTTP::Request
'POST','http://www.ups.com/using/services/rave/qcosthtm.cgi';
$req->content_type('application/x-www-form-urlencoded');

my $curl=url("http:");
$curl->query_form(%form);
$req->content($curl->equery);


print "<PRE>\n</PRE>";


$pricing=$ua->request($req)->as_string;
($price)=$pricing=~/.*Total\sCharge\D*(\d*\.\d\d)/;

%form1=('30_cod'=>'0',accept_UPS_license_agreement=>'yes',
'10_action'=>'3', '13_product'=>'GNDRES', '15_origPostal'=>'90804',
'19_destPostal'=>'90066', '22_destCountry'=>'US', '23_weight'=>'200',
'24_value'=>'320', '39_response'=>'1');

$ua1=new LWP::UserAgent;

my $req1= new HTTP::Request
'POST','http://www.ups.com/using/services/rave/qcosthtm.cgi';
$req1->content_type('application/x-www-form-urlencoded');

my $curl1=url("http:");
$curl1->query_form(%form1);
$req1->content($curl1->equery);


$pricing1=$ua1->request($req1)->as_string;



($price1)=$pricing1=~/.*Total\sCharge\D*(\d*\.\d\d)/;

print'<HTML>';
print $price;
print'</HTML>';





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

Date: Thu, 7 May 1998 06:06:47 GMT
From: tmornini@netcom.com (Tom Mornini)
Subject: Re: qq method calls
Message-Id: <tmorniniEsKozB.4Lx@netcom.com>

Mark Schmick (mark@webz.com) wrote:

: >It's the scalar->method call that I was hoping for substition on like
: >a simple scalar. Is there a better method than removing these items from
: >the double-quoted string and printing them on their own? (which works, but
: >is extra code and typing!)

: Here are two approaches you can use:

: Ugly:
: 	You can use the somewhat-funky embedded string reference like
: 	so:
: 	  print "${ \($IMPQ::query->param(NAME)) }<BR>"

: Pretty:
: 	Use CGI.pm's import_names method, which creates (in a separate
: 	little package) "real" variables named after the field names
: 	in your web form, wihch you can embed easily in double-quoted
: 	strings, like so:
: 	  print "$Q::NAME<BR>"
: 	For more details, RTM.

: Hope that was helpful,

Very helpful. Thank you!

-- Tom Mornini
-- InfoMania


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

Date: Thu, 07 May 1998 06:09:27 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: francois Simonneau <Francois@sequent.com>
Subject: Re: Setsuid and PERL5LIB
Message-Id: <Pine.GSO.3.96.980506230529.6329J-100000@user2.teleport.com>

On Wed, 6 May 1998, francois Simonneau wrote:

> As long i change the owner of the wrapper with u+s  then it can't the
> module anymore.
> WHY ?
> it looks like PERL5LIB or the environment is gone

When a script is running set-id, Perl knows not to trust environment
variables, among other things. Otherwise, if your script loads SomeMod.pm
from a directory named in PERL5LIB, I could set PERL5LIB to point to my
own file named SomeMod.pm - and you wouldn't like that! :-) 

The general solution is to hard-code a known-safe library path into the
script, with 'use lib'. Hope this helps! 

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 07 May 1998 06:30:11 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Frank Meng <frankmeng@usa.net>
Subject: Re: settime
Message-Id: <Pine.GSO.3.96.980506232919.6329N-100000@user2.teleport.com>

On Wed, 6 May 1998, Frank Meng wrote:

> I want to compare two times. But how can I set it back as a TIME?

Maybe one of the modules on CPAN would do what you want. Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: Thu, 07 May 1998 06:39:16 GMT
From: Tom Phoenix <rootbeer@teleport.com>
To: Ian Sergeant <pezhead@cheerful.com>
Subject: Re: What is wrong with this?
Message-Id: <Pine.GSO.3.96.980506233458.6329Q-100000@user2.teleport.com>

On Wed, 6 May 1998, Ian Sergeant wrote:

> Subject: What is wrong with this?

Please check out this helpful information on choosing good subject
lines. It will be a big help to you in making it more likely that your
requests will be answered.

    http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post

> I got this from the perl book called Learning Perl.  I am trying to
> learn Perl and i can't get this to work.  What is the problem? 

When perl fails, there should be a diagnostic message. If you don't know
what it means, you should look in the perldiag manpage to find out more
about it. 

Of course, a program may fail by doing just what you've asked, rather than
what you intended. In this case, perl isn't failing, so there may be no
diagnostic message. Is that what happened?

Hope this helps!

-- 
Tom Phoenix       Perl Training and Hacking       Esperanto
Randal Schwartz Case:     http://www.rahul.net/jeffrey/ovs/



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

Date: 7 May 1998 03:54:38 GMT
From: mgjv@comdyn.com.au (Martien Verbruggen)
Subject: Re: Win95 Perl scripts DONT WORK on UNIX
Message-Id: <6irb9u$hks$3@comdyn.comdyn.com.au>

Please read the following information on how to choose a good subject
line:

http://www.perl.com/CPAN/authors/Dean_Roehrich/subjects.post


In article <6ir18l$flv@dfw-ixnews8.ix.netcom.com>,
	"edepot" <phlin@ix.netcom.com> writes:

> Hello.  I found out that perl scripts written to run
> on Windows 95 Perl DOES NOT WORK
> on unix Perl.

Depends on how they're written.

> The reason is that Windows (or DOS) puts a
> character "^M" after a line, and UNIX perl
> does NOT understand this character.

Oh, boy. This is not a perl problem. A text file created on a DOS
derivative box will have something different at the end of a line than
one created on a Unix box. Nothing new about that. This comes up on
this group about once a week, and gets answered every time. Did you
even check?

> The only way to fix it is if you have a utility

'Only' way? What a restricted view of the world.

> to STRIP the "^M" characters on the scripts from unix
> side after you have ftp'ed them from your
> win95 computer.  You can
> see the characters by editing the file using
> vi editor from the UNIX side.
> 
> My question is, HOW DO YOU STRIP THE

Stop shouting. You're annoying me.

> "^M" character?  Is there a perl script that

have you tried FTP in ascii mode?
have you tired to use perl for this?

Did you really need all this shouting and inanae chattering to ask
that question?

Perl CGI FAQ and (no offense) Idiot's guide:

http://www.perl.com/CPAN/doc/FAQs/cgi/idiots-guide.html
http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html

Section 9 of the perl FAQ:

# perldoc perlfaq9

> PLEASE EMAIL me responses as well...

Not a bleeding chance. Especially since you shouted at me.

Martien
-- 
Martien Verbruggen                  | 
Webmaster www.tradingpost.com.au    | Inside every anarchy lurks an old boy
Commercial Dynamics Pty. Ltd.       | network - Mitchell Kapor
NSW, Australia                      | 


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 2524
**************************************

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