[22178] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4399 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jan 14 09:06:02 2003

Date: Tue, 14 Jan 2003 06: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)

Perl-Users Digest           Tue, 14 Jan 2003     Volume: 10 Number: 4399

Today's topics:
    Re: Book Question (Andrew F)
    Re: command-line args style flags from a file (Kevin Newman)
    Re: command-line args style flags from a file (Kevin Newman)
    Re: command-line args style flags from a file (Kevin Newman)
    Re: command-line args style flags from a file (Tad McClellan)
    Re: command-line args style flags from a file (Tad McClellan)
        comment multiple lines <a@b.c>
    Re: comment multiple lines <tassilo.parseval@post.rwth-aachen.de>
    Re: comment multiple lines <nobull@mail.com>
    Re: How to check responce on specific tcp-ports? <josef.moellers@fujitsu-siemens.com>
        How to delete leading&trailing spaces&tabs at once? <a@b.c>
    Re: How to delete leading&trailing spaces&tabs at once? (Anno Siegel)
    Re: How to delete leading&trailing spaces&tabs at once? <bernard.el-hagin@DODGE_THISlido-tech.net>
    Re: How to delete leading&trailing spaces&tabs at once? <fb@geo-guide.com>
    Re: How to delete leading&trailing spaces&tabs at once? <a@b.c>
    Re: How to delete leading&trailing spaces&tabs at once? (Tad McClellan)
    Re: How to execute a perl script from within a perl scr <nobody@dev.null>
    Re: how to redirect STDIN to such place like /dev/null  <bik.mido@tiscalinet.it>
        IFRAME and Cookies <fb@geo-guide.com>
    Re: IFRAME and Cookies <nobull@mail.com>
    Re: IFRAME and Cookies <fb@geo-guide.com>
    Re: overriding subroutines (Anno Siegel)
    Re: Picking out options in argv (Johan Vromans)
    Re: Regenerating Activeperl html documentation <stjm2@cam.ac.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: 14 Jan 2003 01:06:01 -0800
From: tinthaut@hotmail.com (Andrew F)
Subject: Re: Book Question
Message-Id: <d47e862a.0301140106.5fbc9755@posting.google.com>

"Ning li" <ningli2000@worldnet.att.net> wrote in message news:<J1KU9.109942$hK4.8929539@bgtnsc05-news.ops.worldnet.att.net>...
> Hi,
> 
>     I am new to Perl and I have used awk and sed for quite some time. I
> would like to use Perl mainly for file manipulation and formatting. Can
> someone suggest a good Perl book with focus on this topic?
> 
>     Thanks in advance.

The Llama book -- Learning Perl by Randal Schwartz,
http://www.oreilly.com/catalog/lperl3/


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

Date: 13 Jan 2003 21:06:23 -0800
From: knewman00@earthlink.net (Kevin Newman)
Subject: Re: command-line args style flags from a file
Message-Id: <4c8e4398.0301132106.2e748e11@posting.google.com>

mauzo@mimosa.csv.warwick.ac.uk (Ben Morrow) wrote in message news:<avt2o9$1ms$1@wisteria.csv.warwick.ac.uk>...
> knewman00@earthlink.net (Kevin Newman) wrote:
> >[snip]
> >For example, let's say I have file called do_flags.txt.  Inside of
> >do_flags.txt are the following lines of text:
> >---------------------------
> >-c -o <outputfile-A>
> >-c -b  -o <outputfile-B>
> >-b  -o <outputfile-C>
> >--------------------------
> >To invoke this series of operations:
> >myscript.pl -f<inputfile> -L do_flags.txt
> >b
> >[snip]
> 
> Would something like: [untested and incomplete code]
> 
> use Getopt::Std;
> use constant options => 'cbf:o:';
> 
> getopts(options . 'L:', \my(%cmd_opts));
> my $file = delete $cmd_opts{L};
> unless($file) {
>   process_options(%cmd_opts);
> }
> else {
>   open my $CONFIG, "<", $file;
>   for my $opts (<$CONFIG>) {
>     @ARGV = split ' ', $opts;
>     getopts(options, \my %file_opts);
>     my %all_opts = (%cmd_opts, %file_opts);
>     process_options(%all_opts);
>   }
> }
> 
> be what you're looking for? The basic idea is to add each set of options from
> the file to those given on the command line, then process the whole set.

Nice....
I'm always learning new syntax, so could you explain a few statements
in your code?
1. Why use constants? 2. Why options . 'L:'? 3. Why do you have to do
(%cmd_opts, %file_opts)?  Any suggestions on how to do a "soft error
trap within the loop (see the unfinished but tested code below)? 
Let's suppose there are 10 lines of commands in a file, but line 3 an
8 are incorrectly formatted (use -Y flag).  How can I by pass that
"bad line" and continue processing.

Thanks,

kln
=========== Code Starts Here =========
CMD LINE
bm.pl -L cmdfile.dat
INPUT
==== cmdfile.dat ===
-c -b -o outfileA
-c -o outfileB
-c
==== cmdfile.dat ===
OUTPUT
Filename: cmdfile.dat
b => 1
c => 1
o => outfileA
****************************************
c => 1
o => outfileB
****************************************
c => 1
****************************************
====== CODE ====
use strict;
use Getopt::Std;
use constant options => 'cbf:o:';

getopts(options . 'L:' , \my %cmd_opts) or useage();

#The delete function returns the value that was deleted
my $file = delete $cmd_opts{L};

if (defined ($file)) {print "Filename: $file \n";}

unless($file) {
	process_options(%cmd_opts);
} else {
	open (my $CONFIG, "<", $file) or die "Can't open $file $!";
	for my $opts (<$CONFIG>) {
 		@ARGV = split ' ', $opts;
		getopts(options, \my %file_opts); #Need Soft Error Here
		my %all_opts = (%cmd_opts, %file_opts);
		process_options(%all_opts);
		}
}

sub process_options{
	my %cmdline = @_ ;
	 #$flag;
	foreach my $flag (sort keys %cmdline) {
		print "$flag => $cmdline{$flag}\n";
	}
	print "*" x40 . "\n";
}

sub useage {	
(my $progName = $0) =~ s!.*/!!;
	die <<CMD
useage: $progName [flags] [files]
	[-i filename] REQUIRED
	or 
	[-L <LIST of commands file>] REQUIRED
	[-f <fully qualified filname>] REQUIRED
	[-b remove blank lines]
	[-c Compress the file]
	[-o <Output filename>]
CMD
}


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

Date: 13 Jan 2003 21:09:17 -0800
From: knewman00@earthlink.net (Kevin Newman)
Subject: Re: command-line args style flags from a file
Message-Id: <4c8e4398.0301132109.313ed2bc@posting.google.com>

tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2440p.bg3.tadmc@magna.augustmail.com>...
> Kevin Newman <knewman00@earthlink.net> wrote:
> 
> > is there some module or example existing code that allows
> > command-line style flags to be read from a file?
> 
> 
> Getopt::Std works on whatever is in @ARGV when you call getopts().
> 
> Do plain ol' file input to read the switches, stuff them
> into @ARGV, then call getopts().
> 
> eg:
> 
>    @ARGV = qw/ -c -o outputfile-A/;
>    getopts('co:');
>    print $opt_c, "\n";
>    print $opt_o, "\n";

I'm not sure how this works.  If I can get my code to work in this few
lines I really want to know how it works. :-)

Thanks,

kln


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

Date: 13 Jan 2003 21:18:03 -0800
From: knewman00@earthlink.net (Kevin Newman)
Subject: Re: command-line args style flags from a file
Message-Id: <4c8e4398.0301132118.7bf79dac@posting.google.com>

"Harald H.-J. Bongartz" <bongie@gmx.net> wrote in message news:<1601609.3xdfVSxWaW@nyoga.dubu.de>...
> Kevin Newman wrote:
> > I have code that works for input from the command-line (using
> > Getopt::Std).  I've even made an attempt at getting the arguments to
> > work from a file.  Before I post my code (it's currently about 100
> > lines), is there some module or example existing code that allows
> > command-line style flags to be read from a file?
> 
> You can use Getopt::Std for that, too.  Just read the lines from your
> do_flags.txt into @ARGV, line by line:
> 
>   getopts('...F:', \%Options);  # get command line options
>   if ($Options{F}) {    # there is a "-F do_flags.txt"
>       open (OPTFILE, "<$Options{F}")
>         or die "cannot open option file: $!";
>       while (<OPTFILE>) {
>           my %LocalOptions = %Options; # inherit global options
>           @ARGV = split;
>           getopts(..., \%LocalOptions); # analyze one line of options
>           do_something_with_options (\%LocalOptions);
>       }
>       close OPTFILE;
>   } else {
>    do_something_with_options (\%Options);
>   }
> 
> (untested)
> 
> Of course, when using this trivial method you won't get the quoting
> capabilities of the shell, i.e. your do_flags.txt should not contain
>         -c -o "Output File With Blanks.o"
> or something like that.
> 

I like this too (see the reply to Ben Morrow).  BTW, can you describe
a non trivial method to handle filenames with spaces?  Also, what is
inherit global options?  The following code has been tested.

Thanks,

kln
============= Code =============
(The input and output is the same as the Ben Morrow reply)

use strict;
use Getopt::Std;

	my $optionFlags = 'cbf:o:F:';
	getopts($optionFlags, \my %Options);  # get command line options
	if ($Options{F}) {    # there is a "-F do_flags.txt"
		open (OPTFILE, "<$Options{F}") or 
		die "cannot open option file: $!";
      while (<OPTFILE>) {
          my %LocalOptions = %Options; 	# inherit global options
          @ARGV = split;
          getopts($optionFlags, \%LocalOptions); # analyze one line of
options
          do_something_with_options (\%LocalOptions);
          }
      close (OPTFILE);
  } else {
  	do_something_with_options (\%Options);
 }

sub do_something_with_options
{
	my $cmdline = shift @_ ;
	foreach my $flag (sort keys %$cmdline) {
		print "$flag => $cmdline->{$flag} \n";
	}
	print "*" x40 . "\n";
}


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

Date: Mon, 13 Jan 2003 23:24:06 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: command-line args style flags from a file
Message-Id: <slrnb277nm.5i8.tadmc@magna.augustmail.com>

Kevin Newman <knewman00@earthlink.net> wrote:
> tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrnb2440p.bg3.tadmc@magna.augustmail.com>...

>> eg:
>> 
>>    @ARGV = qw/ -c -o outputfile-A/;
>>    getopts('co:');
>>    print $opt_c, "\n";
>>    print $opt_o, "\n";
> 
> I'm not sure how this works.  


It works just as I wrote it. Copy it, paste it, run it 
and see for yourself.

I hard-coded @ARGV, you'll need to replace that with code
that loads up @ARGV with whatever you want it to contain.


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


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

Date: Tue, 14 Jan 2003 00:08:16 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: command-line args style flags from a file
Message-Id: <slrnb27aag.5ma.tadmc@magna.augustmail.com>

Kevin Newman <knewman00@earthlink.net> wrote:
> "Harald H.-J. Bongartz" <bongie@gmx.net> wrote in message news:<1601609.3xdfVSxWaW@nyoga.dubu.de>...
>> Kevin Newman wrote:
>> > I have code that works for input from the command-line (using
>> > Getopt::Std).  I've even made an attempt at getting the arguments to
>> > work from a file.

>> You can use Getopt::Std for that, too.  Just read the lines from your
>> do_flags.txt into @ARGV, line by line:

>>           @ARGV = split;

>> Of course, when using this trivial method you won't get the quoting
>> capabilities of the shell, i.e. your do_flags.txt should not contain
>>         -c -o "Output File With Blanks.o"
>> or something like that.


> I like this too (see the reply to Ben Morrow).  BTW, can you describe
> a non trivial method to handle filenames with spaces?  


That is a Question that is Asked Frequently:

   perldoc -q split

      How can I split a [character] delimited string except when
      inside [character]?


Using the module suggested there:

   use Text::ParseWords;
   @ARGV = quotewords(q/ /, 0, $_);

or, even more non-trivially :-) you could do this

   @ARGV = grep {defined and length} split /(?:"([^"]+)")|\s+/;

Rather too much job security in that second one though,
so use the module instead.


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


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

Date: Tue, 14 Jan 2003 13:55:41 +0100
From: ZZT <a@b.c>
Subject: comment multiple lines
Message-Id: <b011cd$pik$1@news1.wdf.sap-ag.de>

Hi all,

i c/c++ you can comment out multiple line by using /*   ...  */
Is there something comparable in perl?

thanks



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

Date: 14 Jan 2003 13:17:22 GMT
From: "Tassilo v. Parseval" <tassilo.parseval@post.rwth-aachen.de>
Subject: Re: comment multiple lines
Message-Id: <b012l2$m38$1@nets3.rz.RWTH-Aachen.DE>

Also sprach ZZT:

> i c/c++ you can comment out multiple line by using /*   ...  */
                  ^^^^^^^^^^^
> Is there something comparable in perl?

That's a FAQ (which you are asked to check before posting, by the way):

    perldoc -q "comment out"

Tassilo
-- 
$_=q!",}])(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus;})(rekcah{lrePbus;})(lreP{rehtonabus;})(rehtona{tsuJbus!;
$_=reverse;s/sub/(reverse"bus").chr(32)/xge;tr~\n~~d;eval;


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

Date: 14 Jan 2003 12:59:21 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: comment multiple lines
Message-Id: <u9r8bfj1pv.fsf@wcl-l.bham.ac.uk>

ZZT <a@b.c> writes:

> i c/c++ you can comment out multiple line by using /*   ...  */
> Is there something comparable in perl?

See FAQ: "How can I comment out a large block of perl code?"

In case it had eascaped your notice, you are expected to consult the
FAQ _before_ you post.

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


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

Date: Tue, 14 Jan 2003 11:27:47 +0100
From: Josef =?iso-8859-1?Q?M=F6llers?= <josef.moellers@fujitsu-siemens.com>
Subject: Re: How to check responce on specific tcp-ports?
Message-Id: <3E23E623.DE846082@fujitsu-siemens.com>

ZZT wrote:
> =

> Josef M=F6llers wrote:
> =

> > This is called a port scan.
> > It is very rude, to say the least.
> > Not giving your real name indicates that you know that.
> =

> thanks for your answer, but didn't help to much.
> Believe it or not but there are reasonable tasks for checking port, for=

> instance if you want to detect that a service is running.
> If I would like to do a port-scan I wouldn't use perl!

I apologize if I mistook your intentions, but all evidence was against
you.

-- =

Josef M=F6llers (Pinguinpfleger bei FSC)
	If failure had no penalty success would not be a prize
						-- T.  Pratchett


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

Date: Tue, 14 Jan 2003 13:32:18 +0100
From: ZZT <a@b.c>
Subject: How to delete leading&trailing spaces&tabs at once?
Message-Id: <b0100j$oe4$1@news1.wdf.sap-ag.de>

Hi all,

doing this:
$_ =~ s/^ +//;
$_ =~ s/ +$//;
$_ =~ s/^\t+//;
$_ =~ s/\t+$//;

didn't work really reliable. Is there a better way?

thanks!



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

Date: 14 Jan 2003 12:59:05 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <b011ip$oot$1@mamenchi.zrz.TU-Berlin.DE>

ZZT  <a@b.c> wrote in comp.lang.perl.misc:
> Hi all,
> 
> doing this:
> $_ =~ s/^ +//;
> $_ =~ s/ +$//;
> $_ =~ s/^\t+//;
> $_ =~ s/\t+$//;
> 
> didn't work really reliable. Is there a better way?

In which way did it fail?  "Didn't work" is vague and "didn't work
reliably" is more so.  Be specific about your problem.

Otherwise, that's a faq, and it is trivially found through "perldoc -q
blank".  Please consult your local documentation before asking a question
here.

Anno


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

Date: Tue, 14 Jan 2003 13:02:08 +0000 (UTC)
From: Bernard El-Hagin <bernard.el-hagin@DODGE_THISlido-tech.net>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <b011og$9h4$1@korweta.task.gda.pl>

In article <b0100j$oe4$1@news1.wdf.sap-ag.de>, ZZT wrote:
> Hi all,
> 
> doing this:
> $_ =~ s/^ +//;
> $_ =~ s/ +$//;
> $_ =~ s/^\t+//;
> $_ =~ s/\t+$//;
> 
> didn't work really reliable. Is there a better way?


s/[ \t]+$//;
s/^[ \t]+//;


Or get rid of *all* leading and trailing whitespace with:


s/^\s+//;
s/\s+$//;


Cheers,
Bernard
--
echo 42|perl -pe '$#="Just another Perl hacker,"'


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

Date: Tue, 14 Jan 2003 14:30:34 +0100
From: "Frode Bjerkholt" <fb@geo-guide.com>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <BeUU9.13485$Rc7.209492@news2.e.nsc.no>

Hi

You can at least reduce it two expressions:

$_ =~s/^[\x20\t]+//;
$_ =~s/[\x20\t]+$//;

or if you want to remove all leading and trailing whitespaces (not just
spaces and tabs):

$_ =~ s/^\s+//;
$_ =~ s/\s+$//;

Regards,

Frode




"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:b011ip$oot$1@mamenchi.zrz.TU-Berlin.DE...
> ZZT  <a@b.c> wrote in comp.lang.perl.misc:
> > Hi all,
> >
> > doing this:
> > $_ =~ s/^ +//;
> > $_ =~ s/ +$//;
> > $_ =~ s/^\t+//;
> > $_ =~ s/\t+$//;
> >
> > didn't work really reliable. Is there a better way?
>
> In which way did it fail?  "Didn't work" is vague and "didn't work
> reliably" is more so.  Be specific about your problem.
>
> Otherwise, that's a faq, and it is trivially found through "perldoc -q
> blank".  Please consult your local documentation before asking a question
> here.
>
> Anno


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 11.01.03




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

Date: Tue, 14 Jan 2003 14:10:39 +0100
From: ZZT <a@b.c>
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <b0128f$q6f$1@news1.wdf.sap-ag.de>

Bernard El-Hagin wrote:

> s/[ \t]+$//;
> s/^[ \t]+//;

thanks! thats perfect :)

bye



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

Date: Tue, 14 Jan 2003 07:54:53 -0600
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: How to delete leading&trailing spaces&tabs at once?
Message-Id: <slrnb285ld.6ar.tadmc@magna.augustmail.com>

ZZT <a@b.c> wrote:
> 
> doing this:
> $_ =~ s/^ +//;
> $_ =~ s/ +$//;
> $_ =~ s/^\t+//;
> $_ =~ s/\t+$//;
> 
> didn't work really reliable. 


It works fine. There is something else going on that you 
haven't told us.

Give us a short and complete program that we can run showing
that it "didn't work", and we will be able to explain the
program's behavior.


>Is there a better way?


No.


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


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

Date: Tue, 14 Jan 2003 12:53:36 GMT
From: Andras Malatinszky <nobody@dev.null>
Subject: Re: How to execute a perl script from within a perl script and return info
Message-Id: <3E240769.3060305@dev.null>



Anders Torvill Bjorvand wrote:

> This is the situation:
> 
> I have two scripts a.cgi and b.cgi residing the following places on the
> server:
> /home/www/myserver/a.cgi
> /home/www/myserver/mydir/b.cgi
> 
> Both scripts are executable (755).
> 
> This is the simplified code of a.cgi:
> ------------
> #!/usr/bin/perl
> $content = `/home/www/myserver/mydir/b.cgi`;
> 
> print "Content-type:text/html\n\n";
> print $content;
> 
> exit;
> ------------
> 
> This is the simplified code of b.cgi:
> ------------
> #!/usr/bin/perl
> 
> print "Content-type:text/html\n\n";
> print "This is the output from b";
> 
> exit;
> ------------
> 
> When running a.cgi, it should produce the output from b.cgi, but a.cgi
> outputs nothing.
> 
> Changing line 2 in a.cgi to:
> $content = ` perl /home/www/myserver/mydir/b.cgi`;
> does not seem to change anything.
> 
> Why doesn't this work, and how can I get it to work?
> 
> Sincerely,
> Anders T. B.
> 

This is just a guess, but check the permissions of mydir. I assume this 
is all in a CGI context, and the user your a.cgi is running as may not 
have read permissions to the mydir directory. See if moving b.cgi up one 
level into the myserver directory changes things.

Of course our guesses could be more educated if you asked perl to help 
you with things like error checking.





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

Date: Tue, 14 Jan 2003 09:06:30 +0100
From: Michele Dondi <bik.mido@tiscalinet.it>
Subject: Re: how to redirect STDIN to such place like /dev/null ??
Message-Id: <a0b62voj7t46k5tdn6hmjie6kthraimn0l@4ax.com>

On Sun, 12 Jan 2003 02:46:26 +0800, "oooooops" <oooooops@163.com>
wrote:

>I set up a script for catching output of a pipe
>from aother program as following.
>but I can not close the STDIN
>or just redirect else behind double "\n"
>input. if I run it with

You either want to change the input record separator or catch the
first empty line. Is the following ok for you (with output file given
as first arg on cmd line)?


#!/usr/bin/perl -w

use strict;

die "Usage: '$0 <outfile> [<files>]'\n" unless @ARGV;
my $file=shift;
open DEST, ">>", $file or 
  die "Can't open '$file' for appending, reason: $!\n";

while (<>) {
    last if /^$/;
    print DEST;
}
__END__
-- 
>It's because the universe was programmed in C++.
No, no, it was programmed in Forth.  See Genesis 1:12:
"And the earth brought Forth ..."
- Robert Israel on sci.math, thread "Why numbers?"


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

Date: Tue, 14 Jan 2003 13:24:38 +0100
From: "Frode Bjerkholt" <fb@geo-guide.com>
Subject: IFRAME and Cookies
Message-Id: <QhTU9.13463$Rc7.209427@news2.e.nsc.no>

Hi

I have made a CGI-script in Perl, that is using cookies. The script is
lauched as a IFRAME in a HTML document.
If this HTML document is located on the same server as the CGI-script, it
works fine.......but if the HTML document is located on a different host -
as is my intension - the script never gets any cookies from the browser.
Is there anyway that this can be fixed...or is it this way because of
security reasons?

Regards,

Frode




---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 11.01.03




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

Date: 14 Jan 2003 13:20:48 +0000
From: Brian McCauley <nobull@mail.com>
Subject: Re: IFRAME and Cookies
Message-Id: <u9znq3j2a7.fsf@wcl-l.bham.ac.uk>

"Frode Bjerkholt" <fb@geo-guide.com> writes:

> I have made a CGI-script in Perl, 

What makes you think that the "in Perl" bit is relevant to your
problem?  You have a question about the circumstances under which a
HTTP client will include cookies in an HTTP request.  Do you really
think this will depend on the language you used to write scripts on
the HTTP server?

> that is using cookies. The script is
> lauched as a IFRAME in a HTML document.
> If this HTML document is located on the same server as the CGI-script, it
> works fine.......but if the HTML document is located on a different host -
> as is my intension - the script never gets any cookies from the browser.
> Is there anyway that this can be fixed...

Make sure your cookies are tied to a domain suffix not a specific
host.  This, of course, pre-supposes that the two servers have a
common domain suffix.  (Note: the common suffix must be more than just
a TLD).

> or is it this way because of  security reasons?

Yes the reason cookies are only sent to the owner of the cookie is
security.

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


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

Date: Tue, 14 Jan 2003 14:58:54 +0100
From: "Frode Bjerkholt" <fb@geo-guide.com>
Subject: Re: IFRAME and Cookies
Message-Id: <9FUU9.13502$Rc7.209596@news2.e.nsc.no>

Hi

Thanks for your answer :-)

"Brian McCauley" <nobull@mail.com> wrote in message
news:u9znq3j2a7.fsf@wcl-l.bham.ac.uk...
> "Frode Bjerkholt" <fb@geo-guide.com> writes:
>
> > I have made a CGI-script in Perl,
>
> What makes you think that the "in Perl" bit is relevant to your
> problem?  You have a question about the circumstances under which a
> HTTP client will include cookies in an HTTP request.  Do you really
> think this will depend on the language you used to write scripts on
> the HTTP server?
>

Not really, but I must admit that I find it quite amusing that you actually
commented it :-) Annoying isn't it?

> > that is using cookies. The script is
> > lauched as a IFRAME in a HTML document.
> > If this HTML document is located on the same server as the CGI-script,
it
> > works fine.......but if the HTML document is located on a different
host -
> > as is my intension - the script never gets any cookies from the browser.
> > Is there anyway that this can be fixed...
>
> Make sure your cookies are tied to a domain suffix not a specific
> host.  This, of course, pre-supposes that the two servers have a
> common domain suffix.  (Note: the common suffix must be more than just
> a TLD).

That is a problem. The two servers, do not have a common domain suffix.
So I guess I am stuck then?

Here is some additional information, to help clarify the situation:

The reason for using IFRAME, is that I do not want to have anything do with
content of the web-pages on the other server.
The owners of this remote server should only input the IFRAME tag into one
of their HTML-page and be able to use my CGI-based service without bothering
anything more about it. This remote server belong to a larger domain. The
server running my CGI-based service do not belong to any named domain. It
has only got a static IP-address.

Regards,

Frode

>
> > or is it this way because of  security reasons?
>
> Yes the reason cookies are only sent to the owner of the cookie is
> security.
>
> --
>      \\   ( )
>   .  _\\__[oo
>  .__/  \\ /\@
>  .  l___\\
>   # ll  l\\
>  ###LL  LL\\


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.443 / Virus Database: 248 - Release Date: 11.01.03




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

Date: 14 Jan 2003 12:08:15 GMT
From: anno4000@lublin.zrz.tu-berlin.de (Anno Siegel)
Subject: Re: overriding subroutines
Message-Id: <b00ujf$kml$2@mamenchi.zrz.TU-Berlin.DE>

David S April <april@syclo.com> wrote in comp.lang.perl.misc:
> Hi all - 
> 
> I'm confused over how and when subroutines are parsed.
> If I have 3 files, test1.pl, test2.pl, test3.pl:
> #--------------------------
> #!/usr/bin/perl
> #
> # test1.pl
> 
> sub test() {
> 	print "in test1.pl\n";
> }
> 
> sub test() {
> 	print "in test1.pl v2\n";
> }
> 
> test();
> 
> 1;
> #--------------------------
> #!/usr/bin/perl
> #
> # test2.pl
> 
> sub test() {
> 	print "in test2.pl\n";
> }
> 
> 1;
> #--------------------------
> #!/usr/bin/perl
> #
> # test3.pl
> 
> require "test2.pl";
> 
> sub test() {
> 	print "in test3.pl\n";
> }
> 
> 
> test();
> 
> 1;
> #--------------------------
> and I run test1.pl and test3.pl, the output will be 
> test1.pl - "in test1.pl v2" <-- as expected.
> test3.pl - "in test2.pl"    <-- not expected.
> 
> why doesn't the subroutine in test3.pl override the earlier
> declaration from the "require" statement?

That's a compile time vs runtime issue.

The local test() in test3.pl is defined at compile time, as all sub
declarations are.  "require 'test2.pl'" is executed later at run time,
so it overwrites the local definition.  When you call test(), the
definition from test2.pl is in effect, as the output shows.

If you change "require 'test2.pl'" to "use test2", test2.pl will be
read at compile time and the local definition will be in effect.

Anno


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

Date: 14 Jan 2003 10:14:02 +0100
From: jvromans@squirrel.nl (Johan Vromans)
Subject: Re: Picking out options in argv
Message-Id: <m2n0m4f605.fsf@phoenix.squirrel.nl>

"Harald H.-J. Bongartz" <bongie@gmx.net> writes:

> Getopt::Long and Getopt::Std are part of the standard Perl distribution,
> Getopt::Long at least since 5.6.0.

Make that 5.000. 
In perl 4.xxx it was called "newgetopt.pl".

-- Johan


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

Date: Tue, 14 Jan 2003 12:46:27 -0000
From: "Stuart Moore" <stjm2@cam.ac.uk>
Subject: Re: Regenerating Activeperl html documentation
Message-Id: <b010t2$2p3$1@pegasus.csx.cam.ac.uk>

In news:avvcjb$pk0$1@hpcvsgen.cv.hp.com, Brian Helterline
<brian_helterline@hp.com> declared:
> here's what I've done after manually installing modules from CPAN:

I tweaked your code a bit - it didn't set the css path right (it needs to
take into account the level of the file). $dots now takes care of this



use Pod::Html;
use Config;
use File::Basename;
use File::Spec qw( :ALL );

my $prefix = $Config{prefix};
my ($file, $infile, $htmlfile);

foreach ( @ARGV ) {
 $infile = File::Spec->rel2abs( $_ );
 $file = $infile;
 if ( $file =~ s/^\Q$prefix\E//oi ) {
  $htmlfile = $prefix . "\\html" . $file;
  $htmlfile =~ s/\.[^.]*$/\.html/;
  $dots = $file;
  $dots =~s![\\/][^\\/]+$!!g;
  $dots =~s![\\/][^\\/]+!../!g;
  pod2html(  "--header",
     "--css=${dots}Active.css",
     "--norecurse",
     "--infile=$infile",
     "--outfile=$htmlfile",
     "--verbose"
    );
 }
}

use ActivePerl::DocTools;
print "Building TOC....";
ActivePerl::DocTools::WriteTOC();
print "done.\n\n";




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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

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

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

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


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


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