[18378] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 546 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 22 03:05:40 2001

Date: Thu, 22 Mar 2001 00:05:12 -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: <985248311-v10-i546@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 22 Mar 2001     Volume: 10 Number: 546

Today's topics:
    Re: `pwd` doesn't work on all servers? <jazrant@zsc.nrcan.zc.ca>
    Re: Can't combine > and $ <joe+usenet@sunstarsys.com>
        CGI redirect implementation <yuriyt@ix.netcom.com>
    Re: checkbox problem <tomcat@visi.com>
        CPAN.pm endless configure loop <prschmitt@home.com>
        DBI and Activestate's perlapp <anthonyc@mincom.com>
    Re: FAQ 8.1:   How do I find out which operating system <johnlin@chttl.com.tw>
    Re: h2xs recursive failure in assign_typemap_entry <david_no_spam@carter.net>
        Help determining ShockwaveFlash h & w? <user@host.com>
        how do I deal with "Uncaught exception..."? <jazrant@zsc.nrcan.zc.ca>
    Re: lwp download status (Rafael Garcia-Suarez)
        LWP::UserAgent  <len.green@ntlworld.com>
    Re: LWP::UserAgent  (Rafael Garcia-Suarez)
        Need help with script as I suck at perl. (Kev.-)
    Re: Perl 5.6 - Spinning cursor routine? (Damian James)
    Re: Perl 5.6 - Spinning cursor routine? <comdog@panix.com>
    Re: Perl 5.6 - Spinning cursor routine? <joe+usenet@sunstarsys.com>
    Re: Print "tar" Success or Failure (BUCK NAKED1)
    Re: Still can't die with Tar (BUCK NAKED1)
    Re: Still can't die with Tar (BUCK NAKED1)
    Re: Still can't die with Tar (The Mosquito ScriptKiddiot)
    Re: time calculation <TeKno@supportinfo.com>
    Re: Trouble compiling modules from CPAN <randy@theory.uwinnipeg.ca>
    Re: usernames & passwords - how to ??? <steve10@videotron.ca>
    Re: usernames & passwords - how to ??? <cbunn@udel.edu>
    Re: Win32::ODBC::ColAttributes  problem (Philip Lees)
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Wed, 21 Mar 2001 23:19:40 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: Re: `pwd` doesn't work on all servers?
Message-Id: <99buok$ktb5@nrn2.NRCan.gc.ca>

"Tony Curtis" <tony_curtis32@yahoo.com> wrote in message
news:87g0g64tif.fsf@limey.hpcc.uh.edu...
> >> On Wed, 21 Mar 2001 17:47:03 -0500,
> >> "John A. Grant" <jazrant@zsc.nrcan.zc.ca> said:
    [...]
> > I have never had a problem in C with system() or
> > getcwd() failing just because of a path problem.  It's
> > Yet Another Perl Weakness I guess. Sigh.
>
> A C program running as a CGI program without "standard"
> directories on its PATH envariable would suffer the same
> fate if you used system() [with a basename for the
> executable].
    [...]
    True, but the implementation of getcwd() in the C RTL
    would never fail.  It's never failed me on several flavours
    of unix, dos, or windows.  With Perl, I have had to modify
    the #!/.../perl directive to run it on 2 different unix boxes.
    I've also had to add and modify a $pwd variable to get it
    to run.

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





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

Date: 22 Mar 2001 00:47:15 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Can't combine > and $
Message-Id: <m3k85i4aos.fsf@mumonkan.sunstarsys.com>

"John W. Krahn" <krahnj@acm.org> writes:

> Richard Kennaway wrote:
> > 
> > In article <E0Ps6.73$ez4.3092@eagle.america.net> Garry Williams,
> > garry@zvolve.com writes:
> > > open(OUT, ">$_/scripts/make_mask.txt")
> > >     || die "can't open $_/scripts/make_mask.txt: $!\n";
> > 
> > The three-argument version of open would be better:
>       ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> 
> Really? Did you compile your own version of Perl with this feature
> added?

Maybe so.

> >     open(OUT, ">", "$_/scripts/make_mask.txt")
> 
> Too many arguments for open at -e line 1, near
> ""$_/scripts/make_mask.txt")"
> Execution of -e aborted due to compilation errors.

  % perl -ce 'open(OUT, ">", "$_/scripts/make_mask.txt")'
  Too many arguments for open at -e line 1, at end of line
  -e had compilation errors.
  % /usr/local/bin/perl -ce 'open(OUT, ">", "$_/scripts/make_mask.txt")'
  -e syntax OK
  % /usr/local/bin/perl -v

  This is perl, v5.6.0 built for i586-linux
  ...

(It actually works just as Richard advertised on my 5.6).

-- 
Joe Schaefer    "Whoever undertakes to set himself up as a judge of Truth and
                    Knowledge is shipwrecked by the laughter of the gods."
                                               --Albert Einstein


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

Date: Wed, 21 Mar 2001 21:34:29 -0800
From: Yuriy Tenenbaum <yuriyt@ix.netcom.com>
Subject: CGI redirect implementation
Message-Id: <3AB98EE5.87B70FF4@ix.netcom.com>

OK, as i have read many times and learned on my own experience, if I
want to do

$query->redirect('http://new_url/cgi-bin/script.cgi')

I should NOT use headers.

But lets say i have a CGI form.  When user submits the information, i
want to print that information on a clean page and ask the user to
"confirm" the entered information.  Obviously in order to create an
original form i must have used headers....  QUESTION - how do i redirect
the user to the confirmation page?  This must be a very common
manipulation, and i don't know it because i just started using CGI.  Is
there another way to implement this?

To finalize - i have a form... i want to print the entered information
on another page and ask user to confirm... i had to use headers on the
original form, so i can't redirect... What do i do?  How do people
normally jump from the form to "confirmation" page?

thanks

-sergey-



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

Date: Thu, 22 Mar 2001 03:25:27 GMT
From: uNcONvEntiOnaL <tomcat@visi.com>
Subject: Re: checkbox problem
Message-Id: <Hgeu6.1559$SB2.147171@ruti.visi.com>

Damian James <damian@qimr.edu.au> wrote:
: For more details, see the documentation for CGI.pm -- it is part of the
: standard distribution of Perl, and as such should already be sitting on
: your hard drive. Try typing 'perldoc CGI' at the command prompt.

I run my perl scripts on my unix shell account at my ISP.
All are involked from web pages.  I cannot get either the perl
library or module mechanism to work, hence I end up writing
my own stuff.  I can bring in textbox and textarea data, I
can's seem to bring in checkbox arrays.  Just thought someone
else might have wrestled with this without using CGI.pm or
such.

Your information on CGI.pm looks compelling.  I will have to 
give it a go again.  I use perl -d to try and see debugging,
but it is the server logs unfortunately that I think I need to
look at to see what errors when I try and refer to CGI.pm

The "cross post" came about because I *thought* I posted a new
article, and it didn't show up.  I made a mistake and did
a followup.  Not knowing this, I posted again.  Hey, give me
credit for looking at similar posts before posting myself ;)

Regards

Tom


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

Date: Thu, 22 Mar 2001 04:02:51 GMT
From: Pete Schmitt <prschmitt@home.com>
Subject: CPAN.pm endless configure loop
Message-Id: <3AB97916.CEA19261@home.com>

Greetings, all.
	I've just fired up the CPAN module for the first time on a new
Slackware 7.1 install (perl 5.6.0 that I had to compile from source so
perl, apache, mod_perl and php4 were all built with the same compiler -
gcc 2.95.2. That went ok.)
	I went through the initial questions, and got back to the cpan> prompt.
I then installed the latest Bundle::CPAN as suggested. That went well
too. Everything downloaded and built just fine.
	Next was getting Bundle::DBI. Peachy.
	I then realised that I hadn't done a reload cpan, so I did so.
	The cpan module then decided that I had to configure again, as it
announced that my cache_metadata was uninitialised. I figured ok, fine..
later version.. maybe something has changed.
	Went through the configure questions again, only to end up where I
started. Uninitialised cache_metadata. 
	One more time through all this, and I ^C'd my way out of the program.
	Fired it up again. Cool, there's the cpan> prompt. Attempt 'install
Image::Size', and the configure crap starts yet again. "unitialised
cache_metadata".
	I had this happen once before, on a different machine, different OS
rev, older perl version. I can't for the life of me remember  if I got
it working again. I think I just installed all my modules by hand after
that.
	Any ideas what's going on or how to fix it? I've been reading FAQ's and
drilling into search engines all afternoon to no avail.
	Thanks much in advance.
	Pete.

-- 
- Nobody moves very much in a Hanna Barbera cartoon! - Zorak
- Philip Glass! Muzak for the new millenium!
- Prschmitt at home dot com http://www.geocities.com/prschmitt/


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

Date: Thu, 22 Mar 2001 17:35:06 +1000
From: "Anthony Carbone" <anthonyc@mincom.com>
Subject: DBI and Activestate's perlapp
Message-Id: <99c9q6$pkm$1@sol.mincom.oz.au>

When you have a script that 'uses DBI' and you compile the script using
'perlapp -s <script name> -e <script exe> -f -r -v', the executable crashes
on and DBI method call. For example, this is a small test script that works
if you don't compile it and use perl.exe to process it and DOES NOT WORK if
you compile it using 'perlapp' and invoke the made executable. There is no
output what so ever about why it crashes.

Activestate's 'perlapp' is really cool which allows you to turn perl scripts
into a large meaty executable file on Windows. Saves a lot of execution time
(memory is debatable) if you have a busy Windows system with a lot of perl
scripts.

thanks in advanced for any help.

anthonyc.

---------------
use Win32;
use DBI;

open (FOO,"> c:\\temp\\cur.txt");

print FOO "before dbi method call\n";


$dbh = DBI->connect('DBI:ODBC:ELLIPSE','mimsadmin','mims') || die
$DBI::errstr;

print FOO "after dbi method call\n";

$sql_statement = "SELECT PROG_NAME from MSF080";

$cursor = $dbh->prepare("$sql_statement");
if ( ! $cursor ) {
    print "$DBI::errstr\n";
}

$cursor->execute;

while ( $foo = $cursor->fetchrow() ) {
        print FOO "$foo\n;";
}





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

Date: Thu, 22 Mar 2001 09:22:33 +0800
From: "John Lin" <johnlin@chttl.com.tw>
Subject: Re: FAQ 8.1:   How do I find out which operating system I'm running under?
Message-Id: <99bk1r$lkn@netnews.hinet.net>

"PerlFAQ Server" wrote
>   How do I find out which operating system I'm running under?
>     The $^O variable ($OSNAME if you use English)

WinNT and Win95 got the same result 'MSWin32', right?
Why don't HPUX ('hpux') and SunOS ('solaris') get the same result 'Unix'?
The difference between WinNT and Win95 is quite large.

John Lin





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

Date: Thu, 22 Mar 2001 03:48:58 GMT
From: "david carter" <david_no_spam@carter.net>
Subject: Re: h2xs recursive failure in assign_typemap_entry
Message-Id: <KCeu6.159518$Z8.34327128@typhoon.southeast.rr.com>

"Ilya Zakharevich" <ilya@math.ohio-state.edu> wrote in message
news:99b79h$a9c$1@charm.magnus.acs.ohio-state.edu...

> Thank you for tracing this far.  The next step is to isolate the
> problem: remove the dependencies (like you did with windows.h), and
> those parts of the .h file which are irrelevant to the failure.
>
> Let us know the results.  [Better Cc me.]

Ilya - yes, I was thinking along the same lines. Here's what I did:
(1) commented out the union-typedef'd member of the struct. (Left the union
defined, but unreferenced.) h2xs completed with no errors.
Now looks like this:

typedef union arm_user_metric1_u {
    arm_unsigned32_t  counter32;       /*  Counter32  */
    arm_unsigned64_t  counter64;       /*  Counter64  */
    arm_cntrdivr32_t  cntrdivr32;      /*  Counter32 + Divisor32  */
    arm_int32_t       gauge32;         /*  Gauge32  */
    arm_int64_t       gauge64;         /*  Gauge64  */
    arm_gaugedivr32_t gaugedivr32;     /*  Gauge32 + Divisor32  */
    arm_unsigned32_t  numericid32;     /*  NumericID32  */
    arm_unsigned64_t  numericid64;     /*  NumericID64  */
    char              string8[8];      /*  String8  */
} arm_user_metric1_u;

typedef struct arm_user_data1_t {
    arm_int32_t          format;        /*  Version/format id (userdata_e)
*/
    arm_bit8_t           flags[4];      /*  Flags for metrics' presence  */
/*    arm_user_metric1_u   metric[6];     */
==> commenting this out lets h2xs finish
    char                 string32[32];  /*  32 byte non-terminated string
*/
    arm_app_correlator_t correlator;    /*  Correlator  */
} arm_user_data1_t;


(2) next, moved the union in-line to the struct, since the union typedef is
not referenced anywhere else in the .h file. h2xs completes with no errors,
but code generated in the .xs will not compile - there seem to be two types
of errors, one of which is related to accessor functions for the
union-within-a-struct. The other class of error seems to relate to
non-type-safe assignments of "char <varname>[n]" members of structs to/from
pointer types.
Now looks like this:

typedef union arm_user_metric1_u {                                /* ==>
this typedef is no longer referenced in the code */
    arm_unsigned32_t  counter32;       /*  Counter32  */
    arm_unsigned64_t  counter64;       /*  Counter64  */
    arm_cntrdivr32_t  cntrdivr32;      /*  Counter32 + Divisor32  */
    arm_int32_t       gauge32;         /*  Gauge32  */
    arm_int64_t       gauge64;         /*  Gauge64  */
    arm_gaugedivr32_t gaugedivr32;     /*  Gauge32 + Divisor32  */
    arm_unsigned32_t  numericid32;     /*  NumericID32  */
    arm_unsigned64_t  numericid64;     /*  NumericID64  */
    char              string8[8];      /*  String8  */
} arm_user_metric1_u;

typedef struct arm_user_data1_t {
    arm_int32_t          format;        /*  Version/format id (userdata_e)
*/
    arm_bit8_t           flags[4];      /*  Flags for metrics' presence  */
/*    arm_user_metric1_u   metric[6];
==> replacing this with in-line union lets h2xs finish */
    union  {
        arm_unsigned32_t  counter32;       /*  Counter32  */
        arm_unsigned64_t  counter64;       /*  Counter64  */
        arm_cntrdivr32_t  cntrdivr32;      /*  Counter32 + Divisor32  */
        arm_int32_t       gauge32;         /*  Gauge32  */
        arm_int64_t       gauge64;         /*  Gauge64  */
        arm_gaugedivr32_t gaugedivr32;     /*  Gauge32 + Divisor32  */
        arm_unsigned32_t  numericid32;     /*  NumericID32  */
        arm_unsigned64_t  numericid64;     /*  NumericID64  */
        char              string8[8];      /*  String8  */
     } metric[6];
    char                 string32[32];  /*  32 byte non-terminated string
*/
    arm_app_correlator_t correlator;    /*  Correlator  */
} arm_user_data1_t;

Any suggestions where I should go from here?

Thanks,
David
david_no_spam_%carter.net






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

Date: Thu, 22 Mar 2001 00:56:50 -0600
From: xris <user@host.com>
Subject: Help determining ShockwaveFlash h & w?
Message-Id: <user-9A70F2.00565022032001@newsrump.sjc.telocity.net>

A possible new client is interested in using flash instead of gif/jpeg 
on his site.  Currently, I have a web-based form for allowing users to 
upload images, and autodetect both the file type and the height & width 
of the uploaded files.  I've searched all over for any easy way to do 
this same thing with Flash files, and have wracked my brain with hex 
dumps of several .swf files but with no luck (I'm just not that good at 
hacking file formats)..

I'm hoping that someone out there in the perl world has come up with an 
easy solution that can be integrated with my software (my isp won't 
install new perl modules).

Thanks,

Chris

(ps. please reply here, I get too much spam to trust using a real email 
address in newsgroup posts)


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

Date: Thu, 22 Mar 2001 01:20:55 -0500
From: "John A. Grant" <jazrant@zsc.nrcan.zc.ca>
Subject: how do I deal with "Uncaught exception..."?
Message-Id: <99c5s0$n0b3@nrn2.NRCan.gc.ca>

This is for CGI use, rather than local (if it makes a difference).

I'm getting this error message when I call "die":
    "Uncaught exception from user code: main::Error() called at ..."

My code looks like this:
    my $error=0;

    sub Error
    {
        if(@_){
            my $message=$_[0];
            print "<b><font color=red>Error: </font> $message</b>";
            $error=$1;
        }else{
            die "abort" if $error;
        }
    }

and I call it like this:
    if(...) Error("whatever");
    if(...) Error("something else");

and finally after doing all of this checking, I call this:
    Error();

The last call (without parameters) should "die" if there has
been an error, otherwise do nothing and the program carries
on from there. It all works as it should, but I get the
"uncaught exception" message when it calls "die".

1. is that normal?
2. what is uncaught? how do I catch it? :)
3 can I suppress the message?
4. should I suppress it?

--
John A. Grant  * I speak only for myself *  (remove 'z' to reply)
Radiation Geophysics, Geological Survey of Canada, Ottawa
If you followup, please do NOT e-mail me a copy: I will read it here





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

Date: Thu, 22 Mar 2001 07:40:39 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: lwp download status
Message-Id: <slrn9bjb3t.281.rgarciasuarez@rafael.kazibao.net>

Eric wrote in comp.lang.perl.misc:
> is there any way to show the status of a file transfer using lwp in
> activeperl?

With LWP::UserAgent, you can specify to the request() method a reference
to a subroutine which will be called when chunks of data will be
received. You can also specify a recommended chunk size. Something like:

  $ua->request($request, \&show_progress, 1024);

The show_progress callback should then store the response content
in an appropriate place, and is able to calculate the download progress
if you got previously the value of the Content-Length header. (This
value can be retrieved from the response object passed to the callback).

See the docs for LWP::UserAgent for details.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/
perl -sleprint -- -_='Just another Perl hacker,'


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

Date: Wed, 21 Mar 2001 20:02:14 -0000
From: "len.green" <len.green@ntlworld.com>
Subject: LWP::UserAgent 
Message-Id: <aXhu6.26573$bL.2447135@news6-win.server.ntlworld.com>

Hi

Can Anyone help
I'm trying to get a response code from a server with custon 404 pages, even
if a page is missing it still returns a 200 OK
???????????????????????
I've looked in to HTTP::status but with not much success, am I missing the
point somewhere

Cheers

Len

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

#!/usr/local/bin/perl

print "Content-type: text/html\n\n";
use LWP::UserAgent;
$ua = new LWP::UserAgent;

$url="http://www.serverwithcustom404.com";
$req = new HTTP::Request 'GET' => $url;
$req->header('Accept' => 'text/html');

$res = $ua->request($req);

print $res->code; # 200 all the time I don't want this :(

exit;

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




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

Date: Thu, 22 Mar 2001 08:00:50 GMT
From: rgarciasuarez@free.fr (Rafael Garcia-Suarez)
Subject: Re: LWP::UserAgent 
Message-Id: <slrn9bjc9o.281.rgarciasuarez@rafael.kazibao.net>

len.green wrote in comp.lang.perl.misc:
> I'm trying to get a response code from a server with custon 404 pages, even
> if a page is missing it still returns a 200 OK
> 
[snip]
> 
> $url="http://www.serverwithcustom404.com";
> $req = new HTTP::Request 'GET' => $url;
> $req->header('Accept' => 'text/html');
> 
> $res = $ua->request($req);
> 
> print $res->code; # 200 all the time I don't want this :(

If you have access to the configuration of the server (what kind of
server is it anyway ?) you can look at how the custom 404 thing is
implemented. It's possible that there is a redirection to the custom 404
page, which will be served with a status code equal to 200. Try using
simple_request() instead of request() to ensure that LWP does not
perform any unwanted operation.

-- 
Rafael Garcia-Suarez / http://rgarciasuarez.free.fr/perl/biscuit.html


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

Date: Thu, 22 Mar 2001 04:42:30 GMT
From: java2e@yahoo.com (Kev.-)
Subject: Need help with script as I suck at perl.
Message-Id: <3ab981ce.23655584@news.zyan.com>

Hello All,

I am suppose to call this link:

http://www.abc.com/xxx.cgi?link=Dude/1/test&seed=41FLZ9FJJ 

which return this:

http://www.xzy.com/default.asp?seed=41FLZ9FJJ &pop=12&receipt=12

Then I am suppose to pass the pop to a function called valid.

How heck to I do this??

I am suppose to recall the abc.com link but I cant figure it out.

Thanks,

Kev.-




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

Date: 22 Mar 2001 02:10:38 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: Perl 5.6 - Spinning cursor routine?
Message-Id: <slrn9bino6.7rt.damian@puma.qimr.edu.au>

Monte chose Thu, 22 Mar 2001 00:18:03 GMT to say this:
>...
>$count=0;  # place this at beginning of program
>           # you can make the following a subroutine
>
>if ($count==0) {
>        print "\|\b" ;
>        }
>    if ($count==1) {
>        print ("\/\b");
>        }
>        print "-\b";
>    if ($count==2) {
>        print "\\\b";
>        }
>
>$count = $count + 1;
>    if ($count==3) {
>        $count=0;
>    }

Much more useful as a closure:

#!/usr/local/bin/perl -w
use strict;

sub make_twiddle {
    my @chars = qw(\ | / -);
    my $count = 0;

    return sub {
        local $| = 1;
        return "\b"x($count>0).$chars[$count++%4];
    }
};

my $twiddle = make_twiddle();

EVENT_LOOP:
for (0..50) {

    print $twiddle->();

    # do your processing here...
    select undef, undef, undef, 1/5;
};

print "\n";
__END__

This allows you to stick a single call to the coderef in your processing loop,
without having to worry about what it's up to.

HTH

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


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

Date: Wed, 21 Mar 2001 22:04:10 -0500
From: brian d foy <comdog@panix.com>
Subject: Re: Perl 5.6 - Spinning cursor routine?
Message-Id: <comdog-85891B.22041021032001@news.panix.com>

In article <slrn9bino6.7rt.damian@puma.qimr.edu.au>, damian@qimr.edu.au 
(Damian James) wrote:

> Much more useful as a closure:
> 
> #!/usr/local/bin/perl -w
> use strict;
> 
> sub make_twiddle {
>     my @chars = qw(\ | / -);
>     my $count = 0;
> 
>     return sub {
>         local $| = 1;
>         return "\b"x($count>0).$chars[$count++%4];
>     }
> };
> 
> my $twiddle = make_twiddle();
> 
> EVENT_LOOP:
> for (0..50) {
> 
>     print $twiddle->();
> 
>     # do your processing here...
>     select undef, undef, undef, 1/5;
> };
> 
> print "\n";
> __END__
> 
> This allows you to stick a single call to the coderef in your processing loop,
> without having to worry about what it's up to.

in that case, just use Tie::Cycle and save yourself the work. :)

    #!/usr/bin/perl

    use Tie::Cycle;

    $|++;

    tie my $indicator, 'Tie::Cycle', [ qw( \ | / - ) ];

    print "\n$indicator";

    while ( 1 ) { print "\b$indicator"; sleep 1 }

-- 
brian d foy <comdog@panix.com>



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

Date: 22 Mar 2001 01:27:18 -0500
From: Joe Schaefer <joe+usenet@sunstarsys.com>
Subject: Re: Perl 5.6 - Spinning cursor routine?
Message-Id: <m3elvq48u1.fsf@mumonkan.sunstarsys.com>

damian@qimr.edu.au (Damian James) writes:

> sub make_twiddle {
>     my @chars = qw(\ | / -);
>     my $count = 0;
> 
>     return sub {
>         local $| = 1;
          ^^^^^

As Uri pointed out to me a few months ago, you can't 
really localize $| without some cooperation from your 
print calls located elsewhere in the code.  IMHO it's 
less confusing to leave off the 'local' declaration 
in this code, or alternatively move the print statement
inside the closure.

> my $twiddle = make_twiddle();
> 
> EVENT_LOOP:
> for (0..50) {
> 
>     print $twiddle->();
            ^^^^^^^^^^^^

What's happening here is that each time perl evaluates 
the closure, it sets $| = 1, which causes an autoflush 
on stdout. Hence the characters printed are from the 
previous loop, and the print statement puts a new pair 
in its place.  To see this, try this loop instead:

  EVENT_LOOP:
  for (0..10) {
    print $twiddle->();
    sleep 2;
  }

It should take 2 seconds for the first character to 
appear. The first time through the loop, $|=1 is set,
but there's nothing in the buffer to flush. By the
time print is called, $|=0 again since the localization 
of $| has disabled autoflush. On the second pass, the 
buffer is flushed by the "local $|=1" call in the 
closure, and the process repeats. 


Hope I'm not being too nitpicky, but I appreciated it
when Uri pointed this out before.

-- 
Joe Schaefer   "The difference between the right word and the almost right word
                 is the difference between lightning and the lightning bug."
                                               --Mark Twain


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

Date: Wed, 21 Mar 2001 22:20:11 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Print "tar" Success or Failure
Message-Id: <25531-3AB97D7B-70@storefull-245.iap.bryant.webtv.net>

bmb@ginger.libs.uga.edu (Brad=A0Baxter) 
> Does the following help at all? 
>  =A0=A01 #!/usr/local/bin/perl
>=A0=A0=A0=A02 use warnings;
>=A0=A0=A0=A03 use strict;
> =A0=A0=A04 
>=A0=A0=A0=A05 my $success =3D system('tar cvf x.tar qt paste');
>  =A0 6 
>=A0=A0=A0=A07 print "\n\$?:$? \$success:$success\n\n";
>  =A0=A08 
>   =A09 my $failure =3D system('tar Z');
>=A0=A0=A010 
>=A0=A0=A011 print "\n\$?:$? \$failure:$failure\n";
>  =A012 
>=A0=A0=A013 __END__
> [snipped output]
> Brad 

Ummm, no. All that the output to the above shows is a success return
value of 0, and failure return value of 256. However, the failure is
based on a totally different operation, and incomplete code(tar -Z ???).
If I replaced either of your 'tar' operations in my $success or in my
$failure with "tar -zxf", I get a return value of 0 either way...
whether the tar file is good or bad.

That's what is confusing me. Why does $? have a return value of 0
whether the tar operation is successful or not? Is there another
variable that checks child return status? I know of $@, but it is only
used with eval.

Thanks anyway,
--Dennis

 



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

Date: Wed, 21 Mar 2001 23:07:55 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Still can't die with Tar
Message-Id: <22263-3AB988AB-66@storefull-242.iap.bryant.webtv.net>

peter.sundstrom-eds@eds.com 
> Why not expand it out a bit to make it a >  little more readable. 
> system("tar -zxf file.tar.gz 2>&1"); 
> if ($? =3D=3D 0) {
>=A0=A0=A0=A0print "SUCCESS\n"; 
> } 
> else { 
>=A0=A0=A0=A0=A0=A0=A0=A0unlink $tmpfile or die "Can not 
> unlink $tmpfile $!\n";
> =A0=A0=A0die "FAILURE\n"; 
> } 

Thanks Peter for trying to help and giving me yet another example. I had
written one fairly similar to the one above and tried it, but it, and
the script above, both give me a success message for either a successful
or failed tar operation. (FWIW, I have tested all of the suggested
scripts from this thread both with a good tar file and a messed up tar
file that always fails.)

It seems that the confusing part for me now is what tar is returning.
Now that I know that tar should return 0 when successful (and I reviewed
the post... sorry Gary, you did tell me), I don't understand why $? is
returning a value of 0 whether tar is successful or fails?

However, when tar fails... I see an additional message from tar stating
something to the effect of "tar child status return 1"... but $? still
prints 0, and my "success" message still prints, as above.

Regards,
--Dennis

 



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

Date: Wed, 21 Mar 2001 23:52:29 -0600 (CST)
From: dennis100@webtv.net (BUCK NAKED1)
Subject: Re: Still can't die with Tar
Message-Id: <16936-3AB9931D-105@storefull-243.iap.bryant.webtv.net>

I thought this might help explain my problem better. Here's my latest
complete test code and the results..

#!/usr/bin/perl -wd
use CGI::Carp qw(fatalsToBrowser);
print "Content-type: text/html\n\n";

system("tar -zxf failure.tar.gz 2>&1"); 
if ($? == 0) { 
print "SUCCESS: $?\n"; 
} 
else { 
unlink $tmpfile or die "Can not unlink $tmpfile $!\n"; 
die "FAILURE: $?\n"; 
}; 

OUTPUT for Failure...
gzip: stdin: unexpected end of file tar: child returned status 1
SUCCESS: 0    

OUTPUT for Success...
SUCCESS: 0

Now, WHY is "SUCCESS: 0" printing whether the tar operation is
successful or fails? Shouldn't $? print a different value on success
than it does on failure?

Things I've learned from this thread:
1. tar returns 0 if successful, and nonzero if it fails.
2. use "system" to check the success of tar
3. "system" errors and return values are found in $?
4. use backticks with a 2>&1 for printing the tar operation to STDOUT

So, I probably need to do something like this:

system('tar -zxf file.tar.gz`);
if ($? == 0) 
{
`tar-zxf file.tar.gz 2>&1';
 print "success: $?\n";
} else {
print "TAR FAILED: $?\n"; unlink $tmpfile or die "Can't remove $tmpfile:
$!\n"; 
};

Regards,
--Dennis



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

Date: 22 Mar 2001 06:17:04 GMT
From: anotherway83@aol.com (The Mosquito ScriptKiddiot)
Subject: Re: Still can't die with Tar
Message-Id: <20010322011704.22172.00000600@ng-fc1.aol.com>


>Subject: Re: Still can't die with Tar

sumtimes tar doesn't work so u need to use other things if u want to die

rat poison and an overdose of DDT are sum possibilities u mite want to consider

the best way, tho, is to take a whole bottle of sleeping pills

thats how i would like to go

thank u, thank u, thank u, i know im good

peace


The Mosquito ScriptKiddiot
Championing the Cause of Mosquitoes in Technology


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

Date: Thu, 22 Mar 2001 07:03:45 GMT
From: "TeKno" <TeKno@supportinfo.com>
Subject: Re: time calculation
Message-Id: <lthu6.487$Wx3.103814240@newssvr10-int.news.prodigy.com>


"Ebonyxman" <ebonyxman@aol.com> wrote in message
news:20010320222120.27536.00000129@ng-mj1.aol.com...
> Can anyone point me in the right direction? I need to calculate the number
of
> minutes between two date/time fields in the form "03/20/01 12:30 PM".
Does
> PERL have any help in this area?
>
> Thanks for any help anyone can provide....

I use this in a program

use Date::Manip

#at beginning of main process
$start=localtime(time);

#Store Finish Time - near end of script(after main processing)
$finish = localtime(time);
#perform time calculations
$elap = &DateCalc($start,$finish,\@err);
@elapse = split(/:/,$elap);
$hrs=@elapse[4];
$mins=@elapse[5];
$secs=@elapse[6];

I am not by far a perl wizzard so if I am all screwed up with this it is
cool to let me know
but it works for me















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

Date: Wed, 21 Mar 2001 20:42:49 -0600
From: "Randy Kobes" <randy@theory.uwinnipeg.ca>
Subject: Re: Trouble compiling modules from CPAN
Message-Id: <99bp8d$4gr$1@canopus.cc.umanitoba.ca>

"Jørgen Gusgaard" <gusgaard@ementa.net> wrote in
    message news:Vf2u6.3021$mh4.198580@news3.oke.nextra.no...
> Hello.
> I am trying to compile modules from cpan on my windows 2000.
> When dooing this the nmake.exe (v1.5)  complains that it can't find the
> program cl.exe
> What do I need to fix this problem ?

cl.exe is the Microsoft Visual C++ compiler. Do you have
that? If so, adding it to your PATH should fix the problem.

best regards,
randy kobes





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

Date: Wed, 21 Mar 2001 22:54:41 -0500
From: "Steve Martin" <steve10@videotron.ca>
Subject: Re: usernames & passwords - how to ???
Message-Id: <sIeu6.12754$7g.250695@wagner.videotron.net>

JavaScript, can do it, but it is highly unsecure.  You just view the source
or download the someName.js file and you get the password.  Do not use
javaScript for this.

Use Perl it's simple or use htacess

Steve


Francois Richard <richard@science.uottawa.ca> wrote in message
news:997t3t$99k3@mercury.cc.uottawa.ca...
> (sorry for cross-posting, but I'm really shooting in the dark: I have no
> idea where to start with this!)
>
> Can someone please point me in the right direction (FAQ, web resources,
> etc.)?
>
> I want to create a simple web page that allows guests to the web site to
> enter a userid and password, and store these with their names in a text
> or database file on our server.
>
> What is the best way to do this? Does it involve JavaScript alone, or a
> combination with other tools (CGI, Perl, Java, etc.)?
>
> I have looked for info on the internet, but so far this is proving to be
> a very frustrating experience... I would greatly appreciate any
> pointers/advice you may have.
>
> Cheers,
> _________________________________________________
> François Richard  -  Earth Sciences
> University of Ottawa (Canada)
>
>
>




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

Date: Wed, 21 Mar 2001 23:10:52 -0800
From: "Tyler Durden" <cbunn@udel.edu>
Subject: Re: usernames & passwords - how to ???
Message-Id: <99btv8$ntd$1@news.udel.edu>

the simplest way of doing things is to use HTTP's built in user
authentication with an.htaccess file.  For more robust and complex
situations you can combine that with a server-side element (PHP, CGI, etc).
Or, you could just use the server-side element alone.  I am doing some user
authentication soon, and i intend on using HTTP user authentication with
PHP, because the application doesnt require anything fancy.  Good Luck.


--
Christopher Bunn
AIM: cmbski14
ICQ: 49116317

********************************************

"A man sits with a pretty girl for an hour, it seems like a minute. He sits
on a hot stove for a minute, it's longer than any hour. That is relativity."
                                     - Albert Einstein

My Web Site:
http://copland.udel.edu/~cbunn/

"Francois Richard" <richard@science.uottawa.ca> wrote in message
news:997t3t$99k3@mercury.cc.uottawa.ca...
> (sorry for cross-posting, but I'm really shooting in the dark: I have no
> idea where to start with this!)
>
> Can someone please point me in the right direction (FAQ, web resources,
> etc.)?
>
> I want to create a simple web page that allows guests to the web site to
> enter a userid and password, and store these with their names in a text
> or database file on our server.
>
> What is the best way to do this? Does it involve JavaScript alone, or a
> combination with other tools (CGI, Perl, Java, etc.)?
>
> I have looked for info on the internet, but so far this is proving to be
> a very frustrating experience... I would greatly appreciate any
> pointers/advice you may have.
>
> Cheers,
> _________________________________________________
> François Richard  -  Earth Sciences
> University of Ottawa (Canada)
>
>
>




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

Date: Thu, 22 Mar 2001 07:48:58 GMT
From: pjlees@ics.forthcomingevents.gr (Philip Lees)
Subject: Re: Win32::ODBC::ColAttributes  problem
Message-Id: <3ab9ade4.3150269@news.grnet.gr>

On Wed, 21 Mar 2001 21:28:28 +0100, Jaroslaw Olczak
<jarojaro@delta.ds2.pg.gda.pl> wrote:

>I have MSSQL 7 Server and Win98. I have installed AcitvPerl v 5.22 and
>use Win32::ODBC to get some data from tables, and database scheme.  I
>have problem with ColAttributes method. When I use this method to
>retrive attributes of  some  columns, I get only 4 spaces without any
>error messages.  Using script  ( from FAQ ):
>
> $db=new Win32::ODBC("DSN=MQIS;UID=sa;PWD=") ;
>  $db->Sql("SELECT * FROM  Customers ");
>  my(@fields) = $db->FieldNames;
>  my(%type) = $db->ColAttributes($db->SQL_COLUMN_TYPE);
>  my(%len) = $db->ColAttributes($db->SQL_COLUMN_LENGTH);
>  my(%null) = $db->ColAttributes($db->SQL_COLUMN_NULLABLE);

I think that should be:

my %type = $db->ColAttributes( ODBC::SQL_COLUMN_TYPE );

 ... and so on. At least, that works for me.

Phil
--
@x=split//,'Just another Perl decoder,';split//,'*'x@x;%i=split/=/,
'AA=a=aa= =1=,';for$i(0..$#x){$_[$i]=chr($=+5);while($_[$i]ne$x[$i])
{$_[$i]=$i{$_[$i]}if$i{++$_[$i]};print@_,"\r";while(rand!=rand){}}}
Ignore coming events if you wish to send me e-mail


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

Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 16 Sep 99)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 546
**************************************


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