[16635] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4047 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Aug 17 14:10:39 2000

Date: Thu, 17 Aug 2000 11:10:27 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <966535827-v9-i4047@ruby.oce.orst.edu>
Content-Type: text

Perl-Users Digest           Thu, 17 Aug 2000     Volume: 9 Number: 4047

Today's topics:
    Re: Perl Pfad <tony_curtis32@yahoo.com>
    Re: Perl Pfad <struebig@mail.uni-mainz.de>
    Re: PERL/TK AND WIDGETS <dunfeeje@pilot.msu.edu>
    Re: PERL/TK AND WIDGETS <dunfeeje@pilot.msu.edu>
    Re: PERL/TK AND WIDGETS <panderse@us.ibm.com>
    Re: Pipe on WinNT <pgunreben@lucent.com>
        read files from dir then write as csv??? kingofkingston@my-deja.com
    Re: read files from dir then write as csv??? <jeff@vpservices.com>
        Reading a %hash of Directory names <kevin.costantino.b@bayer.com>
    Re: Reading a %hash of Directory names <kevin.costantino.b@bayer.com>
    Re: Reading a %hash of Directory names nobull@mail.com
    Re: Reading remote files <admin@salvador.venice.ca.us>
        References to hashes <dwishar1@ford.com>
        remove blanks melet@my-deja.com
    Re: remove blanks <sariq@texas.net>
    Re: remove blanks nobull@mail.com
        RSA Encryption <steven@younghousehold.fsnet.co.uk>
        Running Perl-Script as NT-Service <guenther.degenfelder@datev.de>
    Re: Running Perl-Script as NT-Service nobull@mail.com
    Re: Sorting is very slow (Abigail)
        SUID in perl <lithium@ev1.net>
    Re: Time stamp on Bulletin Board (Colin Keith)
    Re: Trouble installing Bundle::DBI <michael.segulja@sgi-lsi.com>
    Re: wav or mp3 perl module (Colin Keith)
        wwwadmin.pl and deleting messages xlr6drone@my-deja.com
        Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)

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

Date: 17 Aug 2000 10:12:08 -0500
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: Perl Pfad
Message-Id: <87em3nhqgm.fsf@limey.hpcc.uh.edu>

>> On Thu, 17 Aug 2000 16:53:33 +0200,
>> "Stefan Soller" <Stefan.Soller@gmx.ch> said:

> $database_dir = "/www/nsi/_md/meinlink.de/data/"; wie
> oben muss ich den pfad der datenbank angeben, wo sich
> meine *.csv dateien befinden! Doch ich will der pfad
> nicht so definieren sondern ich will
> z.b. "http://www.meinlink.de/data" angeben können! Wie
> muss ich das machen?  Sobald ich dies angebe
> $database_dir = "http://www.meinlink.de/data"; kommt,
> dass er die datei *.csv nicht öffnen kann obwohl der
> pfad stimmt!! Könnt ihr mir helfen?

Du willst Resourcen uebers Netz oeffnen?  Dann brauchst

    perldoc lwpcook

Resourcen unter http URLs sind nicht Files, und koennen
daher durch open() nicht geoeffnet werden.  Du musst mit
dem remote Server kommunizieren.

(The OP wants to access data through a http URL instead of
with a local filesystem pathname.  He needs to use the LWP
modules in perl to obtain access to the remote server,
hence the direction to lwpcook which includes examples.)

hth
t
-- 
"I'm not easily impressed.  Wow!  A blue car!"
                                               Homer Simpson


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

Date: Thu, 17 Aug 2000 17:16:12 +0200
From: "J. Strübig" <struebig@mail.uni-mainz.de>
Subject: Re: Perl Pfad
Message-Id: <399C01BC.43D4@mail.uni-mainz.de>

Hi,

Stefan Soller wrote:
> 
> $database_dir = "/www/nsi/_md/meinlink.de/data/";
> 
> wie oben muss ich den pfad der datenbank angeben, wo sich meine *.csv
> dateien befinden! Doch ich will der pfad nicht so definieren sondern ich
> will z.b. "http://www.meinlink.de/data" angeben können! Wie muss ich das
> machen?
> Sobald ich dies angebe $database_dir = "http://www.meinlink.de/data"; kommt,
> dass er die datei *.csv nicht öffnen kann obwohl der pfad stimmt!! Könnt ihr
> mir helfen?
> 
> DANKE

Das sind 2 komplett verschiedene Sachen eine http ist eine URL und keine
Pfadangabe auf der Festplatte. Die Dateien auf deinem Computer heissen
ja auch nicht http://c:verzeichniss/datei.ext.

Um auf eine datei (URL) im Internet zugreifen zu können braucht das
Programm eine Verbindung zum internet, dann werden einige Daten hin und
her geschickt und dann kann man die Datei lesen.
Das Modul ist glaube ich LWP das das alles macht.
letzendlich wesentlich komplizierter und langsamer als wenn du sie
normal öffnest.

Frage: Weißt du eigentlich was du da machst, oder machen willst ?

Was ist ein Programm ?
Was ist eine Datei ?
Was ist das Internet ?
Was ist eine URL ?
Wie kommen die Daten auf die Festplatte ?
Wie kommen die Daten ins Internet ?

Struppi.


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

Date: Thu, 17 Aug 2000 11:08:46 -0400
From: Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu>
Subject: Re: PERL/TK AND WIDGETS
Message-Id: <399BFFFE.5EDB7860@pilot.msu.edu>

Well, I guess it would seem alittle confusing. Here is the picture. I am
writing a program to sort through some files in a directory, the files change
so there might be 5 at one point and there might be 2.  According to the
number of files in the directory to I dynamically create and display buttons
in a frame, when I create them I use this code

   foreach (sort @good_agents)
   {
 my $_b = $dynamic_button_fr->Button(-text=>$_, -command=> sub{$agent_text
 ->insert('end',"name of button here
\n");})->pack(side=>'top',-fill=>'both',-anchor=>'ne');
   }

@good_agents - holds all the file names that I need to display (like I said
earlier the count changes)
$dyanmic_button_fr  - is a frame on a toplevel
$_b - is the name of each file with the letter b appended, b for button
$agent_text - is a text widget where I want to insert the name of the button
when I press the button.

The code spits the buttons out fine, but since I use a loop even if I used a
variable name for the hold variable on the loop (i.e foreach $some_variable
(@good_agents)) the variable would not be unique for each button. So I want to
write a callback to try and grab the name or label on the button and then
insert it into a text widget.  The idea is kinda like when you click a button
and it adds the item to a "shopping basket" when you are buying things
online.  That's what I want.  but since there is not set number of buttons
that will be displayed at one time I am using a loop. I run into the problem
of getting a unique variable each time through the loop to hold a value that
holds the information about the button. When the program is running, I don't
have anything, at least that I know yet I am a new programer in perl/tk, that
will tell me what button I pressed? Any help would be much appreciated....

-jeff

Ala Qumsieh wrote:

> Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu> writes:
>
> > I'm trying to find a function that will return the name of a button I
> > have created, or some type of identifier that lets me know what button I
> > have pressed.  Perhaps return the label on the button, that would be
> > ideal. But I can not find any functions like this. Does anybody know
> > anything about PERL/TK enough to tell me if a function like this
> > exists... thanks
>
> I think you are confused. Step back, and tell us the global picture and
> what you would like to do. There's probably a better way to do what you
> want.
>
> When you create a button (or any other widget), you get a reference to
> the widget object that you just created:
>
>         my $button = $mw->Button(...)->pack;
>
> Now, you can use this object (referred to by $button) anywhere in your
> program.
>
> You should also send you Tk-related questions to comp.lang.perl.tk.
>
> --Ala





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

Date: Thu, 17 Aug 2000 11:09:51 -0400
From: Jeffrey Scott Dunfee II <dunfeeje@pilot.msu.edu>
Subject: Re: PERL/TK AND WIDGETS
Message-Id: <399C003F.89EC68B9@pilot.msu.edu>


Well, I guess it would seem alittle confusing. Here is the picture. I am
writing a program to sort through some files in a directory, the files change
so there might be 5 at one point and there might be 2.  According to the
number of files in the directory to I dynamically create and display buttons
in a frame, when I create them I use this code

   foreach (sort @good_agents)
   {
 my $_b = $dynamic_button_fr->Button(-text=>$_, -command=> sub{$agent_text
 ->insert('end',"name of button here
\n");})->pack(side=>'top',-fill=>'both',-anchor=>'ne');
   }

@good_agents - holds all the file names that I need to display (like I said
earlier the count changes)
$dyanmic_button_fr  - is a frame on a toplevel
$_b - is the name of each file with the letter b appended, b for button
$agent_text - is a text widget where I want to insert the name of the button
when I press the button.

The code spits the buttons out fine, but since I use a loop even if I used a
variable name for the hold variable on the loop (i.e foreach $some_variable
(@good_agents)) the variable would not be unique for each button. So I want to

write a callback to try and grab the name or label on the button and then
insert it into a text widget.  The idea is kinda like when you click a button
and it adds the item to a "shopping basket" when you are buying things
online.  That's what I want.  but since there is not set number of buttons
that will be displayed at one time I am using a loop. I run into the problem
of getting a unique variable each time through the loop to hold a value that
holds the information about the button. When the program is running, I don't
have anything, at least that I know yet I am a new programer in perl/tk, that
will tell me what button I pressed? Any help would be much appreciated....

-jeff



"Paul R. Andersen" wrote:

> Jeffrey Scott Dunfee II wrote:
> >
> > I'm trying to find a function that will return the name of a button I
> > have created, or some type of identifier that lets me know what button I
> > have pressed.  Perhaps return the label on the button, that would be
> > ideal. But I can not find any functions like this. Does anybody know
> > anything about PERL/TK enough to tell me if a function like this
> > exists... thanks
> >
> > -jeff dunfee
> > dunfeeje@pilot.msu.edu
> It would help if you showed us what you have tried.  I'm not sure what
> you mean by a function that will return the name of the button.  What
> kind of button are we talking about?  If you are talking about a basic
> button, just off-hand, the only way I can think of to get informatin is
> to have the button invoke a callback and do something in there to put
> the button name someplace.  Wishy-washy I know.  Show me some code and I
> can help more.
> --
> Paul Andersen
> +++++++++++++
> The difference between theory and practice is that in theory there is no
> difference between theory and practice; but in practice there is.

--
*********************************************************************************

                        "To laugh often and much,
                 to win the respect of intelligent people
                      and the affection of children,
                 to earn the appreciation of honest critics
                  and endure the betrayal of false friends,
                 to appreciate beauty, to find the best in others,
                      to leave the world a bit better,
                          whether by a healthy child,
                a garden patch, or a redeemed social condition;
          to know even one life has breathed easier because you have lived.
                            This is to have succeeded!"
                             ... Ralph Waldo Emerson
*********************************************************************************

@@@@@@@@@@@@@@@@@@@@@
    Jeff Dunfee
College of Engineering

  dunfeeje@egr.msu.edu
 -
  dunfeeje@msu.edu
@@@@@@@@@@@@@@@@@@@@@




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

Date: Thu, 17 Aug 2000 12:38:45 -0500
From: "Paul R. Andersen" <panderse@us.ibm.com>
Subject: Re: PERL/TK AND WIDGETS
Message-Id: <399C2325.81913572@us.ibm.com>

Jeffrey Scott Dunfee II wrote:
> 
> Well, I guess it would seem alittle confusing. Here is the picture. I am
> writing a program to sort through some files in a directory, the files change
> so there might be 5 at one point and there might be 2.  According to the
> number of files in the directory to I dynamically create and display buttons
> in a frame, when I create them I use this code
> 
>    foreach (sort @good_agents)
>    {
>  my $_b = $dynamic_button_fr->Button(-text=>$_, -command=> sub{$agent_text
>  ->insert('end',"name of button here
> \n");})->pack(side=>'top',-fill=>'both',-anchor=>'ne');
>    }
> 

The following works for me:


use strict;
use Tk;
require Tk::ROText;
my @good_agents = qw(btn1 btn2 btn3 btn4 btn5);
my $main = new MainWindow;
my $agent_text = $main->Scrolled("ROText")
                     ->pack(-side => 'top', -fill => 'both');
my $bname;
foreach $bname (@good_agents)
{
  $main->Button(-text=>$bname,
                -command=> sub{$agent_text->insert('end',"$bname\n");} )
                ->pack(side=>'top',-fill=>'both',-anchor=>'ne');
}
MainLoop;


Hope this will help you.

Paul Andersen


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

Date: Thu, 17 Aug 2000 18:24:37 +0200
From: Peter Gunreben <pgunreben@lucent.com>
Subject: Re: Pipe on WinNT
Message-Id: <399C11C5.FE456160@lucent.com>

This didn't help!

Anyway, the problem is not
that the second script is not executed, but
that the output of the second script doesn't
occur at the input filehandle. As already 
stated: It works fine under UNIX but not 
under WinNT.


Guenther Degenfelder wrote:
> 
> You should use
>     perl -S update.pl
> and not only
>     update.pl


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

Date: Thu, 17 Aug 2000 15:57:15 GMT
From: kingofkingston@my-deja.com
Subject: read files from dir then write as csv???
Message-Id: <8nh20g$2op$1@nnrp1.deja.com>

Hi there :-)

Note: Please bear in mind I am a newby to Perl and Unix!

We have a perl script that trawls through our oracle database every
night and outputs a list of tables and the number of rows in the table
into a new text file (eg.count20000816.txt, for todays date). The
contents of the resulting text file look like this:

Table Name,16/08/2000
ATTACH,119
BLOB,1258
BRANCH,612
CATEGORY,2


(the number after the table name indicates the number of rows in that
table).


What I would like to do is evaluate the rate at which our tables are
growing. So I need to read the contents of all the files, and then
output a single CSV file which can be imported into MS Excel and show
graphical representations of the data.

I think the CSV would have one large table; dates across the top, table
names along the side, and the number of rows in the middle

I'm not sure what strategy/method to use to do this, as I'm new to Perl.

Any help would be very much appreciated.

Thanks

KingOfKingston


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


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

Date: Thu, 17 Aug 2000 10:58:17 -0700
From: Jeff Zucker <jeff@vpservices.com>
To: kingofkingston@my-deja.com
Subject: Re: read files from dir then write as csv???
Message-Id: <399C27B9.9A7EF4AC@vpservices.com>

kingofkingston@my-deja.com wrote:
> 
> Hi there :-)
> 
> Note: Please bear in mind I am a newby to Perl and Unix!
> 
> We have a perl script that trawls through our oracle database every
> night and outputs a list of tables and the number of rows in the table
> into a new text file (eg.count20000816.txt, for todays date). The
> contents of the resulting text file look like this:
> 
> Table Name,16/08/2000
> ATTACH,119
> BLOB,1258
> BRANCH,612
> CATEGORY,2
> 
> (the number after the table name indicates the number of rows in that
> table).
> 
> What I would like to do is evaluate the rate at which our tables are
> growing. So I need to read the contents of all the files, and then
> output a single CSV file which can be imported into MS Excel and show
> graphical representations of the data.

There are many ways to do this.  Here is one way using DBI (which you
are probably already using for Oracle) and DBD::RAM.  It creates a
single CSV file called 'alldata.csv' that has three columns --
table_name, date, and rows.  It gathers its data from whatever list of
files you feed it (just put in your list of files where I have
'clpm1','clpm2', etc.

#!/usr/local/bin/perl -w
use strict;
use DBI;
my $dbh = DBI->connect('DBI:RAM:',,,{RaiseError=>1});
$dbh->func([['alldata','CSV','alldata.csv']],'catalog');
$dbh->do(qq/
    CREATE TABLE alldata (
        table_name TEXT,
        date       TEXT,
        rows       INTEGER
)/);
my $sth = $dbh->prepare(qq/
    INSERT INTO alldata VALUES(?,?,?)
/);
for my $file('clpm1','clpm2') {
    open(IN,$file) or die "Can't open $file: $!";
    my $date = <IN>;
    $date =~ s/.*,(.*)\n/$1/;
    while (<IN>) {
        chomp;
        my($table_name,$rows) = split ',';
        $sth->execute($table_name,$date,$rows);
    }
    close(IN) or die "Can't close $file: $!";
}
__END__

-- 
Jeff


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

Date: Thu, 17 Aug 2000 11:09:42 -0400
From: Kevin <kevin.costantino.b@bayer.com>
Subject: Reading a %hash of Directory names
Message-Id: <399C0036.C9A04190@bayer.com>

Im reading a hash with directory names in it, in a while loop.
I'm using the "=each" operator and assigning them the classic $k for key
and $v for value. Then I try to "chdir $k || die $!" to change
directories, but each time it reaches this point it dies with a "No such
file or directory". But if I use "$k = "directory name" it works. WTF? I
even tried reading it from an @array and it didn't work either. I really
need the functionality of a %hash because I'm using dir. pairs. This is
running on AIX, am I missing some sytax or something ???

]{evin



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

Date: Thu, 17 Aug 2000 12:36:42 -0400
From: Kevin <kevin.costantino.b@bayer.com>
Subject: Re: Reading a %hash of Directory names
Message-Id: <399C149A.E6A3B84B@bayer.com>

Duh...Got it. Had to chomp($k);
:D

Kevin wrote:

> Im reading a hash with directory names in it, in a while loop.
> I'm using the "=each" operator and assigning them the classic $k for key
> and $v for value. Then I try to "chdir $k || die $!" to change
> directories, but each time it reaches this point it dies with a "No such
> file or directory". But if I use "$k = "directory name" it works. WTF? I
> even tried reading it from an @array and it didn't work either. I really
> need the functionality of a %hash because I'm using dir. pairs. This is
> running on AIX, am I missing some sytax or something ???
>
> ]{evin



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

Date: 17 Aug 2000 17:46:38 +0100
From: nobull@mail.com
Subject: Re: Reading a %hash of Directory names
Message-Id: <u9wvhfn8y4.fsf@wcl-l.bham.ac.uk>

Kevin <kevin.costantino.b@bayer.com> writes:

> Im reading a hash with directory names in it, in a while loop.
> I'm using the "=each" operator and assigning them the classic $k for key
> and $v for value. Then I try to "chdir $k || die $!" to change
> directories, but each time it reaches this point it dies with a "No such
> file or directory". But if I use "$k = "directory name" it works. WTF? I
> even tried reading it from an @array and it didn't work either. I really
> need the functionality of a %hash because I'm using dir. pairs. This is
> running on AIX, am I missing some sytax or something ???

You have written a lot of prose here.  Please don't.  Write as short
bit of Perl that is actually runnable and actually illustrates the
problem you are exeperiencing. There are several reasons why this is
better - here are just a few:
  
  Experts here all speak Perl "like a native" but to some English is a
  second lanugage.

  Even for native English speakers Perl code is easier to read that
  prose describing Perl code.

  You may not accurately describe what you are doing.

  You may not completely describe what you are doing.

  People may mis-read what you say.

  The problem may not be where you think it is.

  Distilling the problem down to an example script may be enough for
  you to solve the problem yourself.

Shot-in-the-dark.  You are using relative directory names and
forgetting to change back. 

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


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

Date: Thu, 17 Aug 2000 10:39:42 -0700
From: Pan <admin@salvador.venice.ca.us>
Subject: Re: Reading remote files
Message-Id: <399C235E.16763A6B@salvador.venice.ca.us>

What kind of files are you talking about?  If it is just text, http
might be a candidate.  But there are different methods for different
chores.  Anyone else using SIP-CGI ? 

Tony Curtis wrote:
> 
> >> On Thu, 17 Aug 2000 13:20:08 GMT,
> >> brian.russo@nextel.com said:
> 
> > Does anyone know if there is a way to read a file from a
> > remote (trusted) host? I would like to read the remote
> > file(s) and avoid nfs mounting the directory.
> 
> > Is there a perl module that can do this?
> 
> How do you intend to get the remote file?  ftp? scp?
> kerberised ftp? something else?
> 
> t
> --
> "I'm not easily impressed.  Wow!  A blue car!"
>                                                Homer Simpson

-- 
Salvador Peralta
admin@salvador.venice.ca.us
http://www.la-online.com


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

Date: Thu, 17 Aug 2000 17:30:06 +0100
From: "Dave Wishart" <dwishar1@ford.com>
Subject: References to hashes
Message-Id: <8nh3um$i1c5@eccws12.dearborn.ford.com>

Longish bit of code - sorry. Included for completeness.

I'm a bit stumped over a small section of code I now have to maintain.

sub store_transaction_info
{
        my ($my_key,$proptouse)=@_;
        my $my_chars_extracted=0;
        my $my_fieldnumber;
        my $my_fieldname;
        my $my_fieldlength; # Total length of field
        my $my_fieldsublength; # No of decimal places in field data. If 0
then no decimal places involved.
        my $my_fieldtype;
        my $my_data;
        my $my_new_data;
        my $i;
        my $a;
        my $b;
        my $my_tmp_secondary_key;
        my %my_temp_transaction=();

        $i=0;

        for ($i=1;$i<=$ord_splitter_file{$my_key}->[0]{COUNT}; $i++)
            {
            $my_fieldnumber=0;
            $my_fieldname="";
            $my_fieldlength=0;
            $my_fieldsublength=0;
            $my_fieldtype="";
            $my_data="";
            $my_tmp_secondary_key="";
            $my_a="";
            $my_b="";
            $my_c="";

            $my_fieldname=$ord_splitter_file{$my_key}->[$i]{FIELDNAME};

$my_fieldnumber=$splitter_file{$my_key}{$my_fieldname}{FIELDNUMBER};

$my_fieldlength=$splitter_file{$my_key}{$my_fieldname}{FIELDLENGTH};

$my_fieldsublength=$splitter_file{$my_key}{$my_fieldname}{FIELDSUBLENGTH};
            $my_fieldtype=$splitter_file{$my_key}{$my_fieldname}{FIELDTYPE};


$my_temp_transaction{$my_fieldname}=substr($buffer,0,$my_fieldlength);
            $my_data=$my_temp_transaction{$my_fieldname};
            if (($my_fieldtype eq "Numeric") and !isnum($my_data))
                {
                data_error("C040",$my_fieldnumber,$my_fieldname);
                 }
            elsif (($my_fieldtype eq "Text") and !isascii($my_data))
               {
               data_error("C041",$my_fieldnumber,$my_key);
               } # end of if
          if ($my_fieldsublength != 0)
               {
               $my_newsublength=$my_fieldlength-$my_fieldsublength;
               ($my_a,$my_b,$my_c)=split(/(^.{$my_newsublength})/,$my_data);
               $my_new_data=$my_b.".".$my_c;
               }
        else
               {
               $my_new_data=$my_data;
               }
        print LOGFILE "$my_fieldnumber  $my_fieldname:$my_new_data\n";

        $buffer=substr($buffer,$my_fieldlength);
        $my_chars_extracted += $my_fieldlength;
         } # end of for


    if (($my_key eq "HEADER") or ($my_key eq "TRAILER"))
        {
        $my_propid="STANDARD";
        }
    elsif ($proptouse eq "USEUTF")
          {
          my $my_which_batch_key=$columntype{$key}{BATCH_KEY};
          $my_propid=$my_temp_transaction{$my_which_batch_key};
          }
     else
          {
          $my_propid=$proptouse;
          } # end of if

     if (((not $my_propid) or ($my_propid eq "0000")) and
($my_which_batch_key ne "NotApplicable"))
          {
          data_error("C010",$fieldnumber,$my_key);
          } # end of if

    $my_tmp_secondary_key=$columntype{$my_key}{SECONDARY_KEY};
    if (($my_tmp_secondary_key) and ($my_tmp_secondary_key ne
"NoSecondaryKey"))
        {
          $my_key="$my_temp_transaction{$my_tmp_secondary_key}:$my_key";
         } # end of if

 $$my_propid{$my_key}=\%my_temp_transaction;

    if (not ($transaction{$my_propid}))
  {
  $transaction{$my_propid}=\%{$my_propid};
  } # end of if

    $buffer =~ s/(^\s*)(.*?)/$2/;
    $my_chars_extracted += length ($1);
    return $my_chars_extracted;

} # end of store_transaction_info



The bit I'm stumped with is:-

 $$my_propid{$my_key}=\%my_temp_transaction;

    if (not ($transaction{$my_propid}))
  {
  $transaction{$my_propid}=\%{$my_propid};
  } # end of if


I think the line

 $$my_propid{$my_key}=\%my_temp_transaction;

assigns

$$my_propid{$my_key} ro a reference to a hash but I'm not sure of the
$$my_propid{$my_key} part. I think its a symbolic reference.

As for the if statement I don't really understand it. I did look at Camel
for advice but things aren't any clearer.

The hash 'transaction' hasn't been declared or used until this section of
code.

Ideally I'd like to use hard references but at the mo I'm sure of what the
codes does.

This is being run under 5.004 on Solaris 2.6



Thanks in advance.


Dave





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

Date: Thu, 17 Aug 2000 15:55:15 GMT
From: melet@my-deja.com
Subject: remove blanks
Message-Id: <8nh1sp$2nt$1@nnrp1.deja.com>

hello

I want to "how to remove blanks before and after a word?".


thanks. FRED


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


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

Date: Thu, 17 Aug 2000 16:20:56 GMT
From: Tom Briles <sariq@texas.net>
Subject: Re: remove blanks
Message-Id: <399C10FF.DA9A8AEA@texas.net>

melet@my-deja.com wrote:
> 
> I want to "how to remove blanks before and after a word?".

Hmmm...that looks alot like a troll.  A *quoted* FAQ, even.

- Tom


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

Date: 17 Aug 2000 17:55:41 +0100
From: nobull@mail.com
Subject: Re: remove blanks
Message-Id: <u9u2cjn7xu.fsf@wcl-l.bham.ac.uk>

melet@my-deja.com trolls:

> I want to "how to remove blanks before and after a word?".

How do you decide which word?  I'll assume that you want to pick one
at random.

$_=' this is a test string';

# Count number of words in string and choose one at random
my $n = int(rand @{[/\w+/g]});

# Remove blanks before and after the (n+1)th word.
s/^((?:\W*\w+){$n}.*?)\s+(\w+)\s+/$1$2/;

print;

Now, what was it you _really_ wanted to ask?  What is perhaps "Where did
I leave my Perl manual?"

Please put at least as much effort into working out what your question
is as you expect use to put in.

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


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

Date: Thu, 17 Aug 2000 16:46:16 +0100
From: "Steven Young" <steven@younghousehold.fsnet.co.uk>
Subject: RSA Encryption
Message-Id: <8nh17j$c8a$1@newsg3.svr.pol.co.uk>

I've decided to use RSA to encrypt an HTML form submission in my Perl script
before writing the data to a file on the web server. The Perl script will
encrypt the data using a public key and then another script or win32
application will decrypt the file using the private key combination.

Can anyone point me in the direction of some code / alogrithms to perform
these encryption functions and to generate a public / private key
combination? Is there a Perl module which can be used for this and if so, is
it a module included as standard with Perl 5.x as I need it to run it on
many different systems.

Thanks in advance for any help,
Steven Young
steven@younghousehold.fsnet.co.uk




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

Date: Thu, 17 Aug 2000 17:45:16 +0200
From: "Guenther Degenfelder" <guenther.degenfelder@datev.de>
Subject: Running Perl-Script as NT-Service
Message-Id: <399c0912$1@news.datev.de>

Yes. Very ugly. I know...

The script should run on Windows NT (and 2K). It should run ALLWAYS (without
a user logged in - and without autologon hacks).

I can't schedule it. The script will observe any services or applications -
the scheduler too...

And i can't install LINUX first!    ;-)

Any hints?!

Post it into NT newsgroup???!!!

rgds

    Guenther




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

Date: 17 Aug 2000 17:49:51 +0100
From: nobull@mail.com
Subject: Re: Running Perl-Script as NT-Service
Message-Id: <u9vgwzn8us.fsf@wcl-l.bham.ac.uk>

"Guenther Degenfelder" <guenther.degenfelder@datev.de> writes:

> Yes. Very ugly. I know...
> 
> The script should run on Windows NT (and 2K). It should run ALLWAYS (without
> a user logged in - and without autologon hacks).
> 
> I can't schedule it. The script will observe any services or applications -
> the scheduler too...
> 
> And i can't install LINUX first!    ;-)
> 
> Any hints?!
> 
> Post it into NT newsgroup???!!!

Someone may someday write a proper NT service Perl module.  Problem is
that for a process to act as a proper NT service necessarily implies
threads, and what's more the OS creates new threads not the app.
Until such time as Perl's threading is a bit more stable I don't see
this happening.  (I thought about it last time I needed a Perl script
to run as an NT service).

Simple solution: SRVANY from the "NT Resource Kit".  This shim allows
an simple EXE (e.g. Perl.exe) to run as a service.

Note: "NT Resource Kit" = "The bits of NT you need to make it half-way
usable as an OS but that Microsoft don't want to include in the
standard release because they can't be bothered to QA them even to
their usual standards".


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


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

Date: 17 Aug 2000 17:09:49 GMT
From: abigail@foad.org (Abigail)
Subject: Re: Sorting is very slow
Message-Id: <slrn8po71m.tj3.abigail@alexandra.foad.org>

Anno Siegel (anno4000@lublin.zrz.tu-berlin.de) wrote on MMDXLIII
September MCMXCIII in <URL:news:8ngl4b$lib$1@lublin.zrz.tu-berlin.de>:
() Sean Malloy  <srmalloy@home.com> wrote in comp.lang.perl.misc:
() >Jim Chim <mecks@ust.hk> wrote:
() >>    I have write a code to sort some meteorological data which contain
() >>281560 data point.
() >>And write a sortin scheme to sort it. I know bubble sort only. I found
() >>that it take more
() >>than 10 hours to sort the data in PIII 800MHz machine. Can anyone give
() >>me some idea
() >>of how to improve the scheme so that it work faster. Thanks.
() >>    My code is attached in this message.
() >
() >The bubble sort is an O(n^2) algorithm; that is, for any data volume
() >n, the amount of time the sort takes is proportional to the square of
() >n. It's a very bad sort algorithm, compared to others. Quicksort, for
() >example is O(n ln(n)) -- for a data volume n, the amount of time it
() >takes will be proportional to n times the natural log of n. So, for
() >any volume of data, quicksort will be (n/ln(n)) times faster. For
() >281560 data points, that comes out to 22438 times faster. For a
() >processing time of ~10 hours with bubblesort, you would need less than
() >1.75 hours with quicksort.
() 
() You don't understand what the O(f(n)) notation means.  Roughly speaking,
() it means that there is a constant A such that for large n the runtime
() of an algorithm is proportional to A*f(n).

That is incorrect. You will know that for large enough n, the runtime is
*less* than A*f(n). Heapsort and mergesort are both O (n log n), but they
are also O (n^2). You cannot say that one sorting algorithm is O (n^2)
and the other is O (n log n), the other is faster. As O (n^2) does not
imply it is not O (n log n). Bubble sort is Omega (n^2), and that's why
it's relatively slow. Note however that worst case, quicksort is Omega
(n^2) as well. If you know that your input is uniformly distributed,
quicksort has an O (n log n) expected running time. However, many
quicksort implementation act poorly on sorted, or nearly sorted data.
Perls implementation of quicksort uses a "middle-of-three" approach
to pick a pivot. This makes sorting sorted data fast (faster than 
randomly shuffled input, as it gets a perfect pivot each time), but
it's still easy to have input that makes the sorting algorithm behave
quadratic. See below.

()                                             So, if all you know is the
() asymptotic behavior, there is no way to predict, for a specific case,
() how big the gain of the faster algorithm will be over the slower one.
() All you know is, that for some (probably large) n there is a point
() where the fast method beats the slow one.

And you certainly won't know the difference in such exact numbers.
Big-Oh notation hides a constant, and constants can be very large or
very small.


Here's a benchmark that benchmarks Perls sorting algorithm for arrays of
various sizes, and with randomly shuffled data, sorted data, reverse sorted
data, and "organ piped" data (data that first increases, then decreases, or
the other way around). Note the quadratic behaviour or organ piped input.


#!/opt/perl/bin/perl -w

use strict;
use Benchmark;
use Algorithm::Numerical::Shuffle qw/shuffle/;

use vars qw /@sorted @reverse @organ @rev_organ @random/;

my $pid = open my $from => "-|";

die "Failed to fork: $!\n" unless defined $pid;

$| = 1;

unless ($pid) {
    # Child writes.
    for (my $size = 10; $size <= 2500; $size *= 2) {
        @sorted    =  map {sprintf "%06d" => $_} 1 .. $size;
        @reverse   =  reverse @sorted;
        @organ     = (@sorted  [1 .. $size / 2],
              reverse @sorted  [1 .. $size / 2]);
        @rev_organ = (@reverse [1 .. $size / 2],
              reverse @reverse [1 .. $size / 2]);
        @random    =  shuffle @sorted;

        print "SIZE: $size\n";

        timethese -2  => {
            sorted    => 'my @a = sort @::sorted',
            reverse   => 'my @a = sort @::reverse',
            organ     => 'my @a = sort @::organ',
            rev_organ => 'my @a = sort @::rev_organ',
            random    => 'my @a = sort @::random',
        };

    }

    exit;
}

# Parent.
my ($size, %times);
while (<$from>) {
    if (/^SIZE: (\d+)/) {
        $size = $1;
        next;
    }
    if (m{^\s*(\w+).*\@\s*(\d+\.\d+)/s}) {
        die "No size!\n" unless defined $size;
        $times {$1} {$size} = $2;
    }
}

# Do some formatting. For each size, find the longest result.
my %length;
my $length = 0;
foreach my $size (keys %{$times {random}}) {
    $length {$size} = 3 + length $size;
    foreach my $method (keys %times) {
        $length = length $method if length $method > $length;
        $length {$size} = length $times {$method} {$size} if
                          length $times {$method} {$size} > $length {$size};
    }
}

printf "%${length}s" => "Method";
foreach my $size (sort {$a <=> $b} keys %{$times {random}}) {
    my $format = $length {$size} - 3;
    printf " %${format}d   " => $size;
}
print "(Size)\n";

foreach my $method (qw /random sorted reverse organ rev_organ/) {
    printf "%${length}s" => $method;
    foreach my $size (sort {$a <=> $b} keys %{$times {$method}}) {
        printf " %$length{$size}.2f" => $times {$method} {$size};
    }
    print "\n";
}

__END__

   Method    10       20      40      80     160    320    640    1280   (Size)
   random 22198.23 10557.41 5373.30 2598.16 1141.67 509.17 233.94  104.57
   sorted 25284.65 14559.24 7155.72 3622.64 1619.43 802.40 360.73  178.33
  reverse 21585.57 12160.19 6227.67 2939.53 1439.61 658.88 328.17  150.23
    organ 21654.71  9545.12 3387.02 1066.67  293.27  81.34  20.20    5.14
rev_organ 21454.76  9569.63 3437.09 1063.80  309.72  81.73  20.74    5.16



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw\\- -eJust -eanother -ePerl -eHacker -e\\-]}-


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

Date: Thu, 17 Aug 2000 12:35:10 -0500
From: "Lithium" <lithium@ev1.net>
Subject: SUID in perl
Message-Id: <spo8e2bfr5j53@corp.supernews.com>

After asking a dumb question, doing research using the info I was
(thankfully) given, and going down a number of other avenues, I now know how
to write a program that uses suid in C (which is all the manpages seem to
cover on this area).  Regrettably, I needed to do this in perl.  I can't
find a command remotely like setuid or setguid or anything similar for perl,
and so far haven't found a module that seems to do something similar to the
c library for it.

I've learned perlsec issues inside out, I've secured out server (partially)
from sperl hacks, and I know quite a bit about tainting, etc... but nothing
useful so far for actually implementing any of it.  I'm not even sure if
this will allow a non-root-owned script to take on root access when run from
cgi (so we can do this thing and move on).

Anyone know where I can go for information on writing what every reference
refers to as a "setuid script"?  Or have a code example, or even just know
of a script that uses it that I can look at?






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

Date: Thu, 17 Aug 2000 17:01:01 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: Time stamp on Bulletin Board
Message-Id: <hTUm5.159$DT4.3928796@nnrp2.clara.net>

In article <8nfjg8$egn$1@nnrp1.deja.com>, gallantknave <gallantknave@my-deja.com> wrote:
>can get the time to show up for each message, but I get the same time
>for every message. When I refresh the page, which is an shtml page(I

*sigh* I really do hate critising people who are asking for help, but it is 
virtually impossible to help you based on what you've said. It may make 
sense to you, but you know what you're looking at. Without more information 
this is the best I can do:

Find the code where you're saving the message to disk and make sure it says 
something like:

  print OUTPUT_FH 'Date: ', scalar(localtime(time())), "\n";

When you're reading it back, make sure your code is using the value stored. 
If you're storing the data in a database of some sort you may find storing 
the time since epoch (number of seconds since 1/1/1970) is more useful. That 
way you can store it as its numeric value, rather than the ASCII characters 
representing that number. You'll also be able to pick and choose what you 
want to show:

  my($time) = time();  # pretend we read this from a file
  my(@dow) = qw(Sun Moon Tiw Wotan Thor Frigg Saturn);
  print "Posted on ", $dow[ (localtime($time))[6] ], "'s day.\n";

>timestamp for each refreshes as well.

This makes it sound even more like you are using the time 'now' and not the 
posting time. If you can't fiddle with the messages themselves, you could 
perhaps try for the timestamp of when the message was created (well, the 
last time it was changed) try using the -M operator (or stat())

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Thu, 17 Aug 2000 11:17:48 -0500
From: "Michael Segulja" <michael.segulja@sgi-lsi.com>
Subject: Re: Trouble installing Bundle::DBI
Message-Id: <deUm5.93086$iI5.1461697@news-west.usenetserver.com>

Yeah, I'm running everything as root.  It acts like it can't mysql.so, even
though it is there.

Any other ideas?


Thanks,
Michael


"NP" <nvp@spamnothanks.speakeasy.org> wrote in message
news:laFk5.458483$MB.6956056@news6.giganews.com...
> 10 Aug 2000 16:24:11 -0500, Michael Segulja <michael.segulja@sgi-lsi.com>
wrote:
> : I am using the CPAN shell to install the DBI module, and I'm having some
> : trouble.  I have actually tried it both ways, from the shell and by
>
> Sorry to ask an obvious question -- but you're running these tests as
> root, right?
>
> --
> Nate II
>






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

Date: Thu, 17 Aug 2000 17:19:45 GMT
From: newsgroups@ckeith.clara.net (Colin Keith)
Subject: Re: wav or mp3 perl module
Message-Id: <R8Vm5.160$DT4.3929521@nnrp2.clara.net>

In article <8nep4v$fl4$1@nnrp1.deja.com>, djberg96@my-deja.com wrote:
>Hi all,
>
>Can anyone out there direct me to a module that plays .mp3 or .wav
>files for both Win32 and Unix? I'm not looking for anything complex.
>Just play the stinkin' file.

The problem isn't the playing, they both have recognised formats so Perl can 
happily read the data. The problem is what to do with it. That is the 
platform specific bit and it isn't really something Perl can 'fix'. 

I don't believe there are any modules, so you might want to try playing 
using external programs based on the platform. Something like this wonky 
stuff:

  use Shell;

  my(%players) = (windows=>[qw(winamp mplayer)],
                  freebsd=>[ ... ],
                  linux  =>[ ... ]);
  foreach (@{$players{windows}}){
    eval {
      &{$_}('xx');
    };
    warn "Couldn't find $_, searching .. " if($@);
  }
  

Col.


---
Colin Keith
Systems Administrator
Network Operations Team
ClaraNET (UK) Ltd. NOC


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

Date: Thu, 17 Aug 2000 17:23:11 GMT
From: xlr6drone@my-deja.com
Subject: wwwadmin.pl and deleting messages
Message-Id: <8nh716$9bi$1@nnrp1.deja.com>

Hi,

I am using Matt's wwwboard (scriptarchive.com) and
I am trying to modify the wwwadmin.pl file so that
entries older than a week will be deleted
automatically.

Is there a way to create a conditional statement
with the date function that will allow me to do
this?

Any suggestions are greatly appreciated.

I posted my code for wwwadmin.pl here:

http://home.mindspring.com/~lexmesa/stest/
wwwadmin.pl.txt

regards,

Tim


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


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

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


Administrivia:

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

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.

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

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

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


------------------------------
End of Perl-Users Digest V9 Issue 4047
**************************************


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