[22995] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5215 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Jul 11 18:05:50 2003

Date: Fri, 11 Jul 2003 15:05:09 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 11 Jul 2003     Volume: 10 Number: 5215

Today's topics:
        Big hash question <newsreadermail@charter.net>
    Re: Big hash question ctcgag@hotmail.com
        Billing / Invoice scripts? (Butch)
        Check fileage with -M when path contains a point? (Math55)
    Re: Check fileage with -M when path contains a point? <glex_nospam@qwest.net>
        Comparing 2 hashes of array refs (simo)
    Re: Comparing 2 hashes of array refs <skuo@mtwhitney.nsc.com>
    Re: Comparing 2 hashes of array refs <drumspoorly@reachone.net>
        Comparing two files.. <member31962@dbforums.com>
    Re: Comparing two files.. <member31962@dbforums.com>
    Re: Comparing two files.. (Glenn Jackman)
    Re: Comparing two files.. <asu1@c-o-r-n-e-l-l.edu>
    Re: Comparing two files.. (Glenn Jackman)
    Re: compiling Perl code (-bill)
        Is there some reason why warn and die would be very ver (Sara)
        Matts Form Mail help - Redirect & Submit button in body (shane)
    Re: Matts Form Mail help - Redirect & Submit button in  <asu1@c-o-r-n-e-l-l.edu>
    Re: Newbie Perl Question: RE Configuration Files <cingram@pjocsNOSPAMORHAM.demon.co.uk>
    Re: Perl code question <moliverius@w-link.net>
        Perl script not running properly... (abstractjoe)
    Re: Perl script not running properly... <flavell@mail.cern.ch>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 11 Jul 2003 14:17:04 -0500
From: "S. Heiling" <newsreadermail@charter.net>
Subject: Big hash question
Message-Id: <vgu39at0610747@corp.supernews.com>

I have a very large hash inside a script.
The $values of the $keys can be very large.

When the script runs, it takes a long time to load the hash.
And this eats up memory...really fast!
At least I'm assuming that's what it's doing.

My question is, is there a way to stop this?
How can I keep the whole hash from loading at startup?

while ( ($key, $value) = each %hash) {

# This is what I'm using for the hash

}

Thanks.




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

Date: 11 Jul 2003 21:14:53 GMT
From: ctcgag@hotmail.com
Subject: Re: Big hash question
Message-Id: <20030711171453.475$bC@newsreader.com>

"S. Heiling" <newsreadermail@charter.net> wrote:
> I have a very large hash inside a script.
> The $values of the $keys can be very large.
>
> When the script runs, it takes a long time to load the hash.
> And this eats up memory...really fast!
> At least I'm assuming that's what it's doing.

Yep, very large hashes tend to do that.

> My question is, is there a way to stop this?

Tie your hash to a file, or use a database rather than a hash.

> How can I keep the whole hash from loading at startup?

Don't load the whole hash at startup.

>
> while ( ($key, $value) = each %hash) {
>
> # This is what I'm using for the hash
>
> }

If you want us to help you not load the whole hash at start-up,
you should show us the code that loads the hash, not the code that
later iterates over the hash.

However, if this is the only way you ever use the hash, it doesn't
look like you need a hash in the first place.

while (<FH>) {
  chomp;
  my ($key,$value)=split /whatever/;
  # This is what you're doing with the non-hash
};

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service              New Rate! $9.95/Month 50GB


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

Date: 11 Jul 2003 14:38:41 -0700
From: webmaster@2clones.com (Butch)
Subject: Billing / Invoice scripts?
Message-Id: <1921f571.0307111338.7684cdaf@posting.google.com>

I am looking for a script to automate the billing of my web hosting
and development clients.  I've looked at CBMS and WebHost.  Both look
as though they would do the job for me but both are EXTREMLY WEAK in
documentation and since both have plenty of broken links on their
website, I'm not feeling confident in them.

I'd appreciate suggestions for scripts to automate my billing process.


Butch


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

Date: 11 Jul 2003 12:40:09 -0700
From: magelord@t-online.de (Math55)
Subject: Check fileage with -M when path contains a point?
Message-Id: <a2b8188a.0307111140.36604290@posting.google.com>

hi, i have this program. why cant i check the age of a file with -M?

---
use File::Basename;
$path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
#$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";

chdir (dirname($path));
$relFile= (fileparse($path));
$rf.="/".$relFile;

print "\n age of $path = ".(-M $rf). "\n" if (-M $rf <=100 && !(-d
$rf));

---

maybe you have to change to a pth that contains a point at your
system. i tried with absolute and relative path, both did not
work:-(...


THANKS:-)


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

Date: Fri, 11 Jul 2003 16:53:49 -0500
From: "J. Gleixner" <glex_nospam@qwest.net>
Subject: Re: Check fileage with -M when path contains a point?
Message-Id: <3lGPa.38$99.54122@news.uswest.net>

Math55 wrote:
> hi, i have this program. why cant i check the age of a file with -M?
> 
> ---
> use File::Basename;
> $path="/home/raid/golchert/.cxoffice/dotwine/filelist.dat";
> #$path="/home/raid/golchert/Downloads/CD Control QE 1.0.1.12.exe";
> 
> chdir (dirname($path));
> $relFile= (fileparse($path));
> $rf.="/".$relFile;
> 
> print "\n age of $path = ".(-M $rf). "\n" if (-M $rf <=100 && !(-d
> $rf));
> 
> ---
> 
> maybe you have to change to a pth that contains a point at your
> system. i tried with absolute and relative path, both did not
> work:-(...

print the value of $rf and you should see your error.

No need doing a chdir, unless it's needed for something else, a -M $path 
works fine.



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

Date: 11 Jul 2003 09:19:15 -0700
From: simoninusa2001@yahoo.co.uk (simo)
Subject: Comparing 2 hashes of array refs
Message-Id: <30260531.0307110819.34bd8128@posting.google.com>

Hi, I've been working on this for days and don't seem to be getting
very far.

I have a hash of task titles which holds an array of permissions
needed to do those tasks:

my %task = {'gardening' => [1,2,6], 'cleaning' => [3,2,5]}

And then I have an array of permissions that the user has, which I put
into a hash so that the data formats would be similar, although it
might not be helping, basically the permissions array is [1,4] for
this example:

my %permissions = {'gardening' => [1,4], 'cleaning' => [1,4]}

So I basically have to loop through each task, checking to see if I
have permission to do it (if any of 1,4 are included then I have
permission, so it's 1 OR 4, not 1 AND 4).

So it's kinda like comparing each array reference in the task hash
with each element in the permissions array, but I can't do it! :-(

The following is some debugging script I'm using to inspect each
element and compare it, but it's not working. %script_task_hash is the
task hash defined in my script, %file_task_hash is the permissions
hash defined in a CSV file I'm reading in:

    # loop through script task hash - key is task
    foreach $task (keys %script_task_hash) {
    	foreach $sth_array_value (@{$script_task_hash{$task}}) {
    	    print "stask: $task / permission: $sth_array_value \n";
	    
    	    foreach $fth_array_value (@{$file_task_hash{$task}}) {
    	    	print "ftask: $task / permission: $fth_array_value \n";
		if ($fth_array_value ne $sth_array_value) {
		    print "$task cannot be performed \n";
		}
		else {
		    print "$task can be performed \n";
		}
	    }
    	}
    }

I also tried this earlier, but think it's worse than the first one, as
it uses grep which the perldoc/faq says not to do!

    # loop through script task hash - key is task
    foreach $key (keys %script_task_hash) {    
    	# loop through each array of each line in file
	for ($a=0; $a<@{$file_task_hash{$key}}; $a++) {
	
	    foreach (@usertype_array) {
    	    	print "script: $script_task_hash{$key}[$b] / file:
$file_task_hash{$key}[$a] \n";
	
    	    	if (!grep(/^$script_task_hash{$key}[$b]/,
@{$file_task_hash{$key}})) {
		    # remove newlines
	    	    $usertype = $file_task_hash{$key}[$b];
		    $usertype =~ s|\n||gis;
	    	    print "usertype $usertype is needed by $key\n";
	    	} # if
	    } # for 2
	} # for 1
    } # foreach

I'm thinking of going back to simply a permissions array instead of a
hash of the permissions array, as I only made the data that way so it
would match the task hash.

Then I'd have to compare:

    my %task = {'gardening' => [1,2,6], 'cleaning' => [3,2,5]}

with:

    my @permissions = [1,4]

So I'd be able to garden, but not clean.

Can anybody help please?


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

Date: Fri, 11 Jul 2003 10:56:46 -0700
From: Steven Kuo <skuo@mtwhitney.nsc.com>
Subject: Re: Comparing 2 hashes of array refs
Message-Id: <Pine.GSO.4.21.0307111051300.12041-100000@mtwhitney.nsc.com>

On 11 Jul 2003, simo wrote:

> Hi, I've been working on this for days and don't seem to be getting
> very far.
> 
> I have a hash of task titles which holds an array of permissions
> needed to do those tasks:
> 
> my %task = {'gardening' => [1,2,6], 'cleaning' => [3,2,5]}
> 
> And then I have an array of permissions that the user has, which I put
> into a hash so that the data formats would be similar, although it
> might not be helping, basically the permissions array is [1,4] for
> this example:
> 
> my %permissions = {'gardening' => [1,4], 'cleaning' => [1,4]}




It's best to cut and paste from your code, as opposed to retyping.
Hashes are defined by parenthesis, not by curly brackets.  E.g.,

my %permissions = (
    gardening => [1,4], 
    cleaning  => [1,4]
);



> So I basically have to loop through each task, checking to see if I
> have permission to do it (if any of 1,4 are included then I have
> permission, so it's 1 OR 4, not 1 AND 4).
> 
> So it's kinda like comparing each array reference in the task hash
> with each element in the permissions array, but I can't do it! :-(
> 
> The following is some debugging script I'm using to inspect each
> element and compare it, but it's not working. %script_task_hash is the
> task hash defined in my script, %file_task_hash is the permissions
> hash defined in a CSV file I'm reading in:
> 
>     # loop through script task hash - key is task
>     foreach $task (keys %script_task_hash) {
>     	foreach $sth_array_value (@{$script_task_hash{$task}}) {
>     	    print "stask: $task / permission: $sth_array_value \n";
> 	    
>     	    foreach $fth_array_value (@{$file_task_hash{$task}}) {
>     	    	print "ftask: $task / permission: $fth_array_value \n";
> 		if ($fth_array_value ne $sth_array_value) {
> 		    print "$task cannot be performed \n";
> 		}
> 		else {
> 		    print "$task can be performed \n";
> 		}
> 	    }
>     	}
>     }

(snipped)



Your description doesn't match the subject line; I inferred that
you wanted something like this:



use strict;
use warnings;

my %task = (
    gardening => [1,2,6], 
    cleaning  => [3,2,5],
);

my %permissions = (
    gardening => [1,4], 
    cleaning  => [1,4],
);

while (my ($task,$aref) = each %task) {
    my %p = map { $_ => 1 } @{$permissions{$task}};
    if (grep exists $p{$_}, @$aref) {
	print "Can do $task\n";
    } else {
	print "Extnay on $task\n";
    }
}

-- 
Hope this helps,
Steven



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

Date: Fri, 11 Jul 2003 11:17:30 -0700
From: Steve May <drumspoorly@reachone.net>
Subject: Re: Comparing 2 hashes of array refs
Message-Id: <vgtvaem969pf4a@corp.supernews.com>

simo wrote:
> Hi, I've been working on this for days and don't seem to be getting
> very far.
> 
> I have a hash of task titles which holds an array of permissions
> needed to do those tasks:
> 
> my %task = {'gardening' => [1,2,6], 'cleaning' => [3,2,5]}
> 
> And then I have an array of permissions that the user has, which I put
> into a hash so that the data formats would be similar, although it
> might not be helping, basically the permissions array is [1,4] for
> this example:
> 
> my %permissions = {'gardening' => [1,4], 'cleaning' => [1,4]}
> 
> So I basically have to loop through each task, checking to see if I
> have permission to do it (if any of 1,4 are included then I have
> permission, so it's 1 OR 4, not 1 AND 4).
> 
> So it's kinda like comparing each array reference in the task hash
> with each element in the permissions array, but I can't do it! :-(
> 

I know I'm not answering your question directly, but I think you might
consider a different approach.

I use sort of the same concept to control access to my programs, but
use a hash of hashes instead.  Seems a lot cleaner than fiddling with
lists, at least at first glance.

So I have:

%hash = ( module1 => { tool1=>1, tool2=>1, tool3=>1 },
           module2 => { tool1=>1, tool2=>1, tool3=>1 },
         );

A users permission hash might look like:

%hash = { module1 =>{ tool2=>1, tool3=>1 } );

So the user could only access tool2 and tool3 in module1.

Simplified example:

my %hash = &load_permissions( 'user_id' );

my $module = 'module2';
my $tool = 'tool1';

if( $hash{$module}{$tool} ){ &do_work( $module, $tool ); }
else{ &show_default; }


I store the permission hashes for each user in a database and eval them
as needed. (uh... I also do some other things to increase efficiency)

Just a thought.....

s.



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

Date: Fri, 11 Jul 2003 16:52:15 +0000
From: darkname <member31962@dbforums.com>
Subject: Comparing two files..
Message-Id: <3100901.1057942335@dbforums.com>


Hello everyone!

I want to compare two files and get the number of the line where
they match!

Example:

 File1.txt              File2.txt

 a                      dsasadad
 b                      sadd
 b
 dsasadad
 sadd
 sdadas

The result should be:

 Res.txt

 Line 3: dsasadad
 Line 4: sadd

How can i do this??

I made this code but it doesn´t work!


%hash=find();

@keys=sort {$a<=>$b} (keys %hash);

foreach $key (@keys) {
    $value=$hash{$key};
    $hash_order{$key}=$value;
    print "Linha: $key\t$value\n";
}


sub find {

  open(IN,"$file") || die "$!";
  open(F1,"file1") || die "$!";
  @fich=<IN>;
  @fich2=<F1>;
  foreach $line (@fich){
    foreach $line1 (@fich2){
               if($line1=~m/$line/){
                    $res{$i}=$line;
               }
    }
  $i++;
 }

 close(IN);
 close(F1);
 return %res;
}

Can someone tell me why?

Thank you for your help!

--
Posted via http://dbforums.com


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

Date: Fri, 11 Jul 2003 16:54:20 +0000
From: darkname <member31962@dbforums.com>
Subject: Re: Comparing two files..
Message-Id: <3100903.1057942460@dbforums.com>


Hello everyone!

I want to compare two files and get the number of the line where
they match!

Example:

 File1.txt

 a
 b
 b
 dsasadad
 sadd
 sdadas


File2.txt

dsasadad
sadd


The result should be:

 Res.txt

 Line 3: dsasadad
 Line 4: sadd

How can i do this??

I made this code but it doesn´t work!


%hash=find();

@keys=sort {$a<=>$b} (keys %hash);

foreach $key (@keys) {
    $value=$hash{$key};
    $hash_order{$key}=$value;
    print "Linha: $key\t$value\n";
}


sub find {

  open(IN,"$file") || die "$!";
  open(F1,"file1") || die "$!";
  @fich=<IN>;
  @fich2=<F1>;
  foreach $line (@fich){
    foreach $line1 (@fich2){
               if($line1=~m/$line/){
                    $res{$i}=$line;
               }
    }
  $i++;
 }

 close(IN);
 close(F1);
 return %res;
}

Can someone tell me why?

Thank you for your help!

PS. Sorry for the New post.. but the other was unformatted!

--
Posted via http://dbforums.com


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

Date: 11 Jul 2003 18:51:09 GMT
From: xx087@freenet.carleton.ca (Glenn Jackman)
Subject: Re: Comparing two files..
Message-Id: <slrnbgu1os.e98.xx087@freenet10.carleton.ca>

darkname <member31962@dbforums.com> wrote:
> I want to compare two files and get the number of the line where
> they match!
> 
>  File1.txt              File2.txt
>  a                      dsasadad
>  b                      sadd
>  b
>  dsasadad
>  sadd
>  sdadas

    open F2, 'File2.txt' or die $!;
    my @interesting_lines = <F2>;
    close F2;

    open F1, 'File1.txt' or die $!;
    while (defined(my $line = <F1>)) {
        print "$.:\t$line" if grep {$line eq $_} @interesting_lines;
    }
    close F1;


-- 
Glenn Jackman


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

Date: 11 Jul 2003 19:20:04 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Comparing two files..
Message-Id: <Xns93B59BFE71158asu1cornelledu@132.236.56.8>

darkname <member31962@dbforums.com> wrote in news:3100903.1057942460
@dbforums.com:

> I want to compare two files and get the number of the line where
> they match!

That is not exactly what you are trying to do based on the example you 
give below. The example shows that you want to find if lines from the 
second file appear in the first, and if so, where they appear.

>  File1.txt
> 
>  a
>  b
>  b
>  dsasadad
>  sadd
>  sdadas
> 
> 
> File2.txt
> 
> dsasadad
> sadd
> 
> 
> The result should be:
> 
>  Res.txt
> 
>  Line 3: dsasadad
>  Line 4: sadd
> 
> How can i do this??

See end of this message for my attempt.
 
> I made this code but it doesn´t work!

"Doesn't work" is hardly useful. What did you expect and what did you get 
instead?

> sub find {
>   open(IN,"$file") || die "$!";

Where does $file come from?

>   open(F1,"file1") || die "$!";
>   @fich=<IN>;
>   @fich2=<F1>;
>   foreach $line (@fich){
>     foreach $line1 (@fich2){
>                if($line1=~m/$line/){
>                     $res{$i}=$line;
>                }
>     }
>   $i++;
>  }

Maybe I am easily confused but it would help if you declared your 
variables (and initialized $i). In any case, when I replace $file and 
file1 by names of files that exist, and run this script, it produces some 
output. Are you concerned that the line numbers are off by one? Then you 
should initialize $i to equal 1 before the loop. Also what about multiple 
matches?

I am giving my attempt at this primarily because I am a newbie as well, 
and I learn by trying to solve problems others post. 

#! C:/Perl/bin/perl.exe

use strict;
use warnings;

# Given two file names on the command line
# find the lines in the first file that also
# exist in the second file

die "Call with exactly two file names\n" unless $#ARGV == 1;

my %first;

open(FIRST, "< $ARGV[0]") 
  || die "Cannot open $ARGV[0] for reading: $!\n";

while(<FIRST>) {
   chomp;
   if(exists $first{$_}) {
      $first{$_} .= ",$.";
   } else {
      $first{$_} = $.;
   }
}
close(FIRST);

open(SECOND, "< $ARGV[1]") 
  || die "Cannot open $ARGV[1] for reading: $!\n";

while(<SECOND>) {
   chomp;
   if(exists $first{$_}) {
      print "\"$_\" from $ARGV[1] matches line(s) $first{$_} in $ARGV[0]
\n");
   }
}
close(SECOND);

Using the following files:

--- first ---
1
a2bz
2
3
zxsds
3
3
4
as
5
6
6
6
sinan
1
2
3
4
9
--- end: first ---

--- second ---
2
5
sinan
7
9
--- end: second ---

It produces the following output.

C:\src\misc>findlines.pl first second
"2" from second matches line(s) 3,16 in first
"5" from second matches line(s) 10 in first
"sinan" from second matches line(s) 14 in first
"9" from second matches line(s) 19 in first

I hope this helps you somewhat and is not extremely bad code.

OTOH, I have a question of my own. Consider the following lines:

if(exists $first{$_}) {
   $first{$_} .= ",$.";
} else {
   $first{$_} = $.;
}

I originally intended to store an array of line numbers for each line in 
the file, and tried various syntax combinations. Could someone give me a 
hint as to how to do it?

Sinan.

-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: 11 Jul 2003 21:38:18 GMT
From: xx087@freenet.carleton.ca (Glenn Jackman)
Subject: Re: Comparing two files..
Message-Id: <slrnbgubia.e98.xx087@freenet10.carleton.ca>

A. Sinan Unur <asu1@c-o-r-n-e-l-l.edu> wrote:
> if(exists $first{$_}) {
>    $first{$_} .= ",$.";
> } else {
>    $first{$_} = $.;
> }
> 
> I originally intended to store an array of line numbers for each line in 
> the file, and tried various syntax combinations. Could someone give me a 
> hint as to how to do it?

In place of the above code, I would write:  push @{$first{$_}}, $.  
$first{$_} then contains a reference to an array of line numbers.

-- 
Glenn Jackman
NCF Sysadmin
glennj@ncf.ca


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

Date: 11 Jul 2003 09:44:18 -0700
From: i_ching@yahoo.com (-bill)
Subject: Re: compiling Perl code
Message-Id: <1b0363da.0307110844.7bcabe0d@posting.google.com>

Bart Lateur <bart.lateur@pandora.be> wrote in message news:<o9bsgvs37gk4995jrevsn456badns7252g@4ax.com>...
> -bill wrote:
> 
> >I know little about Perl, so I ask the following question. when you
> >compile Perl code, can a PDB(symbols file) be created the way you can
> >within MSVS IDE for VB, C/C++ ?
> 
> "Compile"? Eh...
> 
> Anyway, look at the module B::Xref. You invoke it as 
> 
> 	perl -MO=Xref yourscript.pl
> 
> optionally with options separated with commas, like
> 
> 	perl -MO=Xref,-r,-oXref.out.txt  yourscript.pl
> 
> See B::Xref for the docs.


hey Bart,
thanx for the info. Not sure if I get it....in a simple explanation ,
can PDB's be created where I can use the symbols files to help me
debug a program?


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

Date: 11 Jul 2003 08:10:17 -0700
From: genericax@hotmail.com (Sara)
Subject: Is there some reason why warn and die would be very very slow?
Message-Id: <776e0325.0307110710.36f3d74d@posting.google.com>

I have some not-unusual warn and die statements in my perlcode. Im
using 5.8 on a linux RH8 box. The code runs fine, and even the warn
and die statements work (eventually). In the debugger, when I step
past the warn or die line, it takes from 15-30 seconds to actually
warn or die- in the meantime it just sits there thinking about that
one line. The rest of the code is blazing fast; the box is unloaded.

Here is a typical line:

 warn "No CCX is defined in for ($ma)\n" unless defined $CCx{$ma};

Is there something peculiar about warn or die that would make them run
at this decellerated pace?

Thank-You in advance for your time and advice.

-Gx (wishing I was at OPEN SOURCE this week GRRRRRR)


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

Date: 11 Jul 2003 12:45:57 -0700
From: seherrell@yahoo.com (shane)
Subject: Matts Form Mail help - Redirect & Submit button in body of email
Message-Id: <3a6a0c09.0307111145.6e19e97b@posting.google.com>

I am redirecting the person to a confirmation page and sending the
results to an email address. The problem is the redirect string and
the Submit button show up in the body of the email. What am I doing
wrong. Below is the script.

I changed the actual site name and email address change to protect
their identity.

<form action="http://www.myurlhere.com/cgi-sys/FormMail.cgi"
method=post
<input type=hidden name=recipient value="info@myurlhere.com">
<input type=hidden name="subject" value="Course Registration"> 
<input type=hidden name="redirect"
value="http://www.myurlhere.com/form_confirmation.htm">
<input type="text" name="Email" size="20" tabindex="7">  
<p align="center"><input type="submit" value="Submit" name="Submit" 
<input type="reset" value="Reset" name="B2"></form>


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

Date: 11 Jul 2003 19:52:42 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Matts Form Mail help - Redirect & Submit button in body of email
Message-Id: <Xns93B5A1872D560asu1cornelledu@132.236.56.8>

seherrell@yahoo.com (shane) wrote in 
news:3a6a0c09.0307111145.6e19e97b@posting.google.com:

> I am redirecting the person to a confirmation page and sending the
> results to an email address. The problem is the redirect string and
> the Submit button show up in the body of the email. What am I doing
> wrong. Below is the script.
 ... 
> <form action="http://www.myurlhere.com/cgi-sys/FormMail.cgi"
> method=post

add a ">" at the end of this line and try again.
name="B2"></form>



-- 
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov


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

Date: Fri, 11 Jul 2003 16:49:02 +0100
From: "Clyde Ingram" <cingram@pjocsNOSPAMORHAM.demon.co.uk>
Subject: Re: Newbie Perl Question: RE Configuration Files
Message-Id: <bemm7j$q2o$1$8302bc10@news.demon.co.uk>

Thens,

>     The intelligent ones will use the Config::General or Config::Simple
> and save themselves of all the trouble of parsing config files..

Interesting - Config::General looks particularly good for complex data..

> But if
> your application does not require complex constructs like nested
> information or record like data then you are better off using simple
> perl files that you can just 'do' or require in your file.

Going one step further, you can "rdo" or "reval" files in a sandbox, to
contain any threat of corruption, using Safe.pm, IIRC.




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

Date: Fri, 11 Jul 2003 08:47:08 -0400
From: Matt Oliverius <moliverius@w-link.net>
Subject: Re: Perl code question
Message-Id: <vgtm3rm8eo4710@corp.supernews.com>

Sorry about the confusion in my previous post.  Hopefully this clears it up 
a little better.  When I said that this is the structure of my input file, 
I was referring to the manner in which it is delimited and the naming 
conventions that are used for compartments.  That was my interpretation of 
structure.  In other words, this is the manner in which I receive data, and 
I can't change the way it is structured to accomodate an easier way to 
parse it.  It isn't exactly an example of my input file because my input 
file is too large to post on the newsgroup.  However, I apologize for not 
clarifying this.

Here is the data.  You are correct that there are nine distinct values in 
column 2.  However, each compartment can have either 1 Full, or 2 Halfs. 
(See below data for the 4 permutations). A half combined with a full is not 
allowed, neither is a compartment with only 1 half, or a completely empty 
compartment.


ID    COMPT  SIZE    X           Y        Z
A5    613    Full    2100.00     53.00    200.00
A5    613    Full    2110.00     56.00    200.50
A5    613    Full    2113.00     58.00    201.00
A5    613    Full    2114.00     60.00    202.00
A5    613F   Half    2100.00     61.00    205.00
A5    613F   Half    2110.00     63.00    201.00
A5    613F   Half    2130.00     68.00    205.00
A5    613F   Half    2140.00     62.00    201.00
A5    613A   Half    2120.00     61.00    205.00
A5    613A   Half    2130.00     63.00    201.00
A5    613A   Half    2140.00     68.00    205.00
A5    613A   Half    2150.00     62.00    201.00
A5    614    Full    2100.00     53.00    200.00
A5    614    Full    2110.00     56.00    200.50
A5    614    Full    2113.00     58.00    201.00
A5    614    Full    2114.00     60.00    202.00
A5    614F   Half    2100.00     61.00    205.00
A5    614F   Half    2110.00     63.00    201.00
A5    614F   Half    2130.00     68.00    205.00
A5    614F   Half    2140.00     62.00    201.00
A5    614A   Half    2120.00     61.00    205.00
A5    614A   Half    2130.00     63.00    201.00
A5    614A   Half    2140.00     68.00    205.00
A5    614A   Half    2150.00     62.00    201.00
A5    615    Full    2100.00     53.00    200.00
A5    615    Full    2110.00     56.00    200.50
A5    615    Full    2113.00     58.00    201.00
A5    615    Full    2114.00     60.00    202.00
A5    616    Full    2100.00     53.00    200.00
A5    616    Full    2110.00     56.00    200.50
A5    616    Full    2113.00     58.00    201.00
A5    616    Full    2114.00     60.00    202.00
A5    617    Full    2100.00     53.00    200.00
A5    617    Full    2110.00     56.00    200.50
A5    617    Full    2113.00     58.00    201.00
A5    617    Full    2114.00     60.00    202.00



The 4 possibilities I want to extract are below.  However, I want the 
entire line, not just the COMPT.  


COMPT
-------------------------------
613
614
615            Possibility #1 (All full)
616
617
-------------------------------
613F
613A
614
615            Possibility #2 (All full except 2 halfs in 613)
616
617
--------------------------------
613
614F
614A
615            Possibility #3 (All full except 2 halfs in 614)
616
617
--------------------------------
613F
613A
614F
614A
615            Possibility #4 (All full except 2 halfs in 613 and 614)
616
617
--------------------------------



I want the output to look like below.   

-------------------------------------------------
Permutation 1:

A5    613    Full    2100.00     53.00    200.00
A5    613    Full    2110.00     56.00    200.50
A5    613    Full    2113.00     58.00    201.00
A5    613    Full    2114.00     60.00    202.00
A5    614    Full    2100.00     53.00    200.00
A5    614    Full    2110.00     56.00    200.50
A5    614    Full    2113.00     58.00    201.00
A5    614    Full    2114.00     60.00    202.00
A5    615    Full    2100.00     53.00    200.00
A5    615    Full    2110.00     56.00    200.50
A5    615    Full    2113.00     58.00    201.00
A5    615    Full    2114.00     60.00    202.00
A5    616    Full    2100.00     53.00    200.00
A5    616    Full    2110.00     56.00    200.50
A5    616    Full    2113.00     58.00    201.00
A5    616    Full    2114.00     60.00    202.00
A5    617    Full    2100.00     53.00    200.00
A5    617    Full    2110.00     56.00    200.50
A5    617    Full    2113.00     58.00    201.00
A5    617    Full    2114.00     60.00    202.00
-------------------------------------------------
Permutation 2
A5    613F   Half    2100.00     61.00    205.00
A5    613F   Half    2110.00     63.00    201.00
A5    613F   Half    2130.00     68.00    205.00
A5    613F   Half    2140.00     62.00    201.00
A5    613A   Half    2120.00     61.00    205.00
A5    613A   Half    2130.00     63.00    201.00
A5    613A   Half    2140.00     68.00    205.00
A5    613A   Half    2150.00     62.00    201.00
A5    614    Full    2100.00     53.00    200.00
A5    614    Full    2110.00     56.00    200.50
A5    614    Full    2113.00     58.00    201.00
A5    614    Full    2114.00     60.00    202.00
A5    615    Full    2100.00     53.00    200.00
A5    615    Full    2110.00     56.00    200.50
A5    615    Full    2113.00     58.00    201.00
A5    615    Full    2114.00     60.00    202.00
A5    616    Full    2100.00     53.00    200.00
A5    616    Full    2110.00     56.00    200.50
A5    616    Full    2113.00     58.00    201.00
A5    616    Full    2114.00     60.00    202.00
A5    617    Full    2100.00     53.00    200.00
A5    617    Full    2110.00     56.00    200.50
A5    617    Full    2113.00     58.00    201.00
A5    617    Full    2114.00     60.00    202.00
-------------------------------------------------
Permutation 3
 .
 .
 .
-------------------------------------------------
Permutation 4
 .
 .
 .
--------------------------------------------------

Eric J. Roode wrote:

> -----BEGIN xxx SIGNED MESSAGE-----
> Hash: SHA1
> 
> Matt Oliverius <moliverius@w-link.net> wrote in
> news:vgsl80mu09koae@corp.supernews.com:
> 
>> Hi all,
>> 
>> I'm trying to do something which I believe is quite complex, and I'm
>> hoping someone here might not find it so complex.  The problem
>> involves permutations.  Here is the structure of my input file
> 
> Structure?  No, that's an *example* of your input file.  What's missing
> is descriptions of the columns and what they might hold.
> 
> ...
> 
>> Basically, you can think of the second column as a compartment.  There
>> are 5 compartments total.
> 
> But you have nine distict values listed in column two. ???!
> 
>>  Sometimes one or more of these compartments
>> can be used to store a half size box, so I basically want to permutate
>> every possible combination.  If all compartments used had a full box
>> or alternate half box configuration then there would be 2^5
>> permutations because each compartment either stores one full size box
>> or 2 half size boxes.  In the above example, there are four
>> possibilities since 613 has either full, or half and 614 has either
>> full or half and 615-617 only have full.
> 
> Four....?  I may be dense... that sounds like seven possibilities.
> 
>>  I need to print each
>> permutation along with all the data in columns 0-5 in an ascii file.
>> Does anyone have any easy way of doing this?  I have beat my head on
>> this one for hours.
> 
> How exactly do you want to summarize or group the data in columns 0-5 for
> the permutations?
> 
> - --
> Eric
> $_ =  reverse sort qw p ekca lre Js reh ts
> p, $/.r, map $_.$", qw e p h tona e; print
> 
> -----BEGIN xxx SIGNATURE-----
> Version: PGPfreeware 7.0.3 for non-commercial use <http://www.pgp.com>
> 
> iQA/AwUBPw6PtGPeouIeTNHoEQLzagCffW6N3F4o4WE59CwSoN5kf3xzLFsAoNgj
> /8jMhHKsxTZNsDDdCBvbbAOt
> =NU4u
> -----END PGP SIGNATURE-----



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

Date: 11 Jul 2003 11:18:43 -0700
From: abstract_joe@yahoo.com (abstractjoe)
Subject: Perl script not running properly...
Message-Id: <824524f6.0307111018.8283e26@posting.google.com>

Hi, 

I wrote a CGI script in Perl(see below) and when I execute ./ in Unix
console it works just fine. However, when I use it in an html page it
doesn't work.

Below is the form tag within my html page.

<form name="the_script" method="POST"
action="http://www.mydomain.com/cgi-bin/the_script.cgi">
<input type="submit" value="the_script">

So, when I hit submit it takes me to the redirect, however when I
check the files to see if they are replaced, nothing...

If I just run the script in Unix via ./ the files are replaced...
weird.

Below is the CGI script:

#! /usr/bin/perl
use File::Find;
use File::Copy;
use File::Path;

my $top_src = "/usr/local/whatever";
my $dest = "/usr/local/htdocs/whatever";

find sub {
  ##might need it for later on
  ##ignore non html files
  return unless -f ;

  my $more_subdir;
  for ( $more_subdir = $File::Find::dir) {
    s#^\Q$top_src##;
    s#^/##;
  }

  ## don't copy if we already have a later file
  if (-e "$dest/$more_subdir/$_" and -M "$dest/$more_subdir/$_" <= -M
$_) {
    ## tracing: turn off when you're happy
    warn "ignoring older $File::Find::name\n";
    return;
  }

  mkpath( ["$dest/$more_subdir"], 0, 0711);  # $dest must be an
absolute

  ## tracing: turn off when you're happy
  $content = warn "copying $File::Find::name to
$dest/$more_subdir/$_\n";
  copy $_, "$dest/$more_subdir/$_";
}, $top_src;

$url = "http://www.mydomain.com/redirect.html";
print "Location: $url\n\n";
exit;


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

Date: Fri, 11 Jul 2003 20:58:16 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: Re: Perl script not running properly...
Message-Id: <Pine.LNX.4.53.0307112034001.20513@lxplus102.cern.ch>

On Fri, Jul 11, abstractjoe inscribed on the eternal scroll:

> I wrote a CGI script in Perl(see below) and when I execute ./ in Unix
> console it works just fine. However, when I use it in an html page it
> doesn't work.

If you'd ask Perl to help you, it might tell you what's wrong.

> If I just run the script in Unix via ./ the files are replaced...
> weird.

Well, hardly.  That's an FAQ, isn't it?

http://www.google.com/search?q=%22My+CGI+script+runs+from+the+command+line+but%22

http://www.perldoc.com/perl5.8.0/pod/perlfaq9.html second bullet.

> Below is the CGI script:
>
> #! /usr/bin/perl
> use File::Find;

[...]

No signs of warnings or strict.  You earn the right to be justly
ignored here (see the group's posting guidelines).

>   mkpath( ["$dest/$more_subdir"], 0, 0711);  # $dest must be an absolute

I don't see any code which implements that comment!

Does the web server have the rights to execute that line?

Wouldn't it be wise to test its success before proceeding?

You may also find "Troubleshooting Perl CGI scripts" by brian d foy
to be of benefit.  At the moment its memorable URLs seem to have died,
Google finds it deep in Sourceforge CVS, but it's there.

CGI scripts generally also tend to take data from untrusted sources,
so it might not be such a bad idea to consider -T as a useful security
catcher.



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

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


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