[18415] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 583 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Mar 29 14:07:16 2001

Date: Thu, 29 Mar 2001 11:05:39 -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: <985892738-v10-i583@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 29 Mar 2001     Volume: 10 Number: 583

Today's topics:
        add lines from logfile <td@chemsoft.de>
        Bugs In vss2cvs.pl (Josh Geller)
    Re: Can we make the @array->push(1..10) syntax (Logan Shaw)
    Re: Capturing POD output nobull@mail.com
    Re: Capturing POD output <steve_woolet@us.ibm.com>
    Re: date handling? (e)
    Re: date handling? <pillgrim@mail.ru>
    Re: date handling? <gtoomey@usa.net>
    Re: Docs didn't help - problem setting locale under Win <thoren@southern-division.com>
    Re: Docs didn't help - problem setting locale under Win <sb@engelschall.com>
        Executing a shell command within a perl script. <Noatec@netscape.net>
    Re: Executing a shell command within a perl script. (Logan Shaw)
    Re: external shell commands with perl script <wyzelli@yahoo.com>
    Re: Extracting data from a file <david.lane@mantech.com>
    Re: Extracting data from a file <wyzelli@yahoo.com>
    Re: Extracting data from a file (Tad McClellan)
    Re: file reading and writing (Logan Shaw)
        Form Post Redirect <russelln@opbu.xerox.com>
    Re: Form Post Redirect <flavell@mail.cern.ch>
    Re: help!! confuse problem about flow control. <kstep@pepsdesign.com>
    Re: How can I avoid long 'switch' statement? <david.kernen@bms.com>
        how do i delete already printed characters <mail@ericmarques.net>
    Re: how do i delete already printed characters (Damian James)
    Re: how do i delete already printed characters <Qeacostl@ilstu.edu>
    Re: how do i delete already printed characters <kstep@pepsdesign.com>
    Re: How safe is Safe? <cadet@alum.mit.edu>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 29 Mar 2001 16:01:24 +0200
From: Tobias Dresbach <td@chemsoft.de>
Subject: add lines from logfile
Message-Id: <3AC34034.DB1D4AD2@chemsoft.de>

Hi all,
i have a log file like the following:
IP-Address Port kbytes
192.168.0.1 53  10
192.168.1.2 21  150
how is it possible to add all kbytes from the same port and ip-address?

thanks in advance
tobi


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

Date: Thu, 29 Mar 2001 01:04:40 GMT
From: dclxvi@best.com (Josh Geller)
Subject: Bugs In vss2cvs.pl
Message-Id: <ISvw6.3263$Up.141527@sea-read.news.verio.net>

In article <OFF64CF79E.34487B6B-ON85256A1D.006F1B07@desktop.moneynet.com>,
<tmulle@moneynet.com> wrote:

> Has anyone gotten the vss2cvs.pl script from
> http://www.laine.org/cvs/vss2cvs to work?

> I just downloaded it and set up all the correct paths, etc. and i
> get the following messages: mainly "is not valid SourceSafe syntax"

I am currently debuggering this script.

Zeroth off, I changed #!/usr/bin/perl in the first line to
#!/usr/bin/perl -w. I actually started off by adding the <use strict>
pragma also, but that was just too much for me to deal with.

It would be ungrateful in the extreme for me to complain about the
author of this potentially extremely useful script not putting those
two little things in there. I hope, after the deadline I am trying to
make passes and I either still have a contract and more leisure time or I
have really a lot of leisure time, to strictify this sucker. But I am
famous for wanting to do stuff that I don't actually do.

I am using vss2cvs.pl along with the full cygwin suite; that is, it is
run out of cygwin's bash.

I'd recommend that highly, first off.

Second off:

> /cygdrive/d/junk\convert is not a valid switch, and will be ignored.
> Continue anyway?(Y/N)y

Changing this line (Line 120 in my copy):

exec_cmd("ss workfold \"$ssproj\" \"$workdir\\$subdir\" $ssuserpass");

to this line:

exec_cmd("ss workfold \"$ssproj\" \"$workdir/$subdir\" $ssuserpass");

will fix that part (one of the big, big advantages of using bash
instead of the standard windows cmd "shell" is that you can use
forward slashes throughout).

> ss workfold "$/RML2" "/cygdrive/d/junk\convert"  ++++

Ah, I see you are using bash. One of the big disadvantages of using
bash is that it insists on doing that lame /cygdrive/d/ stuff.

This can, however, be fixed by making sure that your working folder is
in the environment before running the script, thus:

bash$ export WORKDIR=c:/foo/bar/workdir

> ++++ ss dir -R "$-y**SECRET**RML2" -Odirlist  ++++

It also looks like you have at least one too many linefeeds in there.

I fixed similar, possibly identical behavior by changing line 162 in
my copy from:

	$currfile = "$currdir$dirline";
to:
	$currfile = $currdir . $dirline;

and adding directly following the lines:

	chomp $currfile;
	$currfile =~ s/\r//g;

Now, to my current bug, as the clock ticks inexorably towards my
deadline.

We get past the adding of the new directories, and start to try to add
the new files, when the script bails with this:

******** Syncing $/Tools/Exporter/common/ *************
Use of uninitialized value in numeric gt (>) at ../../../../Build/vss2cvs.pl line 357, <SS> line 3.
can't parse timestamp Label: "Exporter2.0.0.11 -- 3/28/01"

I believe that the first part is merely a warning from the -w flag.

The second part is tough. It seems to be related to my time format,
which seems OK.

If anyone else has run into this, or has anything else helpful to say
about this script, I'd sure appreciate it.


Josh Geller
Cross Quarter Consulting, LLC


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

Date: 29 Mar 2001 00:22:02 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Can we make the @array->push(1..10) syntax
Message-Id: <99ukaa$gk8$1@boomer.cs.utexas.edu>

In article <99u6g4$6v1@netnews.hinet.net>,
John Lin <johnlin@chttl.com.tw> wrote:
>
>I said "Wow, OO like syntax.  Great!!!  Then, can we do this?"
>
>use Array;
>@array->push(1..10);
>
>Note: I am not saying $arrayref->push(1..10);
>
>Although it is not so useful, it's a way of learning Perl.
>I tried many ways (protocol, overload...).  It seems not to be do-able.

That's because in Perl there aren't really any objects.  Instead, there
are blessed references.  A blessed reference is just a reference
that has been associated with a certain package, so that it knows
what package to call when you do stuff like this:

	$foo->print();

So why is that important?  It's important because references are scalar
values.  So, they can be stored in scalar variables, or you can store a
bunch of them in an array or hash.  But arrays and hashes aren't
references.  They're just containers that store scalar values.

If you want, you can define a class that happens to work alot like an
array:

	package Array;

	sub new
	{
		my $class = shift;
		$self = [];
		bless $self, $class;
		return $self;
	}

	sub push
	{
		my $self = shift;
		push (@$self, @_);
	}

	sub select
	{
		my $self = shift;
		return @${self}[@_];
	}

	sub all
	{
		my $self = shift;

		if (wantarray) { return @$self; }
		else { return scalar @$self; }
	}

Actually, I think you can do a better job than that with lvalue
subroutines, but that's a whole different story.

Hope that helps.

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: 28 Mar 2001 18:09:36 +0100
From: nobull@mail.com
Subject: Re: Capturing POD output
Message-Id: <u9g0fx6crz.fsf@wcl-l.bham.ac.uk>

"Steven P. Woolet" <steve_woolet@us.ibm.com> writes:

> This is probably a very simple question...Using Pod::Text, how do I
> capture the POD output in a variable instead of sending it to STDOUT (or
> a file)?

There may be a better answer specific to Pod::Text but the general
answer of how to redirect file output to a variable is IO::Scalar.

-- 
     \\   ( )
  .  _\\__[oo
 .__/  \\ /\@
 .  l___\\
  # ll  l\\
 ###LL  LL\\


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

Date: Wed, 28 Mar 2001 16:46:49 -0500
From: "Steven P. Woolet" <steve_woolet@us.ibm.com>
Subject: Re: Capturing POD output
Message-Id: <3AC25BC9.9849B33D@us.ibm.com>

Thank you!!!  That does exactly what I needed.

nobull@mail.com wrote:
> 
> "Steven P. Woolet" <steve_woolet@us.ibm.com> writes:
> 
> > This is probably a very simple question...Using Pod::Text, how do I
> > capture the POD output in a variable instead of sending it to STDOUT (or
> > a file)?
> 
> There may be a better answer specific to Pod::Text but the general
> answer of how to redirect file output to a variable is IO::Scalar.
> 
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\


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

Date: 28 Mar 2001 19:12:32 GMT
From: sendthis@yahoo.delthisandasdf.com (e)
Subject: Re: date handling?
Message-Id: <BE91F2ECACDD1957.CC420C264FB0B4E7.0EF3379FB8CDD1E4@lp.airnews.net>

yeah, thanks. I decided to handle it like excel that way I wouldn't have to 
convert it back since it's eventually going to end up on an excel worksheet.

eric


In article <c4qw6.1477$E71.34442@news.pacbell.net>, ddunham@redwood.taos.com 
says...
>
>e <sendthis@yahoo.delthisandasdf.com> wrote:
>> Is there an easy way to compare dates using perl? Right now, I'm separating 
it 
>> by tabs and writing a lot of if statements 
>
>> i.e. (pseudo code)
>
>> if year < input year
>>       if month < input_month
>>               if day < input _day
>>                       <it is this>
>
>> that's just a pain...
>
>Date comparisons are often done by taking a symbolic date and converting
>it into a numeric representation (see Time::Local).  From there,
>comparisons become < and > operations.  
>
>You can also quantify differences between dates easily by this method.
>
>-- 
>Darren Dunham                                           ddunham@taos.com
>Unix System Administrator                    Taos - The SysAdmin Company
>Got some Dr Pepper?                           San Francisco, CA bay area
>          < How are you gentlemen!! Take off every '.SIG'!! >



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

Date: Wed, 28 Mar 2001 22:27:46 +0300
From: "Aleksandr Guidrevitch" <pillgrim@mail.ru>
Subject: Re: date handling?
Message-Id: <99tdvr$2oaql$1@ID-82007.news.dfncis.de>

> if year < input year
> if month < input_month
> if day < input _day
> <it is this>
>
> that's just a pain...
>
> Eric
use Date::Calc

Aleks




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

Date: Thu, 29 Mar 2001 11:16:43 +1000
From: "Gregory Toomey" <gtoomey@usa.net>
Subject: Re: date handling?
Message-Id: <qRvw6.5202$45.28206@newsfeeds.bigpond.com>

Yes, just convert the date to YYYYMMDD or YYYYMMDDHHMMSS.
Youd can then use <, <=, >, >=,=.
gtoomey
---------
"Darren Dunham" <ddunham@redwood.taos.com> wrote in message
news:c4qw6.1477$E71.34442@news.pacbell.net...
> e <sendthis@yahoo.delthisandasdf.com> wrote:
> > Is there an easy way to compare dates using perl? Right now, I'm
separating it
> > by tabs and writing a lot of if statements
>
> > i.e. (pseudo code)
>
> > if year < input year
> > if month < input_month
> > if day < input _day
> > <it is this>
>
> > that's just a pain...
>
> Date comparisons are often done by taking a symbolic date and converting
> it into a numeric representation (see Time::Local).  From there,
> comparisons become < and > operations.
>
> You can also quantify differences between dates easily by this method.
>
> --
> Darren Dunham                                           ddunham@taos.com
> Unix System Administrator                    Taos - The SysAdmin Company
> Got some Dr Pepper?                           San Francisco, CA bay area
>           < How are you gentlemen!! Take off every '.SIG'!! >




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

Date: Thu, 29 Mar 2001 20:30:57 +0200
From: Thoren Johne <thoren@southern-division.com>
Subject: Re: Docs didn't help - problem setting locale under WinNT
Message-Id: <MPG.152d9dd033c146dc989979@news.t-online.de>

In article <3AC3605A.18F7C0CD@engelschall.com>, Steffen Beyer aka 
sb@engelschall.com says...
> Thoren Johne wrote:
> 
> > In article <3ABB88D5.B1CE6713@engelschall.com>, Steffen Beyer aka
> > sb@engelschall.com says...
> > > Has anybody *SUCCESSFULLY* changed the locale under WinNT,
> > > so that "use locale" does the right thing when comparing strings?
> > > How did you do it?
> > use POSIX qw(locale_h);
> > setlocale(LC_ALL, "de");
> > use locale;
> > ...wenn ich die frage richtig verstanden habe.
> 
> This doesn't solve the problem! (I tried it)
> That's why I asked whether anybody has already *DONE* this successfully
> before!

can you give an example of 'how it fails'?

#!/usr/local/bin/perl
use strict;
use warnings;

use POSIX qw(locale_h);
setlocale(LC_ALL, "de");
use locale;

my @tosort = qw/c g A ä o U ü h ß s d K/;

print sort @tosort;

result:
AäcdghKosßUü

looks good to me.

perl -v
This is perl, v5.6.0 built for MSWin32-x86-multi-thread
(with 1 registered patch, see perl -V for more detail)

Copyright 1987-2000, Larry Wall

Binary build 623 provided by ActiveState Tool Corp. 
http://www.ActiveState.com
Built 16:27:07 Dec 15 2000

 ...

-- 
# Thoren Johne - 8#X - thoren@southern-division.com
# Southern Division Classic Bikes - www.southern-division.com
END{*5=sub{(print'J')+goto&{$=+=2}},$==3,*7=sub{(print'A')-goto&{$=+=4}},
*11=sub{(print'PH 8#X')*goto&{$=+=2}}=>$==42=>*13=sub{42}=>goto&{$=-=37}}


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

Date: Thu, 29 Mar 2001 18:18:34 +0200
From: Steffen Beyer <sb@engelschall.com>
To: Thoren Johne <thoren@southern-division.com>
Subject: Re: Docs didn't help - problem setting locale under WinNT
Message-Id: <3AC3605A.18F7C0CD@engelschall.com>

Thoren Johne wrote:

> In article <3ABB88D5.B1CE6713@engelschall.com>, Steffen Beyer aka
> sb@engelschall.com says...
> > Has anybody *SUCCESSFULLY* changed the locale under WinNT,
> > so that "use locale" does the right thing when comparing strings?
> > How did you do it?
> use POSIX qw(locale_h);
> setlocale(LC_ALL, "de");
> use locale;
> ...wenn ich die frage richtig verstanden habe.

This doesn't solve the problem! (I tried it)
That's why I asked whether anybody has already *DONE* this successfully
before!

> > But even when I try to set these environment variables, the system pays
> > absolutely no
> > heed to them.
> hmmm... control-panel -> regional-settings?

I tried that, no use.

But thanks for answering!

Best regards,
--
    Steffen Beyer <sb@engelschall.com>
    http://www.engelschall.com/u/sb/whoami/ (Who am I)
    http://www.engelschall.com/u/sb/gallery/ (Fotos Brasil, USA, ...)
    http://www.engelschall.com/u/sb/download/ (Free Perl and C Software)



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

Date: Wed, 28 Mar 2001 21:32:10 -0600
From: The Noatec <Noatec@netscape.net>
Subject: Executing a shell command within a perl script.
Message-Id: <3AC2ACBA.4BEB12A7@netscape.net>

Hello all,
Quick and simple question.
How would I execute a korn, or other shell command within a perl script.

I used it once and cannot find the script it is in or a reference in my
perl 5 book.

Thanks,


The Noatec

"No problem can withstand the assault of sustained thinking"

Voltaire,




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

Date: 29 Mar 2001 00:24:22 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: Executing a shell command within a perl script.
Message-Id: <99ukem$gpf$1@boomer.cs.utexas.edu>

In article <3AC2ACBA.4BEB12A7@netscape.net>,
The Noatec  <Noatec@netscape.net> wrote:
>Hello all,
>Quick and simple question.
>How would I execute a korn, or other shell command within a perl script.
>
>I used it once and cannot find the script it is in or a reference in my
>perl 5 book.

Use system().

On Unix at least, you just name the script, and then the operating
system notices the "#! /bin/ksh" line at the beginning of the Korn
shell script and invokes the interpreter on it.  That is, you don't
need to tell Perl that it's a shell script, just that it's an
executable.

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: Thu, 29 Mar 2001 13:23:01 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: external shell commands with perl script
Message-Id: <I7yw6.21$US1.4074@vic.nntp.telstra.net>

"The Noatec" <Noatec@netscape.net> wrote in message
news:3AC2AA06.2A1471B@netscape.net...
> Hello all,
> Quick and simple question.
> How would I execute a korn, or other shell command with a perl script.
> I used it once and cannot find the script it is in or a reference in
my
> perl 5 book.

perldoc -f system
perldoc -f exec

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





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

Date: Wed, 28 Mar 2001 21:54:39 -0500
From: "David A. Lane" <david.lane@mantech.com>
Subject: Re: Extracting data from a file
Message-Id: <3AC2A3EE.FEA2ACA5@mantech.com>

Thanks all for the help.  On the way home I had the ephany that escaped me
while working on this stupid thing.  Yes, I was doing the split wrong
(major), and even though I screwed up the if/elsif, I don't really want to do
that anyway

I had strict on, and it was giving "sperious" errors (they weren't helping me
solve the real problem - that being programming logic, just syntax errors).

DAVID

adventure wrote:

> Hi there,
>
> I am in over my head on this - I am trying to extract the data on two
> lines (the second and the fourth) from the following (output of the free
> -m command).
>
>              total       used       free     shared    buffers     cached
> Mem:           250         67        182         39         26         20
> -/+ buffers/cache:         20        230
> Swap:          517          0        517
>
> My solution thus far is:
>
> while (<FREE>) {
>   chomp;
>   if ($. = 2) {
>       ($mem, $total, $used, $free, $shared, $buf, $cache) = split
> /\b[0-9]\b/;
>       } elsif ($. = 4) {
>                       ($swap, $stotal, $sused, $sfree) = split
> /\b[0-9]\b/;
>         }
>                 };
>
> The problem is that nothing seems to be being split out.  When I simply
> loop through the file, the contents of each line are dumped into $mem and
> the rest are empty.  I figure I am:
>
> 1) Doing the split wrong
> 2) Doing the if/elsif incorrectly at least
> 3) Doing it the hard way.
>
> At the end of the day, the $mem and $swap variables will be tossed, and
> the values pushed into an Oracle database through DBI (which I haven't
> written yet).
>
> Thanks for any advice,
>
> DAVID
>
> --
> ---------------------------------------------------
> David A. Lane, CNE
> ERP Technical Lead
> ManTech International Corp.
> +1.703.218.8241 VOICE
> +1.703.218.8391 FAX
> PGP ID: 679DF4EE

--
---------------------------------------------------
David A. Lane, CNE
ERP Technical Lead
ManTech International Corp.
+1.703.218.8241 VOICE
+1.703.218.8391 FAX
PGP ID: 679DF4EE




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

Date: Thu, 29 Mar 2001 12:56:11 +0930
From: "Wyzelli" <wyzelli@yahoo.com>
Subject: Re: Extracting data from a file
Message-Id: <yKxw6.20$US1.4565@vic.nntp.telstra.net>

"adventure" <bag_end@clark.net> wrote in message
news:b0dw6.17579$FS3.217472@sjc-read.news.verio.net...
> Hi there,
>

[SNIP]

>
> My solution thus far is:
>
> while (<FREE>) {
>   chomp;
>   if ($. = 2) {

I think you are probably looking for an equality test here rather than
an assignment (== not =)

>       ($mem, $total, $used, $free, $shared, $buf, $cache) = split
/\b[0-9]\b/;

That attempts to split on a single digit.  Pretty much not only wrong,
but the reverse of what you want.  You seem to want to split on
whitespace, and return all the text/numbers.

($mem, $total, $used, $free, $shared, $buf, $cache) = split  /\s+/;

BUT!!!

The default operation of split is to split $_ on whitespace, so this can
be written as:

($mem, $total, $used, $free, $shared, $buf, $cache) = split;


>       } elsif ($. = 4) {

Same assignment problem, use ==

>                       ($swap, $stotal, $sused, $sfree) = split
/\b[0-9]\b/;

Same split issue.

>         }
>                 };
>

You should also look into the use of -w and strict.  You would have
received warnings about the conditionals that way.

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





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

Date: Wed, 28 Mar 2001 22:42:29 -0500
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Extracting data from a file
Message-Id: <slrn9c5bp5.jrh.tadmc@tadmc26.august.net>

[ Please put your comments *following* the quoted text that you
  are commenting on.

  Please do not quote an entire article.

  Please never quote .sigs. (you even quoted your very own .sig!)

  Thanks.
]


David A. Lane <david.lane@mantech.com> wrote:

>I had strict on, and it was giving "sperious" errors 


stricture messages are never spurious, nor are they hard to quiet.

Just fix what it complains about and run it again.


>(they weren't helping me
>solve the real problem - that being programming logic, just syntax errors).


That may be true (but that may also be false).

You just pop in some my()s until it is quiet, then you _know_ you
don't have any of the problems that it guards against.

Note also that strictures have nothing to do with syntax errors.

You get syntax error messages with strictures or without, with 
warnings or without.


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


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

Date: 29 Mar 2001 00:29:02 -0600
From: logan@cs.utexas.edu (Logan Shaw)
Subject: Re: file reading and writing
Message-Id: <99ukne$h7f$1@boomer.cs.utexas.edu>

In article <99ub36$mo@news.or.intel.com>,
terminalsplash <shino_korah@yahoo.com> wrote:
>   I'm trying to read and write to a file
>my file...
>    john is apple
>   george is orange
>   u r grapes
>
>I want to read this file and write back
>     john is apple
>     george is BANANA
>    u r grapes
>so I'm seraching the file for george and then how to write back at the same
>point?
>I tried seek tell etc?
>how can I do this in an efficient way?

There isn't a really efficient way to do this.  You potentially have to
read and write almost the entire file (if the string occurs at the
beginning).  At least, there isn't a way to do it that takes less time
than some number proportional to the length of the file.

By using seek and tell and all that great stuff, you are saving one
thing, which is memory.  If you have a 25 GB file, then using the seek
and tell method is going to save you from having to read the whole
thing into memory, which could be important.

  - Logan
-- 
whose?  my  your   his  her   our   their   _its_
who's?  I'm you're he's she's we're they're _it's_


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

Date: Wed, 28 Mar 2001 20:12:20 GMT
From: "Russell Neville" <russelln@opbu.xerox.com>
Subject: Form Post Redirect
Message-Id: <EArw6.263$td2.29583@news-west.eli.net>

I have a form POST to a script that I need to redirect to another location.

When I use the CGI redirect method:
    $query->redirect(-uri=>'http://myNewUrl.com')

the POSTed content is always dropped and the redirected REQUEST_METHOD is
GET (rather than the needed POST).

I've monkeyed with the redirect, trying to change the content header type
(to application/x-www-form-urlencoded) along with some other failed
tinkering.  In my stumblings, I haven't come across the correct way to
redirect the form.  Any ideas?

Thanks!
Russell




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

Date: Wed, 28 Mar 2001 23:13:12 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Form Post Redirect
Message-Id: <Pine.LNX.4.30.0103282251000.27615-100000@lxplus003.cern.ch>

On Wed, 28 Mar 2001, Russell Neville wrote:

> I have a form POST to a script that I need to redirect to another location.
>
> When I use the CGI redirect method:
>     $query->redirect(-uri=>'http://myNewUrl.com')

If I'm not mistaken, that's going to use status 302 unless you take
steps to tell it otherwise.

> the POSTed content is always dropped and the redirected REQUEST_METHOD is
> GET (rather than the needed POST).

Say, suppose I were to type your terms, "post redirect location" into
Google, what do you suppose would come up?  In third place, I find a
web page (well, I don't exactly "find" it, because I was the one who
wrote it), entitled "Redirect in response to POST transaction".

Judging from some nice emails I've received, one as recent as this
morning, I know that some people out there found the page by their own
initiative, and felt that the content was of value to them.  Albeit
rather disappointing, but that's not my fault  :-}

> I've monkeyed with the redirect, trying to change the content header type
> (to application/x-www-form-urlencoded) along with some other failed
> tinkering.  In my stumblings, I haven't come across the correct way to
> redirect the form.

I'm sorry to have to tell you this, but the fact is that although
redirecting a POST into an equivalent POST transaction at a different
URL is defined in HTTP, it's not practically usable on the WWW. Unless
you have close control over the client software used.

But the default status for a redirection is 302, and if you're to
stand any hope of making it do what you want, you'd need to use a
different status.  De facto in HTTP/1.0, and de jure in HTTP/1.1,
status 302 will present the redirected transaction by GET and not by
POST.  I suspect you want 307 (temporary redirect), rather than 301
(moved permanently).  I don't know a browser other than Lynx that
implements both of these correctly.

If you're still interested, consult the page

   http://ppewww.ph.gla.ac.uk/~flavell/www/post-redirect.html

but if you have any questions, you'd should pose them on
comp.infosystems.www.authoring.cgi.

I would suggest you'd do better to reconsider your requirement, and
tell the c.i.w.a.cgi group what you're trying to achieve in overall
terms, rather than insisting on this one detail which, as I say, isn't
going to work in general.

good luck



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

Date: Thu, 29 Mar 2001 02:39:43 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: help!! confuse problem about flow control.
Message-Id: <99uorp$8fp$1@slb0.atl.mindspring.net>

"sky" <tbsky.bbs@openbazaar.net> wrote in message
news:3fYD7F$Wf_@openbazaar.net...
> Hello!
>  if i have this line :
>       open(FILE,"/tmp/a") or die ;
>
>  and i want to replace "die" to 2 commands
>
>       print STDERR "can not open";exit(1)

Either group the commands using 'do' or create a sub that does what you
want.  Of course, the only thing that this gets you is a way to specify your
own return value rather than the current value of errno (see perldoc -f
die).  In any case, I would also suggest adding $! to the error message to
show the reason why the call failed.

my $file = "/tmp/a";
open(FILE, $file) or do {print STDERR "Can not open $file: $!"; exit(1)};

# or

sub error {
    my ($msg, $code) = @_;
    print STDERR $msg;
    exit $code;
}

my $file = "/tmp/a";
open(FILE, $file) or error("Can not open $file: $!", 1);


HTH,

Kurt Stephens





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

Date: Wed, 28 Mar 2001 15:40:13 -0500
From: Dave <david.kernen@bms.com>
Subject: Re: How can I avoid long 'switch' statement?
Message-Id: <3AC24C2D.EACDF57D@bms.com>

Bart Lateur wrote:

>         require "$inp.pm";

BTW, Bart did not put those quotes around the full filename in the require
by accident. They're really quite important.

Dave Kernen



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

Date: Wed, 28 Mar 2001 22:58:27 GMT
From: "Eric" <mail@ericmarques.net>
Subject: how do i delete already printed characters
Message-Id: <n0uw6.22079$PF4.31945@news.iol.ie>

How do i delete already printed characters?
Like if u do this

print "Status: Loading...\n";
print "Now doing something else...\n";

it prints like this

Status Loading...
Now doing something else...

but can i not delete the first line so that when i print "Now doing
something else..."
it replaces the first line "Status: Loading..."

sorry i dont know how to be more descriptive


--
Eric Marques
mail@ericmarques.net




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

Date: 29 Mar 2001 00:19:46 GMT
From: damian@qimr.edu.au (Damian James)
Subject: Re: how do i delete already printed characters
Message-Id: <slrn9c4vrq.3a8.damian@puma.qimr.edu.au>

Eric chose Wed, 28 Mar 2001 22:58:27 GMT to say this:
>How do i delete already printed characters?
>...
>but can i not delete the first line so that when i print "Now doing
>something else..."
>it replaces the first line "Status: Loading..."
>
>sorry i dont know how to be more descriptive
>

Assuming that you are talking about a text-based terminal session (such as
an xterm window, a console without X running, a dos/NT command window, a 
vt100, etc), you might use the backspace character represented by "\b". 
You can see it being used in my JAPH below. 

You might also want to investigate the Term::Cap or Curses modules.

If you are talking about CGI, and printing stuff that ends up on a browser,
then forget about it, or take it up on a group that discusses javascript.

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, 28 Mar 2001 17:55:58 -0600
From: Erik <Qeacostl@ilstu.edu>
Subject: Re: how do i delete already printed characters
Message-Id: <99ttlg$1l1$1@news.ilstu.edu>

Eric wrote:

> How do i delete already printed characters?
> Like if u do this
> 
> print "Status: Loading...\n";
> print "Now doing something else...\n";
> 
> it prints like this
> 
> Status Loading...
> Now doing something else...
> 
> but can i not delete the first line so that when i print "Now doing
> something else..."
> it replaces the first line "Status: Loading..."
> 
> sorry i dont know how to be more descriptive
> 
> 
> --
> Eric Marques
> mail@ericmarques.net
> 
> 

\b is a meta-character for backspace, print that a few times
-- 
To reply by e-mail, remove the Q from my e-mail address.


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

Date: Wed, 28 Mar 2001 19:28:30 -0500
From: "Kurt Stephens" <kstep@pepsdesign.com>
Subject: Re: how do i delete already printed characters
Message-Id: <99tvk8$ekg$1@slb5.atl.mindspring.net>

"Eric" <mail@ericmarques.net> wrote in message
news:n0uw6.22079$PF4.31945@news.iol.ie...
> How do i delete already printed characters?
> Like if u do this
>
> print "Status: Loading...\n";
> print "Now doing something else...\n";
>
> it prints like this
>
> Status Loading...
> Now doing something else...

It all depends on what you're writng to.  Assuming that you're writing to a
TTY-like device, "\r" should do the trick.  Of course, that's making a lot
of assumptions.  Remember to autoflush STDOUT and print a line of blank
characters to clear the cruft from the previous message.  You might try
something like the following:

[begin code]

#!C:/perl/bin/perl -w
use strict;

$|=1;

my $CR = "\r";
my $CLEAR = ' ' x 60;

sub show_status {
    print $CR, $CLEAR;
    print $CR, $_[0];
}

my @states = (
    "Ready",
    "Starting",
    "Working",
    "Done",
    );

foreach (@states) {
    show_status($_);
    sleep(1);
}

[end code]

HTH,

Kurt Stephens





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

Date: Wed, 28 Mar 2001 22:07:26 GMT
From: David Bakhash <cadet@alum.mit.edu>
Subject: Re: How safe is Safe?
Message-Id: <m3r8zi814c.fsf@alum.mit.edu>

>>>>> "chris" == Chris Fedde <cfedde@fedde.littleton.co.us> writes:

 >> Is the Safe module secure enough to allow execution of arbitrary
 >> code with no danger except resource usage (memory/processor)?
 >> 
 >> This question applies to Perl versions 5.004 and up.

 chris> Read the manual pages for Safe.  I think that will be eye
 chris> opening.  Particulary the section titled "Some Safety Issues"
 chris> In particular Safe is not safe wrt most system resources such
 chris> as memory, CPU usage, signals, and some other important
 chris> issues.  Until Safe supports limits on system resources it
 chris> will not be Safe enough for me.

I'd love to wait until Safe is safe, but Safe will just have to do for
now.

problem is that when I tried to download the Safe.pm module, I found
that the only way I could get it was to download a complete Perl
distribution and then pull it out of there; it wasn't like installing
other modules.

Beyond installation difficulties, I'd like to know if someone has used 
Safe.pm to do anything even remotely similar to what I want to use
Safe.pm for, which is simply to create an environment for evaluating
arithmetic Perl code, with a few functions, and variables
pre-defined.  Denial of service attacks are always an issue, but
barring that, if the code is safe with respect to limiting the kinds
of functions that can be called, then this (for me) is a big enough
win that I want to use it.

Has anyone used Safe.pm for something similar to me?  Anyone willing
to show me some example code?  or, does anyone know where there's
example Safe.pm code usage?

thanks,
dave


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

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


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