[12781] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 191 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Jul 19 17:07:21 1999

Date: Mon, 19 Jul 1999 14:05:15 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Mon, 19 Jul 1999     Volume: 9 Number: 191

Today's topics:
        !(Local file detection) <laughingotter@foxinternet.net>
        #!/usr/bin/perl -w switch esoterica ks@anse.org
    Re: 2-d array sorting (Abigail)
    Re: 3D modeling with Perl? (Kevin Reid)
        Can y axis start at other than 0 in Chart module? <blair.kissel@mts.mb.ca>
    Re: CGI database question (Abigail)
        cgi entry form gqc2017@my-deja.com
    Re: cgi entry form (Dave Cross)
    Re: cgi entry form bayla@gatewayinternet.com
    Re: Comparing a Hash value to a string (Tad McClellan)
    Re: Comparing a Hash value to a string <blair.kissel@mts.mb.ca>
    Re: DBM problem: very weird! <zeng@haas.Berkeley.EDU>
        fetch url from cgi? <falcon@kansas.net>
    Re: Garbage Collection Performance <jerbyr@my-deja.com>
        How to remove a char from end of file <dazimi@yahoo.com>
    Re: How to remove a char from end of file <laughingotter@foxinternet.net>
    Re: How to simulate shell variable parsing in Perl? (Dave Cross)
    Re: How to simulate shell variable parsing in Perl? bayla@gatewayinternet.com
    Re: Local CGI with ActivePerl (Abigail)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: Mon, 19 Jul 1999 13:05:35 -0700
From: Steve Laybourn <laughingotter@foxinternet.net>
Subject: !(Local file detection)
Message-Id: <3793850F.D2501831@foxinternet.net>

Hello again!
   Well, the means suggested to me for detecting local files on a hard
disk before upload didn't work...variants and permutations of the
filename, -e, -s, and -r didn't work at all...
   There is another problem we've been having...this may sound
out-of-context, and perhaps it is, but here goes...
   We have just hired a new server to host our site, but there seems to
be some rather severe limitations being imposed...
   One, the server is in SoCal and I am in Seattle. So, because of this,
I cannot have Telnet access.
   Two, according to one of their server techs, I cannot have both FTP
and the chmod command because the Solaris 2.6 FTP doesn't support chmod
from FTP clients.
   Without either of these, I cannot get Perl scripts to run.
   Should I be seeking a new server or is there a workaround to this
rather nasty problem?
   Thanks for your help.
   Steve Laybourn



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

Date: Mon, 19 Jul 1999 13:22:56 -0700
From: ks@anse.org
Subject: #!/usr/bin/perl -w switch esoterica
Message-Id: <37938920.B38A55CF@anse.org>

I'm running a perl script (command line style) and would like to be able
to ignore the current list of "uninitialized value" errors I'm receiving
(which I will fix later, naturally).  When I remove the -w switch, I get
a "bash: ./file_name.pl: No such file or directory" error.  I'm at a
loss.  Can anyone send some wisdom my way?

Thanks,
Kate Schneider



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

Date: 19 Jul 1999 15:33:51 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: 2-d array sorting
Message-Id: <slrn7p72sc.oqh.abigail@alexandra.delanet.com>

Vorname Nachname (Vorname.Nachname@Infineon.com) wrote on MMCXLVIII
September MCMXCIII in <URL:news:3793197E.75A200FC@Infineon.com>:
:: 
:: I am quite new with Perl. I have a 2-dimensional array (list of lists)
:: and I want to sort its lines by the first and the third column of every
:: line, with first column having priority to third.


RTFFAQ.


Abigail
-- 
%0=map{reverse+chop,$_}ABC,ACB,BAC,BCA,CAB,CBA;$_=shift().AC;1while+s/(\d+)((.)
(.))/($0=$1-1)?"$0$3$0{$2}1$2$0$0{$2}$4":"$3 => $4\n"/xeg;print#Towers of Hanoi


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 19 Jul 1999 17:00:52 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: 3D modeling with Perl?
Message-Id: <1dv6veh.1ize4f012j8vswN@[192.168.0.1]>

kj0 <kj0@mailcity.com> wrote:

> I'd like to write a small application to visualize and rotate 3D
> objects (specifically, simple representations of molecules).  I'd like
> to do this using as much Perl as possible (and conversely, avoiding
> learning new languages/applications as much as possible).  Are there
> any tools or source code on the web that would facilitate this
> programming task?

I have written a program that does 3D graphics mostly in Perl; it
displays a ball bouncing in a cubical box. You can probably adapt the
code to your needs; however, it was written to run on Mac OS, so it uses
some of the Mac OS's graphics primitives.

#!perl -w

# 3D Ball v2.1
# by Kevin Reid
#
# W, A, S and D and/or click & drag to rotate.
# + and - or control-drag to change scale.
# Tab key toggles polygon borders.
# Tilde key freezes ball.
# Spacebar toggles automatic rotation.
# Escape key quits.
#
# Best viewed in thousands of colors or 256 grays.
#
# Version History
# 2.1
#   * Added flicker-free drawing
#   * Added auto-rotate
#   * Added ball freezing
#   * Fixed passing of -1 to PenSize() which may have caused freeze under 8.6
#   * Added complete wireframe
#   * Added current scale to upper-left corner
#   * Changed keyboard rotation increments to avoid "312.4573984..."
#   * No longer ignores menu keyboard equivalents
# 2.0
#   * Added perspective, rotation & scaling
#   * Window now covers screen
#   * Changed name
#   * Added frames-per-second counter
# 1.0
#   * Initial release as "Isometric Ball"

use strict;
use Mac::Windows;
use Mac::QuickDraw;
use Mac::Events;
use Mac::Fonts qw(systemFont);
use Math::Trig qw(deg2rad);

use vars qw(
  $ScrnRect
  $Mods
  $GWindow
  %pos %oldpos %vel $noball
  $tick
  @Polygons
  $ObscureRgn
  $otime $otick $ptick
  %Multipliers
  $frame_size $autospin $frozen
  $rot $pitch
  $distort
  $mouse
  $oldmouse
  $downflag
  $scale
);

use constant GRAV => 0.8;
use constant LOSS => 0.99;
use constant BOOSTVEL => 23;
use constant DISTORT => 700;

use constant BOXSIZE => 100;

use constant ROTSTEP => 5;
use constant PITCHSTEP => 5;

use constant C_EMPTY => new RGBColor (50000, 50000, 65535);
use constant C_BACKL => new RGBColor ((47000)x3);
use constant C_BACKR => new RGBColor ((50000)x3);
use constant C_BACKB => new RGBColor ((49000)x3);
use constant C_LINES => new RGBColor ((40000)x3);

BEGIN {
  $ScrnRect = GetMainDevice()->gdRect;
  $ScrnRect->top($ScrnRect->top + 20);
}
use constant WINSIZEH => $ScrnRect->right - $ScrnRect->left;
use constant WINSIZEV => $ScrnRect->bottom - $ScrnRect->top;
use constant WINRECT => new Rect (0, 0, WINSIZEH, WINSIZEV);

sub CalcRot {
  $rot = $rot - 360 if $rot >= 360;
  $rot = $rot + 360 if $rot < 0;
  $pitch = $pitch - 360 if $pitch >= 360;
  $pitch = $pitch + 360 if $pitch < 0;

  my $rotr = deg2rad($rot);
  my $pitr = deg2rad($pitch);
  %Multipliers = (
    'x' => {'x' => sin($rotr), 'y' => 0, 'z' => cos($rotr)},
    'y' => {'x' => cos($pitr) * cos($rotr), 'y' => sin($pitr), 'z' => cos($pitr) * -sin($rotr)},
    'z' => {'x' => -sin($pitr) * cos($rotr), 'y' => cos($pitr), 'z' => -sin($pitr) * -sin($rotr)},
  );
  CalcPolys();
}

sub IsoFlatten {
  my ($x, $y, $z) = @_;

  my $rz = Rotate_Z(@_) + $distort;
 
  return (
    ($x * $Multipliers{'x'}{'x'} + $y * $Multipliers{'x'}{'y'} + $z * $Multipliers{'x'}{'z'}) / $rz * $distort * $scale + WINSIZEH/2,
    ($x * $Multipliers{'y'}{'x'} + $y * $Multipliers{'y'}{'y'} + $z * $Multipliers{'y'}{'z'}) / $rz * $distort * $scale + WINSIZEV/2,
  );
}

sub Rotate_Z {
  my ($x, $y, $z) = @_;

  return $x * $Multipliers{'z'}{'x'} + $y * $Multipliers{'z'}{'y'} + $z * $Multipliers{'z'}{'z'};
}

sub DotAt {
  PenSize((2.5 * $scale) x 2);
  MoveTo(@_);
  LineTo(@_);
}

sub BallAt {
  my ($x, $y, $siz) = @_;

  $siz *= $scale;
  InvertOval(new Rect($x-$siz, $y-$siz, $x+$siz, $y+$siz));
}

sub DrawObject {
  my (%cd) = @_;
  SetClip($ObscureRgn);

  if ($cd{z} == 0) {
    BallAt(IsoFlatten(@cd{qw(x y z)}), 8);
  } else {
    BallAt(IsoFlatten(@cd{qw(x y z)}), 8 * $distort / (Rotate_Z(@cd{qw(x y z)}) + $distort));
  }

  # PenSize(2,2);
  DotAt(IsoFlatten(@cd{qw(x y)}, - BOXSIZE * .98));
  DotAt(IsoFlatten(- BOXSIZE * .98, (@cd{qw(y z)})));
  DotAt(IsoFlatten($cd{'x'}, - BOXSIZE * .98, $cd{z}));
  ClipRect(WINRECT);
}

sub CalcPolys {

  my $poly;
  foreach (@Polygons) {
    KillPoly $_->{poly};
  }
  @Polygons = ();

  $poly = OpenPoly; # left poly
  MoveTo(IsoFlatten(- BOXSIZE, - BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE, - BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE,   BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE,   BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE, - BOXSIZE, - BOXSIZE));
  ClosePoly;
  push @Polygons, {poly => $poly, depth => Rotate_Z(- BOXSIZE, 0, 0), color => C_BACKL};

  $poly = OpenPoly; # left-ow poly
  MoveTo(IsoFlatten(  BOXSIZE, - BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE, - BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE,   BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE,   BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE, - BOXSIZE, - BOXSIZE));
  ClosePoly;
  push @Polygons, {poly => $poly, depth => Rotate_Z(  BOXSIZE, 0, 0), color => undef};

  $poly = OpenPoly; # right poly
  MoveTo(IsoFlatten(- BOXSIZE, - BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE,   BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE,   BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE, - BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE, - BOXSIZE, - BOXSIZE));
  ClosePoly;
  push @Polygons, {poly => $poly, depth => Rotate_Z(0, 0, - BOXSIZE), color => C_BACKR};

  $poly = OpenPoly; # right-ow poly
  MoveTo(IsoFlatten(- BOXSIZE, - BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE,   BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE,   BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE, - BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE, - BOXSIZE,   BOXSIZE));
  ClosePoly;
  push @Polygons, {poly => $poly, depth => Rotate_Z(0, 0,   BOXSIZE), color => undef};

  $poly = OpenPoly; # bottom poly
  MoveTo(IsoFlatten(- BOXSIZE, - BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE, - BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE, - BOXSIZE,   BOXSIZE));
  LineTo(IsoFlatten(  BOXSIZE, - BOXSIZE, - BOXSIZE));
  LineTo(IsoFlatten(- BOXSIZE, - BOXSIZE, - BOXSIZE));
  ClosePoly;
  push @Polygons, {poly => $poly, depth => Rotate_Z(0, - BOXSIZE, 0), color => C_BACKB};
    
  # use Data::Dumper; print Dumper \@Polygons;

  @Polygons = sort {$b->{depth} <=> $a->{depth}} @Polygons;
  DisposeRgn $ObscureRgn if $ObscureRgn;
  OpenRgn;
  FrameRect(WINRECT);
  foreach (@Polygons) {
    FramePoly($_->{poly}) if ($_->{color}) and $_->{depth} < -15;
  }
  $ObscureRgn = CloseRgn;

  OpenRgn;
  FrameRect(WINRECT);
  my $allRgn = CloseRgn;
  foreach (@Polygons) {
    OpenRgn;
    FramePoly($_->{poly}) if ($_->{color});
    my $polyRgn = CloseRgn;
    my $newRgn = DiffRgn $allRgn, $polyRgn;
    DisposeRgn $allRgn;
    DisposeRgn $polyRgn;
    $allRgn = $newRgn;
  }

  if ($GWindow and $GWindow->window) {
    SetPort $GWindow->window;
    SetClip $allRgn;
    EraseRect(WINRECT);
    ClipRect(WINRECT);
    $GWindow->redraw;
  }
  DisposeRgn $allRgn;
}

%pos    = ('x' => 0, 'y' => BOXSIZE - 10, 'z' => 0),
%oldpos = ('x' => 0, 'y' => BOXSIZE - 10, 'z' => 0),
%vel    = ('x' => rand 10, 'y' => 0, 'z' => rand 10),
$otime = 0; $otick = 0; $ptick = '';

$rot = 135;
$pitch = 235;
$frame_size = 1;
$distort = DISTORT;
$scale = 1;

CalcRot();
$mouse = GetMouse();

$GWindow = new MacColorWindow (
  $ScrnRect,
  'Ball',
  1, plainDBox, 1,
);
$GWindow->sethook(drawgrowicon => sub {});
$GWindow->sethook(click => sub {$Mods = $Mac::Events::CurrentEvent->modifiers; $downflag = 1});
$GWindow->sethook(redraw => sub {
  PenMode(srcCopy);
  PenSize($frame_size,$frame_size);

  if ($frame_size) {
    foreach (@Polygons) {
      if ($_->{color}) {
        RGBForeColor($_->{color});
        PaintPoly($_->{poly});
      }
      RGBForeColor(C_LINES);
      FramePoly($_->{poly});
    }
  } else {
    OpenRgn;
    FrameRect(WINRECT);
    my $allRgn = CloseRgn;

    foreach (reverse @Polygons) {
      if ($_->{color}) {
        RGBForeColor($_->{color});
        PaintPoly($_->{poly});
      }
      RGBForeColor(C_LINES);
      FramePoly($_->{poly});

      OpenRgn;
      FramePoly($_->{poly}) if ($_->{color});
      my $polyRgn = CloseRgn;
      my $newRgn = DiffRgn $allRgn, $polyRgn;
      DisposeRgn $allRgn;
      DisposeRgn $polyRgn;
      $allRgn = $newRgn;

      SetClip $allRgn;
    }
    ClipRect(WINRECT);
    DisposeRgn $allRgn;
  }

  PenMode(srcXor);

  MoveTo(1, 10);
  DrawString($ptick);
  MoveTo(1, 22); DrawString(sprintf("Rot: %-.1f", $rot));
  MoveTo(1, 34); DrawString(sprintf("Tilt: %-.1f", $pitch));
  MoveTo(1, 46); DrawString(sprintf("Scale: %-.2f", $scale));

  if ($frozen) {
    DrawObject(%pos);
  } else {
    $noball = 1;
  }
});
$GWindow->sethook(key => sub {
  my ($win, $key) = @_;
  $key = lc chr $key;
  my $updt = 1;

  my $rs = ((abs $pitch % 360) > 180) ? ROTSTEP / $scale : - ROTSTEP / $scale;
  &{{
    'a' => sub {$rot += $rs},
    'd' => sub {$rot -= $rs},
    'w' => sub {$pitch += PITCHSTEP / $scale},
    's' => sub {$pitch -= PITCHSTEP / $scale},
    "\t" => sub {$frame_size = $frame_size ? 0 : 1},
    ' ' => sub {$autospin = !$autospin; $updt = 0},
    '`' => sub {$frozen = !$frozen; $updt = 0},
    "\c[" => sub {$GWindow->dispose},
    '+' => sub {($scale *= 1.1) += .001},
    '-' => sub {$scale /= 1.1},
  }->{$key} || sub {$updt = 0}};
  if ($updt) {
    CalcRot();
    #$rot = $rot - 360 if $rot >= 360;
    #$rot = $rot + 360 if $rot < 0;
    #$pitch = $pitch - 360 if $pitch >= 360;
    #$pitch = $pitch + 360 if $pitch < 0;
  }
  $updt;
});
SetPort $GWindow->window;
PenNormal;
RGBBackColor(C_EMPTY);
TextMode(srcXor);
TextFont(systemFont);

WaitNextEvent;
WaitNextEvent;
WaitNextEvent;

$tick = 0;
while ($tick++, $GWindow->window) {

  SetPort $GWindow->window;

  $oldmouse = $mouse;
  $mouse = GetMouse;
  if ($downflag) {
    if ($oldmouse->h != $mouse->h or $oldmouse->v != $mouse->v) {
      my $xdiff = $mouse->h - $oldmouse->h;
      my $ydiff = $mouse->v - $oldmouse->v;
      if ($Mods & controlKey) {
        $scale += $ydiff / 60;
        $scale = .1 if $scale < .1;
        $scale = 4 if $scale > 4;
      } else {
        if ((abs $pitch % 360) > 180) {$rot -= ($xdiff) * .5}
                                 else {$rot += ($xdiff) * .5}
        $pitch -= ($ydiff) * .5;
      }

      #$rot = $rot - 360 if $rot >= 360;
      #$rot = $rot + 360 if $rot < 0;
      #$pitch = $pitch - 360 if $pitch >= 360;
      #$pitch = $pitch + 360 if $pitch < 0;
      CalcRot();
    }
    $downflag = Button();
  }

  if (!$frozen) {
    foreach (qw(x y z)) {
      my $did = 0;

      $oldpos{$_} = $pos{$_};
      $pos{$_} += $vel{$_};
      if ($pos{$_} < - BOXSIZE +9) {
        $vel{$_} *= - LOSS;
        $pos{$_} = - BOXSIZE +9;
        $did = 1;
      }
      if ($pos{$_} > BOXSIZE -9) {
        $vel{$_} *= - LOSS;
        $pos{$_} = BOXSIZE -9;
      }
      if ($did and abs($vel{$_}) < 1) {
        $vel{$_} = BOOSTVEL;
      }
    } 
    
    if ($noball) {$noball = 0}
            else {DrawObject(%oldpos)}
    DrawObject(%pos);
 
    $vel{'y'} -= GRAV;
  }

  if ($otime != time) {
    $otime = time;
    MoveTo(1, 10);
    DrawString($ptick);
    $ptick = 'FPS: ' . ($tick - $otick);
    MoveTo(1, 10);
    DrawString($ptick);
    $otick = $tick;
  }

  unless (!$autospin) {
    $rot += 2;
    $pitch += .5;
    CalcRot();
  }

  WaitNextEvent;
}

END {
  $GWindow->dispose if $GWindow;
}

__END__

-- 
 Kevin Reid: |    Macintosh:      
  "I'm me."  | Think different.


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

Date: Mon, 19 Jul 1999 14:46:34 -0500
From: Blair Kissel <blair.kissel@mts.mb.ca>
Subject: Can y axis start at other than 0 in Chart module?
Message-Id: <3793809A.D07B07F4@mts.mb.ca>

I am using the Chart module to plot a line graph of percentages.  The
percentages are all normally above 50% and are very close together.  To
achieve greater detail, I would like to have the y axis start at 50% (or

some other arbitrary value) and go to 100%.  Does anyone know how this
can be done?

Thank you,

Blair Kissel





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

Date: 19 Jul 1999 15:18:01 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: CGI database question
Message-Id: <slrn7p71uo.oqh.abigail@alexandra.delanet.com>

matt (mlopresti@bigfoot.com) wrote on MMCXLVIII September MCMXCIII in
<URL:news:379346B5.EFCBE867@bigfoot.com>:
<> 
<> print "<FORM ...........>";

I assume you don't have "'s inside this string, like you had in the
pseudo code? Because then it wouldn't compile.



Abigail
-- 
perl -e '* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
         / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / / 
         % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % % %;
         BEGIN {% % = ($ _ = " " => print "Just Another Perl Hacker\n")}'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: Mon, 19 Jul 1999 19:55:15 GMT
From: gqc2017@my-deja.com
Subject: cgi entry form
Message-Id: <7mvvqs$6ar$1@nnrp1.deja.com>

   I am trying to create a cgi form which has a few required fields.  If
the user omit these fields and click on the Submit button, the form must
be redisplayed again with an error message at the top.  Do anyone know
how to do this?

Thanks


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 19 Jul 1999 20:50:01 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: cgi entry form
Message-Id: <37948f45.8207057@news.demon.co.uk>

On Mon, 19 Jul 1999 19:55:15 GMT, gqc2017@my-deja.com wrote:

>   I am trying to create a cgi form which has a few required fields.  If
>the user omit these fields and click on the Submit button, the form must
>be redisplayed again with an error message at the top.  Do anyone know
>how to do this?

Yes, it's pretty simple to do in Perl (and, I would guess, most other
languages that you can write CGI scripts in).

Which language are you using?

Dave...

--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

Date: Mon, 19 Jul 1999 20:43:09 GMT
From: bayla@gatewayinternet.com
Subject: Re: cgi entry form
Message-Id: <7n02kq$7gl$1@nnrp1.deja.com>

You can put the printout of your form into a function and then make a
function which will test each cgi->parameter that it exists (in other
words, it has a value) and if the error function detects an error it
should print out the error message and then the form. If it comes back
with no error then the form should be processed. To do this you will
need both the form and the processing of it to be in one perl file and
you get into different parts of the program based on the "Submit"
parameter values.
In article <7mvvqs$6ar$1@nnrp1.deja.com>,
  gqc2017@my-deja.com wrote:
>    I am trying to create a cgi form which has a few required fields.
If
> the user omit these fields and click on the Submit button, the form
must
> be redisplayed again with an error message at the top.  Do anyone know
> how to do this?
>
> Thanks
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 19 Jul 1999 09:59:25 -0400
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Comparing a Hash value to a string
Message-Id: <tvavm7.1a3.ln@magna.metronet.com>

Blair Kissel (blair.kissel@mts.mb.ca) wrote:
: I need to test if a value in a hash is equal to a specific string.  For
: instance:

: if($Hash{KEY} eq "Yes")


   That looks fine to me.

   There is something that you are not telling us.


: I have tried all sorts of combinations and comparisons and it either
: always enters the if statement or never enters the if statement,
: regardless of the value of $Hash{KEY}.  Any suggestions would be
: appreciated...


   I would suggest posting a small and complete program that
   shows the problem you are having.

   Here is an example where the only "combination" that you have
   shown us works just fine:

---------------------
#!/usr/bin/perl -w
use strict;

my %Hash;

$Hash{KEY} = 'Yes';

if($Hash{KEY} eq "Yes")
   { print "yep\n" }
else
   { print "nope\n" }
---------------------


   prints "yep"


--
    Tad McClellan                          SGML Consulting
    tadmc@metronet.com                     Perl programming
    Fort Worth, Texas


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

Date: Mon, 19 Jul 1999 14:42:24 -0500
From: Blair Kissel <blair.kissel@mts.mb.ca>
Subject: Re: Comparing a Hash value to a string
Message-Id: <37937F9F.36E30665@mts.mb.ca>

Thanks very much for your help.  Actually, my problem wasn't related to the
compare operation, the hash values were read in from a text file and thus had
a trailing \n that had to be removed in order for the compare to work
correctly.  :)  I used chop for this and it now works wonderfully!  =)

Thanks again!

Blair

Faisal Nasim wrote:

> : I need to test if a value in a hash is equal to a specific string.  For
> : instance:
> :
> : if($Hash{KEY} eq "Yes")
>
> Whats wrong? It should work. (if the KEY is valid, and contains "Yes"
> without quotes)
>
> :
> : I have tried all sorts of combinations and comparisons and it either
> : always enters the if statement or never enters the if statement,
> : regardless of the value of $Hash{KEY}.  Any suggestions would be
> : appreciated...
>
> This works for me, perhaps will give you some hint.
>
> $hash { 'faisal' } = 'cool';
> print 'wow' if $hash { faisal } eq 'cool';
>
> :
> : Thank you,
> :
> : Blair Kissel
> :



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

Date: Mon, 19 Jul 1999 12:19:26 -0700
From: Zeng <zeng@haas.Berkeley.EDU>
To: Anno Siegel <anno4000@lublin.zrz.tu-berlin.de>
Subject: Re: DBM problem: very weird!
Message-Id: <Pine.SOL.4.05.9907191214450.13826-100000@haas.Berkeley.EDU>

I believe what I did is just following an example given on page 270-271
of Programming Perl by Larry Wall, etc (the camel book). The only
difference is that I have the 'dbmopen %tmp' there. But after getting
rid of that, it still behaves strangely as before. What gives? What is
the correct way to do a hash of hashes?

On 17 Jul 1999, Anno Siegel wrote:

> Zeng  <zeng@haas.Berkeley.EDU> wrote in comp.lang.perl.misc:
> >The following looks a simple algorithm but the %tmp is a bit complex.
> >Notice I put two identical print statements in the middle? The weird
> >thing, at least to me, is that those two printout for @Keys don't always
> >produce the same results. The second (KEY2) always is longer if they are
> 
> [snip]
> 
> >    dbmopen %tmp,  "tmp",  0644 || die "Can't open file ";
> >    dbmopen %rmp,  "rmp",  0644 || die "Can't open file ";
> >
> >    while (($y, $a) = each %rmp) {
> >        ($n, $t, $g) = split($y);
> >
> >        $u = &some_subroutine;
> >
> >	@Keys = keys %{$tmp{$u}};
> >	print "KEY1,  @Keys \n";
> >	@Keys = keys %{$tmp{$u}};
> >	print "KEY2,  @Keys \n";
> 
> Well, since %tmp is tied to a file $tmp{$u} can't be a regular hash
> reference.  But you treat it as a hashref in %{$tmp{$u}}, which means
> it it resolved as a symbolic reference and can point to just about
> anything.  Since we don't know what $tmp{$u} contains we are left to
> speculation, but one remote possibility is that it contains the name
> of the symbol table where @Keys resides.  In that case, the difference
> you observe would have to be expected.
> 



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

Date: Mon, 19 Jul 1999 14:55:44 +0000
From: Riley County Grade School <falcon@kansas.net>
Subject: fetch url from cgi?
Message-Id: <37933C64.FA74C153@kansas.net>



How can I have a cgi fetch a http url and post the results to the page
my cgi generates?

Matt



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

Date: Mon, 19 Jul 1999 19:28:17 GMT
From: Jeremy Purdy <jerbyr@my-deja.com>
Subject: Re: Garbage Collection Performance
Message-Id: <7mvu80$5ia$1@nnrp1.deja.com>

In article <7mogo3$2fr$1@mathserv.mps.ohio-state.edu>,
  ilya@math.ohio-state.edu (Ilya Zakharevich) wrote:
> I have seen things like this before, with Net::FTP.pm and CPAN.pm.
> I think these modules do some expensive cleanup in destructors.
>
> Run you program in Perl debugger, set 'b'reakpoint at the last line of
> execution, 'c'ontinue, then enable 'f'rame 'O'ption, or switch on
> 't'race.
>
> Then 'c'ontinue again.  You may want to redirect the output to file
> via 'L'ineInfo 'O'ption.
>
> Hope this helps,
> Ilya
>

Thanks for the info.  I will try this as soon as I get the memory usage
down a little.  Currently when I run with the debugger, about 2/3
through processing memory allocations shoots over 200M and I get an Out
of Memory! message.

--
Jeremy Purdy
MRJ Technology Solutions


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: Mon, 19 Jul 1999 16:04:07 -0400
From: "Dariush" <dazimi@yahoo.com>
Subject: How to remove a char from end of file
Message-Id: <7n00l2$5ib$1@clio.net.metrotor.on.ca>

Hi everyone;

How can I remove a character form the end of a file. looks like an ascii
char. A square bracket.
How Can I remove this character.?

Thank you.
Please send response to

Teamlinux@hotmail.com

Thank you.





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

Date: Mon, 19 Jul 1999 13:39:28 -0700
From: Steve Laybourn <laughingotter@foxinternet.net>
Subject: Re: How to remove a char from end of file
Message-Id: <37938D00.7EFC4BBF@foxinternet.net>

>>>A copy of this letter has been sent to the querent<<<
Hello:
   Do you know how the character got there in the first place?
   Well, I suppose it would be easier to know whether or not this was a file
with line breaks. If this were so, then:

open(OTTER,"shells.file");
@clams=<OTTER>;
close(OTTER);
chomp @clams; # remove newlines
chop @clams[$#clams]; # get rid of last character on last line
open(OTTER,"+>shells.file");
foreach $x(0 .. $#clams) { print OTTER "$clam[$x]\n"; }
close(OTTER);

would work. (Bet I get a lot of flak for lack of style here from the rest of
the Perl world.)
  Or, if the file were all one line, try this:

open(OTTER,"shells.file");
$clam=<OTTER>;
close(OTTER);
chomp $clam; # get rid of newline
chop $clam; # kill last character
open(OTTER,"+>shells.file");
print OTTER "$clam\n";
close(OTTER);

   At least this is what I would do with what little Perl knowledge I've
got.
   Of course, that's just my opinion. I could be wrong.
   Good luck!

   Steve Laybourn, Perl Programmer
   Laughing Otter Computing Services
   e-mail: otter101@hotmail.com





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

Date: Mon, 19 Jul 1999 20:46:52 GMT
From: dave@dave.org.uk (Dave Cross)
Subject: Re: How to simulate shell variable parsing in Perl?
Message-Id: <37938e32.7932507@news.demon.co.uk>

On Mon, 19 Jul 1999 13:08:33 GMT, shaunj@my-deja.com wrote:

>This may seem a trivial question to some but (as a reletive newbie to
>Perl) I am struggling to find the answer.
>
>Consider this ksh snippet ...
>
>while read key parm1 parm2 parm3 therest
>do
>     ... use the variables as required
>
>done < sometextfile
>
>where ..
>
>sometextfile contains ..
>
># Comment lines containing some descriptive information which
># may or may not be ignored by the program logic
># followed by some parameters which need to be parsed
>
>key parm1 parm2 parm3
>k2 parm1 parm2 parm3 The Rest of the text
>
>------------------------
>
>My question is: What is the most appropriate way to parse this
>information using perl, simulating the ksh logiv as closely as possible?

Something like the following perhaps:

open(PARMS, 'sometextfile') || die "Can't open somtextfile: $!\n";

while (<PARMS>) {
  my ($key, $parm1, $parm2, $parm3, $the_rest = split /\s+/;

  # Do stuff
}


hth,

Dave...

--
Dave Cross <dave@dave.org.uk>
<http://www.dave.org.uk>


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

Date: Mon, 19 Jul 1999 20:50:24 GMT
From: bayla@gatewayinternet.com
Subject: Re: How to simulate shell variable parsing in Perl?
Message-Id: <7n032a$7nq$1@nnrp1.deja.com>

you can do :
while(<F1>){
   if ($_ =~ /key parm1 parm2 parm3 therest/){
         ....use variables as required
   }
}
this is the similar equal sign =~ so the above is saying while the line
is similar to these words...do this. If you don't know what the
parameters will say in advance you can check while $_ is not !~ /#/
process the variables.
In article <7mv809$rku$1@nnrp1.deja.com>,
  shaunj@my-deja.com wrote:
> This may seem a trivial question to some but (as a reletive newbie to
> Perl) I am struggling to find the answer.
>
> Consider this ksh snippet ...
>
> while read key parm1 parm2 parm3 therest
> do
>      ... use the variables as required
>
> done < sometextfile
>
> where ..
>
> sometextfile contains ..
>
> # Comment lines containing some descriptive information which
> # may or may not be ignored by the program logic
> # followed by some parameters which need to be parsed
>
> key parm1 parm2 parm3
> k2 parm1 parm2 parm3 The Rest of the text
>
> ------------------------
>
> My question is: What is the most appropriate way to parse this
> information using perl, simulating the ksh logiv as closely as
possible?
>
> In anticipation .... Shaun.
>
> Sent via Deja.com http://www.deja.com/
> Share what you know. Learn what you don't.
>


Sent via Deja.com http://www.deja.com/
Share what you know. Learn what you don't.


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

Date: 19 Jul 1999 15:19:48 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Local CGI with ActivePerl
Message-Id: <slrn7p7222.oqh.abigail@alexandra.delanet.com>

Floyd Morrissette (Webdesigner@NewWebSite.com) wrote on MMCXLVIII
September MCMXCIII in <URL:news:7mv9ao$s63$1@nnrp1.deja.com>:
@@ I agree and can understand that these same people are frustrated because
@@ of having to answer the same questions over and over again especially
@@ when the answers are everywhere to be found. But I don't understand why,
@@ if they are tired of answering such questions, do they answer at all. If
@@ they don't want to answer, then don't post anything at all.


That doesn't help. The same questions will be asked over and over again.
It's like spam, except with a much higher ratio then email spam.



Abigail
-- 
perl -we 'print split /(?=(.*))/s => "Just another Perl Hacker\n";'


  -----------== Posted via Newsfeeds.Com, Uncensored Usenet News ==----------
   http://www.newsfeeds.com       The Largest Usenet Servers in the World!
------== Over 73,000 Newsgroups - Including  Dedicated  Binaries Servers ==-----


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

Date: 1 Jul 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 1 Jul 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.  

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 V9 Issue 191
*************************************


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