[17674] in Perl-Users-Digest
Perl-Users Digest, Issue: 5094 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Dec 12 21:05:33 2000
Date: Tue, 12 Dec 2000 18:05:13 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <976673113-v9-i5094@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 12 Dec 2000 Volume: 9 Number: 5094
Today's topics:
Re: =~ operator (Tad McClellan)
ANNOUNCE: DDL::Oracle v0.24 <rsutherland@In-Touch.net>
ANNOUNCE: Tie::RangeHash v0.40 released <wlkngowl@unix.asb.com>
Re: Better way to remove lines from output? <khedger@mindspring.com>
Re: Better way to remove lines from output? <mbudash@sonic.net>
Date::Manip. how to calc "days ago"? upuautiii@my-deja.com
Re: Date::Manip. how to calc "days ago"? <mbudash@sonic.net>
Re: DBI prepare method <godoy@conectiva.com>
Re: DBI prepare method <jeff@vpservices.com>
GD::Graph nodo70@my-deja.com
Re: Help! Problem with file uploads using CGI module (David Efflandt)
Re: huh ?? (Randal L. Schwartz)
Re: implicit creation of array? (Tad McClellan)
Re: implicit creation of array? (Garry Williams)
Re: Looking for GREP examples <godoy@conectiva.com>
make a call to ReadParse?? manon_bertolini@mantacorp.com
multiple recipients using Net::SMTP <kandeb@spamcop.net>
Re: net:ping - problem in windows 2000 (Charles DeRykus)
Re: networking... (Martien Verbruggen)
Newbie: Uploading File <scott@sciteq.com.au>
Re: ON - INTERNET TELE COMMUTE ONLY - PERL - Java - Js <lmoran@wtsg.com>
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 12 Dec 2000 17:35:08 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: =~ operator
Message-Id: <slrn93ddhc.11j.tadmc@maxim.metronet.com>
[ Jeopardectomy performed ]
guthrie_linck@my-deja.com <guthrie_linck@my-deja.com> wrote:
>In article <3A368B3D.F52BBBD2@nowhereatall.com>,
> mothra <mothra@nowhereatall.com> wrote:
>> Martin Schmidt wrote:
>> > What is the =~ operator called?
>it is the pattern match operator.
No it isn't.
m// is the pattern match operator.
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Sat, 9 Dec 2000 20:01:43 -0500
From: "Richard Sutherland" <rsutherland@In-Touch.net>
Subject: ANNOUNCE: DDL::Oracle v0.24
Message-Id: <t3dh1f1tu0qb34@corp.supernews.com>
============================================================================
==
Release of version 0.24 of DDL::Oracle
============================================================================
==
NAME
DDL::Oracle - a DDL generator for Oracle8i databases
DESCRIPTION
Overview
Designed for Oracle DBA's and users. It reverse engineers
database objects (tables, indexes, users, profiles, tablespaces,
roles, constraints, etc.). It generates DDL to *resize* tables
and indexes to the provided standard or to a user defined
standard.
We originally wrote a script to defrag tablespaces, but as DBA's
we regularly find a need for the DDL of a single object or a
list of objects (such as all of the indexes for a certain
table). So we took all of the DDL statement creation logic out
of defrag.pl, and put it into the general purpose DDL::Oracle
module. DDL::Oracle was then expanded to include tablespaces,
users, roles, and all other dictionary objects. The completely
revised program 'defrag.pl' is included with the distribution.
Oracle tablespaces tend to become fragmented (now THAT's an
understatement). Even when object sizing standards are adopted,
it is difficult to get 100% compliance from users. And even if
you get a high degree of compliance, objects turn out to be a
different size than originally thought/planned -- small tables
grow to become large (i.e., hundreds of extents); what was
thought would be a large table ends up having only a few rows.
And so forth. So the main driver for creating DDL::Oracle was
the object management needs of Oracle DBA's. The "resize" method
generates DDL for a list of tables or indexes. For partitioned
objects, the "appropriate" size of EACH partition is calculated
and supplied in the generated DDL.
Other uses.
Our user management mainly consists of creating a new user with
the identical privileges of an existing user, so "copy_user.pl"
and "copy_user.sh" wrappers supply this functionality.
What if you have to create a copy of an instance for some reason
-- a QA database, or a new host? Oracle's export utility can
move the instance objects if the new database exists, but it
won't create the tablespaces and their datafiles. Our data
warehouse databases have dozens of tablespaces and hundreds of
data files. How do you create the DDL for that? DDL::Oracle has
this capability.
A hole in Oracle's Designer/2000 case tool is the DDL for
changes to a table's structure. It produces reports of tables
that change, and handles adding columns if they are added to the
end of the table. Our data model czar has a penchant for adding
columns in the MIDDLE of the table (imagine that!). This
requires moving the data from the old table to the new
structure. Designer/2000 supplies no assistance for this
situation. DDL::Oracle will, in a future release.
DBA's, what are your suggestions?
Initialization and Constructor
configure
The configure method is used to define the DBI connection and to
set several session level options. These are:
dbh A reference to a valid DBI connection (obtained via
DBI->connect). This is a mandatory argument.
NOTE: The user connecting MUST have SELECT privileges
on the following (in addition to the DBA or USER
views):
V$INSTANCE
V$PARAMETER
schema Defines whether and what to use as the scema for DDL
on objects which use this syntax. "1" means use the
owner of the object as the schema; "0" means omit the
schema syntax; any other arbtrary string will be
imbedded in the DDL as the schema. The default is "1".
resize Defines whether and what to use in resizing segments.
"1" means resize segments using the default algorithm;
"0" means keep the current INITIAL and NEXT values; any
other string will be interpreted as a resize definition.
The default is "1".
view Defines which Dictionary views to query: DBA or USER
(e.g., DBA_TABLES or USER_TABLES). The default is DBA.
new
The new method is the object constructor. The two mandatory
object definitions are defined by calling this method, to wit:
type The type of object (e.g., TABLE, INDEX, SYNONYM, table
family, etc.).
For 'table family', supply the name(s) of tables -- the
DDL will include the table and its:
Comments (Table and Column)
Indexes
Constraints
Triggers
list An arrayref to an array of arrayrefs (as in the DBI's
"fetchall_arrayref" method) containing pairs of owner and
name.
Object methods
create
The create method generates the DDL to create the list of Oracle
objects.
drop
The drop method generates the DDL to drop the list of Oracle
objects.
resize
The resize method generates the DDL to resize the list of Oracle
objects. The 'type' defined in the 'new' method is limited to
'index' and 'table'. For tables, this generates an ALTER TABLE
MOVE statement; for indexes, it generates an ALTER INDEX REBUILD
statement. If the table or index is partitioned, then a
statement for each partition is generated.
To generate DDL for a single partition of an index or table,
define the 'name' as a colon delimited field (e.g.,
'name:partition').
SYNOPSIS
use DBI;
use DDL::Oracle;
my $dbh = DBI->connect(
"dbi:Oracle:dbname",
"username",
"password",
{
PrintError => 0,
RaiseError => 1
}
);
# Use default resize and schema options.
# query default DBA_xxx tables (could use USER_xxx for non-DBA types)
::Oracle->configure(
dbh => $dbh,
resize => 1
schema => 1
view => 'dba'
);
# Create a list of one or more objects
my $sth = $dbh->prepare(
"SELECT
owner
, name
FROM
user_tables
WHERE
tablespace_name = 'MY_TBLSP' -- your mileage may vary
"
);
$sth->execute;
my $list = $sth->fetchall_arrayref;
my $obj = DDL::Oracle->new(
type => 'table',
list => $list, );
);
my $ddl = $obj->create; # or $obj->resize; or $obj->drop;
print $ddl; # Use STDOUT so user can redirect to desired file.
FILES
ddl.pl
defrag.pl
copy_user.pl
copy_user.sh
README
README.defrag
AUTHOR
Richard V. Sutherland
rvsutherland@yahoo.com
COPYRIGHT
Copyright (c) 2000, Richard V. Sutherland. All rights reserved.
This module is free software. It may be used, redistributed,
and/or modified under the same terms as Perl itself. See:
http://www.perl.com/perl/misc/Artistic.html
==============================================================================
AVAILABILITY
DDL::Oracle has been uploaded to the CPAN and is also available from:
http://sourceforge.net/projects/ddl-oracle
==
============================================================================
------------------------------
Date: Mon, 11 Dec 2000 20:44:28 -0500
From: Robert Rothenburg <wlkngowl@unix.asb.com>
Subject: ANNOUNCE: Tie::RangeHash v0.40 released
Message-Id: <t3dh167ng12e2c@corp.supernews.com>
A mutatation of the README, Changes, and POD are below:
NAME
Tie::RangeHash - Implements "range hashes" in Perl
SYNOPSIS
use Tie::RangeHash;
tie %hash, Tie::RangeHash;
$hash{'A,C'} = 1;
$hash{'D,F'} = 2;
$hash{'G,K'} = 3;
$hash{'E'}; # returns '2'
$hash{'BB'}; # returns '1'
$hash{'KL'}; # returns nothing ('undef')
DESCRIPTION
This module allows hashes to associate a value with a *range* of
keys
rather than a single key.
More detailed descriptions are available in the documentation and
README.
AVAILABILITY
It should show up soon at a CPAN mirror near you in as:
$CPAN/authors/id/R/RR/RRWO/Tie-RangeHash-0.40.tar.gz
HISTORY
Changes since Tie::RangeHash v0.20:
0.40 11 Dec 2000
- fixed bug where EXISTS method missed $hash{'low,high'} = undef
- some minor optimizations
- corrected outdated descriptions in the comments
- added DELETE method
- _find_node() become _find_node_parent for use w/DELETE method
- fixed bug with adding undef node
- warnings are now disabled unless Perl is run with the -w flag
- test.pl will only use Time::HiRes if it is available
- other misc. changes to test.pl
0.30 9 Dec 2000
- fixed bug with missing 'require Tie::Hash'
- overlapping or duplicate STORE now warns rather than dies
- added EXISTS method
- fixed bug with passing range keys (low,high) to FETCH
- Separator can now be a string or a Regexp
- Use of $Tie::RangeHash::SEPARATOR deprecated
- various speed optimizations in adding nodes and searching tree
- improved comments, renamed variables
- improved documentation
- changed to work with Perl 5.005 (not tested)
- added test.pl to distribution
------------------------------
Date: Wed, 13 Dec 2000 01:03:48 GMT
From: "bigtiny" <khedger@mindspring.com>
Subject: Re: Better way to remove lines from output?
Message-Id: <UVzZ5.100323$751.2448696@typhoon.ne.mediaone.net>
You forgot the closed } for the outer while loop.....
k
<Odd_Carnivals@yahoo.com> wrote in message
news:9163c7$2e9$1@nnrp1.deja.com...
> Hi Perl gurus,
>
> Any suggestions for how the following could be improved?
> What I'm doing is creating an output file that is identical
> to the input file minus the second, third and last lines,
> and with the linebreak removed from the next-to-last line
> (i.e. the last line of the output file).
>
> The following works, but I suspect there are better ways
> to do it (I'm new to Perl).
>
> $prev_line = <IN>; # Keep line 1.
> while($. < 3) {<IN>}; # Skip lines 2 & 3.
> while($line = <IN>) {
> print OUT ($prev_prev_line);
> $prev_prev_line = $prev_line;
> $prev_line = $line;
> }
> $prev_prev_line =~ s/\n//; #remove linebreak
> print OUT ($prev_prev_line);
>
>
> Thanks!
>
>
> Sent via Deja.com
> http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 17:43:05 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Better way to remove lines from output?
Message-Id: <mbudash-C8F5FD.17430512122000@news.pacbell.net>
In article <UVzZ5.100323$751.2448696@typhoon.ne.mediaone.net>,
"bigtiny" <khedger@mindspring.com> wrote:
> <Odd_Carnivals@yahoo.com> wrote in message
> news:9163c7$2e9$1@nnrp1.deja.com...
> > Hi Perl gurus,
> >
> > Any suggestions for how the following could be improved?
> > What I'm doing is creating an output file that is identical
> > to the input file minus the second, third and last lines,
> > and with the linebreak removed from the next-to-last line
> > (i.e. the last line of the output file).
> >
> > The following works, but I suspect there are better ways
> > to do it (I'm new to Perl).
> >
> > $prev_line = <IN>; # Keep line 1.
> > while($. < 3) {<IN>}; # Skip lines 2 & 3.
> > while($line = <IN>) {
> > print OUT ($prev_prev_line);
> > $prev_prev_line = $prev_line;
> > $prev_line = $line;
> > }
> > $prev_prev_line =~ s/\n//; #remove linebreak
> > print OUT ($prev_prev_line);
> >
>
>
> You forgot the closed } for the outer while loop.....
>
> k
>
the first while loop isn't an outer, it's just a while loop:
while($. < 3) {<IN>}; # Skip lines 2 & 3.
??
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: Wed, 13 Dec 2000 00:18:56 GMT
From: upuautiii@my-deja.com
Subject: Date::Manip. how to calc "days ago"?
Message-Id: <916f9a$d25$1@nnrp1.deja.com>
I read Date::Manip's doc, and could not find how to do what I need to
do.
I want to be able to calculate the diffrence between two days, and have
the result in the format: X days ago, or, Y days ahead.
I know it's possible, but I can't figure it out.
thanks
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 17:39:50 -0800
From: Michael Budash <mbudash@sonic.net>
Subject: Re: Date::Manip. how to calc "days ago"?
Message-Id: <mbudash-225CFC.17395012122000@news.pacbell.net>
In article <916f9a$d25$1@nnrp1.deja.com>, upuautiii@my-deja.com wrote:
> I read Date::Manip's doc, and could not find how to do what I need to
> do.
>
> I want to be able to calculate the diffrence between two days, and have
> the result in the format: X days ago, or, Y days ahead.
> I know it's possible, but I can't figure it out.
>
> thanks
>
>
> Sent via Deja.com
> http://www.deja.com/
Manip.pod shows:
4. The amount of time between two dates.
$date1=&ParseDate($string1);
$date2=&ParseDate($string2);
$delta=&DateCalc($date1,$date2,\$err);
=> 0:0:WK:DD:HH:MM:SS the weeks, days, hours, minutes, and seconds
between the two
$delta=&DateCalc($date1,$date2,\$err,1);
=> YY:MM:WK:DD:HH:MM:SS the years, months, etc. between the two
so, as an example (beware word wrap):
use Date::Manip;
$date1=&ParseDate("20001201");
$date2=&ParseDate("20001209");
$delta=&DateCalc($date1,$date2,\$err);
($dummy1, $dummy2, $weeks, $days, $hours, $minutes, $seconds) =
split(/:/,$delta);
$totaldays = ((7 * $weeks) + $days);
$totaldays .= " days ";
$delta =~ /^(.)/;
$totaldays .= ($1 eq "+") ? "ago" : "ahead";
print "$totaldays\n";
that code yields:
8 days ago
that oughta get you started...
--
Michael Budash ~~~~~~~~~~ mbudash@sonic.net
------------------------------
Date: 12 Dec 2000 23:05:02 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: DBI prepare method
Message-Id: <kpsnnt9lmp.fsf@dagon.conectiva>
On Tue, 12 Dec 2000, mcdonabNO@SPAMyahoo.com wrote:
>
> Hi. I have a question about the Perl 5 DBI 'prepare' method. Is it
> true that one cannot prepare the following SQL statement
>
> my $sth = $dbh->prepare(q{
> INSERT INTO PathEnum
> SELECT P1.assemblyno, B1.subassemblyno, (P1.pathlength + 1)
> FROM PathEnum AS P1, Blueprint AS B1
> WHERE EXISTS (SELECT *
> FROM PathEnum AS P2
> WHERE B1.assemblyno = P2.subassemblyno)
> AND NOT EXISTS (SELECT *
> FROM PathEnum AS P3
> WHERE B1.assemblyno = P3.assemblyno
> AND B1.subassemblyno = P3.subassemblyno)
> }) || die $dbh->errstr;
>
> because it contains two subqueries -- i.e. the two SELECT statements
> in the EXISTS clauses? I realize that the documentation says that
> the 'prepare' method prepares a single statement for later
> execution... but this _is_ a single statement that should just be
> passed through to the database back-end, isn't it?
But isn't prepare used to allow faster execution of a series of
simmilar queries? I mean, if you're goint to make several SELECTs you
can prepare the db to optimize such queries.
Here you're already making the query, i.e., you'll make it once and
it's over (you'll never change any condition on the above SELECT...).
From DBI man page:
The DBI allows an application to "prepare" statements for
later execution. A prepared statement is identified by a
statement handle held in a Perl variable. We'll call the
Perl variable `$sth' in our examples.
The typical method call sequence for a `SELECT' statement
is:
prepare,
execute, fetch, fetch, ...
execute, fetch, fetch, ...
execute, fetch, fetch, ...
for example:
$sth = $dbh->prepare("SELECT foo, bar FROM table WHERE baz=?");
$sth->execute( $baz );
while ( @row = $sth->fetchrow_array ) {
print "@row\n";
}
The detail is in the question mark at the prepare command. The value
passed to the execute() method is going to change the values returned
by the SQL query.
You should try $dbh->do("SELECT ...."); for your SELECT. I don't know
if it will work.
See you,
--
Godoy. <godoy@conectiva.com>
Departamento de Publicações Conectiva S.A.
Publishing Department Conectiva Inc.
------------------------------
Date: Tue, 12 Dec 2000 17:50:54 -0800
From: Jeff Zucker <jeff@vpservices.com>
Subject: Re: DBI prepare method
Message-Id: <3A36D5FE.9B00CA53@vpservices.com>
Jorge Godoy wrote:
>
> You should try $dbh->do("SELECT ...."); for your SELECT. I don't know
> if it will work.
Nope, the docs for do() could not be any more explicit:
It should not be used for select statements
--
Jeff
------------------------------
Date: Wed, 13 Dec 2000 00:28:13 GMT
From: nodo70@my-deja.com
Subject: GD::Graph
Message-Id: <916fqm$dgs$1@nnrp1.deja.com>
After I install GD (1.27.2) and GDGraph (1.32) by using PPM command. I
run a test.pl and it complaint the error as:
GD object version 1.27 does not match $GD::VERSION 0.0port_port_for_OS2
at C:/Perl/lib/DynaLoader.pm
line 219.
/code of test.pl/
#!perl
# Graph.pm example File
# Please see documentation for more info
use GD::Graph;
$graph = new Graph;
srand();
for ($i=0; $i<30; $i++) {
$num = int( rand()*20000 + 10000);
if (($i % 5) == 0) {
$label = "Sun";
}
else {
$label="";
}
$graph->data($num,$label);
}
$graph->title("Daily Web Site Hits");
$graph->subtitle("Content pages only");
$graph->keys_label("Day of the Week");
$graph->values_label("Hits");
$graph->value_min(0);
$graph->value_max(35000);
$graph->value_labels("10000,20000,30000");
$graph->background_image("bg.gif");
$graph->output("example.gif");
/code/
Perl version: v5.6.0 build 620
GD version: 1.27.2
GDGraph version: 1.32
Anyone has any suggestion or point out what I did wrong?
Thanks,
noDo
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Wed, 13 Dec 2000 00:53:19 +0000 (UTC)
From: efflandt@xnet.com (David Efflandt)
Subject: Re: Help! Problem with file uploads using CGI module
Message-Id: <slrn93di46.3io.efflandt@efflandt.xnet.com>
On Tue, 12 Dec 2000, hroces@my-deja.com <hroces@my-deja.com> wrote:
>
>I am trying to create a CGI to upload files from user to my server,
>using a perl script, but I have a problem, I don´t receive a file
>handle, and I don´t understand it.I only receive the path of the file,
>but no the file handle.
>The code is the following:
>
>#This is the HTML page
>
>use CGI;
>
>#Constructor
>
>$query=new CGI;
>
>#Header
>
>print $query->header;
>
>#Form
>
>print $query->start_multipart_form('GET','transferir.cgi');
>print $query->filefield('uploaded_file','starting value',50,180);
>print $query->br;
>print $query->submit('attach','Attach');
>print $query->endform();
>
>
>
>#This is the CGI: transferir.cgi
>
>use CGI;
>
>#Constructor
>
>$query=new CGI;
>
>#Header
>
>print $query->header;
>
>#Obtain the info
>
>$filename = $query->param('uploaded_file');
>print $filename;
>print $query->br;
>
>#Is a valid file handle?
>
>$fh = $query->upload('uploaded_file');
>if ($fh eq '')
>{
> print "Undefined";
> print $query->br;
>}
>else
>{
> print "Defined";
> print $query->br;
>}
>
># Read a text file and print it out
>
>while (<$filename>)
>{
> $linea=<$filename>;
> print $linea;
>}
Not sure why you do not get file contents, but the above while loop only
prints half of the lines in the file. How many lines does the file have?
If it only has 1 line, this loop would not print anything.
The while (<$filename>) reads one line into $_ (which you discard) and
then $linea=<$filename>; reads the 2nd line into $linea and prints it.
Then the while grabs the 3rd line line (which is discarded) then you read
the 4th line into $linea, etc. So your are only only printing every other
line starting with the second line.
--
David Efflandt efflandt@xnet.com http://www.de-srv.com/
http://www.autox.chicago.il.us/ http://www.berniesfloral.net/
http://cgi-help.virtualave.net/ http://hammer.prohosting.com/~cgi-wiz/
------------------------------
Date: 12 Dec 2000 16:15:28 -0800
From: merlyn@stonehenge.com (Randal L. Schwartz)
Subject: Re: huh ??
Message-Id: <m1puix5g7z.fsf@halfdome.holdit.com>
>>>>> "guthrie" == guthrie linck <guthrie_linck@my-deja.com> writes:
guthrie> although map is concise, remember, it is much more inefficient than a
guthrie> foreach() loop.... it doesn't have to build a whole new array and then a
guthrie> join + copy the whole damn thing.
No, be careful about that. There are times when map will be more
efficient than the spelled-out foreach loop.
--
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: Tue, 12 Dec 2000 18:36:13 -0600
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: implicit creation of array?
Message-Id: <slrn93dh3t.11j.tadmc@maxim.metronet.com>
Brian Runck <brianr72@my-deja.com> wrote:
>Any ideas why this statement:
>
>$self->{'input_data'}{$input_tag}[$i];
>
>doesn't work the way one would expect?
^^^^^^^^^^^^
I think you probably mean something besides what strikes me here:
That is in a void context. I do not see that you are testing
it in any manner.
Is that your real code? Or is that really inside of some kind
of conditional?
On your real problem, you have just discovered autovivication.
It is now time to revise your expectations :-)
>'input_data' is a member of
>class $self. It contains an anonymous, empty hash.
Let's try and speak Perl when possible. So you have
my $self = { input_data => {} };
??
(we don't even need to know that it is OO to discuss your problem)
>If $input_tag =
>'TERM' and $i = 0, I tried to use this to return the value of what is in
>that element in the array stored in the hash stored in 'input_data'.
>Since there isn't anything in the array yet (hasn't yet been created),
>it should return nothing.
It does not matter what it returns, because it is in void context.
In void context the "return" (really the value the expression
evaluates to) is discarded (never used). Which is why you
get warnings about void context :-)
You _do_ have warnings enabled, don't you?
>In other words, this is what $self->{'input_data'} looks like first (in
>the debugger):
>
>0 HASH(0x1f441b8)
> empty hash
>
>Then this statement happens:
>
>$self->{'input_data'}{$input_tag}[$i];
>
>Then this is what $self->{'input_data'} looks like after that statement:
>
>0 HASH(0x1f441b8)
> 'TERM' => ARRAY(0x1edd9f4)
> empty array
>
>I'm assuming it thinks that since $self->{'input_data'} is a reference
>to an empty hash, set up the key $input_tag with the anonymous array of
>0 elements.
Yes. This is called "autovivification". It is documented (a bit
thinly) in perlref.pod.
In 5.6 at least, it is also described in:
perldoc -f exists
>But I just want to check to see if there is a value in location 0 of key
>$input_tag, and return that value or return nothing if it does not
>exist. How do I do that, without assigning anything?
The problem is that in "getting to" the array on the end, perl
must "pass thru" $self->{input_data}{TERM}, so it will create
that key in the hash.
So, add a test to see if it exists _before_ attempting to
"pass through" it:
if ( exists $self->{input_data}{TERM} && defined $self->{input_data}{TERM}[0]) {
print "term zero has a defined value in it\n";
}
That code should not change the data structure established up
there in my "Perl speak".
--
Tad McClellan SGML consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 13 Dec 2000 01:32:47 GMT
From: garry@ifr.zvolve.net (Garry Williams)
Subject: Re: implicit creation of array?
Message-Id: <3lAZ5.765$uF3.50650@eagle.america.net>
On Tue, 12 Dec 2000 21:50:11 GMT, Brian Runck <brianr72@my-deja.com>
wrote:
>In other words, this is what $self->{'input_data'} looks like first (in
>the debugger):
>
>0 HASH(0x1f441b8)
> empty hash
>
>Then this statement happens:
>
>$self->{'input_data'}{$input_tag}[$i];
>
>Then this is what $self->{'input_data'} looks like after that statement:
>
>0 HASH(0x1f441b8)
> 'TERM' => ARRAY(0x1edd9f4)
> empty array
>
>I'm assuming it thinks that since $self->{'input_data'} is a reference
>to an empty hash, set up the key $input_tag with the anonymous array of
>0 elements.
>But I just want to check to see if there is a value in location 0 of key
>$input_tag, and return that value or return nothing if it does not
>exist. How do I do that, without assigning anything?
return exists $self->{'input_data'}{$input_tag}
? $self->{'input_data'}{$input_tag}[$i]
: undef;
for one interpretation of "nothing".
--
Garry Williams
------------------------------
Date: 12 Dec 2000 22:55:01 -0200
From: Jorge Godoy <godoy@conectiva.com>
Subject: Re: Looking for GREP examples
Message-Id: <kpwvd59m3e.fsf@dagon.conectiva>
On Tue, 12 Dec 2000, azby10@hotmail.com wrote:
> Hi,
>
> New to Perl I'm primarily interessed by text searching tools. I'm
> looking for GREP examples or tutorials.
>
> I'm asking myself questions like:
>
> - till what extent is it useful to precise GREP patterns
> (time/length)?
In Perl?
You can do whatever you want :-)))
That's what perl mages do. ;-))
> - can I link different greps ?
Yes. Since you have a Perl program, you can nest / link several
different "greps".
> - is it possible to random grep secondary expressions ?
Random grep???
If you want information on the grep application, try "man grep". ;-)
If you want help on Perl, you're in the right place.
See you,
--
Godoy. <godoy@conectiva.com>
Departamento de Publicações Conectiva S.A.
Publishing Department Conectiva Inc.
------------------------------
Date: Wed, 13 Dec 2000 00:42:41 GMT
From: manon_bertolini@mantacorp.com
Subject: make a call to ReadParse??
Message-Id: <916gm0$e3h$1@nnrp1.deja.com>
Hello all! Learning this for first week ...
I am trying an Upload file sample and they say to make a call to
ReadParse?? Can anyone help me out with a link or where this call is
made from? And what this means?
Cheers!
Sent via Deja.com
http://www.deja.com/
------------------------------
Date: Tue, 12 Dec 2000 16:45:32 -0800
From: Deb <kandeb@spamcop.net>
Subject: multiple recipients using Net::SMTP
Message-Id: <3A36C6AC.F6D49B6F@spamcop.net>
I am using the Net::SMTP module to send email from $Host to
multiple local recipients - moi, joe, and sue.
Mail gets delivered to moi, but joe and sue receive nada.
It doesn't matter if the email is sent to a fully qualified
email address, or just the local username.
For the life of me, I know I had this working with multiple
recipients in the past, but it eludes me as to what I am
now doing wrong.
Any insights would be welcome!
TIA,
kandeb
###########################################################
#!d:/perl/bin/perl.exe -w
use Net::SMTP;
$smtp = Net::SMTP->new('$Host'); # connect to an SMTP server
$smtp->mail( 'moi' ); # use the sender's address here
$smtp->to('moi'); # recipient's address
$smtp->data(); # Start the mail
# Send the header.
$smtp->datasend("To: moi, joe, sue\n");
$smtp->datasend("From: moi\n");
$smtp->datasend("\n");
# Send the body.
$smtp->datasend("Hello, World!\n");
$smtp->dataend(); # Finish sending the mail
$smtp->quit; # Close the SMTP connection
------------------------------
Date: Wed, 13 Dec 2000 01:05:46 GMT
From: ced@bcstec.ca.boeing.com (Charles DeRykus)
Subject: Re: net:ping - problem in windows 2000
Message-Id: <G5HF1M.445@news.boeing.com>
In article <9156ob$91f$1@nnrp1.deja.com>, <mike_solomon@lineone.net> wrote:
>I am trying to use Net::Ping to find out if an IP address is available
>
>I am using ActivePerl under Windows 2000
>
>I used the following code:
>
> use Net::Ping;
> if (pingecho(${fip},5)) {
> print "\n\nPing Succeeded - IP ${fip} in use\n";
> $pop++;
> } else {
> print "\n\nPing Failed - ${fip} OK TO USE\n";
> $ok = 1;
> }
>
>Where $fip is the ip address
>
>Which gave me the following error message:
>
>The Unsupported function alarm function is unimplemented at
> C:/Perl/lib/Net/Ping.pm line 308, <STDIN> line 3 (#1)
>...
>I have read the documentation for Net:Ping but it hasn't helped me
>
You must've missed the warning about pingecho and
a ping object with tcp...look for WARNING near the
end of the doc.
use Net::Ping;
my $p = Net::Ping->new;
if ( $p->ping($fip) ) {
...
--
Charles DeRykus
------------------------------
Date: Wed, 13 Dec 2000 02:01:58 GMT
From: mgjv@tradingpost.com.au (Martien Verbruggen)
Subject: Re: networking...
Message-Id: <slrn93dm3b.nr.mgjv@verbruggen.comdyn.com.au>
On Tue, 12 Dec 2000 12:35:51 -0500,
Lou Moran <lmoran@wtsg.com> wrote:
> On Sun, 10 Dec 2000 20:51:27 +1100, mgjv@tradingpost.com.au (Martien
> Verbruggen) wrote wonderful things about sparkplugs:
>
>>On Sun, 10 Dec 2000 00:18:20 -0800,
>> Rucus20 <rucus20@hotmail.com> wrote:
>
> SNIP
>
>>
>>Martien
>
> MV --
>
> --You need to emote. Let these things out. You will have an ulcer
> otherwise.
Nah. I'd rather keep it inside.
> --Of course Rucus20 is in fact from Mars where Martians write really
> complicated programs and give them away for free. They are also known
> under the name Netscape.
netscape never asked anyone ELSE to write their stuff, just so THEY
could distribute it. They write their own stuff, and distribute it
themselves. Many people here have done that. Larry Wall did it.
It is irrelevant to the request of the OP.
Martien
--
Martien Verbruggen |
Interactive Media Division |
Commercial Dynamics Pty. Ltd. | Curiouser and curiouser, said Alice.
NSW, Australia |
------------------------------
Date: Wed, 13 Dec 0 01:05:34 GMT
From: "Scott Nesbitt" <scott@sciteq.com.au>
Subject: Newbie: Uploading File
Message-Id: <916i8e$170$1@yeppa.connect.com.au>
Hi
I have been struggling to understand the CGI module and have looked up
several resources including the perldoc and numerous FAQ's. I have used
CGI-101 (a very helpful book for newbies like me) to try and upload a file.
The source (listed below) works a treat with only two problems.
1) My server does not allow graphics to be shown from behind the cgi-bin and
so even though the gif/jpeg uploads it will not display it. I have tried to
go on via ftp to find the file that has been uploaded but it simply does not
exist anywhere in my directory structure. Where has it gone and how can I
save it as a "real" file in a directory outside the cgi-bin with the name
that the original file had. (I understand that I will have to possibly
change file names to exclude invalid characters but this is a problem for
another day lol)
2) I have been told by a friend (as much a newbie as I am) that I have to
taint check the file. What is this and why?
Source below (taken directly from CGI-101):
#!/usr/bin/perl
use CGI;
$q = new CGI;
print $q->header, $q->start_html(-title=>"Upload
Results",-bgcolor=>"white");
print $q->h2("Upload Results");
$file = $q->param("upfile");
if (!$file) {
print "Nothing uploaded?<p>\n";
} else {
print "Filename: $file<br>\n";
$ctype = $q->uploadInfo($file)->{'Content-Type'};
print "MIME Type: $ctype<br>\n";
open(OUT,">/tmp/outfile") or dienice("Can't open outfile for writing:
$!");
$flen = 0;
while (read($file,$i,1024)) {
print OUT $i;
$flen = $flen + 1024;
if ($flen > 5120000) {
close(OUT);
dienice("Error - file is too large. Save aborted.<p>");
}
}
close(OUT);
print "Length: ",$flen/1024,"Kb<p>\n";
print "File saved!<p>\n";
# display the image. this only works because we have a symlink from
# tmp.gif/jpeg in the current directory, to /tmp/outfile.
if ($ctype eq "image/gif") {
print "Here's what you sent:<p>\n";
print "<img src=\"tmp.gif\" border=1><p>\n";
} elsif ($ctype eq "image/jpeg") {
print "Here's what you sent:<p>\n";
print "<img src=\"tmp.jpg\" border=1><p>\n";
}
}
$q->end_html;
sub dienice {
my($msg) = @_;
print "<h2>Error</h2>\n";
print "$msg<p>\n";
exit;
}
I am already losing enough hair through standard male pattern baldness and
have found that this "simple" exercise is causing fistfuls of hair to appear
on my desk. I would like to keep as much hair in my scalp for as long as
possible, so I would appreciate any help. :)
Thanks
Scott
____________________________________________________
Scott Nesbitt mailto:scott@sciteq.com.au
Sciteq Pty Ltd http://www.sciteq.com.au
Online store now open....... http://www.sciteq.com.au/store
_____________________________________________________
------------------------------
Date: Tue, 12 Dec 2000 18:43:29 -0500
From: Lou Moran <lmoran@wtsg.com>
Subject: Re: ON - INTERNET TELE COMMUTE ONLY - PERL - Java - Js - css - html - DreamWeaver
Message-Id: <jvdd3tom0pu71jp84o6nti01gabv0libq6@4ax.com>
On 12 Dec 2000 18:03:52 -0500, Joe Schaefer
<joe+usenet@sunstarsys.com> wrote wonderful things about sparkplugs:
>Lou Moran <lmoran@wtsg.com> writes:
>
>> On 12 Dec 2000 21:49:32 GMT, kevin metcalf
>> <xzrgpnys@yvtugubhfrovm.pbz> wrote wonderful things about sparkplugs:
>>
>> >Unbelievably, Telecommuter@Visto.com wrote:
>> >> ***** ON A SCALE FROM 1 - 10 PERL must be 10 *****
>> >> ***** ON A SCALE FROM 1 - 10 NT4.0 ISS SERVER = 10 ***
>>
>> What the Hell is ISS? I have to give myself a 1.
>>
>
>Imperial Sucking Sound.
---Ooh Ooh! I did know that, now i can get the job! Oh wait, I suck
at perl... <fzzt>
lmoran@wtsg.com
print "\x{263a}"
------------------------------
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 5094
**************************************