how to search for intervals in multiple columns?

2004-10-28 Thread Martin A. Hansen
hi

i have a dataset consisting of an array of arrays.

$data = [
[q_beg1, q_end1, s_beg1, s_end1]
[q_beg2, q_end2, s_beg2, s_end2]
[q_beg3, q_end3, s_beg3, s_end3]
...
]

q_beg, q_end, s_beg, s_end are all integers.


now, i would like to find all rows where q_beg and q_end are within one
interval (int1_beg, int1_end) while s_beg and s_end are within another
interval (int2_beg, int2_end).

this can be done with grep:

grep {$_-[0]  int1_beg and $_-[1]  int1_end and
  $_-[2]  int2_beg and $_-[3]  int2_end} @$data;


however, this is too slow for my purpose. so how to speed up such
selection?

the query would be simple enough in a relational database, however i
want to avoid using a database using tables on disk.

i should think this was a pretty generic problem.


ideas are most welcome !


best regards


martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




can system() interrupt perl at runtime?

2003-08-14 Thread Martin A. Hansen
Hi

Is there a way to make an exception from an external program run with 

system( program, arg1, arg2, .. );

trigger a perl exception? that is, without explicitly checking $!, $? or $@
after every call ?


Martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how do i list the methods connected to a object?

2003-08-14 Thread Martin A. Hansen
On Wed, Aug 06, 2003 at 10:24:09PM +0100, Rob Dixon wrote:
 
 Martin A. Hansen [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
  On Tue, Aug 05, 2003 at 08:18:24PM +0100, Rob Dixon wrote:
  
   Ovid [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
--- Peter Scott [EMAIL PROTECTED] wrote:
 The problem here is that it will not print inherited or AUTOLOADed methods.
 [snip]

 So traverse the inheritance hierarchy and do the same thing with each class:

 http://search.cpan.org/author/SBURKE/Class-ISA-0.32/ISA.pm
   
That's certainly a decent 95% solution and if you *really*
need it, it's a good idea.  The original problem, though,
is not one that I want to encourage most people to solve
because for most programmers, when things get that complicated,
it turns out that there's an underlying design flaw that needs
to be addressed.
   
Of course, people seem to get mad when I say that :)
  
   I'll second that. Absolutely.
  
   If you've created an object and are asking, 'Now what can I do
   with this object?' then you're not designing software, you're
   laying bricks. Find a module that, from the documentation,
   looks like it will do what you want. Then commit to using that
   module with the documented interface alone. After that, if
   you find you've made the wrong decision, be prepared to backtrack
   as far as necessary to redeem yourself.
 
  first of all. objects and modules are for software reuse as i understand it. so
  installing and using modules from CPAN leaves me as a bricklayer!
 
 Being a bricklayer is a fine thing. But I thought this group was
 for beginner Perl programmers? If you take your module, poke it
 around a little, and say 'I wonder what this will do if...' then
 you will probably end up with Carhenge. Read the Owners' Manual
 and you'll find that you could have driven countless times to visit
 the magnificent results of a bricklayer at work across the country.
 
hah! so this is the sad story of OO perl. i have been warned off OO perl
repeatedly, but using Bio:: (which i believe is as extensive as Net:: and
HTTP::) is a major source of software reuse, especially because Bio:: stuff has
a lot of parsers of text flatfiles that keep altering format.

i was really hoping that someone more clever than i, had this problem solved
...

:oP

martin

 Cheers,
 
 Rob
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how do i list the methods connected to a object?

2003-08-14 Thread Martin A. Hansen
aargh :o) i was hoping there was a simple answer to this. the object im
investigating do apparantly inherets stuff :/

im not into OO perl at all, and i guess this is the reason why.

ok, so the problem is rather complex, but thats just another perl problem then.
and this one must have been solved by others. i have been looking at the
Class::Inspector module on CPAN, which can track the inheritance i think.

ill add my code snippet here to elaborate on the specific problem. and attach a
test file for the parser.

the problem is that the objects $hit and $hsp gives access to a lot of usefull
functions, but what are they???



#!/usr/bin/perl -w

use strict;
use Data::Dumper;
use Bio::SearchIO;

my ( $script, $usage, @files, $file );

my ( $searchio, $result, $blast_report, $algorithm_type, $hit, $hit_name, $hsp, 
$bit_score,
 $query_beg, $query_end, $query_name, $subject_beg, $subject_end, $strand, $eval, 
$frame );

$script = ( split /, $0 )[ -1 ];

$usage = qq(
$script by Martin A. Hansen, July 2003.

$script parses blast repport files and writes GFF to STDOUT

Usage: $script blast blast blast
blast - blast report files

);

print $usage and exit if not @ARGV;

@files = @ARGV;

foreach $file ( @files )
{
$searchio   = new Bio::SearchIO ( -format = 'blast', -file = $file );
$result = $searchio-next_result;
$query_name = $result-query_name;

$result-database_name;
$algorithm_type = $result-algorithm;

while ( $hit = $result-next_hit )
{
$hit_name= $hit-name;
$hsp = $hit-next_hsp;

$eval= $hsp-evalue;
$bit_score   = $hsp-bits;
$strand  = $hsp-strand( subject );
$frame   = $hsp-frame;
$query_beg   = $hsp-query-start;
$query_end   = $hsp-query-end;
$subject_beg = $hsp-subject-start;
$subject_end = $hsp-subject-end;

if ( $strand eq 1 ) {
$strand = +;
} elsif ( $strand eq -1 ) {
$strand = -;
} else {
$strand = .;
}

print join( \t,
$hit_name,
$algorithm_type,
similarity,
$subject_beg,
$subject_end,
$bit_score,
$strand,
$frame,
Target \$query_name\ $query_beg $query_end ; E_value $eval
  );

print \n;
}
}



On Tue, Aug 05, 2003 at 05:48:04AM -0700, Ovid wrote:
 --- Martin A. Hansen [EMAIL PROTECTED] wrote:
  hi
  
  i wonder how i can list all the methods availible from a given object?
  
  martin
 
 Hi Martin,
 
 The simple answer:  You can't.  Welcome to Perl.
 
 The long answer:  there are a variety of strategies you can use to try and figure 
 this out, but
 all of them fall short.  For example, here's a snippet that prints out defined 
 subroutines (or
 methods) in a given package:
 
   {
 no strict 'refs';
 my $namespace = sprintf %s::, $CLASS;
 foreach (keys %{$namespace}) {
   my $test_sub = sprintf %s%s, $namespace, $_;
   print $test_sub\n unless defined $test_sub;
 }
   }
 
 The problem here is that it will not print inherited or AUTOLOADed methods.  It 
 might be
 sufficient for your needs now, but it's fragile.  You can also test whether or not a 
 particular
 method *is* implemented:
 
   if ($object-can('method_name_to_test')) {
 # this works if $object can have methods called on it.  It will find
 # inherited methods.  It can also find AUTOLOADed methods if they've
 # already been called and installed in the symbol table
   }
 
 A slightly more robust version of that syntax:
 
   if (UNIVERSAL::can($object, $method_name) {
 # almost the same thing, but doesn't die a horrible death if, for example,
 # $object is undef
   }
 
 If you explain the problem you're trying to solve, we might be able to come up with 
 a better
 solution.
 
 Cheers,
 Ovid
 
 =
 Silence is Evil
 http://users.easystreet.com/ovid/philosophy/indexdecency.htm
 Ovid   http://www.perlmonks.org/index.pl?node_id=17000
 Web Programming with Perl  http://users.easystreet.com/ovid/cgi_course/
 
 __
 Do you Yahoo!?
 Yahoo! SiteBuilder - Free, easy-to-use web site design software
 http://sitebuilder.yahoo.com
BLASTN 2.2.5 [Nov-16-2002]


Reference: Altschul, Stephen F., Thomas L. Madden, Alejandro A. Schaffer, 
Jinghui Zhang, Zheng Zhang, Webb Miller, and David J. Lipman (1997), 
Gapped BLAST and PSI-BLAST: a new generation of protein database search
programs,  Nucleic Acids Res. 25:3389-3402.

Query= mt0001-av25gc10k167_AV25_01
 (110 letters)

Database: gbgene 
   2,966,325 sequences; 8,818,290,589 total letters

Searching

SOLVED: how do i list the methods connected to a object?

2003-08-14 Thread Martin A. Hansen
problem solved:

given an arbitrary object, i can now get a dump of all the functions connected to the 
object.

print dump_functions( $obj );

sub dump_functions
{
use Data::Dumper;
use Class::Inspector;

my ( $obj ) = @_;

my ( $ref, $methods, @methods );

$ref = ref $obj;
$methods = Class::Inspector-methods( $ref, 'full', 'public' );

@{ $methods } = grep /$ref/, @{ $methods };

return Dumper( $methods );
}



On Tue, Aug 05, 2003 at 12:19:57PM +0200, Martin A. Hansen wrote:
 hi
 
 i wonder how i can list all the methods availible from a given object?
 
 martin
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



how do i list the methods connected to a object?

2003-08-14 Thread Martin A. Hansen
hi

i wonder how i can list all the methods availible from a given object?

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: SOLVED: how do i list the methods connected to a object?

2003-08-11 Thread Martin A. Hansen
On Thu, Aug 07, 2003 at 09:01:57AM -0500, Dan Muey wrote:
 
 Cool! 1 quick question why do you have @methods?

sorry old remnant. just delete.

martin

 If it's because you use @{ $methods } then $methods would have to be the string 
 'methods' to be a reference to @methods, which doesn't have any data as far as I can 
 tell.
 
 Maybe I'm missing something?
 
 Dan
 
  problem solved:
  
  given an arbitrary object, i can now get a dump of all the 
  functions connected to the object.
  
  print dump_functions( $obj );
  
  sub dump_functions
  {
  use Data::Dumper;
  use Class::Inspector;
  
  my ( $obj ) = @_;
  
  my ( $ref, $methods, @methods );
  
  $ref = ref $obj;
  $methods = Class::Inspector-methods( $ref, 'full', 'public' );
  
  @{ $methods } = grep /$ref/, @{ $methods };
  
  return Dumper( $methods );
  }
  
  
  
  On Tue, Aug 05, 2003 at 12:19:57PM +0200, Martin A. Hansen wrote:
   hi
   
   i wonder how i can list all the methods availible from a 
  given object?
   
   martin
   
   --
   To unsubscribe, e-mail: [EMAIL PROTECTED]
   For additional commands, e-mail: [EMAIL PROTECTED]
  
  -- 
  To unsubscribe, e-mail: [EMAIL PROTECTED]
  For additional commands, e-mail: [EMAIL PROTECTED]
  
  
 
 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: how do i list the methods connected to a object?

2003-08-06 Thread Martin A. Hansen
On Tue, Aug 05, 2003 at 08:18:24PM +0100, Rob Dixon wrote:
 
 Ovid [EMAIL PROTECTED] wrote in message news:[EMAIL PROTECTED]
  --- Peter Scott [EMAIL PROTECTED] wrote:
   The problem here is that it will not print inherited or AUTOLOADed methods.
   [snip]
  
   So traverse the inheritance hierarchy and do the same thing with each class:
  
   http://search.cpan.org/author/SBURKE/Class-ISA-0.32/ISA.pm
 
  That's certainly a decent 95% solution and if you *really*
  need it, it's a good idea.  The original problem, though,
  is not one that I want to encourage most people to solve
  because for most programmers, when things get that complicated,
  it turns out that there's an underlying design flaw that needs
  to be addressed.
 
  Of course, people seem to get mad when I say that :)
 
 I'll second that. Absolutely.
 
 If you've created an object and are asking, 'Now what can I do
 with this object?' then you're not designing software, you're
 laying bricks. Find a module that, from the documentation,
 looks like it will do what you want. Then commit to using that
 module with the documented interface alone. After that, if
 you find you've made the wrong decision, be prepared to backtrack
 as far as necessary to redeem yourself.

first of all. objects and modules are for software reuse as i understand it. so
installing and using modules from CPAN leaves me as a bricklayer! so i have
found a module which is fulfilling my needs, but i find it very annoying that i
cannot simple dump all the functions connected to a certain object. now im
advised to read the module documentation (which can be poor) of this object,
AND the module documentation of ALL inherited objects! i find it rediculous to
go the documentation path, where you clearly should be able to understand the
code based on the code itself! i am aware that OO perl is about abstraction of
the code, but this is no good.

but enough nagging. even if this is a tricky problem, cant it be solved? if
using the ISA.pm as suggested, you are able to track the inheritance solving
95% of the problem, then what is the remaining 5% ?

i guess i wish for a widget to go

print DumpFunctions( $obj );

does it exist?

martin

 
 Software built on what a module /can/ do instead of what it's
 /supposed/ to do isn't a useful thing in any way.
 
 Rob
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



how to: perl and gnuplot ???

2003-01-15 Thread Martin A. Hansen
hi

i have script which generates a set of xy coordinates.

how can i get the script to generate a gnuplot postscript file from theses
xy-pairs?

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




pipe in perl ???

2003-01-15 Thread Martin A. Hansen
hi


how to use an array as input for a external command called within a perl script?

im looking to pipe the array to the extarnal program ...


martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread Martin A. Hansen
On Wed, Jan 15, 2003 at 05:34:59AM -0800, John W. Krahn wrote:
 Martin A. Hansen wrote:
  
  hi
 
 Hello,


hi again


 
  how to use an array as input for a external command called within a perl script?
  
  im looking to pipe the array to the extarnal program ...
 
 open PIPE, '| somecommand' or die Cannot open pipe to somecommand: $!;
 
 print PIPE @array;
 
 close PIPE or die Cannot close pipe to somecommand: $!;
 

i figured that much, but that is not the way to solve my gnuplot problem. i
need to translate the following commandline to perl:

(echo set term post; echo plot '-' w l; cat data) | gnuplot  data.ps

where cat data is replaced by a pipe of some sort ...

gnuplot is tricky because the plot '-' part means that the data is supplied
followingly


gnuplot is wierd, but i hope perl can unwierd it


martin
 
 
 John
 -- 
 use Perl;
 program
 fulfillment
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread Martin A. Hansen
On Wed, Jan 15, 2003 at 08:27:13AM -0600, [EMAIL PROTECTED] wrote:
 Sorry if I already missed a post where you said you couldn't (have had the flu), but 
could you use one of the various modules in CPAN to control gnuplot instead of trying 
to manipulate it yourself?
 

hi

i did look at it, but i found it confusing. anyhows, i need to learn perl and
redirecting output is good to know.


martin


 A quick search:
 http://search.cpan.org/search?query=Gnuplotmode=all
 http://search.cpan.org/author/CAIDAPERL/Chart-Graph-2.0/Graph/Gnuplot.pm
 http://search.cpan.org/author/ILYAZ/Term-Gnuplot-0.5704/Gnuplot.pm
 
 Just a thought.
 
 http://danconia.org

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: pipe in perl ???

2003-01-15 Thread Martin A. Hansen
On Wed, Jan 15, 2003 at 10:33:45AM -0500, Bob Showalter wrote:
 Bob Showalter wrote:
  [EMAIL PROTECTED] wrote:
   i need to translate the following commandline to perl:
   
   (echo set term post; echo plot '-' w l; cat data) | gnuplot 
   data.ps
  
 open(F, | gnuplot data.ps) or die $!;
 print F set term post\n, plot '-' w l\n;
 print $_\n for @commands;
 
 Oops, forgot the filehandle. That should be
 
  print F $_\n for @commands;
 

perfect! i got the same syntax working just before reading this :)))

thanx

martin


 close F or die $!;

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




how to recognize a number with regex?

2002-09-18 Thread Martin A. Hansen

hi


what do a regex look like that only matches numbers of the format

(the length of the number doesnt matter its the . thats the problem)

1233.1234

or 

1234



martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




how to split a perl program on multiple files?

2002-07-16 Thread Martin A. Hansen

for the sake of order and logic, i want to split my perl script into two files.

what is the smart way to do this? i guess there is many ways this can be done,
lemmy hear them all !

:o)

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: help! windows makes ^M in my forms?

2002-05-28 Thread Martin A. Hansen

hi drieux

i had a look on you snippet of code. very neat, i didnt know =cut :))). however, im 
not happy with the regexing solution, since i cant get it to work:

$scalar =~ s/\015\012?|\012/\n/g;

what is this ^M anywat? carrige return?

reading the perldoc -f chomp doesnt tell me if chomp deals with ^M ?

actually im interested in how eval deals with ^M, since i suspect my problems is a 
misinterpretation by eval with regards to  ^M...

anyway im not sure if i can chomp incomming stuff from a CGI submit ?


any help will be appreciated

:0)

martin

On Mon, May 27, 2002 at 08:17:30AM -0700, drieux wrote:
 
 On Monday, May 27, 2002, at 07:31 , Martin A. Hansen wrote:
 
 
 my nice cgi forms works beautiful under konq on linux. but the windows 
 machine generates ^M at the and of lines? this makes eval go fubar? how 
 can i prevent this???
 
 http://www.wetware.com/drieux/pbl/RegEx/eolOut.txt
 
 may help you get the differences in chomp v. RegExing them to
 a common standard. Remember that the browsers will do as
 they will do - and you have to work around that reality
 
 ciao
 drieux
 
 ---

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




help! windows makes ^M in my forms?

2002-05-27 Thread Martin A. Hansen


my nice cgi forms works beautiful under konq on linux. but the windows machine 
generates ^M at the and of lines? this makes eval go fubar? how can i prevent this???


martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




printing from records ?

2002-05-06 Thread Martin A. Hansen

hi

im able to generate records of this kind:


{
  'bleh' = {
  'ISHpix' = [],
  'gelpix' = [],
  'base' = [
  ''
],
  'norm' = [
  ''
],
  'drug' = [
  ''
],
  'organism' = [
  ''
],
  'name' = [
  ''
],
  'cell' = [
  ''
],
  'date' = [
  ''
],
  'tissue' = [
''
  ],
  'quant' = [
   ''
 ],
  'ISH' = [
 ''
   ],
  'bg' = [
''
  ],
  'gel' = [
 ''
   ],
  'primer' = [
''
  ],
  'mt' = [
'bleh'
  ],
  'band' = [
  ''
]
}
}

now, this is very well.

how do i print a specific record?

i would like to be able to check if a record already exist so i dont overwrite it.


:o)

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: printing from records ?

2002-05-06 Thread Martin A. Hansen

hi felix

the exists check works nicely :)

but i cant get the print to work, using my version of your sub:

sub print_record
{
   my ( $record_key ) = @_;
   my $record;
   my $records;

   # read in records
   $records = read_recordfile;

   foreach $record ( keys %{ $records-{ $record_key } } ) {
  print debug . join('', @{ $records-{ $record_key }{ $record } } );
   }

   return $record
}
  
$record_key is passed to the subroutine ok (i did check). and the records are read (i 
did check using Data::Dumper)

 print_record($records, 'bleh');
 
 sub print_record {
 my $source = shift;
 my $key = shift;
   
 return unless exists $source-{$key};
 print Contents of record with primary key $key:\n;
 foreach my $field (sort keys %{$source-{$key}}) {
 print \t$field: ;
 print [ . 
   join(, , @{$source-{$key}{$field}}) . 
   ]\n ;
 }
  print \n;
 return;
 }
 
 But I have a question: what is the functional difference between 
 [] and [''] in your columns?
good question. i have a hash of hashes of arrays. i want to be able, later on, to push 
more values on each secondary hash key - hence the array [''].

martin

 
 -- 
 felix
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: printing from records ?

2002-05-06 Thread Martin A. Hansen

hi again

im practicing handling structures. im very much a newbie at this so theres prolly 
something wrong with my code.

 If this is what you want, maybe you have an error in your 
 read_recordfile?

sub read_recordfile
{
   my $records;

   {
local ($/) = undef;
open SOURCE, $recordfile or die Can't open file: $!;
$records = eval SOURCE;
die $@ if $@;
close SOURCE;
   }

return $records;
}
  
:-)

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




printing element from record ?

2002-05-03 Thread Martin A. Hansen

hi, im having trouble printing out the key of this record hash:

i wan the result to print:

THIS_HERE

im sure its trivial, but i cant figure it :)

martin


{
  'THIS_HERE' = {
   'ISH' = [
  '3'
],
   'ISHpix' = [],
   'bg' = [
 ''
   ],
   'gelpix' = [],
   'base' = [
   'T'
 ],
   'norm' = [
   ''
 ],
   'gel' = [
  '456'
],
   'drug' = [
   ''
 ],
   'primer' = [
 '2'
   ],
   'mt' = [
 'foo'
   ],
   'organism' = [
   'Human'
 ],
   'band' = [
   '1'
 ],
   'name' = [
   'abc'
 ],
   'date' = [
   '123'
 ],
   'cell' = [
   ''
 ],
   'quant' = [
''
  ],
   'tissue' = [
 'Testis'
   ]
 }
}

i read in the hash using this:



{ #block to control scope
  local ($/) = undef; #make this change local so as not to screw up anything else

  open SOURCE, $hash_file or die Can't open file: $!;
  $hash_ref = eval SOURCE;
  die $@ if $@;
  close SOURCE;
}

so printing should be something ala:

print $hash_ref - { ? };

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Solved: sort regex trouble!

2002-04-25 Thread Martin A. Hansen

hi

i finally got it to work. it was very simple ... _if_ you remember that its not td 
but td align=foo you are trying to match!

martin



On Wed, Apr 24, 2002 at 11:04:42AM -0400, David Gray wrote:
  May I suggest:
  (my $A = $a) =~ s/^trtd(\d+)\/td/$1/;
  (my $B = $b) =~ s/^trtd(\d+)\/td/$1/;
  
  That's not what he's doing.  He's doing:
  
my ($A) = $a =~ m{^trtd(\d+)/td};
my ($B) = $b =~ m{^trtd(\d+)/td};
  
  Yours leaves everything after the /td tacked onto the end 
  of $A; mine and his only store the number in $A.
 
 Argh, good catch. I usually do that kind of thing like:
 
 my $A = $1 if $a =~ m{^trtd(\d+)/td};
 
 But I didn't that time :)
 
 Let us know if any of this fixes your problem, Martin...
 
  -dave
 
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




web automation - where to read?

2002-04-25 Thread Martin A. Hansen

hi

im trying to write a scipt that crawls a website. however, with only the documentation 
from the perl cookbook and some no_good manpages from the LWP modules, im stuck!

where can i find som documentation (pref. online) ?

or even some examples ?


regards

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: web automation - where to read?

2002-04-25 Thread Martin A. Hansen

On Thu, Apr 25, 2002 at 01:57:07PM -, Felix Geerinckx wrote:
  im trying to write a scipt that crawls a website. however, with
  only the documentation from the perl cookbook and some no_good
  manpages from the LWP modules, im stuck! 
 
 Would you care to explain what is 'no_good' about the LWP manpages?
 
no good for beginners.

  where can i find som documentation (pref. online) ?
 
 Do you know 'The Web Robot Pages' at
 
thanks, ill have a look :)
   http://www.robotstxt.org/wc/robots.html?
 
 Here you will find a lot of info about all kind of webrobots (or 
 crawlers).
 
 If you want more documentation, why not type
 
   'web crawling Perl LWP'
 
 in the google.com search box, and find out?
 Last time I tried it listed about 390 hits.
 
yes, but here i was hoping for some recommendated reading ...

 -- 
 felix
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
--

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: regex question

2002-04-18 Thread Martin A. Hansen

hi john

i implementet your solution. mine actually did work, but yours seemed more logical.

it works nicely.

thank you

martin

On Wed, Apr 17, 2002 at 12:58:07PM -0700, John W. Krahn wrote:
 [EMAIL PROTECTED] wrote:
  
  hi,
 
 Hello,
 
  im pasting some more of the lines i need to parse. i guess
  im just learning regex and just espesially learning how to
  ask the correct questions! heh, dont ask regex without
  showing enuf of the stuff you want to parse :)
  
  theres is these three basic entries (skakkebaek is spelled awfully. only skak 
matches em all :-) :
  
  Hits  Cited Author  Cited WorkVolume  Page  Year
  
__
  
  [_][667] 279   ...Skakkebaek NE  ENVIRON HEALTH PERSP 104   741
  1996
  [_]   1   SKAKKEBAEK NE EARLY DETECTION TEST26  
1981
  [_]   3   SKAKKEBAEK NE EARLY DETECTION TEST
1981
  
  then there is these freaks:
  this one contains NE in the name and NE in GENE so GENE is truncated if care is 
not taken.
  
  [_][718]  18   ...Skakkebaek NE  GENE CHROMOSOME CANC  20   412
  1997
  
  here the journal name starts with 7
  
  [_]   3   SKAKKEBAEK NE 7 WORLD C FERT STER 
1971
  
  here the journal name ends with a digit thus entangling it in the following page 
number 101.
  
  [_]   1   SKAKKEBAEK NE ENV HLTH PERSPECT S2 101 1  
1993
  
  here is my mathing routine - works with all but the last freak!:
  
  [snip code]
 
 
 This works with the data above:
 
 while ( DATA ) {
 chomp;
 my @field = split /\s{2,}/;
 
 shift @field if $field[0] =~ /]$/;
 (my $citations) = (shift @field) =~ /(\d+)$/;
 
 shift @field if $field[0] =~ /skak.*ne$/i;
 
 my $journal = shift @field;
 my $year= pop @field || '';
 my $page= pop @field || '';
 my $volume  = pop @field || '';
 
 print Citation: $citations\nJournal: $journal\nVolume: $volume\nPage: 
$page\nYear: $year\n\n;
 }
 
 __DATA__
 [_][667] 279   ...Skakkebaek NE  ENVIRON HEALTH PERSP 104   741  
1996
 [_]   1   SKAKKEBAEK NE EARLY DETECTION TEST26  1981
 [_]   3   SKAKKEBAEK NE EARLY DETECTION TEST1981
 [_][718]  18   ...Skakkebaek NE  GENE CHROMOSOME CANC  20   412  
1997
 [_]   3   SKAKKEBAEK NE 7 WORLD C FERT STER 1971
 [_]   1   SKAKKEBAEK NE ENV HLTH PERSPECT S2 101 1  1993
 
 
 
 
 John
 -- 
 use Perl;
 program
 fulfillment
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




strange cgi error?

2002-04-16 Thread Martin A. Hansen

hi

i have a faulty cgi script which hangs my browser (konq). running the cgi script from 
a shell shows this first line:

Something is wrong?Content-type: text/html


so, what is wrong?

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




automagic web query ?

2002-04-15 Thread Martin A. Hansen

hi


im trying to write a script that does a search on a remote website. the script needs 
to fill in a form field with a search word and save all the results. there is three 
different form fields on the webpage, but im only interested in the first one. the 
results comes in 10 per page only, and i would like the script to follow the links so 
i get all results.

can this be done with perl? (i think so).

can anyone help me out here?

thanks

best

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Data::Dumper documentation ?

2002-03-19 Thread Martin A. Hansen

hi

i have read the documentation on Data::Dumper from Learning Perl, Perl Cookbook and 
perldoc. however, im still very confused. im looking for some beginners documentation 
and examples. can anyone direct me?

:o)

martin

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: Data::Dumper documentation ?

2002-03-19 Thread Martin A. Hansen

heh - that was exactly half of what i was looking for - how to dump stuff! great :)

mayby you can help me out with the second part too? :

if i have a datastructure (a hash) dumped to a file using Data::Dumper,
how can i recreate the datastructure/hash in another program?

if i do something like this:

open SOURCE, source.file;
undef $/;
eval SOURCE;
die $@ if $@;
close IN;


then eval will turn the datastructure into a scalar? but i want it as a hash!

or how does it work ?

:o)

martin

ps, love the missile address line!

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




external hashtable

2002-03-18 Thread Martin A. Hansen

hi

i have some files of the format:

{
'key1' = 'value2',
'key2' = 'value3',
'key3' = 'value4',
'key4' = 'value5',
'key5' = 'value6',
}

the values are large huge chunks of text.

how can i import such a file into a perl script as a hash?
and how can i write the hash to a new file (same format as above)?

best :)

martin

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: external hashtable

2002-03-18 Thread Martin A. Hansen

ok, im on a linux box here. and i do have Data::Dumper.

so how would the solution with Dumper work? theres not very much documentation on 
Dumber in the camel...

martin

 I suggest Data::Dumper, which can do exactly this
 function.
 

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




interesting question about variables

2002-03-15 Thread Martin A. Hansen

hi

i have a loop containing the following block of code. however, first time the loop is 
run, $text_link is empty, which it shouldn't be. i cant move the declaration of 
$text_link above the if statment, because then the $figure_name would be empty.

now i guess im really missing out on something fundamental here, since i cant figure 
out how this issue is solved!

any suggestions will be appreciated

:o)

martin

 
if ( ( $hash - { $paragraph } ) =~ s/###(\w+.*\.jpg)###/($text_link)/ ) {
  $figure_name = $1;

  $text_link = $cgi - a({-href = javascript: window.open('$pix_dir/$figure_name', 
 .  '', 
 .  'status=yes, 
 .   resizable=yes, 
 .   scrollbars=no, 
 .   width=530,
 .   height=380'
 . );
   void('');
   }, Fig $figure_number );
  
  $figure_number++;
}

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




regex question

2002-03-13 Thread Martin A. Hansen

hi


i have a long text file. in this text file several strings of the form:  ### 
filename.jpg ### are embedded.

how should a regex look that takes following:

text before ### filename.jpg ### text after

and returns

text before text after

and the filename.jpg saved in a $

:o)

martin
-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




easy way to make a hash of filenames?

2002-03-11 Thread Martin A. Hansen

hi

im trying to make a hashtable of filenames, where the key is a forthrunning number and 
the value is a filename in a dir.

so i have a dir with files:

/dir/foo.jpg
 bar.jpg

and i want a

%hashtable = (
   1 = 'foo',
   2 = 'bar'
 )

how can this be done ?

:o)

martin
-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Solved: easy way to make a hash of filenames?

2002-03-11 Thread Martin A. Hansen

neat

works straight away :)

thx

martin

On Mon, Mar 11, 2002 at 02:15:59PM +, Jonathan E. Paton wrote:
  so I have a dir with files:
  
  /dir/foo.jpg
   bar.jpg
  
  and I want a
  
  %hashtable = (
 1 = 'foo',
 2 = 'bar'
   )
  
  how can this be done ?
 
 Try map:
 
 %hashtable = map { $ctr++, $_ } @files;
 
 Or even:
 
 %hashtable = map { $ctr++, $_ } *;
 
 Of course, I've probably got the syntax wrong - since I
 don't use map that often.  You can, of course, write many
 programs in terms of sub/map like:
 
 sub add {
 return map {
 #do processing
 } @_;
 }
 
 which can really annoy your coworkers.
 
 Jonathan Paton
 
 __
 Do You Yahoo!?
 Everything you'll ever need on one web page
 from News and Sport to Email and Music Charts
 http://uk.my.yahoo.com
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




sort order of hash keys

2002-02-26 Thread Martin A. Hansen

hi


i would like to know if theres a smart way to unwind a hashtable so that
the key / value pairs comes out in the same order as they are in the table.

:o)

martin
-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: sort order of hash keys

2002-02-26 Thread Martin A. Hansen

yeah, i new this was tricky.

my hash keys / values have uneven names so i cant use a sort routine directly. thats 
why i would like to get the key / values in the same order as they are in the 
hashtable file.

whats the name of that hash modules?

:o)

martin


On Tue, Feb 26, 2002 at 10:28:16AM -, John Edwards wrote:
 hash keys are stored unsorted. If you have the following hash
 
 %test = ( one = 1,
   two = 2,
   three = 3);
 
 and print out the hash key/value pairs.
 
 foreach $key (keys %test) {
   print $key is $test{$key}\n;
 }
 
 you will find they don't come out in the same order as they were stored.
 
 You can perform a sort on the keys to arrange them in order
 
 foreach $key (sort keys %test) {
   print $key is $test{$key}\n;
 }
 
 or you can reverse the hash, making the values the keys, and sort on the new
 keys
 
 %reversed = reverse %test;
 
 foreach $key (keys %reversed) {
   print $key is $reversed{$key}\n;
 }
 
 In doing this though, you must be aware that you will lose any data that has
 identical values. For example
 
 %test = ( one = 1,
   two = 2,
   three = 3,
   alpha = 1,
   beta = 2,
   gamma = 3);
 
 %reversed = reverse %test;
 
 foreach $key (keys %reversed) {
   print $key is $reversed{$key}\n;
 }
 
 will print out
 
 1 is one
 2 is two
 3 is three
 
 There is probably another/better way of doing this using the comparison
 operator =, but I don't know it. There is also a module available that
 lets you store and retrieve hashes in a fixed order.
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: 26 February 2002 09:16
 To: [EMAIL PROTECTED]
 Subject: sort order of hash keys
 
 
 hi
 
 
 i would like to know if theres a smart way to unwind a hashtable so that
 the key / value pairs comes out in the same order as they are in the table.
 
 :o)
 
 martin
 -- 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 
 
 --Confidentiality--.
 This E-mail is confidential.  It should not be read, copied, disclosed or
 used by any person other than the intended recipient.  Unauthorised use,
 disclosure or copying by whatever medium is strictly prohibited and may be
 unlawful.  If you have received this E-mail in error please contact the
 sender immediately and delete the E-mail from your system.
 
 

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




appending files

2002-02-25 Thread Martin A. Hansen

hi

i have this very interesting task, and i need some inspiration.

i have a directory with say 10 fcgi files (text files):

now i would like to have a temp.fcgi file which contains all of the date from the 
.fcgi files (appended). however, i want my program to update the temp.fcgi file if new 
.fcgi files are added the directory. i was thinking something like testing the 
combined size of the .fcgi files compared to temp.fcgi and if it differs then wipe 
temp.fcgi and generate a new one?

how can that be done?


-martin

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: appending files

2002-02-25 Thread Martin A. Hansen

interesting, but no.

i can download these .fcgi files from a database and they are quite generic (they 
contains loads of records). all i wanted is to collect all therecords in one big fcgi 
file for outputting and sorting. but i may download new .fcgi files regularly and i 
want them included in the big fcgi file as well. however, i dont want to do the 
include process with each run of the program!

:)


martin


On Mon, Feb 25, 2002 at 07:48:07AM -0800, Wagner-David wrote:
   Might be better off using a hash with the filename and say last mod time. Then 
if a new file or the last mod time is different, then rebuild your data.
 
 Wags ;)
 
 -Original Message-
 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
 Sent: Monday, February 25, 2002 06:11
 To: [EMAIL PROTECTED]
 Subject: appending files
 
 
 hi
 
 i have this very interesting task, and i need some inspiration.
 
 i have a directory with say 10 fcgi files (text files):
 
 now i would like to have a temp.fcgi file which contains all of the date from the 
.fcgi files (appended). however, i want my program to update the temp.fcgi file if 
new .fcgi files are added the directory. i was thinking something like testing the 
combined size of the .fcgi files compared to
 temp.fcgi and if it differs then wipe temp.fcgi and generate a new one?
 
 how can that be done?
 
 
 -martin
 
 -- 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]

-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




unwinding hash or what it is?

2002-02-14 Thread Martin A. Hansen


hi

i have inherited this piece of code and i have been wondering hard about how i can 
print the different @records returned from the subroutine? im not even sure whats on 
my hand here. is this a hash of arrays or a hash of array references? and how do i 
unwind those?



martin, beginning perl.




my @records = parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] );


## subroutines 


sub parse_pubmed_fcgi {

  my ( $keys ) = @_;

  my ( @records, $record, $record_id, $line, $key );

  my %wants = map { $_ = 1 } @{ $keys };

  while ( defined ($line = ) ) {
chop $line;

if ( $line =~ /^(UI)\s*-/ ) {
  $key = $1;

  if ( $record ) {
push @records, $record;
undef $record;
  }
}

if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) {
  $key = $1;
  push @{ $record-{ $key } }, $2 if $wants{ $key };
}
  elsif ( $line =~ /^\s+(\S.*)/ ) {
$record-{ $key }-[-1] .=  $1 if $wants{ $key };
  }
}

  push @records, $record if $record;

  if ( wantarray ) {
return @records;
  } else {
  return \@records;
  }

}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: unwinding hash or what it is?

2002-02-14 Thread Martin A. Hansen

On Thu, Feb 14, 2002 at 10:40:20AM -0500, Chas Owens wrote:
 On Thu, 2002-02-14 at 10:19, Martin A. Hansen wrote:
  
  hi
  
  i have inherited this piece of code and i have been wondering hard about how i can 
print the different @records returned from the subroutine? im not even sure whats on 
my hand here. is this a hash of arrays or a hash of array references? and how do i 
unwind those?
  
  
  
  martin, beginning perl.
  
  
  
  
  my @records = parse_pubmed_fcgi( [ qw(UI AU TI TA VI IP PG DA) ] );
  
  
  ## subroutines 
  
  
  sub parse_pubmed_fcgi {
  
my ( $keys ) = @_;
  
my ( @records, $record, $record_id, $line, $key );
  
my %wants = map { $_ = 1 } @{ $keys };
  
while ( defined ($line = ) ) {
  chop $line;
  
  if ( $line =~ /^(UI)\s*-/ ) {
$key = $1;
  
if ( $record ) {
  push @records, $record;
  undef $record;
}
  }
  
  if ( $line =~ /^([A-Z]+)\s*-\s*(.+)/ ) {
$key = $1;
push @{ $record-{ $key } }, $2 if $wants{ $key };
  }
elsif ( $line =~ /^\s+(\S.*)/ ) {
  $record-{ $key }-[-1] .=  $1 if $wants{ $key };
}
  }
  
push @records, $record if $record;
  
if ( wantarray ) {
  return @records;
} else {
return \@records;
}
  
  }
  
 
 Data::Dumper is your friend.  If you have a data structure and you don't
 know what is in it just say:
 
 print Dumper(\@Records);
 
 and bingo the data structure is printed out to the screen.
 
 -- 
 Today is Setting Orange the 45th day of Chaos in the YOLD 3168
 Kallisti!
 
 Missle Address: 33:48:3.521N  84:23:34.786W
 
 
 -- 
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 

ok, if Data::Dumper is my friend, how can i print all record fields of type AU only?

martin
-- 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




CGI table width

2002-02-04 Thread Martin A. Hansen

hi

how can i control the width of each column or cell in my table?

i dont exactly know what the following width switch does?

print table({-border = 0, -width = '100%'},
 Tr[
   td({ width = 75 }, ['', $headline,  '']),
   td( ['', $hr,'']),
   td( ['', $subheadline,   '']),
   td( ['', $embeddedtable, '']),
   td( ['', $hr,'']),
 ]
   );

and by the way. where can i find more description on CGI functions
and especially the switches?

regards

-martin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




width of table cells and CGI ???

2002-01-31 Thread Martin A. Hansen



hi

i am playing with CGI and tables

how do i set the width of a cell?


my $embeddedtable = table({-border = 0},
Tr[
  td(['Title', $title]),
  td(['First Name', $firstname]),
  td(['Last Name', $lastname]),
  td(['E-mail', $email]),
  td([$submit, $reset]),
]
);


martin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: width of table cells and CGI ???

2002-01-31 Thread Martin A. Hansen


thats is pure HTML code... i know!

i want to do it the CGI way!

aint there a -width = 150 switch i can set?


martin


On Thu, 31 Jan 2002, Darryl Schnell wrote:

 I usually do TD WIDTH='60' or TD WIDTH='60%' please note that both are different 
lengths of the screen.


 Darryl

 -Original Message-
 From: Martin A. Hansen [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, January 31, 2002 7:47 AM
 To: [EMAIL PROTECTED]
 Subject: width of table cells and CGI ???




 hi

 i am playing with CGI and tables

 how do i set the width of a cell?


 my $embeddedtable = table({-border = 0},
 Tr[
   td(['Title', $title]),
   td(['First Name', $firstname]),
   td(['Last Name', $lastname]),
   td(['E-mail', $email]),
 td([$submit, $reset]),
 ]
 );


 martin


 --
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




how to get hash values returned from a subroutine?

2002-01-28 Thread Martin A. Hansen

hi there


im trying to call a subroutine and get it to return some hash table values. however, i 
have two problems.

1.  it does not work. theres something wrong with my foreach sentence,
but i cant see what it is. however, the commented foreach sentence
do work?

2.  the @return_array needs to be split so i get the values on
seperate lines. how can that be done?


i take this is a very general problem and there is probably many
solution strategies. any suggestion on how to solve my current problem
and any ideas as how to improve the return values from hash issue will be greatly 
appreciated.

best regards

martin



#!/usr/bin/perl -w

subroutine;

print \n, @return_array, \n;

sub subroutine {
%hash_table = (
'en'   = '1',
'to'   = '2',
'tre'  = '3',
'fire' = '4',
'fem'  = '5',
'seks' = '6',
'syv'  = '7',
'otte' = '8',
'ni'   = '9',
'ti'   = '10'
  );

  $extract = qw (en tre ni);

#  foreach $number (qw en tre ni) {
  foreach $number ($extract) {
 push (@return_array, $hash_table{$number});
  }
  return @return_array;
}



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




how do i utilize an external hashtable?

2002-01-28 Thread Martin A. Hansen


hi

if i have a file called table.hash looking like this:


{
'HEADLINE' = 'Carcinoma in Situ',

'SUBHEADLINE' =
'
the precursor cell for testicular germ cell cancer in adolescents and young adults
',

'BODYTEXT' =
'
This site provides information on research, diagnosis and management
of early forms of testicular cancer and is directed to physicians,
researchers and patients.
The site has been developed by members of the CIS  Testis Cancer
Research Group led by Professor Niels E. Skakkebæk, MD at the
Department of Growth  Reproduction in collaboration with the Danish
Cancer Society, Copenhagen, Denmark.
'
}


how do i access the hashtable with a key and return the appropriate
value?


martin


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




CGI and tables ?

2002-01-25 Thread Martin A. Hansen


hi

im trying to build a webpage with perl CGI the object way...


the only documentation i have looked at is man CGI

can anyone recommend some online documentation?

anyway:

is it possible to render a table with something like:

print $newCGI-start_table(-border='1');
print $newCGI-end_table(-border='1');


doesnt seem to work thou, but i must be missing a lot of parameters.
and its only mentioned in the man CGI for the function-oriented way.

:o)

martin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




subroutine returning lines of text

2002-01-16 Thread Martin A. Hansen

hi

im wondering how i can make a subroutine that will return all text lines between 
certain marks such as START and STOP:

text file:

START
text
is here
and there
is
a
lot of it
STOP

so i would like to call the subroutine with the arguments START and STOP (because i 
may need more starts and stops later) and have the subroutine return the lines between 
START and STOP in a $.

i guess it should be pretty simple, however its out of my reach still :P

any help will be appreciated :) !

martin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




silly beginners problem :)

2002-01-15 Thread Martin A. Hansen

hi

im trying to make a script to read a textfile with the following format:

TITLE
Welcome to Carcinoma in Situ


i want my script to recognice the TITLE tag and save the following line(s) in $TITLE:

heres what i have done:

while () {
  chomp;
if (/TITLE\s*([A-Za-z]+)/) {
   $TITLE=$1;
  }
}
print $TITLE;

upon script textfile.txt  outputfile i get this error:
Use of uninitialized value in concatenation (.) or string in line (the one with print 
$TITLE in it)

i think my regex is not doing what i want it to do??? why?

:/

martin


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]