[17241] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4663 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Oct 19 14:05:53 2000

Date: Thu, 19 Oct 2000 11:05:17 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <971978716-v9-i4663@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 19 Oct 2000     Volume: 9 Number: 4663

Today's topics:
    Re: @Arrays as Parameters <mjcarman@home.com>
    Re: [very off topic] Re: Perl: Day One, a Stupid Questi frannyzoo@hotmail.com
        Array stuck within a loop <bhui_ipsg@yahoo.com>
    Re: Array stuck within a loop nobull@mail.com
    Re: Array stuck within a loop <ren.maddox@tivoli.com>
    Re: cgi & frame problem <jukka.pakkanen@qnet.fi.no.spam>
    Re: Counter doesn't work <james@NOSPAM.demon.co.uk>
    Re: Email.pm and file attachments <than@wwa.com>
        error out of my control bing-du@tamu.edu
        File Locking and CGI jeacocks@uk.ibm.com
    Re: File::Find pruning (Peter Scott)
    Re: File::Find pruning (Gary E. Ansok)
        Filehandle redirection <paulf@angliaed.co.uk>
    Re: Filehandle redirection <tony_curtis32@yahoo.com>
    Re: Filehandle redirection <godzilla@stomp.stomp.tokyo>
    Re: Filehandle redirection <bkennedy@hmsonline.com>
    Re: How to get rid of '/' in a telnet prompt? <bruce_phipps@my-deja.com>
        http referer manipulation <me@privacy.net>
    Re: http referer manipulation nobull@mail.com
    Re: I've trashed my serial ports! HELP! <godzilla@stomp.stomp.tokyo>
        RE: Make this regex neater, anyone? (H. Merijn Brand)
        matching balanced text (Robert C. Helling)
    Re: matching balanced text <jeffp@crusoe.net>
    Re: newbie intro <lr@hpl.hp.com>
    Re: Newbie Question: command line parameters - WIN32 (Ben Coleman)
        Object destructors not working properly? <lesley@natric.demon.co.uk>
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: Thu, 19 Oct 2000 10:12:50 -0500
From: Michael Carman <mjcarman@home.com>
Subject: Re: @Arrays as Parameters
Message-Id: <39EF0F72.A16CB10B@home.com>

Stuart MacCallum wrote:
> 
> What I want to do is call a perl function named $params[1], and 
> pass the array @PIDVALS to it.
> 
> eval("$params[1](@PIDVALS2)");

I don't know your application, but I doubt that this is really what you
want to do. I'd wager that what you want to use is a code reference, not
eval().

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

# Declare a hash of code references
my %subs = (
    foo => \&foo,
    bar => \&bar,
);

# Sample data
my @data = (0 .. 5);

# Call foo() via coderef and pass it @data
&{$subs{foo}}(@data);

# Call bar() via coderef and pass it @data
&{$subs{bar}}(@data);

sub foo {
    my @values = @_;
    print "foo() here\n";
    print "@values\n";
}

sub bar {
    my @values = @_;
    print "bar() here\n";
    foreach (@values) {
        print $_ + 1, "\n";
    }
}
--------------------
Output:
--------------------
foo() here
0 1 2 3 4 5
bar() here
1
2
3
4
5
6
--------------------

I used a hash instead of an array to store the code refs so that I can
access them by name instead of index. You could use an array, but I
prefer a hash because it's clearer.

-mjc


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

Date: Thu, 19 Oct 2000 17:02:04 GMT
From: frannyzoo@hotmail.com
Subject: Re: [very off topic] Re: Perl: Day One, a Stupid Question
Message-Id: <8sn9e9$8b4$1@nnrp1.deja.com>

absolutely no offense intended with the "college bowl" reference...I
guess the kid in "Magnolia" is pretty poetic/mystical really...much more
than anyone else in the movie.  Glad to hear perl is the language of p/m
folks...perhaps that's why i starting that instead of C or something.

thanks again for the help.
scot


In article <39EDE1EF.34D89818@vpservices.com>,
  Jeff Zucker <jeff@vpservices.com> wrote:
> frannyzoo@hotmail.com wrote:
> >
> > ..but holden was taken, etc.  I'm guessing F&Z appeals to you from
the
> > "college bowl" encyclopedic knowledge angle.
>
> Umm, no, it appeals to me because it is a great book and a formative
> part of my early adolescence. I actually read _The Way of the Pilgrim_
> after F&Z and then the _Philokalia_, etc. because of the emotional
> impact F&Z had on me.  What did you think, all Perl hackers are geeks?
> Perl is the language of poets and mystics!
>
> > What did you think of
> > "Magnolia"?
>
> Absolutely loved it, except for the frogs and the silly intro.
>
> --
> Jeff
>


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: Thu, 19 Oct 2000 08:53:47 -0700
From: "bhui" <bhui_ipsg@yahoo.com>
Subject: Array stuck within a loop
Message-Id: <8sn5km$2ac$1@schbbs.mot.com>

I have used regex to separate a large string into a bunch of little ones,
within one of these little ones I have created and array using split to
converting each character into the array.

The problem is when I go parsing throught this array and get to the end or
an unassigned value it hangs my while loop.

I suspect whats happening it the string i converted into an array does not
have a /n to tell the while loop we are at the end. Is there a way to
terminate the while if the array is unassigned ??

thx

Ben

$string =~ (/^(.*?) "(.*?);(.*?)"
\/REVISION="(.*?)"(.*?)VCS_TAGS(.*?)\)(.*?)\n.*/) ;

    {
     $ui  =    $1 ;
 $item_id_tmp =  $2 ;
 $old_rev =  $3 ;
 $real_rev =   $4 ;
 $cmd1 =   $5 ;
 $vcs_tags =   $6 ;
 $user_filename =  $7 ;


@tags = split (//,$vcs_tags) ;
 $num_of_tags_ui = scalar @tags ;
 $char_count = 150;
 $char_to = $char_count ;

until (@tags[$char_to] =~ /\,/)
   {
   $char_to++ ;
   }

$tag1 = join("",@tags[1..--$char_to]);
 print "$ui \"$item_id_tmp;$old_rev\" \/REVISION=\"$real_rev\"$cmd1
VCS_TAGS=\[$tag1\]\) $user_filename\n\n";

while ($char_to < $num_of_tags_ui)


   print "I got to while \n\n";
   print "num of tags $num_of_tags_ui\n";

   until (@tags[$char_to] =~ /\,/)
     {
     print "got to until \n";
       $char_to++ ;
     }
  print "$num_of_tags_ui\n";
  print "@tags[$char_to]\n";
  print "$char_to\n";
   &write_uia ;




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

Date: 19 Oct 2000 18:10:14 +0100
From: nobull@mail.com
Subject: Re: Array stuck within a loop
Message-Id: <u9aec0pxjd.fsf@wcl-l.bham.ac.uk>

"bhui" <bhui_ipsg@yahoo.com> writes:

> I have used regex to separate a large string into a bunch of little ones,

OK with you so far.

> within one of these little ones I have created and array using split to
> converting each character into the array.

Really?  That's rarely a good idea.  Perl has execlent pattern
matching facilities.

> The problem is when I go parsing throught this array and get to the end or
> an unassigned value it hangs my while loop.
> 
> I suspect whats happening it the string i converted into an array does not
> have a /n to tell the while loop we are at the end. Is there a way to
> terminate the while if the array is unassigned ??

I've not looked at your code yet but the function to terminate a loop
is last() and the function to tell if something is defined is defined().


> 
>     {
>      $ui  =    $1 ;
>  $item_id_tmp =  $2 ;
>  $old_rev =  $3 ;
>  $real_rev =   $4 ;
>  $cmd1 =   $5 ;
>  $vcs_tags =   $6 ;
>  $user_filename =  $7 ;

Messy.  Better written as:

my ($ui, $item_id_tmp, $old_rev, $real_rev, $cmd1, $vcs_tags,
    $user_filename ) = $string =~ 
    /^(.*?) "(.*?);(.*?)"\/REVISION="(.*?)"(.*?)VCS_TAGS(.*?)\)(.*?)\n.*/;


> @tags = split (//,$vcs_tags) ;
>  $num_of_tags_ui = scalar @tags ;
>  $char_count = 150;
>  $char_to = $char_count ;
> 
> until (@tags[$char_to] =~ /\,/)
>    {
>    $char_to++ ;
>    }
> 
> $tag1 = join("",@tags[1..--$char_to]);

You appear to be trying to extract the part of $vcs_tags starting at
the second character at ending just before at the first comma after
the 150th position.  You also appear to be trying to do so as
inefficiently as possible.

my ($tag1) = $vcs_tags =~ /^.(.{,149}),/;  

I don't know what you want to do if there is no suitable comma.

The rest of you code is just incomprehesible.

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


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

Date: 19 Oct 2000 12:27:20 -0500
From: Ren Maddox <ren.maddox@tivoli.com>
Subject: Re: Array stuck within a loop
Message-Id: <m3em1civwn.fsf@dhcp11-177.support.tivoli.com>

"bhui" <bhui_ipsg@yahoo.com> writes:

> I have used regex to separate a large string into a bunch of little ones,
> within one of these little ones I have created and array using split to
> converting each character into the array.
> 
> The problem is when I go parsing throught this array and get to the end or
> an unassigned value it hangs my while loop.
> 
> I suspect whats happening it the string i converted into an array does not
> have a /n to tell the while loop we are at the end. Is there a way to
> terminate the while if the array is unassigned ??
> 

It would really help a lot if you posted a self-contained piece of
code.  Further, warnings should be enabled and, even better, so should
strict:

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

Of course, enabling strict is going to require you to declare all of
these variables, and I'm not going to go through and indicate all of
those necessary changes.  But it sure helps us help you if you have
already done so.

> $string =~ (/^(.*?) "(.*?);(.*?)"
> \/REVISION="(.*?)"(.*?)VCS_TAGS(.*?)\)(.*?)\n.*/) ;
> 
>     {
>      $ui  =    $1 ;
>  $item_id_tmp =  $2 ;
>  $old_rev =  $3 ;
>  $real_rev =   $4 ;
>  $cmd1 =   $5 ;
>  $vcs_tags =   $6 ;
>  $user_filename =  $7 ;
> 
> 
> @tags = split (//,$vcs_tags) ;

There's almost never a real need to treat a string as an array.  Perl
offers numerous ways to deal with strings, including index, substr,
split and, of course, regular expressions.

>  $num_of_tags_ui = scalar @tags ;
>  $char_count = 150;
>  $char_to = $char_count ;
> 
> until (@tags[$char_to] =~ /\,/)

This looks incorrect, though without knowing what you data looks like,
it is hard to tell.  But starting at 150 and moving forward doesn't
seem likely to be correct.  Also, that should be $tags[$char_to], not
@tags[$char_to].  The second is an array slice, which does work OK in
this case, but is not what you really want.  If you were running with
warnings enabled, you would have been warned of this.  

Also, the only apparent point of this loop is to set $char_to to the
offset of a comma (which, by the way, doesn't need to be escaped --
and for that matter, doesn't need to be a regex), perhaps after 150
characters (if that is correct).  The entire loop could be replaced
by:

   $char_to = index($vcs_tags, ",", 150)

See "perldoc -f index" for information on this function.

>    {
>    $char_to++ ;
>    }
> 
> $tag1 = join("",@tags[1..--$char_to]);

This could be:

$tag1 = substr($vcs_tags, 1, $char_to - 2);

Note also that by using 1 you are skipping the first character of
$vcs_tags (both with your array and with substr).  If that is not
intended, then use:

$tag1 = substr($vcs_tags, 0, $char_to - 1);

Also note that decrementing $char_to will lead to matching the same
comma again below.

>  print "$ui \"$item_id_tmp;$old_rev\" \/REVISION=\"$real_rev\"$cmd1
> VCS_TAGS=\[$tag1\]\) $user_filename\n\n";
> 
> while ($char_to < $num_of_tags_ui)

Uh-oh... infinite loop warning.... the outer while loop never changes
$char_to, and the until loop below stops at a comma.  Two big
problems:

1. Once a comma is found, $char_to never moves past it, so the while
loop never finishes.

2. If there isn't a comma, then the until loop will just go on
forever.

>    print "I got to while \n\n";
>    print "num of tags $num_of_tags_ui\n";
> 
>    until (@tags[$char_to] =~ /\,/)

Here again is a slice where it shouldn't be, an escaped comma that
doesn't need to be, and a regex where a simple string compare ("eq")
should be.  Of course, this loop could also be replaced by an index as
above.

>      {
>      print "got to until \n";
>        $char_to++ ;
>      }
>   print "$num_of_tags_ui\n";
>   print "@tags[$char_to]\n";
>   print "$char_to\n";
>    &write_uia ;

I would say that the biggest problem with this code is that it
attempts to be C code, and not very good C code at that.

Here is a quick rewrite assuming that the 150 and the start at 1 are
intended:

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

# Get $string from somewhere unknown...
use vars qw($string);

# Test value
$string = 'Blah blah blah "foo;bar"
/REVISION="wow" VCS_TAGS=(we need a bunch of stuff here, so that the
150 has a chance to take effect.  So I will just ramble on a bit to
get some good data.  I do not know about the real data, but this test
string has some extra newlines so I added the "s" modifier to the
pattern below so that the newlines would not cause any trouble,
here is a value, and another, and a third.)some junk at the end
';

my($ui, $item_id_tmp, $old_rev, $real_rev, $cmd1, $vcs_tags, $user_filename)
   = $string =~ /^(.*?) "(.*?);(.*?)"
\/REVISION="(.*?)"(.*?)VCS_TAGS(.*?)\)(.*?)\n/s;

my @tags = split /,/, substr($vcs_tags, 150);
$tags[0] = substr($vcs_tags, 1, 148) . $tags[0];

print qq{$ui "$item_id_tmp;$old_rev" /REVISION="$real_rev"$cmd1
VCS_TAGS=[$tags[0]]\) $user_filename\n\n};

# Not sure what is supposed to happen with the rest of the tags, so...
print join "\ntag: ", "The rest of the tags are:", @tags[1..$#tags];
print "\n";

__END__

-- 
Ren Maddox
ren@tivoli.com


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

Date: Thu, 19 Oct 2000 15:35:10 GMT
From: Jukka Pakkanen <jukka.pakkanen@qnet.fi.no.spam>
Subject: Re: cgi & frame problem
Message-Id: <39EF1548.CBC845D1@qnet.fi.no.spam>


Anders Lund wrote:
> 
> Jukka Pakkanen wrote:
> 
> > Problem is:
> >
> > print "Location: http://www.qnet.fi\n\n";
> >
> your FORM tag should read
> 
> <FORM action="mywondefullscript.pl" target="_top">

Yes!  Thanks.

 ...Jukka


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

Date: Thu, 19 Oct 2000 16:18:59 +0100
From: James Taylor <james@NOSPAM.demon.co.uk>
Subject: Re: Counter doesn't work
Message-Id: <ant191559bbafNdQ@oakseed.demon.co.uk>

In article <8sn1b3$26d$1@nnrp1.deja.com>, Miker
<URL:mailto:mrobison@c802.crane.navy.mil> wrote:
> i'm gonna love this group!  a bunch of obviously
> experienced programmers who can actually disagree
> without starting a big flame war.

Don't bet on it though.  ;-)

-- 
James Taylor <james (at) oakseed demon co uk>
PGP key available ID: 3FBE1BF9
Fingerprint: F19D803624ED6FE8 370045159F66FD02



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

Date: Thu, 19 Oct 2000 10:57:10 -0500
From: jmad <than@wwa.com>
To: Alain BARBET <alian@alianwebserver.com>
Subject: Re: Email.pm and file attachments
Message-Id: <39EF19D6.D60DDBC@wwa.com>

Hi, I'm having similar issues, where can I find the message you're
referring to below?

JonM


Alain BARBET wrote:

> Hi,
>
> See "Re:Form to Email with FILE UPLOAD HELP!!!"
> --
> Alain & Estelle BARBET
> http://www.alianwebserver.com



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

Date: Thu, 19 Oct 2000 15:56:04 GMT
From: bing-du@tamu.edu
Subject: error out of my control
Message-Id: <8sn5il$5bl$1@nnrp1.deja.com>

Platform: IRIX64 switch 6.5 10181058 IP27
Perl: version 5.005_03 built for irix-64

'#!/usr/freeware/bin/perl64 -w' and 'use strict' are used in the script.

Modules used:

use lib qw(/usr/freeware/lib/perl5/site_perl/5.005/irix-64
/usr/freeware/lib/perl5/5.00503
/usr/local/md/libdata/httpd/htdocs/classroster
/usr/local/md/libdata/httpd/htdocs/classroster/search-3.0
/usr/local/md/libdata/httpd/htdocs/classroster/Mail-IMAPClient-1.15/);

use strict;
use POSIX;
use Net::LDAP;
use SDBM_File;
use Fcntl;
use Digest::MD5 qw(md5 md5_hex md5_base64);

use DBI qw(:sql_types);
use DBD::Oracle;

use CGI_LIB;
use SendMail;
use Perlfect::Template;
use IMAPClient;
use Benchmark;


Question:

If '/usr/freeware/bin/perl64 -c myscript.pl' reports some error related
to some system file which is out of my control like the following, how
should I check what is wrong in myscript.pl?  Which module uses
'type.ph' file?

Argument "_ABIN32" isn't numeric in eq at
/usr/freeware/lib/perl5/site_perl/5.005/sys/types.ph line 11.

Any suggestions are appreciated.

Bing


Sent via Deja.com http://www.deja.com/
Before you buy.


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

Date: 19 Oct 2000 17:03:46 GMT
From: jeacocks@uk.ibm.com
Subject: File Locking and CGI
Message-Id: <8sn9hi$sse$1@sp4en10.hursley.ibm.com>

I have a perl cgi script which allows a user to edit a record that is held 
in a plain text file. It works like this
1) User requests that he/she wants to modify a particular record in the 
file
2) The perl CGI script then retrieves the record from the file and, using 
the values of the fields in the record as defaults, sends back an HTML 
form with all the data in it
3) The user makes any changes to the data and then submits the form
4) The CGI script takes the data from the HTML form and writes out the 
modified record to the text file

At the moment there is no file locking implemented. I would like to 
implement file locking. I cannot use flock() as the file in question is on 
an AFS filesystem. The only PERL module that I have found to do file 
locking writes out the PID to the lockfile. I assume that this is to allow 
you to detect stale lockfiles created by processes that have died. 
Unfortunately this is not what I want, as the perl script gets run twice, 
once in step 2 and once in step 4, each time it will run with a different 
PID. However, I wish for a lockfile created in step 2 to still be valid in 
step 4 even though the PID will be different. So my question is - are 
there any modules out there that take this into account or am I going to 
have to write my own file locking routine. I am sure someone must have 
solved this problem as it would seem to be a very common one 

Thanks

Stewart


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

Date: Thu, 19 Oct 2000 16:35:16 GMT
From: peter@PSDT.com (Peter Scott)
Subject: Re: File::Find pruning
Message-Id: <8pFH5.2290$q9.76959@news1.gvcl1.bc.home.com>

In article <ant191253345fNdQ@oakseed.demon.co.uk>,
 James Taylor <james@NOSPAM.demon.co.uk> writes:
>I have a hierarchy of newsgroup directories to scan, and below each
>group in the structure are further (numbered) directories containing
>article files. Also in each group directory is an article index file
>called .overview which I want to process in my script. Having processed
>the .overview file I want to move on to the next newsgroup without
>scanning all the article subdirectories of the current group.
>I had a look at the code for File::Find and saw that it resets its
>$prune variable for each call to wanted() and takes no action when
>the current item is a file.

In your callback, try

	$File::Find::prune = 1 if -e "$_/../.overview";

Note that pruning doesn't work if you're using finddepth or the bydepth attribute.

-- 
Peter Scott


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

Date: 19 Oct 2000 17:17:29 GMT
From: ansok@alumni.caltech.edu (Gary E. Ansok)
Subject: Re: File::Find pruning
Message-Id: <8snab9$hjo@gap.cco.caltech.edu>

In article <ant191253345fNdQ@oakseed.demon.co.uk>,
James Taylor  <james@NOSPAM.demon.co.uk> wrote:
>I recently had a task which I thought would be ideal for File::Find
>but I was disappointed with it's behaviour in regard to pruning.
>I am therefore tempted to write my own recursive routine, but you'll
>probably tell me that I'm doing something wrong and that File::Find
>will do what I want after all. Here's what I want to do:
>
>I have a hierarchy of newsgroup directories to scan, and below each
>group in the structure are further (numbered) directories containing
>article files. Also in each group directory is an article index file
>called .overview which I want to process in my script. Having processed
>the .overview file I want to move on to the next newsgroup without
>scanning all the article subdirectories of the current group.
>
>So here's the structure:
>
>comp/lang/perl/misc/.overview      <--- now I want to prune avoiding
>                   /00000/00001    <--- all the article files
>                         /..etc
>                   /00075/..etc
>                   /..etc/..etc
>comp/lang/python/announce/.overview    <--- now I want to prune again
>                         /00000/00001  <--- avoiding the article files
>                         /..etc/..etc
>
>However, when I set $File::Find::prune=1 after processing the
>.overview file File::Find does *not* return to the parent directory.

$File::Find::prune only applies, as you've discovered, to whether
find() should read the contents of the directory under consideration
(i.e., the one in $_) -- not the processing of the current parent
directory (i.e., $File::Find::dir).  It has no effect when $_
names a file.

Part of the problem with what you propose is that File::Find does
not guarantee anything about the order in which the files/directories
within a directory are returned.  You could still end up scanning
00000 before finding .overview.  (Specific systems may always return
files in ASCIIbetical order, or you might just get lucky.)

Besides, are you sure you're ready to prune after seeing .overview?
Couldn't there be newsgroup directories still to be checked?  You
wouldn't want to skip comp/lang/c/moderated just because you saw
comp/lang/c/.overview, would you?

>Worse than that, it goes into all the subdirectories of the current
>newsgroup taking an age to complete what should be a quick scan.
>In desperation I added the following test at the top of my wanted():
>
>$File::Find::prune=1, return if /^\d{5}$/;

This is probably the best way.

If you knew that ".overview" would be the *only* interesting file in
a directory, and having seen it you could skip all subdirs, I might
code it like this:

sub wanted { 
    return unless -d && -e "$_/.overview";
    process("$_/.overview");
    $File::Find::prune = 1;
}

But as I understand your program design, this won't work given the
current newsgroup hierarchies.

>Perhaps it should be possible to set
>$File::Find::prune to a number higher than 1 to indicate that it
>should prune that many levels off the search tree, thus allowing me
>to return to the parent by setting prune to 2.

I can imagine cases where this might be useful, but I expect that
most can handled by moving the processing into the consideration of the
parent directory (as I did above).

-- Gary Ansok


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

Date: Thu, 19 Oct 2000 17:23:47 +0100
From: paul_france <paulf@angliaed.co.uk>
Subject: Filehandle redirection
Message-Id: <39EF2005.BCE04611@angliaed.co.uk>

Hello All

I have a Perl CGI script that uses lots of print statements (to STDOUT)
to output dynamically generated web content. Is it possible to intercept
this output by temporarily redirecting the STDOUT filehandle to a
variable within the script so I can do some regexs on it and then send
it to the browser via STDOUT?

For your info, this will enable me to run the same script on two
different versions of our website without me rewriting large chunks of
it.

Thanks,

Paul F.



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

Date: 19 Oct 2000 11:26:39 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Filehandle redirection
Message-Id: <87itqo3igw.fsf@limey.hpcc.uh.edu>

>> On Thu, 19 Oct 2000 17:23:47 +0100,
>> paul_france <paulf@angliaed.co.uk> said:

> Hello All I have a Perl CGI script that uses lots of
> print statements (to STDOUT) to output dynamically
> generated web content. Is it possible to intercept this
> output by temporarily redirecting the STDOUT filehandle
> to a variable within the script so I can do some regexs
> on it and then send it to the browser via STDOUT?

Just put the content into a variable and then operate on
that and then print it to STDOUT.

hth
t
-- 
Eih bennek, eih blavek.


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

Date: Thu, 19 Oct 2000 09:52:48 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: Filehandle redirection
Message-Id: <39EF26E0.83C2B5A@stomp.stomp.tokyo>

paul_france wrote:
 
> I have a Perl CGI script that uses lots of print statements (to STDOUT)
> to output dynamically generated web content. Is it possible to intercept
> this output by temporarily redirecting the STDOUT filehandle to a
> variable within the script so I can do some regexs on it and then send
> it to the browser via STDOUT?
 
> For your info, this will enable me to run the same script on two
> different versions of our website without me rewriting large chunks
> of it.
 

This is illogical. How would you grab and redirect content
which has already been sent to a buffer by a print command?

You indicate two versions of a website. Clearly you have a 
device to determine which content of two is to be sent to 
a browser. Use this device to determine what your script
will do, before you send content via a print command.

Godzilla!


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

Date: Thu, 19 Oct 2000 18:00:07 GMT
From: "Ben Kennedy" <bkennedy@hmsonline.com>
Subject: Re: Filehandle redirection
Message-Id: <HEGH5.58228$td5.8727558@news1.rdc2.pa.home.com>


"paul_france" <paulf@angliaed.co.uk> wrote in message
news:39EF2005.BCE04611@angliaed.co.uk...
> Hello All
>
> Is it possible to intercept
> this output by temporarily redirecting the STDOUT filehandle to a
> variable within the script so I can do some regexs on it and then send
> it to the browser via STDOUT?

One way would be to create a tie package that captures print() statements,
then tie STDOUT to it (or another handle you have select()'ed).  See perldoc
perltie for more information.

--Ben Kennedy




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

Date: Thu, 19 Oct 2000 18:37:13 +0100
From: "Bruce Phipps" <bruce_phipps@my-deja.com>
Subject: Re: How to get rid of '/' in a telnet prompt?
Message-Id: <8snbhl$7lv$1@sshuraab-i-1.production.compuserve.com>

You can "escape" forward slashes and other special characters by using a
backslash:

\/   equals /

Bruce




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

Date: Thu, 19 Oct 2000 17:09:45 GMT
From: "EM" <me@privacy.net>
Subject: http referer manipulation
Message-Id: <tVFH5.7056$44.21265@news.iol.ie>

I use this code to redirect the browser to an url

print "Content-type: text/html\n";
print "Location: $url\n\n";

this works fine but i want a way to do this but not to send any http referer
to the target url
if possible also is there a way to send a fake http referer?

Please help, URGENT
Thanks





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

Date: 19 Oct 2000 18:37:07 +0100
From: nobull@mail.com
Subject: Re: http referer manipulation
Message-Id: <u97l74pwak.fsf@wcl-l.bham.ac.uk>

"EM" <me@privacy.net> writes:

> I use this code to redirect the browser to an url
                              ^^^^^^^^^^

> print "Content-type: text/html\n";
> print "Location: $url\n\n";
> 
> this works fine but i want a way to do this but not to send any http referer
> to the target url
> if possible also is there a way to send a fake http referer?

This is a question about the browser, not related to Perl.

I've not tried it but it is possible that some browsers will set the
redirected request's "Referer" headers based on the redirect's
"Content-location" header.  You may have to do a refresh rather than a
simple redirect.

The only other way I can think of is client-side scripts.

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


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

Date: Thu, 19 Oct 2000 10:07:46 -0700
From: "Godzilla!" <godzilla@stomp.stomp.tokyo>
Subject: Re: I've trashed my serial ports! HELP!
Message-Id: <39EF2A62.E11AD1DE@stomp.stomp.tokyo>

Phil xxx wrote:

(snippage)

> I'm in a spot of bother! I've been playing around with tip and cu and
> now I seem to have somehow disabled my serial ports....

> This has always worked before.


Undo what you changed.

Godzilla!


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

Date: Thu, 19 Oct 00 17:41:14 +0200
From: h.m.brand@hccnet.nl (H. Merijn Brand)
Subject: RE: Make this regex neater, anyone?
Message-Id: <8FD2B2921Merijn@192.0.1.90>

bart.lateur@skynet.be (Bart Lateur) wrote in
<irgtussq6ind437vu2l462442m9au93gk8@4ax.com>: 

>Philip Lees wrote:
>
>>>This list can be indexed into like any other list.  Perl provides an
>>>incredibly handy bit of semantics which interprets negative array
>>>indices as being offsets from the *end* of the list, so $a[-1] is the
>>>last element in @a, $a[-5] is the fifth-from-the-last element, and so
>>>forth. So the [-1] index above indexes the last matched string of
>>>non-digits -- which is what you wanted.
>>
>>Thanks again. So the list indexing behaves in a cyclic way - that _is_
>>handy. 
>
>Actually, not for 100%. For example,
>
>     @a[2 .. -2]

      @a[1 .. -2]      or '... but the first two and the last ...'

>in order to get every element but the first and the last, DOES NOT WORK.
>Your numerical range must be of the same sign:
>
>     @a[2..5]
>     @a[-5 .. -2]
>
>although this works too (not very useful, IMO):
>
>     @a[-2 .. 2]
>
>In short: it's the list that interprets the meaning of -1 as pointing to
>the last element. But it's value still is -1.

-- 
H.Merijn Brand
using perl5.005.03 and 5.6.0 on HP-UX 10.20, HP-UX 11.00, AIX 4.2, AIX 4.3,
  DEC OSF/1 4.0 and WinNT 4.0 SP-6a,  often with Tk800.022 and/or DBD-Unify
ftp://ftp.funet.fi/pub/languages/perl/CPAN/authors/id/H/HM/HMBRAND/
Member of Amsterdam Perl Mongers (http://www.amsterdam.pm.org/)


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

Date: 19 Oct 2000 16:54:23 GMT
From: helling@x4u2.desy.de (Robert C. Helling)
Subject: matching balanced text
Message-Id: <slrn8uu9pv.2iega.helling@x4u2.desy.de>

Hi,

I remember seeing some annoncements that perl5.6 has regex features
that support matching balanced expressions but I cannot find
any description of those in the documentation. Could somebody
please point me to the file (not the old version of prelfaq6).

Thanks
Robert


-- 
 .oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oOo.oO
Robert C. Helling        Albert Einstein Institute Potsdam
                         Max Planck Institute For Gravitational Physics
                         and
                         2nd Institute for Theoretical Physics
                         DESY / University of Hamburg
                         Email helling@x4u2.desy.de  Fon +49 40 8998 4706      
			 <href=http://www.aei-potsdam.mpg.de/~helling>



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

Date: Thu, 19 Oct 2000 13:22:26 -0400
From: Jeff Pinyan <jeffp@crusoe.net>
Subject: Re: matching balanced text
Message-Id: <Pine.GSO.4.21.0010191321380.25707-100000@crusoe.crusoe.net>

[posted & mailed]

On Oct 19, Robert C. Helling said:

>I remember seeing some annoncements that perl5.6 has regex features
>that support matching balanced expressions but I cannot find
>any description of those in the documentation. Could somebody
>please point me to the file (not the old version of prelfaq6).

The perlre docs for 5.6.  You can see them at

  http://www.pobox.com/~japhy/perl/5.6/perlre.pod

You want to look for the (??{ ... }) construct, and the re.pm module's
'eval' option.

-- 
Jeff "japhy" Pinyan     japhy@pobox.com     http://www.pobox.com/~japhy/
PerlMonth - An Online Perl Magazine            http://www.perlmonth.com/
The Perl Archive - Articles, Forums, etc.    http://www.perlarchive.com/
CPAN - #1 Perl Resource  (my id:  PINYAN)        http://search.cpan.org/





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

Date: Thu, 19 Oct 2000 09:58:29 -0700
From: Larry Rosler <lr@hpl.hp.com>
Subject: Re: newbie intro
Message-Id: <MPG.1458c80c930f915298ae49@nntp.hpl.hp.com>

In article <8sn0oh$1kb$1@nnrp1.deja.com> on Thu, 19 Oct 2000 14:33:53 
GMT, Miker <mrobison@c802.crane.navy.mil> says...
> hello,

Hello back at ya'.

> my name is michael robison and i've been programming
> for a long time but i'm new to perl.  i just posted
> my first question, about a win98 activestate install,
> and i thought it would be nice to also say hello and
> introduce myself.  i live in southern indiana.  i've
> been tasked to come up to speed on perl and slowly
> start building an intranet at the workplace.  i've
> got a linux box up and running on the net and i've
> got some html and minor scripts running.
> 
> this looks like a good group... i notice a decent
> amount of posts and not too many unanswered ones.  i
> hope that i can come up to speed so that i can
> contribute answers to the group instead of just
> questions.

Thanks for the kind words and good intentions.  I would suggest you try 
answering questions yourself offline, and then compare them with the 
answers provided, until you feel comfortable about your hit rate.

When you do get around to posting responses, please:

    Don't post conjectures.

    Don't post untested code unless clearly labeled as such.

    Post code that compiles with 'use strict;' and runs quietly with
    warnings enabled.

Until then, in the words of The Larry, "Have the appropriate amount of 
fun!"

-- 
(Just Another Larry) Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com


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

Date: Thu, 19 Oct 2000 17:43:45 GMT
From: oloryn@mindspring.com (Ben Coleman)
Subject: Re: Newbie Question: command line parameters - WIN32
Message-Id: <39ef3253.509925243@localhost>

On Thu, 19 Oct 2000 11:11:24 GMT, Adam <acheney@my-deja.com> wrote:

>Is this to be expected?  Whilst I realise that this probably has more to
>do with Wind'ohs than Perl, can I rectify it (other than by preceding
>with 'perl')?

Check the file type that you have associated with perl files.  It
should look something like

C:\>ftype Perl
Perl=C:\Perl\bin\Perl.exe "%1" %*

It sounds like you have left off the %*, which is what tells it to
include the arguments.

Ben


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

Date: Thu, 19 Oct 2000 18:39:14 +0100
From: "lesley withall" <lesley@natric.demon.co.uk>
Subject: Object destructors not working properly?
Message-Id: <971977131.9901.0.nnrp-10.9e989efa@news.demon.co.uk>

Has anyone had problems with object destructors? According to the excellent
'Programming Perl' - 'When the last reference to an object goes away, the
object is automatically destroyed. '

My experience is that the object is destroyed when the first reference is
deleted. I don't know how to debug this.. any ideas?

Also, if an object contains other object references it appears that these
have been destroyed before the DESTROY method of the container is invoked.
Is this what's supposed to happen?

Thanks




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

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 V9 Issue 4663
**************************************


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