[19316] in Perl-Users-Digest
Perl-Users Digest, Issue: 1511 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Aug 13 18:05:56 2001
Date: Mon, 13 Aug 2001 15:05:16 -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: <997740315-v10-i1511@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Mon, 13 Aug 2001 Volume: 10 Number: 1511
Today's topics:
Re: $string = s/\|//g; error - why? <yf32@cornell.edu>
Re: Accessing a widget when defined local to a sub <gnarinn@hotmail.com>
Re: Accessing a widget when defined local to a sub <Pcmann1@btinternet.com>
Re: Accessing a widget when defined local to a sub <gnarinn@hotmail.com>
Re: array question... sort of <leary@foad.NOSPAM.org>
Re: ASCII-Code in perl <Jan.Krynicky@tmpw.cz>
Re: Can read, but can't write (sowbug)
Re: Can read, but can't write (Tad McClellan)
Re: Disk usage of file <sh@planetquake.com>
Re: Encrypted Email <gnarinn@hotmail.com>
FAQ: How can I open a file with a leading ">" or traili <faq@denver.pm.org>
Fork in background from a script in perl/Tk on remote s <cchatel@libertysurf.fr>
Re: Help - Substitution using a variable (pcsw2@hotmail.com)
How do I assing an entire array? (Stan Brown)
Re: How do I assing an entire array? <Tassilo.Parseval@post.rwth-aachen.de>
Re: How do I assing an entire array? <Tassilo.Parseval@post.rwth-aachen.de>
Re: How do I assing an entire array? <ilya@martynov.org>
Re: How do I assing an entire array? <pne-news-20010813@newton.digitalspace.net>
Re: MIME Type hash <iltzu@sci.invalid>
Re: Net::Ping troubles Solution <m96@gmx.li>
Re: NTTP > HTTP Gateway? (Randal L. Schwartz)
Read a file as STDIN in Windows NT <rob@_DONOTSPAM_symcas-tsg.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Mon, 13 Aug 2001 15:05:02 -0400
From: "Young C. Fan" <yf32@cornell.edu>
Subject: Re: $string = s/\|//g; error - why?
Message-Id: <9l98cu$c8i$1@news01.cit.cornell.edu>
"Richard Lawrence" <ralawrence@my-deja.com> wrote in message
news:b1b8a8d6.0108130625.62302061@posting.google.com...
> Hi all,
>
> I'm a little lost. Can someone please explain to me why:
>
> $string = s/\|//g;
>
> causes the error:
>
> Use of uninitialized value in substitution (s///)
<snip>
Rich, try:
$string =~ s/\|//g;
You forgot the ~ after the =.
Young
------------------------------
Date: Mon, 13 Aug 2001 18:54:35 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Accessing a widget when defined local to a sub
Message-Id: <997728875.752654464449733.gnarinn@hotmail.com>
In article <9l8tmv$ckh$1@uranium.btinternet.com>,
Peter Mann <Pcmann1@btinternet.com> wrote:
>
>Dear all,
>Thanks for the advice, but the code you suggested still doesn't allow me to
>access the combo1 from outside the 'donotebook' subroutine. For instance,
>upon pressing the button which calls 'comboInsert', the element still isnt
>inserted into the combo box!
>The code you provided only works within donotebook!
>Or im I missing some obvious point?
>
the advice was to have donotebook() return the insert closure.
so, in your code:
$comboinsert=donotebook();
and later:
$comboinsert->($item_to_be_inserted);
closures can be nice, but IMHO, not really relevant in your example.
you still have to store the closure in a global, so why not just have
the $combo object in a global. and what if you want 2 combo widgets?
gnari
------------------------------
Date: Mon, 13 Aug 2001 21:17:58 +0100
From: "Peter Mann" <Pcmann1@btinternet.com>
Subject: Re: Accessing a widget when defined local to a sub
Message-Id: <9l9ck2$a5$1@uranium.btinternet.com>
Dear All,
Thanks for all the advice, but I obviously dont understand some of the
concepts! I'll I am trying to achieve is a notebook style interface that has
a selection of widgets on each page of the notebook. Throughout my main
program I will populate some of the widgets and may need to access the
contents of widgets, i.e. 'text boxes' to insert into a database for
instance.
My probem is since they are defined using 'my', I cant seem to access them,
but I could before I made them local to the subroutine. Should I therefore
make them all global? But is this a good idea? The structure of the Notebook
follows the same format as an example I found, but im just not sure if this
is appropraite for what im trying to do. Since my notebook will hold about
six pages, I though it would be best to locate them all with a sub.
Im sorry, but I dont understand the following explanation,
> the advice was to have donotebook() return the insert closure. so, in your
code:
> $comboinsert=donotebook();
> and later:
> $comboinsert->($item_to_be_inserted);
>
> closures can be nice, but IMHO, not really relevant in your example. you
still have to store the closure in a global, so why not just have the $combo
object in a global. and what if you want 2 combo widgets?
I've inserted the code into the following code but im just not sure what it
will achive. And I dont know what IMHO means or why its not relevant to my
example. Would someone please explain in simple terms how this secion of
code should be best strcutured to achive what I require. Ive messed around
with the code for hours and just cant seem to acquire the solution which
seems very simple.
Many thanks in advance
- Pete
use Tk;
use Tk::DialogBox;
use DBI;
use Tk::NoteBook;
use Tk::LabEntry;
use TK::BrowseEntry;
use strict;
use vars qw($top);
$top = MainWindow->new;
my $pb = $top->Button(-text => "Notebook", -command => \&donotebook);
$pb->pack;
MainLoop;
my $f;
sub donotebook {
if (not defined $f) {
$f = $top->DialogBox(-title => "Example",
-buttons => ["OK", "Cancel"]);
my $n = $f->add('NoteBook', -ipadx => 6, -ipady => 6);
my $page1_p = $n->add("page1", -label => "Page 1");
my $page2_p = $n->add("page2", -label => "Page 2");
my $combo1=$page1_p->BrowseEntry(-label=>"combo box : ");
$combo1->pack(-side=>'top', -anchor=>'nw');
# $n->pageconfigure("page1", -createcmd=>sub{fillCombo($combo1)});
# What is the point of this?
my $insert_combo = sub {
my($text) = @_;
$combo1->insert('end', $text);
};
$page1_p->Button(-text=>"Go", -command=>\&fillCombo)
->pack(-side => 'top', -anchor => 'e');
$n->pack(-expand => "yes", -fill => "both", -padx => 5, -pady => 5,
-side => "top");
}
my $result = $f->Show;
}
#sub fillCombo
#{
# my $combo1=shift;
# $combo1->insert_combo('end', "one", "two", "three");
#}
# This still DOESNT work
sub fillCombo
{
my $comboinsert=donotebook();
$comboinsert->('five');
}
------------------------------
Date: Mon, 13 Aug 2001 21:32:42 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Accessing a widget when defined local to a sub
Message-Id: <997738362.637725888751447.gnarinn@hotmail.com>
In article <9l9ck2$a5$1@uranium.btinternet.com>,
Peter Mann <Pcmann1@btinternet.com> wrote:
>Dear All,
>Thanks for all the advice, but I obviously dont understand some of the
>concepts! I'll I am trying to achieve is a notebook style interface that has
>a selection of widgets on each page of the notebook. Throughout my main
>program I will populate some of the widgets and may need to access the
>contents of widgets, i.e. 'text boxes' to insert into a database for
>instance.
maybe we need to restart the discussion, to find out exactly what the
problem is. if i understand you correctly, you want to have a notebook
with several pages and several widgets that will be working in a
interactive manner.
your problem is that you want to minimize use of globals, which is akward
because each widget is accessed via its object interface.
now one way is to wrap all relevant subs in a block along with 'my'
declarations. the lexicals are visible within the block.
example:
my $var='a';
{
my $var=0;
sub func1 {
$var=shift;
}
sub func2 {
$var+=1;
}
sub func3 {
return $var;
}
}
# here $var is still 'a'
func1(42);
# here $var is still 'a'
$x=func3(); # returns 42
is this a solution to your problem ?
now, if we have the scenario that you want to have more than 1
notebooks with the same behaviour, but separate data, then a
OO model is more what you want.
gnari
P.S.: there nothing wrong with globals, just declare them with
use Vars qw(...);
------------------------------
Date: Mon, 13 Aug 2001 15:01:13 -0500
From: "Leary" <leary@foad.NOSPAM.org>
Subject: Re: array question... sort of
Message-Id: <HnWd7.20635$V43.1237142@e3500-atl1.usenetserver.com>
"Tad McClellan" <tadmc@augustmail.com> wrote;
> Leary <leary@foad.NOSPAM.org> wrote:
>
<snip>
>
> When you find yourself explicitly indexing into an array, you
> should pause and consider if you doing it the "non-Perl way".
> You seldom need to index arrays yourself in Perl:
>
> foreach my $aref ( @array ) {
> $tot += $aref->[8];
> }
>
This loop causes an error;
Use of uninitialized value in array element at C:\Perl\hsesum4.pl line 18,
<TEST
DATA> line 979.
I'm guessing that is just an eof thing since my sample data has exactly 979
lines in it, starting at one, not zero.
It also gives an incorrect total, 7785.25. The difference is the exact
amount of the first transaction in the sample data I am working with ...
could it have added that first element twice?
> Let perl manage the indexing for you. Machines make mistakes far
> less often than people do :-)
------------------------------
Date: Mon, 13 Aug 2001 18:48:54 GMT
From: Jenda Krynicky <Jan.Krynicky@tmpw.cz>
Subject: Re: ASCII-Code in perl
Message-Id: <1104_997728534@JENDA>
On Tue, 7 Aug 2001 09:57:21 +0200, "Manuel Körner" <manuel.koerner@rexroth.de> wrote:
> Hi to all,
>
> i want to know how i can get the ASCII-Code
> from a letter.
>
> Manuel
perldoc -f ord
Jenda
------------------------------
Date: 13 Aug 2001 11:57:05 -0700
From: brianwharris@hotmail.com (sowbug)
Subject: Re: Can read, but can't write
Message-Id: <c5d7d22b.0108131057.289963a@posting.google.com>
tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9nav4n.4nh.tadmc@tadmc26.august.net>...
> sowbug <brianwharris@hotmail.com> wrote:
> >I'm trying to write to an html file in htdocs with my perl script
> >that's in cgi-bin. Using Unix with Apache.
>
>
> Sounds like you are writing a Perl program that runs in
> a CGI environment...
> yeh, duh
>
> >The script is executing
> >fine. I'm not getting any errors,
>
>
> Then you have already looked at your server logs to make sure
> that the die() didn't execute?
> Didn't I say I'm not GETTING ANY ERRORS??
>
> >but it will simply not write to the
> >file.
>
>
> >I have even given all permissions to htdocs to everyone.
>
>
> That is a very very very poor attempted solution.
>
> Hope you have good backups, and no private information there...
>
>I only tried it for a minute, then switched back. I'm not stupid.
> >It will
> >write to the file if and only if I put it in the same directory.
>
>
> The same directory as what?
>
> The cgi-bin directory. Are you familiar with an apache server?
> >Please help!
>
>
> If the die() is not executing, then I don't see how it can
> not be writing.
>
> I'd bet the die() _is_ executing though, so find the message in
> the server log and $! will tell you why the open() failed.
>
> Once again, there are no errors. LOGS HAVE BEEN CHECKED.
> >$file2 = "/htdocs/favlinks.html";
> >open (INFILE, ">$file2") || die("favlinks.html does not exist: $!");
> ^^
> ^^
>
> That is a might strange choice of filehandle for a file opened
> for OUTput. Do you get bonus points for confusing yourself?
>
>Do you get a cookie for insulting people?
> >print INFILE "\<html\>" . "\<head\>" . "\<title\>" . "\<\/title\>";
>
>
> Not a single one of those backslashes are needed. Do you get
> paid by the character?
>
> print INFILE "<html><head><title></title>";
>
> Isn't that easier to read and understand?
Why don't you try helping people out more and insulting less
Mr. SGML??
------------------------------
Date: Mon, 13 Aug 2001 19:47:32 GMT
From: tadmc@augustmail.com (Tad McClellan)
Subject: Re: Can read, but can't write
Message-Id: <slrn9ng8ps.5vb.tadmc@tadmc26.august.net>
sowbug <brianwharris@hotmail.com> wrote:
>tadmc@augustmail.com (Tad McClellan) wrote in message news:<slrn9nav4n.4nh.tadmc@tadmc26.august.net>...
>> sowbug <brianwharris@hotmail.com> wrote:
>> >I'm trying to write to an html file in htdocs with my perl script
>> >that's in cgi-bin. Using Unix with Apache.
>> >The script is executing
>> >fine. I'm not getting any errors,
>>
>>
>> Then you have already looked at your server logs to make sure
>> that the die() didn't execute?
>
>> Didn't I say I'm not GETTING ANY ERRORS??
Yes, people say that here all of the time. Many do not know
to look in their server logs.
Don't be upset that lots of clueless folks have been here before
you. We have been conditioned by them. Sorry for misjudging you.
>> The cgi-bin directory. Are you familiar with an apache server?
No, and you would not expect that in a Perl newgroup.
Perl runs fine without apache. I do it all of the time.
You could expect that in a WWW newsgroup, but this is not such a newsgroup.
>> If the die() is not executing, then I don't see how it can
>> not be writing.
>>
>> I'd bet the die() _is_ executing though, so find the message in
>> the server log and $! will tell you why the open() failed.
>>
>> Once again, there are no errors. LOGS HAVE BEEN CHECKED.
Can't help you then. Sorry.
>> print INFILE "<html><head><title></title>";
>>
>> Isn't that easier to read and understand?
>
>Why don't you try helping people out more and insulting less
I help plenty of people here, over 8,000 last time I checked, but
you will not be one of them. So long.
*plonk*
[ I knew I should have trusted my domainist score rules.
I got what I deserved for dipping down into the negative
range. I should stop that too...
]
--
Tad McClellan SGML consulting
tadmc@augustmail.com Perl programming
Fort Worth, Texas
------------------------------
Date: Mon, 13 Aug 2001 19:41:23 GMT
From: "Sean Hamilton" <sh@planetquake.com>
Subject: Re: Disk usage of file
Message-Id: <D3Wd7.39331$uM6.5357359@news1.telusplanet.net>
I need to figure out what kind of space people are using so they can be
charged appropriately.
I don't need to be exact on this stuff, but obviously if somebody fills up
the drive with 1-byte files, I want to charge them for that drive, not for
the few megs that amounts to in file length.
sh
"Anno Siegel" <anno4000@lublin.zrz.tu-berlin.de> wrote in message
news:9l8cqe$eu8$1@mamenchi.zrz.TU-Berlin.DE...
> According to Sean Hamilton <sh@planetquake.com>:
> > How can I get the exact disk usage of a file, rather than the length of
that
> > file?
> >
> > Specifically I am trying to figure out how much disk space is used by a
> > file, or set of files, much like Win2k's "Size on Disk", except on
FreeBSD.
>
> You would have to define the difference.
>
> The only case I know of where file length and disk usage can be
> significantly different is a file with "holes" (unallocated blocks).
> Here the apparent file length can greatly exceed the space actually
> occupied on disk, but except for some databases these files are rare.
>
> Other considerations may concern the file's inode (which isn't included
> in the file length, but which isn't available for data storage anyway),
> fractional blocks (their influence is usually negligible), the space used
> by the directory entry (also negligible and arguably not part of the
file),
> and how to account for multiple hard links.
>
> So, what difference are you aiming at, and how does it matter?
>
> Anno
------------------------------
Date: Mon, 13 Aug 2001 18:27:00 +0000
From: gnari <gnarinn@hotmail.com>
Subject: Re: Encrypted Email
Message-Id: <997727220.722197456285357.gnarinn@hotmail.com>
In article <74f348f7.0108121502.1c259b6f@posting.google.com>,
Yves Orton <demerphq@hotmail.com> wrote:
>"Jeff Snoxell" <Jeff@aetherweb.co.uk> wrote in message news:<9l0kj0$sr1$1@neptunium.btinternet.com>...
>> Hi,
>>
>> Thanks for everyone's help with my BigInt and other problems.
>>
>> I'm still no closer to a solution however.
>>
>> I need a way to send 128-bit (minimum) encrypted emails from my ISP's linux
>> server to my Outlook Express inbox. I have CGI and FTP access to the server
>> but I don't have telnet and hence cannot easily install modules (I never
>> seem to have any luck with installing modules even when I do have telnet
>> access). I'm willing to spend a small amount of money to register some
>> shareware if necessary.
>
>I would have a look at OpenSSL if I were you. Nice command line SSL
>tool. You might have to look into the Mime:: tree for building more
>complicated mails (such as ones that contain attachments) but OpenSSL
>will handle the en/decryption/ authentication of mails using SMIME
>just fine.
unfortunately, OpenSSL needs compiling, thus shell access, so the OP
cannot install it.
However, there is a chance OpenSSL is already installed on the ISPs
server. then it is a question whether a cgi can find/use the tools
(i am assuming you meant to send the emails from cgi)
did you look at the crypt stuff on CPAN to see if there is some
pure-perl implementations you can use?
gnari
------------------------------
Date: Mon, 13 Aug 2001 18:17:02 GMT
From: PerlFAQ Server <faq@denver.pm.org>
Subject: FAQ: How can I open a file with a leading ">" or trailing blanks?
Message-Id: <yQUd7.84$V3.170285568@news.frii.net>
This message is one of several periodic postings to comp.lang.perl.misc
intended to make it easier for perl programmers to find answers to
common questions. The core of this message represents an excerpt
from the documentation provided with every Standard Distribution of
Perl.
+
How can I open a file with a leading ">" or trailing blanks?
Normally perl ignores trailing blanks in filenames, and interprets
certain leading characters (or a trailing "|") to mean something
special. To avoid this, you might want to use a routine like the one
below. It turns incomplete pathnames into explicit relative ones, and
tacks a trailing null byte on the name to make perl leave it alone:
sub safe_filename {
local $_ = shift;
s#^([^./])#./$1#;
$_ .= "\0";
return $_;
}
$badpath = "<<<something really wicked ";
$fn = safe_filename($badpath");
open(FH, "> $fn") or "couldn't open $badpath: $!";
This assumes that you are using POSIX (portable operating systems
interface) paths. If you are on a closed, non-portable, proprietary
system, you may have to adjust the ""./"" above.
It would be a lot clearer to use sysopen(), though:
use Fcntl;
$badpath = "<<<something really wicked ";
sysopen (FH, $badpath, O_WRONLY | O_CREAT | O_TRUNC)
or die "can't open $badpath: $!";
For more information, see also the new the perlopentut manpage if you
have it (new for 5.6).
-
Documents such as this have been called "Answers to Frequently
Asked Questions" or FAQ for short. They represent an important
part of the Usenet tradition. They serve to reduce the volume of
redundant traffic on a news group by providing quality answers to
questions that keep coming up.
If you are some how irritated by seeing these postings you are free
to ignore them or add the sender to your killfile. If you find
errors or other problems with these postings please send corrections
or comments to the posting email address or to the maintainers as
directed in the perlfaq manual page.
Answers to questions about LOTS of stuff, mostly not related to
Perl, can be found by pointing your news client to
news:news.answers
or to the many thousands of other useful Usenet news groups.
Note that the FAQ text posted by this server may have been modified
from that distributed in the stable Perl release. It may have been
edited to reflect the additions, changes and corrections provided
by respondents, reviewers, and critics to previous postings of
these FAQ. Complete text of these FAQ are available on request.
The perlfaq manual page contains the following copyright notice.
AUTHOR AND COPYRIGHT
Copyright (c) 1997-1999 Tom Christiansen and Nathan
Torkington. All rights reserved.
This posting is provided in the hope that it will be useful but
does not represent a commitment or contract of any kind on the part
of the contributers, authors or their agents.
05.15
--
This space intentionally left blank
------------------------------
Date: Mon, 13 Aug 2001 20:10:00 +0000
From: christian chatelain <cchatel@libertysurf.fr>
Subject: Fork in background from a script in perl/Tk on remote station (rsh)
Message-Id: <3B784227.1A4CCD1A@libertysurf.fr>
>
> I try to kill process on remote sun station from a perl/Tk script
> launch in background, in two way (calling two different procedures).
> Whatever the subprocess i call when my
> perl/Tk script is in background it stops and waits something on STDIN.
>
> If i launch my script in foreground there is nothing like that, all
> thing will be nice.
> Is there some one who know how i can workaround this problem.
>
> Below are the two procedures that give the same result.
>
> Thank you for your advice.
>
>
> ##################################################
> sub SelectKill {
> my ($pattern, $station)=@_;
> my @Fld;
>
> print STDOUT ("\nSelectKill_Debut $pattern $station\n");
>
> if ($station eq ""){print STDOUT ("No Station defined \n"); return;}
> system("rsh $station ps -ef 0</dev/null >/tmp/tmp$$") ;
> # here above i have try to redirect STDIN . That works fine, but only
> the first time i call this procedure!!!!
> # the second time the script stops.....and i must return my prog in
> foreground....
> open (PSEF, "</tmp/tmp$$") ;
> while (<PSEF>) {
>
> if (/$pattern/){
> @Fld = split(' ', $_, 9999);
> print STDOUT ("pid: $$, Fld: $Fld[1]\n");
> if ($Fld[1]!=$$){
> $PatternFound=1;
> print STDOUT ("rsh $station kill -9 :
> $_\n");
> system("rsh $station \"kill -9
> $Fld[1]\" ");
> }
> }
> }
> close (PSEF);
> #system ("rm /tmp/tmp$$");
> print STDOUT ("SelectKill_Fin\n");
> return;
> } # End SelectKill
> ##################
> #######################################################
> ##################################################
> # second implementation ###
> ##################################################
> #sub SelectKill {
> #my ($pattern, $station)=@_;
> #my @Fld;
> #
> # print STDOUT ("\nSelectKill_Debut $pattern $station\n");
> #
> # if ($station eq ""){print STDOUT ("No Station defined \n"); return;}
>
> # #Autre commande
> # die "fork impossible : $!" unless defined ($pid =open(FILS_A_LIRE,
> "-|"));
> #
> # if ($pid) { #processus pere
> # while (<FILS_A_LIRE>) {
> #
> # if (/$pattern/){
> # @Fld = split(' ', $_, 9999);
> # print STDOUT ("pid: $$, Fld: $Fld[1]\n");
> # if ($Fld[1]!=$$){
> # $PatternFound=1;
> # print STDOUT ("rsh $station kill -9 : $_\n");
> # system("rsh $station \"kill -9 $Fld[1]\" ");
> # }
> # }
> # }
> # close (FILS_A_LIRE) or warn "le processus fils a rendu la main $?";
>
> #
> # }else{ #processus fils
> # exec("rsh", "$station", "ps -ef") or die "exec de rsh impossible :
> $!";
> # }
> #
> # print STDOUT ("SelectKill_Fin\n");
> # return;
> #} # End SelectKill
>
------------------------------
Date: 13 Aug 2001 11:11:40 -0700
From: pcsw2@hotmail.com (pcsw2@hotmail.com)
Subject: Re: Help - Substitution using a variable
Message-Id: <fa78b2d2.0108131011.5a535d8@posting.google.com>
Thanks for the help on this one. More so, I learned a lot as well!
Carsten.
------------------------------
Date: 13 Aug 2001 14:54:28 -0400
From: stanb@panix.com (Stan Brown)
Subject: How do I assing an entire array?
Message-Id: <9l97p4$bab$1@panix2.panix.com>
I'm trying to assign the entire contents of an array (as an array. here is
what I'm trying:
$cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
Here is where I declare the array:
my ($pk_table, @p_keys)
But what I;m getting is just the qunatity of elements in the array.
What am I doing wrong?
Heres what Dump() has to say about this:
$VAR7 = 'CONSUMER_BRKR';
$VAR8 = {
'NULLABLE' => 'N',
'SRC_COLS' => [
2
],
'SRC_TABLE' => 'BRKR',
'DATA_LENGTH' => '5',
'MASTER_FK' => 1,
'DATA_SCALE' => undef,
'DATA_PRECISION' => undef,
'DATA_TYPE' => 'VARCHAR2'
};
------------------------------
Date: Mon, 13 Aug 2001 21:17:01 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How do I assing an entire array?
Message-Id: <3B7827AD.4080905@post.rwth-aachen.de>
Stan Brown wrote:
> I'm trying to assign the entire contents of an array (as an array. here is
> what I'm trying:
>
> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
The problem is that you try to assign an array to a hash-element. When
designing more complex data-structures you have to bear in mind that
elements of arrays or hashes may only contain scalar variables. Going
along with this, if you want to store the array, you have to use a
reference to the array:
$cols{$f_keys[0]}{'SRC_COLS'} = \@p_keys; # or: $... = [ @p_keys ];
Tassilo
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: Mon, 13 Aug 2001 21:18:18 +0200
From: Tassilo von Parseval <Tassilo.Parseval@post.rwth-aachen.de>
Subject: Re: How do I assing an entire array?
Message-Id: <3B7827FA.5060506@post.rwth-aachen.de>
Tassilo von Parseval wrote:
> Stan Brown wrote:
>
>> I'm trying to assign the entire contents of an array (as an array.
>> here is
>> what I'm trying:
>>
>> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
[...]
Little addition: Do a 'perldoc perldsc' to read a little about complex
data-structures in Perl.
--
$a=[(74,116)];$b=[($a->[1]-1,$a->[1]++,0x20)];$c=[(97,110)];$d=[($c->
[1]+1,$b->[1],"her")];for(@{[$a,$b,$c,$d]}){for(@{$_}){$_=~/\d+/?print
(chr($_)):print;}}$c=sub{$l=shift;[(0x20+$l-1,0x50,0x65,0x73-0x01,108
),(0x20,0x68,0x61,)]};print(map{chr($_)}@{($c->(1))});$h={a=>33*3,b=>
10**2+7,c=>"1"."0"."1",d=>0162};@h=sort(keys(%$h));for(@h){print(chr(
ord(chr($h->{$_}))))};
------------------------------
Date: 13 Aug 2001 23:28:59 +0400
From: Ilya Martynov <ilya@martynov.org>
Subject: Re: How do I assing an entire array?
Message-Id: <87hevbkbd0.fsf@abra.ru>
SB> I'm trying to assign the entire contents of an array (as an array. here is
SB> what I'm trying:
SB> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
SB> Here is where I declare the array:
SB> my ($pk_table, @p_keys)
SB> But what I;m getting is just the qunatity of elements in the array.
SB> What am I doing wrong?
SB> Heres what Dump() has to say about this:
SB> $VAR7 = 'CONSUMER_BRKR';
SB> $VAR8 = {
SB> 'NULLABLE' => 'N',
SB> 'SRC_COLS' => [
SB> 2
SB> ],
SB> 'SRC_TABLE' => 'BRKR',
SB> 'DATA_LENGTH' => '5',
SB> 'MASTER_FK' => 1,
SB> 'DATA_SCALE' => undef,
SB> 'DATA_PRECISION' => undef,
SB> 'DATA_TYPE' => 'VARCHAR2'
SB> };
$cols{$f_keys[0]}{'SRC_COLS'}['scols'] is same as
$cols{$f_keys[0]}{'SRC_COLS'}[0] and it is a scalar
@p_keys is scalar context gives qunatity of elements in the array.
If you need to assign entire contents of an array to scalar you should
use array reference. Either [ @p_keys ] (anonymous reference with copy
of your array) or \@p_keys (reference on your array) instead of just
@p_keys.
--
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
| Ilya Martynov (http://martynov.org/) |
| GnuPG 1024D/323BDEE6 D7F7 561E 4C1D 8A15 8E80 E4AE BE1A 53EB 323B DEE6 |
| AGAVA Software Company (http://www.agava.com/) |
-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
------------------------------
Date: Mon, 13 Aug 2001 21:49:17 +0200
From: Philip Newton <pne-news-20010813@newton.digitalspace.net>
Subject: Re: How do I assing an entire array?
Message-Id: <umbgnt4afkqt6s51chgpppedll3qgo1285@4ax.com>
On 13 Aug 2001 14:54:28 -0400, stanb@panix.com (Stan Brown) wrote:
> $cols{$f_keys[0]}{'SRC_COLS'}['scols'] = @p_keys;
^^^^^^^
This string will be converted to the number 0 so that it can be used as
an array index. This is unlikely to be what you want -- or if it is,
that's not a good way to do it.
(Changing that won't solve your problem, but I thought I'd point it out
to you. See Tassilo's posts for more information, or use @{ ... } = ...)
Cheers,
Philip
--
Philip Newton <nospam.newton@gmx.li>
That really is my address; no need to remove anything to reply.
If you're not part of the solution, you're part of the precipitate.
------------------------------
Date: 13 Aug 2001 18:09:32 GMT
From: Ilmari Karonen <iltzu@sci.invalid>
Subject: Re: MIME Type hash
Message-Id: <997724809.24176@itz.pp.sci.fi>
In article <3B6FED28.6AD4952C@sxb.bsf.alcatel.fr>, Philippe PERRIN wrote:
>
>I need to know MIME types associated with file extensions, such as
>'image/gif' for 'gif' or 'video/mpeg' for 'mpg'.... (see a good list at
>http://www.utoronto.ca/ian/books/html4ed/appb/mimetype.html)
>
>I've started typing a hash to use with pattern matching... it works, but
>I wonder if someone has already done it (quite long to type) ?
If you're on a unix box, take a look at /etc/mime.types. The Apache web
server uses a similar file, but usually places it under /etc/httpd/conf/
or some other Apache-specific directory.
You might also consider parsing the data on the page you quoted instead
of retyping it. (Ask permission if this is for more than just personal
use.)
--
Ilmari Karonen -- http://www.sci.fi/~iltzu/
"Get real! This is a discussion group, not a helpdesk. You post something,
we discuss its implications. If the discussion happens to answer a question
you've asked, that's incidental." -- nobull in comp.lang.perl.misc
------------------------------
Date: Mon, 13 Aug 2001 20:43:08 +0200
From: "m96" <m96@gmx.li>
Subject: Re: Net::Ping troubles Solution
Message-Id: <pan.2001.08.13.20.43.03.763.13359@gmx.li>
hi,
i have the same problem on linux - perl 5.6.
icmp works fine as root but as a normal user i can't ping any host.
regards,
alias m96.
In article <maBa7.1280$TQ6.197874@news-nb00s0.nbnet.nb.ca>, "Brian McGee"
<mcgeeb@jot.nb.ca> wrote:
> The solution (or at least the one I wound up using):
>
> Net::Ping->ping() or Net::Ping->ping('udp') is not recognized by many
> servers, so they are reported as inactive even though they are up and
> running.
>
> Net::Ping->ping('tcp') will not work on ActivePerl. ActivePerl does not
> have the alarm
> function, required for this method. Note: if ActivePerl does have an
> alarm function or the function
> can be added, please let me know as I would like to be able to the the
> tcp ping method.
>
> Net::Ping->ping('icmp') needs administrative priviledges to run
> correctly. As soon as I told IIS to run that cgi file as an
> administrator, it worked perfectly and was recognized by the NT, 2000
> and Linux machines on which I tested it.
>
> I just thought I would share the solution as I did share the problem
> too. Maybe it will help someone else.
>
> -Brian
>
>
>
> "Brian McGee" <mcgeeb@jot.nb.ca> wrote in message
> news:0Jwa7.1219$TQ6.191971@news-nb00s0.nbnet.nb.ca...
>> On an NT based machine running ActivePerl 5.6+, I can not get Net::Ping
>> to behave.
>>
>> The following code always says that my server does not exist
>>
>> use Net::Ping;
>>
>> my $ping = Net::Ping->new();
>> print "The result of pinging $address is: ", $ping->ping($address);
>> $ping->close();
>>
>> I have experimented with new('tcp') and new ('icmp') but I get the
>> errors
>>
>> The Unsupported function alarm function is unimplemented at
>> D:/Perl/lib/Net/Ping.pm line 308.
>>
>> and
>>
>> icmp socket error - Unknown error at c:\inetpub\wwwroot\test1.pl line
>> 11
>>
>> respectively. Any ideas? It is a simple function but it seems to have
>> just stopped up on me.
>>
>> -Brian
>>
>>
>>
>
------------------------------
Date: 13 Aug 2001 11:51:16 -0700
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: NTTP > HTTP Gateway?
Message-Id: <m1bsljztcr.fsf@halfdome.holdit.com>
>>>>> "Terence" == Terence Cooling <webmaster@1360squadron.co.uk> writes:
Terence> I've been looking for an example of a perl NTTP > HTTP
Terence> gateway for quite some time and have yet to turn one up. My
Terence> old system used a PHP version, but since my change in servers
Terence> I can only use ASP or perl - any ideas?
Do you mean something like this:
<http://www.stonehenge.com/merlyn/WebTechniques/col62.html>
--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn@stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
------------------------------
Date: Mon, 13 Aug 2001 14:47:05 -0700
From: "Robert Cervantez" <rob@_DONOTSPAM_symcas-tsg.com>
Subject: Read a file as STDIN in Windows NT
Message-Id: <3b7846a1_1@news.vic.com>
Hello,
I'm using ActiveState Perl on a Windows NT 4.0 box. I have a script which
is expecting <STDIN>, but NT doesn't seem to handle this properly. In its
stead, I would like to have the script access the file from disk and process
it as it would had it been STDIN.
The goal of this script is to read certain values from the email message on
disk and return the proper values. The details of the script aren't
important, but the method of opening/accessing the file is.
sub read_input {
undef $input;
# I know I need to modify the while ($_ - <STDIN>) line below, but I don't
know how to make the
#script read a file from disk as STDIN
#
while ($_ = <STDIN>) {
$input .= $_;
}
#
#
$input =~ s/\r\n/\n/g;
$input =~ s/\r/\n/g;
$username_text = $L{EMAIL_REPLY_USERNAME_TEXT};
$username_text =~ s/^\s+//;
$username_text =~ s/\s+$//;
$password_text = $L{EMAIL_REPLY_PASSWORD_TEXT};
$password_text =~ s/^\s+//;
$password_text =~ s/\s+$//;
print "Username text: '$username_text'\n" if $DEBUGGING;
print "Password text: '$password_text'\n" if $DEBUGGING;
my ($headers, $body) = split(/\n\n/, $input, 2);
if ($headers =~ m|X-Loopback-Stopper: 1|) {
print "Incoming message has loopback stopper flag set\n" if $DEBUGGING;
exit(0);
}
return ($headers, $body);
}
Thanks in advance,
Rob.
------------------------------
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 1511
***************************************