[11612] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 5212 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 24 06:07:27 1999

Date: Wed, 24 Mar 99 03:00:18 -0800
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Wed, 24 Mar 1999     Volume: 8 Number: 5212

Today's topics:
    Re: << string definer (Bart Lateur)
    Re: [AJM] CGI.pm Cookie question <Savage.Ron.RS@bhp.com.au>
        Can i do tcp/ip programming on NT platforms? smnayeem@my-dejanews.com
        Date function question nkaiser@my-dejanews.com
    Re: Date function question (Bill Moseley)
        Date/Time calculation: % through current month? <tony@blackstar.co.uk>
    Re: Environtmental Variables In IE4 <ebohlman@netcom.com>
    Re: Help Needed Please!!! leonandrews@my-dejanews.com
        how to extract a datestring.html or meta-refresh.html? (f_x)
        interactive shell command from perl <wing@ans.com.au>
    Re: interactive shell command from perl <Tony.Curtis@vcpc.univie.ac.at>
        NET::ESP Where? <lgcl01@es.co.nz>
        Newbie to Perl <kenmar@ihug.co.nz>
        Newbie-prints source code <flight69@cs.uh.edu>
        Perl/DBI/MS-Access: Problems inserting an integer... dgeorgop@home.com
        Problem using SWIG with Activestate Perl <S.Manschot@Inter.NL.net>
    Re: Q : Best way to implement a C struct? (Arved Sandstrom)
        Resizing File <davidrn@pobox.com>
    Re: Resizing File (Larry Rosler)
    Re: Simple Question :-) <frowijn@itc.nl>
        SMTP Problem <aikema@attcanada.net>
    Re: SMTP Problem <mfoster@canuck.com>
        Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)

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

Date: Wed, 24 Mar 1999 09:21:37 GMT
From: bart.lateur@skynet.be (Bart Lateur)
Subject: Re: << string definer
Message-Id: <36f8a2a0.1830265@news.skynet.be>

Ala Qumsieh wrote:

>Anyone thought about reading some documentation? maybe?

>   Following a C<E<lt>E<lt>> ...

Ah, no wonder it's impossible to find. Searching for "<<" will do no
good.

	Bart.


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

Date: Wed, 24 Mar 1999 17:30:41 +1100
From: "Ron Savage" <Savage.Ron.RS@bhp.com.au>
Subject: Re: [AJM] CGI.pm Cookie question
Message-Id: <7da0qp$5dr5@atbhp.corpmel.bhp.com.au>

Note that -cookie is ignored according to the documentation:
Official Guide to Programming with CGI.pm
Lincoln Stein
Wiley
0-471-24744-8
page 225 (at the end of redirect() ).


--
Ron Savage
Office (preferred): Savage.Ron.RS@bhp.com.au
Home: rpsavage@ozemail.com.au
http://www.ozemail.com.au/~rpsavage
Ronald J Kimball wrote in message
<1dp56et.xlr9ljlw5zn2N@[207.60.170.219]>...
>Murphy <jt45@tir.com> wrote:
>
>> Here's the code.
>> -------------
>> $cookie1=cookie(-name=>'name',-value=>$fname);
>> $cookie2=cookie(-name=>'nic',-value=>$nic);
>> print header(-cookie=>[$cookie1,$cookie2]);
>> -------------
>> Now according to the book, the above should store the cookie, but it
>> doesn't.   In fact, when I do this the following line of code does NOT
>> do what it's supposed to do:
>>
>> Here it is:
>> --------------
>> print redirect('http://main/mainmenu.html');
>
>You're trying to print two sets of headers.  That won't work.  As the
>documentation for CGI.pm's redirect() method states:
>
>    GENERATING A REDIRECTION INSTRUCTION
>
>       print $query->redirect('http://somewhere.else/in/movie/land');
>
>    redirects the browser elsewhere.  If you use redirection like this,
>    you should not print out a header as well.
>    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>
>
>The documentation is less explicit about this, but you can use the same
>named parameters to redirect() that you can to header():
>
>
>  print redirect(-uri=>'http://main/mainmenu.html',
>                 -cookie=>[$cookie1,$cookie2]);
>
>
>HTH!
>
>
>--
> _ / '  _      /       - aka -
>( /)//)//)(//)/(   Ronald J Kimball      rjk@linguist.dartmouth.edu
>    /                                http://www.tiac.net/users/chipmunk/
>        "It's funny 'cause it's true ... and vice versa."




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

Date: Wed, 24 Mar 1999 09:31:37 GMT
From: smnayeem@my-dejanews.com
Subject: Can i do tcp/ip programming on NT platforms?
Message-Id: <7dabdp$m8a$1@nnrp1.dejanews.com>

most of the socket functions of perl comes direct from unix, but how will i do
these on NT platform?
if anyone knows please let me know, id greatly appreciate ur help.
thanks

Syed Muhammad Nayeem

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 24 Mar 1999 04:49:40 GMT
From: nkaiser@my-dejanews.com
Subject: Date function question
Message-Id: <7d9qt2$8n6$1@nnrp1.dejanews.com>

Is there  a way to get the current date in as a large number, rather than
localtime(time). Then, convert it back to localtime(time) format for
displaying.

I ask this cause I need to compare dates.

I want to do something like:

$now = datefunction(time);
# now would be a large num, similar if you stat a file on lastmod date

And then, be able to do something like:
$prettydisplay = datetoString($now);

ANd this would display like 'Jan 01 11:11:11 EDT' or something like that.

Thanks alot!

-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Tue, 23 Mar 1999 21:41:26 -0800
From: moseley@best.com (Bill Moseley)
Subject: Re: Date function question
Message-Id: <MPG.11621adfdac5adc99896e6@206.184.139.132>

In article <7d9qt2$8n6$1@nnrp1.dejanews.com>, nkaiser@my-dejanews.com 
says...
> Is there  a way to get the current date in as a large number, rather than
> localtime(time). Then, convert it back to localtime(time) format for
> displaying.

This what you mean?

$time = time();

$later = $time + 12 * 3600;

$string_date = scalar localtime( $later );

print "And the time was: $string_date\n";


The docs on localtime are enjoyable.





-- 
Bill Moseley mailto:moseley@best.com


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

Date: 24 Mar 1999 09:01:52 GMT
From: Tony Bowden <tony@blackstar.co.uk>
Subject: Date/Time calculation: % through current month?
Message-Id: <7da9m0$12s$1@nclient3-gui.server.ntli.net>

I've been trying to produce some pretty basic stats, whereby knowing how
many times an event has happened so far this month, I want to estimate
how many times it's likely to happen in the month.

This is quite simple once I work out how far into the current month it is...
but actually finding that out is relatively tricky!

My basic logic is that I find out
  a) how many seconds into the month it is
  b) how many seconds are in this month

This obviously involves knowing
  1) the date/time it is now
  2) when this month started
  3) how long this month is, _or_ 4) when next month starts

I figure that if I need to know (2) then it's easier to get (4) than
worry about days_in_month type stuff to do 3, so I'm left with a basic
equation of:

      now - start_of_month
  -----------------------------
  end_of_month - start_of_month

I've played with a variety of the Date and Time modules, but I can't find
one that will neatly give me all this information. Time::ParseDate has
promise, but I can't calculate the start / end of month stuff from it.
Date::DateManip or Date::DateCalcLib seem useful for this, but this all
seems like a lot of overhead, for what should surely be a relatively
straightforward calculation....

So, is there

a) any easier way I'm missing to get this figure?
or
b) any way of getting it using just one pre-existing module?

and if not, is it worth writing a module for something like this? It seems
this wouldn't be that unusual a task ...

Thanks

Tony
--
-----------------------------------------------------------------------------
 Tony Bowden | tony@blackstar.co.uk               http://www.blackstar.co.uk/
  Black Star |    The UK's Biggest Video & DVD store * Free Postage Worldwide
-----------------------------------------------------------------------------


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

Date: Wed, 24 Mar 1999 06:08:51 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Environtmental Variables In IE4
Message-Id: <ebohlmanF9352r.KxI@netcom.com>

[followups set to comp.infosystems.www.authoring.cgi]

gorgano@my-dejanews.com wrote:
: I'm trying to get $ENV{HTTP_REFERER} from IE4.	However, i can not use a
: standard link to click on when i load the page.  I need to use something like
: a meta refresh or location="foo.htm" to do this.  However, when ever i use
: something like this IE won't pass the HTTP_REFERER variable which i really
: need for security reasons.  If any one has any ideas as to how to fix this I
: would REALLY appreciate it!  Thanks for your help.

If the browser doesn't send it, you can't get it.  Period.  You can't 
conjure data out of thin air.  This turnip won't give you any blood when 
you squeeze it.

If you "really need HTTP_REFERER for security reasons," you're already 
barking up the wrong tree.  HTTP_REFERER is trivially forgeable.  Find 
some other way to do it, because this dog won't hunt.

This post was brought to you by the Chicago chapter of the National 
Society for the Preservation of Cliches.



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

Date: Wed, 24 Mar 1999 06:36:23 GMT
From: leonandrews@my-dejanews.com
Subject: Re: Help Needed Please!!!
Message-Id: <7da156$dlj$1@nnrp1.dejanews.com>



mate,

have you tried printing out your variables such as $buffer, ie

print "Content-type: text/html\n\n";
print "buffer is $buffer\n";

etc

 ...to see whether the data is getting across the CGI?


-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/       Search, Read, Discuss, or Start Your Own    


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

Date: Wed, 24 Mar 1999 10:53:05 +0100
From: f_x@xoom.com (f_x)
Subject: how to extract a datestring.html or meta-refresh.html?
Message-Id: <f_x-2403991053050001@node10013.a2000.nl>

does anybody has written a snippet 
how to fetch/write automatically
a datestring.html like 19990324.html
or extract a ...html from a meta refresh-tag

thanks in advance


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

Date: Wed, 24 Mar 1999 17:15:01 +1100
From: C W Poon <wing@ans.com.au>
Subject: interactive shell command from perl
Message-Id: <36F882E5.3FC4A160@ans.com.au>

Specifically, I'm trying to run htpasswd which prompts for a password twice.  I used the code below and it creates the user no problem.  The httpd however, gives the old 500 internal server error.

Code:
=====
open (HTPASSWD, "|$passprog $passfilefull $login") || die "Can't open $passprog!\n";
print HTPASSWD "$password\n";
print HTPASSWD "$password\n";
close (HTPASSWD);

httpd error log:
================
New password:
Re-type new password:
httpd: [Wed Mar 24 12:58:09 1999] [error] [client 192.168.3.2] malformed header from script. Bad header=Adding user wingos: /usr/local/etc/httpd/cgi-bin/
register.pl

If htpasswd is run by hand, it looks like this:

1) this come first

Add user wingos:
New password:

2) then this after a password is typed

Re-type new password:

3) then that's it.

But how can I do it so that it doesn't make a "malformed header".  As I say, the user get created but the server freaks out.  I want to go to a thank you page afterwards, not the server 500 internal error page.

Any help is great help.

Wing


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

Date: 24 Mar 1999 10:28:30 +0100
From: Tony Curtis <Tony.Curtis@vcpc.univie.ac.at>
Subject: Re: interactive shell command from perl
Message-Id: <83oglj8ce9.fsf@vcpc.univie.ac.at>

Re: interactive shell command from perl, C
<wing@ans.com.au> said:

C> Specifically, I'm trying to run htpasswd which
C> prompts for a password twice.  I used the code
C> below and it creates the user no problem.  The
C> httpd however, gives the old 500 internal server
C> error.  Code: ===== open (HTPASSWD, "|$passprog
C> $passfilefull $login") || die "Can't open
C> $passprog!\n"; print HTPASSWD "$password\n";
C> print HTPASSWD "$password\n"; close (HTPASSWD);

Can't do that.  htpasswd doesn't use stdin to read
your input.  It munges a tty to turn off echo.

This, if I may, is an attempt to solve the wrong
problem.  What you're trying to do is to manage WWW
authentication databases, and htpasswd is just one
command-line-based tool to do that.  You should
really be using a perl-based tool, viz.

    HTTPD::UserAdmin

C> But how can I do it so that it doesn't make a
C> "malformed header".  As I say, the user get

Are you outputting the correct MIME headers?

perldoc CGI will tell you more...

C> created but the server freaks out.  I want to go
C> to a thank you page afterwards, not the server
C> 500 internal error page.

That's an issue between your server and you...best
asked in a newsgroup for whichever server you are
using.

hth
tony
-- 
Tony Curtis, Systems Manager, VCPC,    | Tel +43 1 310 93 96 - 12; Fax - 13
Liechtensteinstrasse 22, A-1090 Wien.  | <URI:http://www.vcpc.univie.ac.at/>
"You see? You see? Your stupid minds!  | private email:
    Stupid! Stupid!" ~ Eros, Plan9 fOS.| <URI:mailto:tony_curtis32@hotmail.com>


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

Date: Wed, 24 Mar 1999 13:57:25 +1200
From: "Christopher Fairbairn" <lgcl01@es.co.nz>
Subject: NET::ESP Where?
Message-Id: <922271755.588331@inv.ihug.co.nz>

Hi,

In an early reply to my post about producing a search engine for a site
which doesn't have CGI support someone suggested I use the NET::ESP module
to get access to the HTML files from a server which has CGI support (I have
another server with CGI support).

I have looked in CPAN etc but can't find any reference to this module. Can
any one provide any help? I havn't used perl modules before and to make
matters worse I don't have shell access to a server (as of yet) so I can't
see error messages from Perl or read the man pages.

Thanks,
Christopher Fairbairn.






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

Date: Thu, 25 Mar 1999 17:54:48 +0800
From: Ken Mar <kenmar@ihug.co.nz>
Subject: Newbie to Perl
Message-Id: <36FA07E8.8A7B7DB3@ihug.co.nz>

Hi all,
 With all humility, I'm posting this Perl proggie to acquant myself with
the wonderful world of Perl programming. Downloaded it from Stein's site
and tried running it. Encounter the following problems:
    Got the guestbook form page going.
    After input of info and click confirm button, got the
write_guestbook() subroutine working until the point where the err
message - Sorry, an error ocurred: unable to open guestbook file,
showed. However, the "Thank you, so-and-so, for signing the guestbook"
message was displayed. 
    The perl script froze there.

 I'm using Win95 and running ActivePerl5.005. Also had the CGI.pm
installed. Looking at the proggie, I suspect the POSIX module must be
missing (just guessing). If indeed, where to get one? Are not all the
exotic modules package into the latest build of ActivePerl? Please
enlighten this confused guy. Thanks.

Here's the proggie:

#!/usr/bin/perl
# guestbook.pl
use CGI qw/:standard :html3 :netscape/;
use POSIX;
@REQUIRED = qw/name e-mail/;
@OPTIONAL = qw/location comments/;
$TIMEOUT = 10;  # allow up to 10 seconds for waiting on a locked
guestbook
$GUESTBOOKFILE = "./guestbookfile.txt";
%ENTITIES = ('&'=>'&amp;', '>'=>'&gt;','<'=>'&lt;','\"'=>'&quot;');
print header,  
	start_html('Guestbook'),   
	h1("Guestbook");
$_ = param('action');
 CASE: {   /^sign/i and do    { sign_guestbook(); last CASE; };     	  
/^confirm/i and do { write_guestbook() and view_guestbook(); last CASE;
};
           /^view/i and do    { view_guestbook(); last CASE; };
    # default
     generate_form();
 }

sub sign_guestbook {
  my @missing = check_missing(param());
  if (@missing) {
       print_warning(@missing);
       generate_form();
       return undef;
    }
    my @rows;
    foreach (@REQUIRED,@OPTIONAL) {           
push(@rows,TR(th({-align=>LEFT},$_),td(escapeHTML(param($_)))));      }
    print "Here is your guestbook entry.  Press ",                 
em('Confirm')," to save it, or ",em('Change'),
        " to change it.",
        hr,
        table(@rows),
        hr;
    print start_form;
    foreach (@REQUIRED,@OPTIONAL) {
        print hidden(-name=>$_);
    }
    print submit(-name=>'action',
                 -value=>'Change Entry'),
          submit(-name=>'action',
                 -value=>'Confirm Entry'),
          end_form;
}

print end_html;

sub check_missing {
    my (%p);
    grep (param($_) ne '' && $p{$_}++,@_);
    return grep(!$p{$_},@REQUIRED);
}

sub print_warning {
    print font({-color=>'red'},
          'Please fill in the following fields: ',
          em(join(', ',@_)),
          '.');
}

sub generate_form {
    print start_form,
     table(
        TR({-align=>LEFT},
          th('Your name'),
          td(textfield(-name=>'name',-size=>50))
        ),
        TR({-align=>LEFT},
          th('Your e-mail address'),
          td(textfield(-name=>'e-mail',-size=>50))
        ),
        TR({-align=>LEFT},
          th('Your location (optional)'),
          td(textfield(-name=>'location',-size=>50))
        ),
        TR({-align=>LEFT},
          th('Comments (optional)'),
          td(textarea(-name=>'comments',-rows=>4,
                      -columns=>50,
                      -wrap=>1))
        )
     ),
     br,
     submit(-name=>'action',-value=>'View Guestbook'),
     submit(-name=>'action',-value=>'Sign Guestbook'),
     end_form;
}

sub write_guestbook {
    my $fh = lock($GUESTBOOKFILE,1);
    unless ($fh) {
       print strong('Sorry, an error occurred: unable to open guestbook
file.'),p();
       Delete('action');
       print a({-href=>self_url},'Try again');
       return undef;
    }
    my $date = strftime('%D',localtime);
    print $fh join("\t",$date,map {CGI::escape(param($_))}
(@REQUIRED,@OPTIONAL)),"\n";
    print $fh "\n";
    print "Thank you, ",param('name'),", for signing the guestbook.\n",
      p(),
      a({href=>"../source.html"},'Code Examples');
    unlock($fh);
    1;
}

sub view_guestbook {

    print start_form,
          submit(-name=>'Sign Guestbook'),
          end_form
          unless param('name');

    my $fh = lock($GUESTBOOKFILE,0);

    my @rows;
    unless ($fh) {
       print strong('Sorry, an error occurred: unable to open guestbook
file.'),br;
       Delete('action');
       print a({-href=>self_url},'Try again');
       return undef;
    }
    while (<$fh>) {
       chomp;
       my @data = map {CGI::unescape($_)} split("\t");
       foreach (@data) { $_ = escapeHTML($_); }
       unshift(@rows,td(\@data));
    }
    unshift(@rows,th(['Date',@REQUIRED,@OPTIONAL]));
    print table({-border=>''},
          caption(strong('Previous Guests')),
          TR(\@rows));
    print p,a({href=>"../source.html"},'Code Examples');
    1;
}

sub escapeHTML {
    my $text = shift;
    $text =~ s/([&\"><])/$ENTITIES{$1}/ge;
    return $text;
}

sub LOCK_SH { 1 }
sub LOCK_EX { 2 }
sub LOCK_UN { 8 }

sub lock {
    my $path = shift;
    my $for_writing = shift;

    my ($lock_type,$path_name,$description);
    if ($for_writing) {
        $lock_type = LOCK_EX;
        $path_name = ">>$path";
        $description = 'writing';
    } else {
        $lock_type = LOCK_SH;
        $path_name = $path;
        $description = 'reading';
    }
    local($msg,$oldsig);
    my $handler = sub { $msg='timed out'; $SIG{ALRM}=$oldsig; };
    ($oldsig,$SIG{ALRM}) = ($SIG{ALRM},$handler);
    alarm($TIMEOUT);

    open (FH,$path_name) or
       warn("Couldn't open $path for $description: $!"), return undef;

    # now try to lock it
    unless (flock (FH,$lock_type)) {
       warn("Couldn't get lock for $description (" . ($msg || "$!") .
")"); 
       alarm(0);
       close FH;
       return undef; 
    }

    alarm(0);
    return FH;
}

sub unlock {
    my $fh = shift;
    flock($fh,LOCK_UN);
    close $fh;
}


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

Date: Wed, 24 Mar 1999 00:58:37 -0600
From: Chris L Fullilove <flight69@cs.uh.edu>
Subject: Newbie-prints source code
Message-Id: <Pine.SUN.3.96.990324005524.13364A-100000@pegasus>

Hi, I am having trouble running a simple CGI script.

#!/usr/local/bin/perl -w

print "Content-type: text/html\n\n";

print "<html>\n";
print "<head>\n";
print "<title>Hello World with Perl</title>\n";
print "</head>\n";
print "<body>\n";
print "<h2> Hello World with Perl</h1>\n";
print "<p>Test</p>\n";
print "</body>\n";
print "</html>\n";


the only output I get is the actual source code in my browser.
when I run it at the unix prompt, I get the HTML code.

I think it is something that is not set up correctly.
any help would be greatly appreciated.

you can see the output for yourself at 
http://www.cs.uh.edu/~flight69/cgi-bin/cgiprac1.cgi

Thanks in advance
Chris



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

Date: Wed, 24 Mar 1999 07:33:27 GMT
From: dgeorgop@home.com
Subject: Perl/DBI/MS-Access: Problems inserting an integer...
Message-Id: <36F8BE3C.D612FF8@NOSPAM.canada.com>

It sounds basic enough but I've been having no luck.  I'm not sure if
this is a perl or an MS-Acess related problem.  I've searched the usual
places for help but came up short.  I'm desperately hoping that someone
can point me in the right direction.  Here's my problem:

I'm trying to insert an integer into an Ms-Access 97 table and on the
execute, I get this error:

DBD::ODBC::st execute failed: [Microsoft][ODBC Microsoft Access 97
Driver] Data type mismatch in criteria expression. (SQL-22005)(DBD:
st_execute/SQLExecute err=-1) at register3.pl line 84.

Here's a snipet of the code:
 ...
$employeeID = 21;

$cursor = $dbh->prepare(q{SELECT * FROM EMP WHERE EMPID = ?})
 || die $dbh->errstr;
$cursor->execute($employeeID);

EMP table's EMPID colum is a Long Integer data type (indexed without
dups).  It seems as though $employeeID is being interpreted as a string
and not an integer on execute.  So I tried "typecasting" the variable,
as seen below, but that didn't work:

$cursor->execute(int($employeeID));

I also read in DejaNews that doing $employeeID*=1 forces perl to
evaluate employeeID as an integer.  That didn't work.

Another thing I tried was change the data type of the column to
Integer.  That didn't work.

If you've got any clue on this one, please throw your ideas my way.

TIA,
Dino

Config:  Active State 5.09, Perl for Win32 on Win98








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

Date: 24 Mar 1999 07:33:37 GMT
From: Steven Manschot <S.Manschot@Inter.NL.net>
Subject: Problem using SWIG with Activestate Perl
Message-Id: <36F89332.D64E597B@Inter.NL.net>

Hi,

I'm testing SWIG with ActiveState's perl.
After a couple of tries I managed to build a test project (Elapsed.Dll
and Elapsed.pm from TPJ)

When I want to use the functionality from the Dll in perl I get:

Elapsed 10 required--this is only version (undef) (Elapsed.pm) at ....

Where can I set the version of the Dll ?

Thank in advance,

Steven Manschot.



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

Date: Wed, 24 Mar 1999 06:52:25 -0400
From: Arved_37@chebucto.ns.ca (Arved Sandstrom)
Subject: Re: Q : Best way to implement a C struct?
Message-Id: <Arved_37-2403990652250001@dyip-104.chebucto.ns.ca>

In article <01be7540$bffae440$41a208cf@TR-DEALGKREM.tr.unisys.com>,
"Gregory K. Deal" <gkd1@keystonenet.com> wrote:

>         My data structure can be thought of as a 2 dimensional array with the
> first dimension being a cluster number, and the second dimension pointing
> to various attributes of a particluar cluster. But, some of these
> attributes want to be another array of numbers, so I just continued with
> the dimensioning and seem to be working OK with 3 dimensional access. My
> concern is that, although this seems to be working, it is not the best/most
> efficient/elegant/etc. way of doing it. I've reviewed Programming Perl,
> Chapter 4, "References and nested data structures", and see their use of
> multidimensional array access, but with their examples of lists of lists,
> hashes of hashes, etc., I suspect I'm not making use of important
> features/ideas. The perldoc files I have seem to just be a summary of the
> book. So, the question is : Is there a standard way of turning a general C
> struct (or Pascal record) into a Perl data structure? All my subscripts are
> numeric, so general use of hashes doesn't seem needed, but are they
> better/faster/easier to make multidimensional? Thanks for any help or
> guidance.

Unless you're talking about massive amounts of data, I'd make the
selection between hashes and arrays based on higher principles than speed.

Hashes could still be the way to go if you have sparse indexing, but in
general with the data structure you describe lists of lists of lists
should work.

Order of items would be another consideration. With hashes you lose that
unless you sort keys. So if the arrangement of data has some importance,
but there are no natural keys other than numeric indices, then arrays make
more sense.

I don't think there are any hard and fast rules, other than that Perl
arrays don't necessarily correspond to classic mathematical arrays in
terms of when you'd use one rather than a hash.

Arved


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

Date: Wed, 24 Mar 1999 01:12:29 -0500
From: David J Whalen-Robinson <davidrn@pobox.com>
Subject: Resizing File
Message-Id: <36F8824D.78336AFB@pobox.com>

I want to resize a file, preferably while it is open.
I know all about seek, tell, and eof and how
to read and write into the file, but I don't know
how to shrink the file size...

The goal is to most efficiently as possible cut of the end of the file.
The OS should support this...

I don't want to have to copy the file just to cut it off at a certain
point

Thanks for any help

David
davidrn@pobox.com



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

Date: Tue, 23 Mar 1999 23:28:32 -0800
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Resizing File
Message-Id: <MPG.116233f97744e4e9897b0@nntp.hpl.hp.com>

[Posted and a courtesy copy sent.]

In article <36F8824D.78336AFB@pobox.com> on Wed, 24 Mar 1999 01:12:29 -
0500, David J Whalen-Robinson <davidrn@pobox.com >says...
> I want to resize a file, preferably while it is open.
> I know all about seek, tell, and eof and how
> to read and write into the file, but I don't know
> how to shrink the file size...

In your previous post on this topic (Subject:  File Length And 
Truncating), you said, "I want to truncate a file to a shorter length 
 ...'  Here you say 'resize'.  Have you forgotten about 'truncate'?

perldoc -f truncate

-- 
(Just Another Larry) Rosler
Hewlett-Packard Company
http://www.hpl.hp.com/personl/Larry_Rosler/
lr@hpl.hp.com


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

Date: Wed, 24 Mar 1999 08:26:31 +0100
From: "Oscar Frowijn" <frowijn@itc.nl>
Subject: Re: Simple Question :-)
Message-Id: <7da430$srj$1@news.surfnet.nl>

>#!/usr/bin/perl -w
>
>open FILE1, 'file1' or die "open file1: $!\n";
>open FILE2, 'file2' or die "open file2: $!\n";
>open FILE3, 'file3' or die "open file3: $!\n";
>
>my ($line1, $line2, $line3);
>
>LOOP:
>while ( 1 ) {
>    $line1 = <FILE1>;
>    $line2 = <FILE2>;
>    $line3 = <FILE3>;
>
>    last LOOP if ( defined($line1) + defined($line2) + defined($line3) ==
0 );
>
>    for ( $line1, $line2, $line3 ) {
>        $_ = defined($_) ? $_ : "";
>        chomp;
>    }
>
>    printf "%s%s%s\n", $line1, $line2, $line3;
>}
>
>close FILE1;
>close FILE2;
>close FILE3;
>


This will do the trick :-)


Thanks a lot !!!!





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

Date: Wed, 24 Mar 1999 06:52:57 GMT
From: Jakob Aikema <aikema@attcanada.net>
Subject: SMTP Problem
Message-Id: <36F88C9C.54374615@IHATESPAM.attcanada.net>

The problem I am having is that I want to set up a CGI program in order
for people to access their email from the web.  Although the POP3 server
is accessible from anywhere, the smtp server is limited to behind the
firewall.  I was hoping that maybe someone could give me an idea how to
get something like sendmail to work instead in one of these
mail-checking scripts.
Currently I know a bit of perl.  I can setup most scripts and have
written a few simple ones of my one, but with a problem like this I
haven't got a clue what to do.  (plus I haven't got much $$$ to throw
around)

Thanks in advance for all your help,
David

(Please remove IHATESPAM from the email address when replying)



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

Date: Wed, 24 Mar 1999 01:45:47 -0700
From: Martin Foster <mfoster@canuck.com>
Subject: Re: SMTP Problem
Message-Id: <36F8A63B.25448F01@canuck.com>

Jakob Aikema wrote:
> 
> The problem I am having is that I want to set up a CGI program in order
> for people to access their email from the web.  Although the POP3 server
> is accessible from anywhere, the smtp server is limited to behind the
> firewall.  I was hoping that maybe someone could give me an idea how to
> get something like sendmail to work instead in one of these
> mail-checking scripts.
> Currently I know a bit of perl.  I can setup most scripts and have
> written a few simple ones of my one, but with a problem like this I
> haven't got a clue what to do.  (plus I haven't got much $$$ to throw
> around)
> 
> Thanks in advance for all your help,
> David
> 


Hash: SHA1

The PERL Cookbook by O'Reilly and Associated (http://www.ora.com)
contains a lot of scripts that may come in handy to you on this
project.  Either that or check the PERL FAQ et cetera for information
on such things.  

But, I do know (since I asked a similar question) that there is a
module named Net::SMTP, that will allow you to communicate with a SMTP
server, which will allow you to send out mail using PERL.   CPAN, as I
was told should have what you need on using this module. 

As for sending mail, that may depend on how you want to configure
this.   Do you intend the user to compose the message on the page
created by the PERL Script?  A little like Hotmail or other such
clients?   If so (and someone correct me if I am wrong), the script
should be located on the server, and work as if it were within the
firewall, which should allow you to access SMTP or directly access
sendmail by opening up a process.  This would take care of one
problem.

On the other hand they are not composing the messages on the HTML
document.  I heard of a product that when used with Sendmail and POP3
will allow the users to relay once they have authenticated themselves.
 This might be useful as well and worth looking into.  

					Martin Foster
					mfoster@canuck.com


Version: PGP 6.0.2

iQA/AwUBNvimLnijzK9vyOcEEQKN5wCfS54Q1e9ydoXDYMxRoam0e6wlEqEAoIhg
itotXmggg4RJYvvtHuNeh8ro
=fF5J
-----END PGP SIGNATURE-----


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

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


Administrivia:

Well, after 6 months, here's the answer to the quiz: what do we do about
comp.lang.perl.moderated. Answer: nothing. 

]From: Russ Allbery <rra@stanford.edu>
]Date: 21 Sep 1998 19:53:43 -0700
]Subject: comp.lang.perl.moderated available via e-mail
]
]It is possible to subscribe to comp.lang.perl.moderated as a mailing list.
]To do so, send mail to majordomo@eyrie.org with "subscribe clpm" in the
]body.  Majordomo will then send you instructions on how to confirm your
]subscription.  This is provided as a general service for those people who
]cannot receive the newsgroup for whatever reason or who just prefer to
]receive messages via e-mail.

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.misc (and this Digest), send your
article to perl-users@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.

The Meta-FAQ, an article containing information about the FAQ, is
available by requesting "send perl-users meta-faq". The real FAQ, as it
appeared last in the newsgroup, can be retrieved with the request "send
perl-users FAQ". Due to their sizes, neither the Meta-FAQ nor the FAQ
are included in the digest.

The "mini-FAQ", which is an updated version of the Meta-FAQ, is
available by requesting "send perl-users mini-faq". It appears twice
weekly in the group, but is not distributed in the digest.

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 V8 Issue 5212
**************************************

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