[9212] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2807 Volume: 8

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jun 7 18:07:16 1998

Date: Sun, 7 Jun 98 15:00:33 -0700
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sun, 7 Jun 1998     Volume: 8 Number: 2807

Today's topics:
    Re: . (Larry Rosler)
    Re: Am I looking at an anonymous array (Kevin Reid)
    Re: Am I looking at an anonymous array (Jonathan Stowe)
    Re: Am I looking at an anonymous array (Mike Heins)
    Re: Am I looking at an anonymous array <tchrist@mox.perl.com>
    Re: delete slice in list (Daniel Grisinger)
        END{} to dump object data. <ckilburn@nbnet.nb.ca>
    Re: Force garbage collection (Jason D Gloudon)
    Re: Foreach Efficiency <p-fein@uchicago.edu>
    Re: HTTP Header Info bobbybooby@my-dejanews.com
    Re: HTTP Header Info (Jonathan Stowe)
    Re: HTTP Header Info (Brian Lavender)
    Re: I'm having problems: (Kevin Reid)
    Re: I'm having problems: (Jonathan Stowe)
    Re: lines of text, inserting spaces (Mike Stok)
    Re: newbie ques:  Here Documents (Tad McClellan)
    Re: Not even an RFD (yet)... comp.lang.perl.(newbie|que (Gary M. Greenberg)
    Re: perl-frage (Jonathan Stowe)
    Re: problem with LWP (Jonathan Stowe)
    Re: Problem with re-iterating if loops... (Larry Rosler)
    Re: Reading a file from the bottom up <dformosa@st.nepean.uws.edu.au>
    Re: Removing a character from a string (Larry Rosler)
    Re: Stupid syntax question (Kevin Reid)
        The Very Basics! <peach@cin.net>
    Re: The Very Basics! (Jonathan Stowe)
        what's a cross-platform \n please? <flavell@mail.cern.ch>
    Re: what's a cross-platform \n please? (Larry Rosler)
        Digest Administrivia (Last modified: 8 Mar 97) (Perl-Users-Digest Admin)

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

Date: Sun, 7 Jun 1998 13:46:28 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: .
Message-Id: <MPG.fe49bfcee4f584b989699@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <357AC935.348105AC@derby-county.com>, support@derby-county.com 
says...
> http://u2me3.com

Weird that this cross-posting spammer should pick this newsgroup!

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Sun, 7 Jun 1998 16:12:06 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Am I looking at an anonymous array
Message-Id: <1da9dla.1yemwso1nyyer8N@slip166-72-108-25.ny.us.ibm.net>

Erland Sommarskog <sommar@algonet.se> wrote:

> THE SHORT QUESTION:
> If say "ref $x" I might get ARRAY or HASH in return. But can I tell 
> whether this array or hash is a real variable, or just an anonymous
> entity?

#!perl -w

sub packs ($) {
  my $package = $_[0]=~/::$/?$_[0]:$_[0]."::";
  my @packages = grep /::$/, keys %$package;
  my @retlist = ($package);
  foreach (@packages) {
    push @retlist, packs($package . $_) unless $_ =~ /main/;
  }
  map {s/::$//; $_} @retlist;
}

sub isanon ($$) {
  my ($ref, $type) = @_;
  my ($pack, $value, $notanon);
  $notanon = 0;

  foreach $pack (packs 'main') {
    foreach (sort keys %{$pack . "::"}) {
      *val = ${$pack . "::"}{$_};
      $value = *val{SCALAR};
      $notanon ||= 1 if $value == $ref;
    }
  }
  return !$notanon;
}

$var = "x";

$ref = \$var;

print "\$ref is @{[isanon($ref, 'SCALAR') ? 'now' : 'not']}
anonymous.\n";

print "Deleting symbol table entry...\n";
delete $main::{var};

print "\$ref is @{[isanon($ref, 'SCALAR') ? 'now' : 'not']}
anonymous.\n";


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


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

Date: Sun, 07 Jun 1998 20:15:00 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: Am I looking at an anonymous array
Message-Id: <357af02c.35528291@news.btinternet.com>

On Sun, 07 Jun 1998 12:25:35 GMT, Erland Sommarskog wrote :


>
>   ARRAY(0x9100a8)
>   ARRAY(0x9100cc)
>   ARRAY(0x910198)
>   main=ARRAY(0x9100a8)
>   main=ARRAY(0x9100cc)
>

If then you have an array reference you can dereference it thus:

@{$reference_to_array}

/j\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 7 Jun 1998 16:29:30 -0500
From: mikeh@minivend.com (Mike Heins)
Subject: Re: Am I looking at an anonymous array
Message-Id: <357af82a.0@news.one.net>

Erland Sommarskog <sommar@algonet.se> wrote:
> mikeh@minivend.com (Mike Heins) skriver:
>>Just bless it and see if it has a package name in front.
>>
>>        @Main::Package::ref = 1;
>>
>>        my @ref;
>>        @ref = 1;
>>
>>        $ref = [ 1 ];
>>
>>        for ( \@Main::Package::ref, \@ref, $ref) {
>>        print "$_\n";
>>        }
>>
>>        for ( \@Main::Package::ref, \@ref) {
>>        bless $_;
>>        print "$_\n";
>>        }
>>

> The output I got I was:

>    ARRAY(0x9100a8)
>    ARRAY(0x9100cc)
>    ARRAY(0x910198)
>    main=ARRAY(0x9100a8)
>    main=ARRAY(0x9100cc)

> Adding $ref to the last for clause did only give:

>    main=ARRAY(0x910198)

Of course -- a reference is a reference, which is why you can't tell.
But if you are creating a named array, you must do so by declaring it;
unless you are not using strict, as I would hope you are with such a
complex application. When you declare the array, load it with an undef
element and bless it. Don't bless an anonymous ref.

-- 
Mike Heins                          http://www.minivend.com/  ___ 
                                    Internet Robotics        |_ _|____
"The U.S. Senate -- white           131 Willow Lane, Floor 2  | ||  _ \
male millionaires working           Oxford, OH  45056         | || |_) |
for YOU!" -- Dave Barry             <mikeh@minivend.com>     |___|  _ <
                                    513.523.7621 FAX 7501        |_| \_\


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

Date: 7 Jun 1998 21:33:06 GMT
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Am I looking at an anonymous array
Message-Id: <6lf0ui$eq$1@csnews.cs.colorado.edu>

 [courtesy cc of this posting sent to cited author via email]

In comp.lang.perl.misc, 
    sommar@algonet.se (Erland Sommarskog) writes:
:I guess if Tom Christiansen says I can't do it, that probably means I 
:can't do it. (Well, I was contemplating that you could chase around
:in symbol tables, but that seems like an utterly bad idea, if all I 
:want to do is to avoid a warning.)

Here's one that does that.  It won't work for anons.

--tom

#!/bin/sh
# This is a shell archive (produced by GNU sharutils 4.2).
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
# Made on 1998-06-07 14:25 MDT by <tchrist@jhereg.perl.com>.
# Source directory was `/home/ftp/pub/perl/scripts/ADVLABS/rprint'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
#
# This shar contains:
# length mode       name
# ------ ---------- ------------------------------------------
#    982 -rwxr-xr-x testpref
#   2410 -rw-r--r-- pref.pm
#
save_IFS="${IFS}"
IFS="${IFS}:"
gettext_dir=FAILED
locale_dir=FAILED
first_param="$1"
for dir in $PATH
do
  if test "$gettext_dir" = FAILED && test -f $dir/gettext \
     && ($dir/gettext --version >/dev/null 2>&1)
  then
    set `$dir/gettext --version 2>&1`
    if test "$3" = GNU
    then
      gettext_dir=$dir
    fi
  fi
  if test "$locale_dir" = FAILED && test -f $dir/shar \
     && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
  then
    locale_dir=`$dir/shar --print-text-domain-dir`
  fi
done
IFS="$save_IFS"
if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
then
  echo=echo
else
  TEXTDOMAINDIR=$locale_dir
  export TEXTDOMAINDIR
  TEXTDOMAIN=sharutils
  export TEXTDOMAIN
  echo="$gettext_dir/gettext -s"
fi
touch -am 1231235999 $$.touch >/dev/null 2>&1
if test ! -f 1231235999 && test -f $$.touch; then
  shar_touch=touch
else
  shar_touch=:
  echo
  $echo 'WARNING: not restoring timestamps.  Consider getting and'
  $echo "installing GNU \`touch', distributed in GNU File Utilities..."
  echo
fi
rm -f 1231235999 $$.touch
#
if mkdir _sh00828; then
  $echo 'x -' 'creating lock directory'
else
  $echo 'failed to create lock directory'
  exit 1
fi
# ============= testpref ==============
if test -f 'testpref' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'testpref' '(file already exists)'
else
  $echo 'x -' extracting 'testpref' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'testpref' &&
use pref;
X
print "listfunc is "; pref ( [ \&wild::func ] ); print "\n";
X
$x = "i am a string";
$n = 38.3;
print "n is "; pref(\$n); print "\n";
X
print "listfunc is "; pref ( [ \&wild::func ] ); print "\n";
print "n ptr is "; pref(\\$n); print "\n";
X
$ar =  [3, "fred", undef, [2, 9, 666, [more => stuff], reddish], 3.2];
X
$tr = {
X    "fred"	=> "funny",
X    "bill"	=> 21,
X    "bizzare1"	=> \&wild::func,
X    "ouch"	=> *STDIN,
X    "bizzare2"	=> \&wild::func,
X    "fh"	=> \*STDERR,
X    "imafunc"   => \&pref,
X    "nuther"   => sub { print 1 },
X    "sammy"	=> [1, 2, 3],
X    1e6		=> {
X	difficil => hard,
X	"bizzare0"	=> \&wild::func,
X	millon   => 1e6,
X	many	=> [ qw(here are more words) ],
X    }, 
};
X
#print "ar is "; pref ($ar); print "\n";
X
print "listfunc is "; pref ( [ \&wild::func ] ); print "\n";
print "tr is ";pref ($tr); print "\n";
X
X
print "x is "; pref(\$x); print "\n";
print "fr is ";pref (\&pref); print "\n";
print "listfunc is "; pref ( [ \&wild::func ] ); print "\n";
SHAR_EOF
  $shar_touch -am 0526165495 'testpref' &&
  chmod 0755 'testpref' ||
  $echo 'restore of' 'testpref' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'testpref:' 'MD5 check failed'
78938ea806d089246a3e53e2467878f3  testpref
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'testpref'`"
    test 982 -eq "$shar_count" ||
    $echo 'testpref:' 'original size' '982,' 'current size' "$shar_count!"
  fi
fi
# ============= pref.pm ==============
if test -f 'pref.pm' && test "$first_param" != -c; then
  $echo 'x -' SKIPPING 'pref.pm' '(file already exists)'
else
  $echo 'x -' extracting 'pref.pm' '(text)'
  sed 's/^X//' << 'SHAR_EOF' > 'pref.pm' &&
package pref;
use Carp;
require Exporter;
@ISA = ('Exporter');
@EXPORT = ('pref');
X
#use strict;
X
#%didpack;
#$indent;
#%known_func;
X
$didpack{'main::main::'} = 1;
find_funcs('main::');
X
sub usage {
X    carp "@_" if @_;
X    croak "usage: pref some-reference";
}; 
X
sub pref {
X    my $r = $_[0];
X    usage("wrong argcount") unless @_ == 1;
X    my $type = ref $r;
X    #usage("arg not a reference") unless defined $type && $type;
X    if (!defined $type) {
X	print_scalar($r);
X	return;
X    } 
X
X
X    for ($type) {
X	/SCALAR/	&& do {
X				print_scalar($$r);
X				last;
X			   };
X	/ARRAY/ 	&& do {
X				my $max = @$r - 1;
X				my $i;
X				print "[\n";
X				for $i ( 0 .. $max ) {
X				    pindent();
X				    printf " %5d => ", $i;
X				    $indent++;
X				    pref($r->[$i]);
X				    $indent--;
X				    print "\n";
X				} 
X				pindent();
X				print "]";
X				last;
X
X			   };
X	/HASH/  	&& do {
X				print "{\n";
X				my $k;
X				for $k ( keys %$r ) {
X				    pindent();
X				    printf " %-8s => ", sprint_scalar($k);
X				    $indent++;
X				    pref($r->{$k});
X				    $indent--;
X				    print "\n";
X				} 
X				pindent();
X				print "}";
X				last;
X
X				last;
X			   };
X	/CODE/  	&& do {
X				my $name = $known_func{$r};
X				$name =~ s/^main:://;
X				print $name ? "&$name()" : "$r";
X				#print "$r";
X				last;
X			   };
X	/GLOB/  	&& do {
X				print "(REF TO ) \\$$r";
X				last;
X			   };
X	/REF/		&& do {
X				print "(REF TO ) \\";
X				pref($$r);
X				last;
X			   };
X
X	print "UNKOWN REFERENCE: $r";
X    } 
} 
X
sub pindent {
X    print " " x  (10 * $indent);
} 
X
sub print_scalar {
X    print &sprint_scalar;
}
X
X
sub sprint_scalar {
X    my $s = $_[0];
X    if (!defined $s) {
X	return "undef";
X    } elsif ($s != 0) {
X	return $s;
X    } elsif ($s =~ /^\*\w+/) {
X	return qq($s);
X    } else{
X	return qq("$s");
X    } 
} 
X
sub find_funcs {
X    my $stabname = $_[0];
X    #print "starting on $stabname\n";
X    return if $didpack{$stabname}++;
X    no strict;
X    local *stab = *$stabname;
X    my $ident;
X    for $ident (keys %stab) {
X	if (defined &{$stab{$ident}}) {
X	    my $addr = \&{$stab{$ident}};
X	    my $funcname = "$stabname$ident";
X	    $known_func{$addr} = $funcname;
X	    #print "func $funcname is at $addr\n";
X	} elsif ($ident =~ /::$/ && defined %{$stab{$ident}} ) {
X	    #print "$ident $stab{$ident}\n";
X	    my $newpack = $stabname . $ident;
X	    #print "recursing on $newpack";
X	    find_funcs($newpack);
X	} 
X    } 
} 
X
sub wild::func { }
X
1;
SHAR_EOF
  $shar_touch -am 0510040295 'pref.pm' &&
  chmod 0644 'pref.pm' ||
  $echo 'restore of' 'pref.pm' 'failed'
  if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
  && ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
    md5sum -c << SHAR_EOF >/dev/null 2>&1 \
    || $echo 'pref.pm:' 'MD5 check failed'
46154a10e3a4c2cc15576680cbe054b0  pref.pm
SHAR_EOF
  else
    shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'pref.pm'`"
    test 2410 -eq "$shar_count" ||
    $echo 'pref.pm:' 'original size' '2410,' 'current size' "$shar_count!"
  fi
fi
rm -fr _sh00828
exit 0
-- 
"Lazy people never bother to actually read the manual.  Instead they
  (like kids) pick something with big, colorful buttons."
    --Eugene Tyurin <gene@insti.physics.sunysb.edu> 


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

Date: Sun, 07 Jun 1998 21:00:04 GMT
From: dgris@perrin.dimensional.com (Daniel Grisinger)
Subject: Re: delete slice in list
Message-Id: <6leul0$od$1@perrin.dimensional.com>

In article <6leqfp$hej$0@206.165.146.137>,
Allan M. Due <due@murray.fordham.edu> wrote:
<snip discussion of what the actual question is>

>All of which leaves the original question unanswered to my way of thinking.
>
Will this suffice?

$a = 'split and splice with just one semicolon for a guy on clpm';
@result = map { @$_[0 .. $#$_-5] } [split / /, $a];
print join ' ', @result;

>Any additional edification would be appreciated.
>
Hope this helps :-).

Regards,
Daniel
-- 
Daniel Grisinger       dgris@perrin.dimensional.com
"No kings, no presidents, just a rough consensus and
running code."
                        Dave Clark


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

Date: Sun, 07 Jun 1998 18:14:45 -0300
From: Colin Kilburn <ckilburn@nbnet.nb.ca>
Subject: END{} to dump object data.
Message-Id: <357B02C5.910EA00F@nbnet.nb.ca>

I would like to have the END{} subroutine dump the object data.
Since END{} is not a callable method, I don't see how I can access
the object data.

I am confused about the scope of END{}.
All of the examples I have seen only print messages for illustration.

The script I am writing calls other scripts of which any could fail.
I store the status of the process, what failed what succeeded,
within the object's data so that I can rerun the process without
redoing what succeeded.

Maybe I should put an explicit call within the END{}.

END {
  Class->cleanup();
}

Before I try this, I would like so experienced input.

Thanks,
Colin Kilburn



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

Date: Sun, 7 Jun 1998 21:17:09 GMT
From: jdg@world.std.com (Jason D Gloudon)
Subject: Re: Force garbage collection
Message-Id: <slrn6nm0qk.448.jdg@world.std.com>

Preferred Customer <plmiller@postoffice.worldnet.att.net> wrote:
>
>I am running a perl program to process a large file ( 15,000,000 records of
>1000 bytes each).  I simply read a single record, process it, and write it
>out to a file.  What is happening is that I get an out of memory failure. 
>It appears that the arrays and hashes I am using are not being reused but
>new memory is assigned for each record. Using top Isee that my address
>space is approaching 2 gig when I get the out of memory message.  Is there
>a way I could force garbage collection every 100,000 records?

What version of perl are you using ? You may be suffering from a memory leak,
but it is also likely you aren't reusing the memory yourself. Without showing
or describing how you are manipulating the data it is difficult to say without 
guessing what could be the real cause of your
problem.

--
Jason


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

Date: Sun, 7 Jun 1998 21:12:58 GMT
From: Peter A Fein <p-fein@uchicago.edu>
Subject: Re: Foreach Efficiency
Message-Id: <87vhqcx6ed.fsf@bj2-64.rh.uchicago.edu>

Gellyfish@btinternet.com (Jonathan Stowe) writes:

> On Sun, 07 Jun 1998 14:40:06 -0400, samdie@wsfd.org wrote :
> 
> <big snip>
> 
> >
> >From what I've seen, the only questions *guaranteed* to receive careful
> >reading and studied replies are those that propose some regex and ask if
> >it cannot be made a few bytes shorter.
> >
> 
> Rubbish.  This question has received  far more coverage than it need
> have. When:

Actually, he phrased it rather well.  That was what I was asking.
Although using benchmarking would have given me an idea of which
option was more efficient, it wouldn't haven't really given me an idea
of what was actually going on, which is what my question was.  Perhaps
I should have rephrased it three or four times.

> 
> On Thu, 04 Jun 1998 21:07:47 GMT, John Porter wrote :
> 
> >Peter A Fein wrote:
> >> 
> >> foreach my $i (sort article_cmp @all_pages) {
> >> 
> >> My inclination is that the list-generating sort only gets done once,
> >> and therfore doing it outside the loop and storing it in a variable
> >> which foreach then indexes would be unnecessary.  Is this correct?
> >
> >That's a good inclination to have.
> >Why don't you test your hypothesis using Benchmark?
> >
> 
> That was basically enough of it.  Peter was correct in his assumption
> that the list was sorted once.  John pointed him toward a way of
> determining whether he was correct.  But unfortunately Peter got out
> of his pram:

Actually, I'm not so sure.  See above.  And a simple "yes, your
understanding is correct" would have saved a lot of effort on ALL sides.

<snip>

> Your initial assertion is obviously incorrect - if it was correct then
> this newsgroup would cease to function. Although of course some would
> suggest that this newsgroup has already ceased to function.

I tend to agree with samdie on this.  I'm not sure his example of
regexes is so good, but the majority of questions tend to get RTFM's
or use module X responses.  I will readily conceed that many of the
question deserve such responses (ie, "How do I send mail from a CGI?"
& the like), but people seem a little too eager to respond in this
manner, as I think happened here.

-- 
Peter Fein                                                         773-834-6206
1005 E. 60th St.                                              Chicago, IL 60637
p-fein@uchicago.edu                                   http://pfein.home.ml.org/


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

Date: Sun, 07 Jun 1998 19:50:02 GMT
From: bobbybooby@my-dejanews.com
Subject: Re: HTTP Header Info
Message-Id: <6leqta$sek$1@nnrp1.dejanews.com>

I think I may have been unclear.  I think I have the correct group.

Here's the story.  The site I'm working on is  driven using a perl script
calling the content from a flat database file (so I can use a layout
template).  Each link in the site is pointing to the script with a filename
delimiter (i.e., <A HREF="cgi-bin/script.pl?filename">name</A> (an implied
GET, thus the reason for the URL Address Window showing
"http://www.servername.com/cgi-bin/script.pl?filename").  If I called using
an implied POST (i.e., <A
HREF="cgi-bin/script.pl?filename=filename">name</A>, I'd eliminate the
"?filename" information caused by the GET, but would still get the
"http://www.servername.com/cgi-bin/script.pl" part.  I do not want the
browser clients to show full URL in the Address window, I want the URL parsed
and have the browser only show the main URL info (i.e.,
http://www.servername.com).  I realize that I can turn off showing the
address in my browser - duh!  The question is, can I control what address is
shown in the browser address window from within the perl script potentially
by declaring the HTTP headers to override the actual?  Thus the reason for
the posting here.

In article <357a81e7.7719049@news.btinternet.com>,
  Gellyfish@btinternet.com (Jonathan Stowe) wrote:
>
> On Sun, 07 Jun 1998 05:59:20 GMT, bobbybooby@my-dejanews.com wrote :
>
> >Does anyone know how to do the following?
> >
> >I'd like to control the address that appears in the browser address bar.  I
> >have a site that draws the info from a flat files using perl and forms and
> >the resulting URL that appears in the Browser Address bar looks like
> >"http://www.servername.com/cgi-bin/script.pl?filename"
> >
>  Eh,oh
> Yes thats what happens when the HTTP request method is GET and this
> will happen whatever language the CGI is written in. If you dont like
> it you could always check in the documentation for your browser how to
> hide the URL box.
>
> >Is there a way to set the HTTP header information in the script to fool the
> >browser so it doesn't show all the garbage after the
> >"http://www.servername.com"?  Kind of like
> >
>
> Ask in an appropriate newsgroup about how to use the POST method and
> this isnt an appropriate newsgroup.
>
> >print FILEHANDLE Location:http://www.servername.com";
> >
>
> What do you think that will achieve ?
>
It was an example.  This particular line does nothing.
> /J\
> Jonathan Stowe
> Some of your questions answered:
> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
>
>

-----== Posted via Deja News, The Leader in Internet Discussion ==-----
http://www.dejanews.com/   Now offering spam-free web-based newsreading


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

Date: Sun, 07 Jun 1998 20:34:31 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: HTTP Header Info
Message-Id: <357af587.36748340@news.btinternet.com>

On Sun, 07 Jun 1998 19:50:02 GMT, bobbybooby@my-dejanews.com wrote :

>I think I may have been unclear.  I think I have the correct group.
>

Dong!!  next!
>Here's the story.  The site I'm working on is  driven using a perl script
>calling the content from a flat database file (so I can use a layout
>template).  Each link in the site is pointing to the script with a filename
>delimiter (i.e., <A HREF="cgi-bin/script.pl?filename">name</A> (an implied
>GET, thus the reason for the URL Address Window showing
>"http://www.servername.com/cgi-bin/script.pl?filename").  If I called using
>an implied POST (i.e., <A
>HREF="cgi-bin/script.pl?filename=filename">name</A>

Better check the Documentation bucko.  A POST just dont work like that
its an HTML thing and not appropriate to a Perl Newsgroup.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 07 Jun 1998 21:18:37 GMT
From: brian@brie.com (Brian Lavender)
Subject: Re: HTTP Header Info
Message-Id: <357bff94.1690726@news.jps.net>

[mailed,posted]

You will get a lot of flack for posting this question to this group
even though it can be related to perl. You may wish to also try the
following newsgroup.
 news://comp.infosystems.www.authoring.cgi

Anyway,

here is what I would do. If you want to obfusicate the url encoded
string then I would start with the MIME::Base64 module and encode the
url string (sample code below). I would make your url's in your pages
encoded becuase all they have to do is look at the source in order to
see what the filename is. This will deter the unscrupulous users.
Otherwise you will have to go to some sort of encryption scheme. Take
a look at http://www.wellsfargo.com online banking. You will have to
have an online banking account in order to see it, but they encrypt or
encode their url's so all the stuff is not there out in the open.

Brian
----------------
Brian Lavender
Sacramento,CA
Brie Business Directory - Napa Valley     http://www.brie.com/bbd/
(916) 443-6195

"I hate to advocate drugs, alcohol, violence, or insanity to
anyone, but they've always worked for me."
                                -- Hunter S. Thompson

#!/usr/local/bin/perl

use MIME::Base64;

$encoded = encode_base64('filename');

$url = "http://www.secondLevelDomain.com/cgi-bin/test.cgi?$encoded\n";

print "Encoded \n",$url,"\n";

$decoded = decode_base64($encoded);

print "Decoded:\n",$decoded,"\n";


On Sun, 07 Jun 1998 19:50:02 GMT, bobbybooby@my-dejanews.com wrote:

>I think I may have been unclear.  I think I have the correct group.
>
>Here's the story.  The site I'm working on is  driven using a perl script
>calling the content from a flat database file (so I can use a layout
>template).  Each link in the site is pointing to the script with a filename
>delimiter (i.e., <A HREF="cgi-bin/script.pl?filename">name</A> (an implied
>GET, thus the reason for the URL Address Window showing
>"http://www.servername.com/cgi-bin/script.pl?filename").  If I called using
>an implied POST (i.e., <A
>HREF="cgi-bin/script.pl?filename=filename">name</A>, I'd eliminate the
>"?filename" information caused by the GET, but would still get the
>"http://www.servername.com/cgi-bin/script.pl" part.  I do not want the
>browser clients to show full URL in the Address window, I want the URL parsed
>and have the browser only show the main URL info (i.e.,
>http://www.servername.com).  I realize that I can turn off showing the
>address in my browser - duh!  The question is, can I control what address is
>shown in the browser address window from within the perl script potentially
>by declaring the HTTP headers to override the actual?  Thus the reason for
>the posting here.
>
>In article <357a81e7.7719049@news.btinternet.com>,
>  Gellyfish@btinternet.com (Jonathan Stowe) wrote:
>>
>> On Sun, 07 Jun 1998 05:59:20 GMT, bobbybooby@my-dejanews.com wrote :
>>
>> >Does anyone know how to do the following?
>> >
>> >I'd like to control the address that appears in the browser address bar.  I
>> >have a site that draws the info from a flat files using perl and forms and
>> >the resulting URL that appears in the Browser Address bar looks like
>> >"http://www.servername.com/cgi-bin/script.pl?filename"
>> >
>>  Eh,oh
>> Yes thats what happens when the HTTP request method is GET and this
>> will happen whatever language the CGI is written in. If you dont like
>> it you could always check in the documentation for your browser how to
>> hide the URL box.
>>
>> >Is there a way to set the HTTP header information in the script to fool the
>> >browser so it doesn't show all the garbage after the
>> >"http://www.servername.com"?  Kind of like
>> >
>>
>> Ask in an appropriate newsgroup about how to use the POST method and
>> this isnt an appropriate newsgroup.
>>
>> >print FILEHANDLE Location:http://www.servername.com";
>> >
>>
>> What do you think that will achieve ?
>>
>It was an example.  This particular line does nothing.
>> /J\
>> Jonathan Stowe
>> Some of your questions answered:
>> <URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>
>>
>>
>
>-----== Posted via Deja News, The Leader in Internet Discussion ==-----
>http://www.dejanews.com/   Now offering spam-free web-based newsreading



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

Date: Sun, 7 Jun 1998 16:12:08 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: I'm having problems:
Message-Id: <1da9emb.14k7mx41ak7bb4N@slip166-72-108-25.ny.us.ibm.net>

Randal Schwartz <merlyn@stonehenge.com> wrote:

> No.  Please don't.  Please stop reinventing File::Find.  This code is
> broken, as it will follow symlinks incorrectly, off into gaga land,
> even back to where you've been before, and that'll be an infinite
> loop.  Not only that, but a lot of what you're doing is pretty
> inefficient.
> 
> Please stop reinventing File::Find.

I think the name File::Find is misleading. It ought to be called
File::DirRecurse or something like that.

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


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

Date: Sun, 07 Jun 1998 20:34:33 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: I'm having problems:
Message-Id: <357af6e9.37103155@news.btinternet.com>

On Sun, 7 Jun 1998 16:12:08 -0400, Kevin Reid wrote :

>Randal Schwartz <merlyn@stonehenge.com> wrote:
>
<snip>
>> 
>> Please stop reinventing File::Find.
>
>I think the name File::Find is misleading. It ought to be called
>File::DirRecurse or something like that.
>

Not in the least.  It carries out some of the same functionality as
the find command in Unix.  It was developed (as I understand) to
support the find2perl utility.  Lets not forget the heritage here.

/J\

Sometimes I feel like I'm almost gone ...

<Trad arr. Paul Robeson >
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: 7 Jun 1998 21:05:23 GMT
From: mike@stok.co.uk (Mike Stok)
Subject: Re: lines of text, inserting spaces
Message-Id: <6levaj$4m8@news-central.tiac.net>

You might consider using unpack if you're dealing with formatted records.
The debugger example below carves up the line into fields containing 4, 4,
5, 6 characters and the rest of the line, and then the print takes
advantage of spaces being inserted between array elements inside double
quotes:

  DB<1> $str = "112121821745647263562393434941947\n"

  DB<2> @fields = unpack 'a4 a4 a5 a6 a6 a*', $str

  DB<3> print "@fields"
1121 2182 17456 472635 623934 34941947

  DB<4> 

The description of pack in the perlfunc man page should describe what the
template (first arg of unpack) is.

Hope this helps,

Mike

In article <3579AF2E.54FDB9E7@ibm.net>,  <plener@ibm.net> wrote:
>newbie needs some help on inserting spaces in lines of continuous
>text--fi;e is 250 megs of text data and each line is erminated by a
>carrage return
>data looks like this 112121821745647263562393434941947 ......cr
>i need to insert spacea at certain positions
>so data looks like this
>1212 1218 45678 7677767 121212..
>please note that the above data is just examples
>i need to insert the space to act as a deliminater for a statistical
>data file
>can you help?
>i have looked in the books and kind of got some idea on how to do it
>but really need a little basic help
>could you  please also email me your answer?
>plener@ibm.net
>


-- 
mike@stok.co.uk                    |           The "`Stok' disclaimers" apply.
http://www.stok.co.uk/~mike/       |   PGP fingerprint FE 56 4D 7D 42 1A 4A 9C
http://www.tiac.net/users/stok/    |                   65 F3 3F 1D 27 22 B7 41
stok@colltech.com                  |            Collective Technologies (work)


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

Date: Sun, 7 Jun 1998 16:06:16 -0500
From: tadmc@flash.net (Tad McClellan)
Subject: Re: newbie ques:  Here Documents
Message-Id: <8cvel6.6qc.ln@localhost>

Jonathan Stowe (Gellyfish@btinternet.com) wrote:
: On 7 Jun 1998 07:45:26 GMT, angst wrote :

: >Timothy Lowe <timlowe@u.washington.edu> wrote:

[snip here-doc terminator not found]


: > Also, make sure the HTML on a line by itself is
: >not indented (ie, the H is the first character on the line).
: >

: That is almost certainly the case.  


With the number two case being when the scripts are developed on
dissimilar platforms, and then FTP'd in BINARY mode.

Be sure to use ASCII mode if you are switching between systems.


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


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

Date: Sun, 07 Jun 1998 20:38:24 GMT
From: garyg@gator.net (Gary M. Greenberg)
Subject: Re: Not even an RFD (yet)... comp.lang.perl.(newbie|questions)
Message-Id: <4TCe1.700$%a.752646@news.randori.com>

In article <3578314D.57C3@min.net>, jdporter@min.net wrote:
> Matt Curtin wrote:
> > 
> > I'm getting concerned about the quality of clpm, [snip]...
> > If we could move some of the less technical,
> > hand-holding, newbie-oriented sort of traffic
> 
Let's create:
        comp.lang.perl.help-me
        ;p
> q{
>   This is a FAQ.  (Although it's not in the FAQ yet.)
> 
>   Please use DejaNews to research this issue: 
>   that's why God gave us DejaNews.
> }
> 
> In a nutshell: it's a stupid idea.
> 
> John Porter

otoh, what is the status of the potential c.l.p.moderated?

Cheers,

gary         -=-  The C Programmers' Reference  -=-
              http://www.gator.net/~garyg/C/c.html
        -=-  Avenue Programmers' Classes' Requests  -=-
             http://www.gator.net/~garyg/class.htm


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

Date: Sun, 07 Jun 1998 20:15:02 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: perl-frage
Message-Id: <357af3f8.36350024@news.btinternet.com>

On 7 Jun 1998 17:46:26 GMT, wolfram.oehms wrote :

>Wer kann mir helfen?
>

I will write two hundred times "I will not feed that through
babelfish".

English please.  Or use a de.* newsgroup.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 07 Jun 1998 20:15:01 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: problem with LWP
Message-Id: <357af338.36160807@news.btinternet.com>

On Sun, 7 Jun 1998 11:16:06 +0500, tower wrote :

>Thanks very much for all the help.  I'm at the stage now from copying some
>code in previous posts where I run the below and get further, but still no
>cigar.  The error message the below gives me is:
>
>D:\Projects\Tiger>perl proxyhelp3.pl
>Error: 501 Protocol scheme '' is not supported
>--- HTTP::Response=HASH(0x88cf18) ---
>RC: 501 (Not Implemented)
>Message: Protocol scheme '' is not supported
>
<snip>

># Set up the proxy
>$ua->proxy('http' => 'http://192.168.1.1:8080/');
>
That will be:

$ua->proxy(['http'] => 'http://192.168.1.1:8080');

that first thing is a list.

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 7 Jun 1998 13:34:19 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Problem with re-iterating if loops...
Message-Id: <MPG.fe498ec8e5920cf989696@nntp.hpl.hp.com>

[This followup was posted to comp.lang.perl.misc and a copy was sent to 
the cited author.]

In article <6lef2n$8ho$1@csnews.cs.colorado.edu>, tchrist@mox.perl.com 
says...
>  [courtesy cc of this posting sent to cited author via email]
> 
> In comp.lang.perl.misc, 
>     Randal Schwartz <merlyn@stonehenge.com> writes:
> :Ewww.  Didn't anyone ever teach you NOT to use A && B || C as if-then-else
> :because it doesn't scale to the times when B returns false?  Ewww.
> 
> But they didn't.  
> 
> :Moral: *don't* use A && B || C for if-then-else.  Use A ? B : C, as
> :Ritchie (via Wall) intended.
> 
> Don't think so.  I know quite exactly what I'm doing.  That's like saying
> "don't use while if $x{K} because you should always say if exists $x{$K}".
> Which would also be going too far.

You surely do know quite exactly what you're doing.  But don't do it too 
often where performance matters.  The peephole optimizer evidently isn't 
smart enough to eliminate the superfluous test for TRUE after each of the 
successful selections.

#!/usr/local/bin/perl -w
use Benchmark;

timethese (1 << 20, {
    '&& ||' => q{ $x = $a && 1 || $b && 2 || $c && 3 || $d && 4 || $e && 
5 || 6 },
    '? :'   => q{ $x = $a ? 1 : $b ? 2 : $c ? 3 : $d ? 4 : $e ? 5 : 6 },
} );
__END__

Benchmark: timing 1048576 iterations of && ||, ? :...
     && ||: 15 secs (12.77 usr  0.03 sys = 12.80 cpu)
       ? :: 10 secs ( 8.25 usr  0.02 sys =  8.27 cpu)

This is perl, version 5.004_03

Of course, the optimizer may be smarter in 5.004_04 :-)

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 7 Jun 1998 20:49:44 GMT
From: ? the platypus {aka David Formosa} <dformosa@st.nepean.uws.edu.au>
Subject: Re: Reading a file from the bottom up
Message-Id: <897252584.760586@cabal>

In <Pine.BSI.3.96.980606201207.639F-100000@pentagon.io.com> REUBEN LOGSDON <rlogsdon@io.com> writes:

[...]

>this reads the file lien-by-line:
>open(F,"<file");
>foreach (<F>) {
>	$myLine = $_;
>	&doSomethingWith($myLine);
>	}

It reads all the file, and then steps threw it line by line.

>this reads file line-by-line from last line to first line:
>open(F,"<file");
>foreach (reverse <F>) {

And theis one reads all the file reverses it and then steps thew it line
by line.

--
I'm a perl programer; if you need perl programing, hire me. 
Please excuse my spelling as I suffer from agraphia; see the url. Support NoCeM
http://www.cit.nepean.uws.edu.au/~dformosa/Spelling.html  http://www.cm.org/ 
I'm sorry but I just don't consider 'because its yucky' a convincing argument


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

Date: Sun, 7 Jun 1998 13:42:46 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: Removing a character from a string
Message-Id: <MPG.fe49b17d320e93c989698@nntp.hpl.hp.com>

In article <357ADE2A.A619986D@matrox.com>, aqumsieh@matrox.com says...
> Ala Qumsieh wrote:
 ...
> > $string =~ tr/&//;
> >
> > Ala
> 
> Oooooppps!
> 
> $string =~ tr/&//d;
> 
> of course ;-)

Ancient advice for carpenters:  Measure twice, cut once!

Unless your newsreader software has an "Oooooppps!" button, of course.  
Mine does -- it's called "Cancel this message".  As your *two* Oooooppps! 
messages were posted within two minutes after the original, you might 
have tried that.

HTH for the future.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: Sun, 7 Jun 1998 16:12:02 -0400
From: kpreid@ibm.net (Kevin Reid)
Subject: Re: Stupid syntax question
Message-Id: <1da6yq7.1ajvhl518c81sqN@slip166-72-108-25.ny.us.ibm.net>

gateway <betabeta@geocities.com> wrote:

>     I just started learning Perl, so forgive me if this is stupid. I can't
> seem to get the syntax right. what I want to do is use a loop to cycle
> through all elements in an array, one at a time, using a variable as the
> array index (ie &array[$counter]). can someone clear this up for me.
> I'm sorry if this sounds simple, but I've tried everything I can think of.

@array = qw(one three two four six five);

foreach $value (@array) {
  print $value, "\n";
  # No index here, but modifying $value
  # modifies the element of the array,
  $value =~ s/e/!/;
}

for ($i = 0; $i < @array; $i++) {
  # explaining this ^^^: when you use an array in scalar context,
  # it returns the number of elements in the array.
  print $array[$i], "\n";
  $array[$i] =~ s/!/e/;
  # This loop is most likely to be what you want.
}

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


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

Date: Sun, 07 Jun 1998 15:21:23 -0400
From: Tim & Kim <peach@cin.net>
Subject: The Very Basics!
Message-Id: <357AE833.E60EF469@cin.net>

Ok,  Lamer question.  Do I have to find a particular CGI directory on my
web page server?  Can I just put a CGI with Perl program up, where my
current page is, and have it run?  Very confused about this as the book
I bought assumes previous genius status.
   Please e-mail if willing to help!
         Thanks!



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

Date: Sun, 07 Jun 1998 20:58:01 GMT
From: Gellyfish@btinternet.com (Jonathan Stowe)
Subject: Re: The Very Basics!
Message-Id: <357afa53.37975913@news.btinternet.com>

On Sun, 07 Jun 1998 15:21:23 -0400, Tim & Kim wrote :

>Ok,  Lamer question.  Do I have to find a particular CGI directory on my
>web page server?  Can I just put a CGI with Perl program up, where my
>current page is, and have it run?  Very confused about this as the book
>I bought assumes previous genius status.

Yep Lamer question Tim or Kim ( and I would guess Tim).  I would get
onto the support people at your ISP

CGI can be done in any language - this newsgroup is concerned with
Perl.  There are newsgroups that concern themselves with CGI issues.

>   Please e-mail if willing to help!

Eh,oh

>         Thanks!
>
No problem

/J\
Jonathan Stowe
Some of your questions answered:
<URL:http://www.btinternet.com/~gellyfish/resources/wwwfaq.htm>



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

Date: Sun, 7 Jun 1998 23:04:59 +0200
From: "Alan J. Flavell" <flavell@mail.cern.ch>
Subject: what's a cross-platform \n please?
Message-Id: <Pine.A41.3.95a.980607223728.35170J-100000@rsplus15.cern.ch>


Despite hunting through the FAQs etc. I'm still confused about precisely
what a \n represents. 

In places it's described as a "newline", which I would understand to be
the platform-specific end-of-line representation whatever that might be;
while in other places it's described as a "linefeed", which I understand
to be one specific control character (\012) irrespective of platform. 

Of course, these two are identical on unix, which is no doubt how the
confusion arises.  What _is_ \n meant to represent on other platforms? 
And does it make any difference whether the file is open for binary or
text?  There are some allusions in the documentation for "open" and
"binmode", but to me they seem to assume that the reader already knows
the answer, which I don't.  They certainly cause me to suspect that when
the authors say "newline" they really mean "linefeed", whereas I would
understand "newline" to mean "platform-specific end of line
representation".

thanks



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

Date: Sun, 7 Jun 1998 14:36:22 -0700
From: lr@hpl.hp.com (Larry Rosler)
Subject: Re: what's a cross-platform \n please?
Message-Id: <MPG.fe4a7b418f03d0898969c@nntp.hpl.hp.com>

In article <Pine.A41.3.95a.980607223728.35170J-100000@rsplus15.cern.ch>, 
flavell@mail.cern.ch says...
> 
> Despite hunting through the FAQs etc. I'm still confused about precisely
> what a \n represents. 
> 
> In places it's described as a "newline", which I would understand to be
> the platform-specific end-of-line representation whatever that might be;
> while in other places it's described as a "linefeed", which I understand
> to be one specific control character (\012) irrespective of platform. 
> 
> Of course, these two are identical on unix, which is no doubt how the
> confusion arises.  What _is_ \n meant to represent on other platforms? 
> And does it make any difference whether the file is open for binary or
> text?  There are some allusions in the documentation for "open" and
> "binmode", but to me they seem to assume that the reader already knows
> the answer, which I don't.  They certainly cause me to suspect that when
> the authors say "newline" they really mean "linefeed", whereas I would
> understand "newline" to mean "platform-specific end of line
> representation".

It makes all the difference whether the file is open for binary or text!

For text files, \n means the "platform-specific end-of-line 
representation".  For binary files, it means "linefeed".  I think there's 
no more to it than that.

There are some other differences, including the interpretation of 
control-Z as input end-of-file in some environments, but they aren't 
relevant to your specific question.

-- 
Larry Rosler
Hewlett-Packard Laboratories
lr@hpl.hp.com


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

Date: 8 Mar 97 21:33:47 GMT (Last modified)
From: Perl-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 8 Mar 97)
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 V8 Issue 2807
**************************************

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