[11556] in Perl-Users-Digest
Perl-Users Digest, Issue: 5156 Volume: 8
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 17 11:07:29 1999
Date: Wed, 17 Mar 99 08:00:20 -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, 17 Mar 1999 Volume: 8 Number: 5156
Today's topics:
Re: 'Securing' a chunk of perl code (Tad McClellan)
Re: 'Securing' a chunk of perl code (Greg Bacon)
[Q] Big-endian IEEE floats I/O with perl <loulou@ltt.ntua.gr>
Re: Can't Increment Counter in FILE Using http:// <rp@win.tue.nl>
Re: difference between my $x = 1 and my $x; $x = 1 <ebohlman@netcom.com>
Re: Embedded-encyption perl interpreters for hiding per <zenin@bawdycaste.org>
Re: Filehandle Q... (Tad McClellan)
Re: Finding end of line <jglascoe@giss.nasa.gov>
Re: How do I split an list of text into separate lists <ebohlman@netcom.com>
How to call CORE::opendir() via AUTOLOAD()? <Jochen.Stenzel.gp@icn.siemens.de>
Re: how to get CGI perl script to run another perl scri <Philip.Newton@datenrevision.de>
How to get stack backtrace into a logfile <prlawrence@lehigh.edu>
Re: How to get stack backtrace into a logfile <jeffp@crusoe.net>
how to run scrip on mac via html <zax@imago.hr>
Re: How to sort a LoL? <ebohlman@netcom.com>
Re: How to sort a LoL? (Tad McClellan)
Re: image sizes <"rhrh@hotmail.com,or,rhardicr"@ford.com>
Re: Install ActivePerl? <ebohlman@netcom.com>
Re: Install ActivePerl? <camerond@mail.uca.edu>
Port of Perl to Vxworks? (Bernard Farrell)
Re: problem with scoping using strict no refs <Philip.Newton@datenrevision.de>
Re: ternary operator (Tad McClellan)
Re: Undefined subroutine error (Tad McClellan)
Re: Variable splitting <Allan@due.net>
Re: Variable splitting <ebohlman@netcom.com>
Re: Variable splitting (Andrew M. Langmead)
Re: Variable splitting (Tad McClellan)
Re: Which OS am I in <zenin@bawdycaste.org>
Special: Digest Administrivia (Last modified: 12 Dec 98 (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 17 Mar 1999 02:50:31 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: 'Securing' a chunk of perl code
Message-Id: <7smnc7.149.ln@magna.metronet.com>
Sandy Currier (dsc@tiac.net) wrote:
: I would like to obfuscate a chunk of perl code.
[snip]
: be 'really' secure (in the sense that, for example, C compiled
: code is),
compiled C code is not "really" secure either...
: Anyone with experience solving 'source code level' copyright problems
: with deploying perl scripts?
I think the conventional wisdom is to attach a license to it.
Perl FAQ, part 3:
"How can I hide the source for my Perl program?"
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Mar 1999 15:49:20 GMT
From: gbacon@itsc.uah.edu (Greg Bacon)
Subject: Re: 'Securing' a chunk of perl code
Message-Id: <7coiu0$423$1@info2.uah.edu>
In article <36EFAB23.5E49704E@tiac.net>,
Sandy Currier <dsc@tiac.net> writes:
: I would like to obfuscate a chunk of perl code.
#! /usr/bin/perl -w
# Copyright (c) 1998 Greg Bacon. All Rights Reserved.
# This program is free software. You may distribute it or modify
# it (perhaps both) under the terms of the Artistic License that
# comes with the Perl Kit.
use strict;
use integer;
foreach my $file (@ARGV) {
unless (open FILE, $file) {
warn "$0: failed open $file: $!\n";
next;
}
my $key = int rand 256;
my $out = <<EOTop;
#! /usr/bin/perl
my \$prog = '';
{
my \$key = $key;
local \$/;
\$prog = pack "c*",
map { \$_ ^= \$key }
unpack "c*", <DATA>;
}
eval \$prog;
__END__
EOTop
while (<FILE>) {
$out .= pack "c*",
map { $_ ^= $key }
unpack "c*", $_;
}
close FILE;
unless (open FILE, ">$file") {
warn "$0: failed open >$file: $!\n";
next;
}
print FILE $out;
close FILE;
}
__END__
Greg
--
...ccoommiitteess (aside: don't you think committee looks cooler and is easier
to write if we just double every letter and be done with it?).
-- Alex Lopez-Ortiz
------------------------------
Date: Wed, 17 Mar 1999 17:36:11 +0200
From: Costis Angelis <loulou@ltt.ntua.gr>
Subject: [Q] Big-endian IEEE floats I/O with perl
Message-Id: <36EFCBEB.5AD74BD@ltt.ntua.gr>
I handle very often large files containing float numbers, single
precision in binary format. Since I work both on Linux and IRIX, I would
like to know if there is any easy way to deal with portability problems.
Though I guess those who could help me out understand what I mean, let
me explain a little better what I am looking for. I am no Perl expert,
but I managed to find in the man pages that you can write 'network'
format integers consistently, so that they are portable across various
CPU architectures. However, the man page says that this is not
respectively implemented for floats, as there is no similar standard
convention. What I am looking for is some kind of module(?) which might
deal with the problem in this same way, regardless of the machine on
which I sit. The script executes, actually.
I don't care much about speed, despite the large size of the files. The
inconvenience has just been larger...
Thank you for any answers,
Costis 'Mirni' Angelis
--
cangelis@hpc.ntua.gr <--- Preferred
loulou@ltt.ntua.gr
------------------------------
Date: 17 Mar 1999 15:12:45 +0100
From: Reinier Post <rp@win.tue.nl>
Subject: Re: Can't Increment Counter in FILE Using http://
Message-Id: <7cod8t$5kp@cursus02.win.tue.nl>
abigail@fnx.com wrote:
>(What other programs does a browser call? Certainly not CGI programs.)
Lynx does.
--
Reinier
------------------------------
Date: Wed, 17 Mar 1999 14:11:20 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: difference between my $x = 1 and my $x; $x = 1
Message-Id: <ebohlmanF8qsqw.8I4@netcom.com>
Samuel Kilchenmann <skilchen@swissonline.ch> wrote:
: Where can i find a description of the semantic difference between
: a) my $x = something;
: and
: b) my $x; $x = something;
The only difference occurs when 'something' has '$x' in it. In the first
form, the internal $x will refer to a global called $x because the
lexical $x isn't created until after the expression is evaluated. use
strict will catch this. In the second form, any $x in something will be
evaluated as the lexical $x.
------------------------------
Date: 17 Mar 1999 13:58:18 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Embedded-encyption perl interpreters for hiding perl source
Message-Id: <921679380.256338@thrush.omix.com>
[posted & mailed]
Patrick Sweeney <ftidev@fhb.clickcharge.com> wrote:
: We have a need that I suppose is shared by other commercial software
: developers: hiding our source code from competitors, (or from curious
: customers that would create knock-offs from our product source.)
>snip<
Try this out:
ftp://thrush.omix.com/pub/misc/shc-3.0b3.tgz
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
Date: Wed, 17 Mar 1999 03:04:20 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Filehandle Q...
Message-Id: <4mnnc7.149.ln@magna.metronet.com>
Morris (gt4329b@prism.gatech.edu) wrote:
: I figure this will be easy to someone...
: I want a script to call an external program (whois), write the output that
: would normally be echoed to the screen to a file, and then return to normal
: behavior. My latest attempt looks like this:
system("whois $domain >$out_file) && die "system(whois) failed $!";
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 17 Mar 1999 10:19:51 -0500
From: Jay Glascoe <jglascoe@giss.nasa.gov>
To: Rick Delaney <rick.delaney@home.com>, Larry Rosler <lr@hpl.hp.com>
Subject: Re: Finding end of line
Message-Id: <36EFC817.3928D1C5@giss.nasa.gov>
[posted and mailed to Rick and Larry]
Rick Delaney wrote:
[corrections on my curious notions on special characters]
urf. Sorry, thanks to Larry Rosler too for pointing
out my errors on this one. :)
Jay
--
beep beep!
------------------------------
Date: Wed, 17 Mar 1999 14:30:54 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How do I split an list of text into separate lists of paragraphs
Message-Id: <ebohlmanF8qtnI.9Gn@netcom.com>
Jim Britain <jbritain@home.com> wrote:
: There's got to be a better way to break text to paragraphs..
: Code snippet:
: foreach (@abstract){
: if (/^$/ or $set){
: push(@para2, $_);
: $set=1;
: }else{
: push(@para1, $_);
: }
: }
: I can forsee the day, when I may need more than two paragraphs, and
: for a week now, I have been trying to generate a list of paragraphs
: for an arbitrary number of paragraphs without success.
You'll probably want to use a two-dimensional array ('list of lists' aka
lol) to store the paragraphs, rather than separate variables. We'll call
it @paras.
my $nparas=0;
foreach (@abstract){
++$nparas if /^$/;
push(@{$paras[$nparas]}, $_);
}
Note that this duplicates your code's behavior of treating the blank line
between paragraphs as the first line of the next paragraph.
------------------------------
Date: Wed, 17 Mar 1999 14:39:03 +0100
From: "Hr. Jochen Stenzel" <Jochen.Stenzel.gp@icn.siemens.de>
Subject: How to call CORE::opendir() via AUTOLOAD()?
Message-Id: <36EFB077.9F3E1DB1@icn.siemens.de>
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<body text="#000000" bgcolor="#FFFFFF" link="#0000FF" vlink="#FF0000" alink="#000088">
Hello,
<p>I want to override some builtin function, e.g. opendir(), to call my
own functions instead. To handle candidates that are currently not oevrridden
yet, I wrote a simple AUTOLOAD():
<p>- snip ----
<p># declare functions to override
<br>use subs qw(opendir);
<p># emulate undefined overridden functions
<br>sub AUTOLOAD
<br> {
<br> # trim package
<br> my $function=$AUTOLOAD;
<br> $function=~s/.*:://;
<p> # info
<br> warn "[Warn] $function() is not overridden yet, calling
CORE::$function().";
<p> # call core function
<br> eval "my \$rc=CORE::$function(\@_)";
<br> warn "[Trace] CORE::$function(", join(", ", @_), ") replied
$rc (", $@ ? "error message: $@" : 'no error', ).\n";
<br> $rc;
<br> }
<p>opendir(D, '.');
<p>- snip ---
<p>This code fails if opendir() is called, the eval() result trace displays
"Not enough arguments for opendir at (eval 16) line 1". If I remove "opendir"
from the "use subs" list, the final opendir() call works.
<p>What's wrong here?
<p>Thanks in advance
<p>
J. Stenzel
<br>
<br>
</body>
</html>
------------------------------
Date: Wed, 17 Mar 1999 15:46:13 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: how to get CGI perl script to run another perl script
Message-Id: <36EFC035.727F51D9@datenrevision.de>
(Followups set to comp.lang.perl.misc)
Mean Gene wrote:
>
> I've got a monster CGI perl script that produces reports by using an
> ODBC connection to MS SQL Server.
>
> On fair-to-large reports, the script fails with "Out of memory".
>
> One idea I had was to run the database query as a separate script, and
> have it create a text file with the query results. The main script
> could then read the text file and continue with the report. I thought
> of this because I have heard that the ODBC library is a memory-hog.
>
> However, I can't get the report script to successfully call another
> perl script. I'm currently calling the script using backticks. While
> testing this capability, I find that I can run NT-internal commands
> such as 'dir' using backticks, but external commands such as mem.exe
> will not run.
>
> I'm a novice at CGI programming, so this may be a well-known
> occurrence but I'm in the dark.
You should probably not run the other command with backticks, but rather
with the system() function (perldoc -f system for details), if you're
not planning on capturing the output of the other script.
As I understand you, the other script is only supposed to create a file,
which is going to be read by the main script -- it won't produce any
other output. In that case, system() is probably better.
As for not being able to find things, my guess is that your path is not
set correctly. What does $ENV{'PATH'} give you inside a Perl script?
Cheers,
Philip
------------------------------
Date: Wed, 17 Mar 1999 10:07:05 -0500
From: "Phil R Lawrence" <prlawrence@lehigh.edu>
Subject: How to get stack backtrace into a logfile
Message-Id: <7coges$1so0@fidoii.cc.Lehigh.EDU>
I like all the info that spills out when I die() with use diagnostics. I read
that Carp->confess() does something similiar. However, I don't want to have all
that info going to STDERR, just to a logfile.
How can I get to the backtrace info so i can dump it into the logfile and not
have it display on the screen?
--
Phil R Lawrence
Lehigh University
Enterprise Systems Implementation
Programmer / Analyst
prlawrence@lehigh.edu - work
prlawrence@planetall.com - personal
------------------------------
Date: Wed, 17 Mar 1999 10:39:38 -0500
From: evil Japh <jeffp@crusoe.net>
Subject: Re: How to get stack backtrace into a logfile
Message-Id: <Pine.GSO.3.96.990317103842.28812J-100000@crusoe.crusoe.net>
> How can I get to the backtrace info so i can dump it into the logfile and not
> have it display on the screen?
It dumps it to STDERR. So, read
perldoc -f open
to find out how to open STDERR to a file. It will even tell you how to
save the old STDERR, should you want it back.
--
Jeff Pinyan (jeffp@crusoe.net)
www.crusoe.net/~jeffp
Crusoe Communications, Inc.
973-882-1022
www.crusoe.net
------------------------------
Date: Wed, 17 Mar 1999 15:41:19 -0800
From: Super-User <zax@imago.hr>
Subject: how to run scrip on mac via html
Message-Id: <36F03D9F.4D64DD56@imago.hr>
I am new to perl and this newsgroup, so please be gentle with the
answers.
Is there something I should put down in the first line of the script
like a path to perl app, and how to set it.
------------------------------
Date: Wed, 17 Mar 1999 14:32:30 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: How to sort a LoL?
Message-Id: <ebohlmanF8qtq6.9IA@netcom.com>
Federico Abascal <fabascal@gredos.cnb.uam.es> wrote:
: I have an array of two element arrays, and I want to sort it by the
: number contained in the second element of each of the arrays of the
: array. (In C/C++: sort by array[i][1]). Do you know how to do it?
Take a look at the discussion entitled "How do I sort an array by
(anything)?" in perlfaq4.
------------------------------
Date: Wed, 17 Mar 1999 03:39:58 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: How to sort a LoL?
Message-Id: <uopnc7.149.ln@magna.metronet.com>
Federico Abascal (fabascal@gredos.cnb.uam.es) wrote:
: I have an array of two element arrays,
Sounds to me like a hash would be a better data structure
for the job, provided that the first elements are unique...
: and I want to sort it by the
: number contained in the second element of each of the arrays of the
: array. (In C/C++: sort by array[i][1]). Do you know how to do it?
------------------
#!/usr/bin/perl -w
use strict;
my @ra = ( ['Bubba', 250],
['Joe', 200],
['Mary', 225]
);
# Schwartzian Transform
my @sorted = map { $_->[0] }
sort { $a->[1] <=> $b->[1] }
map { [ $_, $$_[1] ] } @ra;
foreach (@sorted) {
print "$$_[0] ==> $$_[1]\n";
}
------------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 17 Mar 1999 13:39:36 +0000
From: Richard H <"rhrh@hotmail.com,or,rhardicr"@ford.com>
Subject: Re: image sizes
Message-Id: <7cob9r$evh1@eccws1.dearborn.ford.com>
>
> you probably want the Image::Size
>
> use Image::Size;
> ($x, $y) = imgsize("something.gif");
>
cunning really when you think about it !! :-)
Richard H
------------------------------
Date: Wed, 17 Mar 1999 14:16:58 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Install ActivePerl?
Message-Id: <ebohlmanF8qt0A.8pC@netcom.com>
Michael Stevens <michaelx59@hotmail.com> wrote:
: Hi, I'm a Window95 user just starting with Perl. I have Perl for Win32
: build 315 installed on my computer. I have noticed a download from
: Activestate called ActivePerl. Could someone tell me if this would be
: better than my current installation? I know it comes with more tools but
: I'm not sure what they all do.
ActivePerl is ActiveState's port of perl 5.005. Unlike the 300-series
builds of 5.003, ActivePerl is built from the standard Perl source code
used to build perl on Unix and other systems, so it's *much* easier to
install modules and the like.
There's been quite a lot of improvement in Perl since 5.003 (which is
about two years old), so I'd definitely advise upgrading. Oh, and
ActivePerl comes with a complete set of Perl documentation, unlike the
300-series builds.
: If I do install ActivePerl do I need to uninstall my current interpreter
: first?
Not necessarily.
------------------------------
Date: Wed, 17 Mar 1999 09:12:11 -0600
From: Cameron Dorey <camerond@mail.uca.edu>
To: Michael Stevens <michaelx59@hotmail.com>
Subject: Re: Install ActivePerl?
Message-Id: <36EFC64B.6ABA7F3@mail.uca.edu>
[cc'd to ms]
Your version of Perl is ancient in computer time. Go ahead and uninstall
your Perl (less on the disk is always better, IMHO) and install
ActivePerl. It is as up to date Perl as you can get (unless you roll
your own) and simple to install.
Cameron
camerond@mail.uca.edu
Michael Stevens wrote:
>
> Hi, I'm a Window95 user just starting with Perl. I have Perl for Win32
> build 315 installed on my computer. I have noticed a download from
> Activestate called ActivePerl. Could someone tell me if this would be
> better than my current installation? I know it comes with more tools but
> I'm not sure what they all do.
>
> If I do install ActivePerl do I need to uninstall my current interpreter
> first?
> --
> Michael Stevens
> michaelx59@hotmail.com
------------------------------
Date: Wed, 17 Mar 1999 10:28:09 -0500
From: bernard@ultranet.com (Bernard Farrell)
Subject: Port of Perl to Vxworks?
Message-Id: <MPG.115994108b00b11a989685@news.ma.ultranet.com>
Has anyone ported Perl (5.x or 4.x) to VxWorks?
I'm intrigued that I can find a port of Tcl and Python for VxWorks, but
apparently no one has done the same for Perl.
Please email direct at bernard@bernardfarrell.com if you can help as I
don't read these newsgroups very often.
Thanks
Bernard
bernard@bernardfarrell.com
------------------------------
Date: Wed, 17 Mar 1999 16:01:07 +0100
From: Philip Newton <Philip.Newton@datenrevision.de>
Subject: Re: problem with scoping using strict no refs
Message-Id: <36EFC3B3.D91A8AF8@datenrevision.de>
(Followups set to comp.lang.perl.misc)
Tim Speevack wrote:
>
> I have an (unpredictable) series of name/value pairs stored in a database.
> I need to extract these pairs from the database and dynamically create
> variables of the same name as the 'name' column from the database.
Is there a special reason why this could not be solved using a hash?
("A hash is your own portable namespace")
> If I don't use strict, this works fine:
> ${$name_from_database} = $value_from_database;
> Assuming the name/value from the database was "foo" and "bar" respectively,
> the statement above would create the variable $foo = "bar". No problem.
Even if you "use strict;", this will still work:
my %var;
$var{$name_from_database} = $value_from_database;
> If I use strict it won't allow me to "use string ("foo") as a SCALAR ref
> while "strict refs" in use". To get around that error I added 'no strict
> refs'.
>
> After adding 'no strict refs', it allows the statement, but the assignment
> doesn't happen, I assume because of scoping, but I really don't understand
> what's happening.
>
> Here's a script which demonstrates what I'm trying to accomplish, though it
> doesn't work. Anyone have any ideas? (Feel free to tell me I'm going about
> this the wrong way).
>
> #!perl
You forgot "-w" (see the first item under "BUGS" in `man perl`)
> use strict;
> no strict 'refs';
Same effect (currently) as "use strict qw(vars refs);" -- if you tell
Perl explicitly what to be strict about, it won't be strict about
anything else. However, if you use a hash, you can just "use strict;"
and let Perl be strict about everything.
> # normally this is populated from the database, but for
> # this demo, I'll populate it manually:
> my @dbvariables = ();
> $dbvariables[0] = { "name","var_one","value","1" };
> $dbvariables[1] = { "name","var_two","value","2" };
Probably clearer and more idiomatical as:
$dbvariables[0] = { name => "var_one",
value => 1 };
$dbvariables[1] = { name => "var_two",
value => 2 };
Here, the => quotes the bareword to its left. Furthermore, using =>
serves to show up more clearly the comma separating key from value, from
the comma separating one key-value pair from the next.
>
> # These are the variables I need to create dynamically.
> # my goal is to NOT create them here, but I've been
> # trying lots of variations on this theme.
> my $var_one;
> my $var_two;
my %var;
>
> for my $record ( @dbvariables ) {
> print "record contains: $record->{name} = $record->{value}\n";
>
> # create $var_one = 1, e.g.:
> ${$record->{name}} = $record->{value};
$var{$record->{name}} = $record->{value};
>
> print "in loop, var_one = [$var_one]\n";
> print "in loop, var_two = [$var_two]\n";
print "in loop, var_one = [$var{var_one}]\n";
etc.
similaraly for "after"
> }
>
> print "after var_one = [$var_one]\n";
> print "after var_two = [$var_two]\n";
You may also wish to read Mark-Jason Dominus' little anecdote on using
variables as variable names, at
http://www.plover.com/~mjd/perl/varvarname.html .
Cheers,
Philip
------------------------------
Date: Wed, 17 Mar 1999 04:25:35 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: ternary operator
Message-Id: <fesnc7.149.ln@magna.metronet.com>
23_skidoo (23_skidoo@geocities.com) wrote:
: been unable to find a reference for ternary in the perlfaq. does it go
: by any other names or can someone point me to a reference?
perlop.pod
---------------
=head2 Conditional Operator
Ternary "?:" is the conditional operator, just as in C.
...
---------------
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 17 Mar 1999 02:59:25 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Undefined subroutine error
Message-Id: <tcnnc7.149.ln@magna.metronet.com>
John (John@melon17.freeserve.co.uk) wrote:
: On Tue, 16 Mar 1999 21:14:04 -0500, tadmc@metronet.com (Tad McClellan)
: wrote:
: >Paul Cameron (thrase@slip.net) wrote:
: >: John wrote:
: >
: >: > I run a perl script via a cgi with no real problem.
: >: >
: >: > When i run it from a cronjob i get undefined sub-routine
: >: > error.
: >: >
: >: > Does anyone know why i might be getting this ?
: >
: >: My remote debugging skills (operating through the medium of
: >: telepathy) are rather weak.
: >
: >
: > But mine is working fine.
: >
: > There is an error on line 17.
: >
: Zzzzzzz........wrong
My point was that we cannot tell you what is wrong with
code that we cannot see.
You have pretty much forced us to guess, so I guessed...
Can you make a small and complete program that exhibits
the problem that you are having?
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: Wed, 17 Mar 1999 09:23:03 -0500
From: "Allan M. Due" <Allan@due.net>
Subject: Re: Variable splitting
Message-Id: <7codf7$gad$1@camel19.mindspring.com>
Ruud Limbeck wrote in message <36ef893c.10566640@news.NL.net>...
:Hi there ;
:I need to split up a variable but is don't work .....
:The problemm $test contains : thisisatestandiwant
:All I want to have is test (actually 7 characters from
:the beginning and 4 caracters long .and drop it in a
:variable called $new .
So you a substring from within the string $test that starts 7 characters
from the start and is 4 characters long? Very intuitive in Perl <g>.
perldoc -f substr
$test ='thisisatestandiwant';
$new = substr($test,7,4);
print $new;
HTH
AmD
--
$email{'Allan M. Due'} = ' All@n.Due.net ';
--random quote --
An old pond-
The sound of the water
When the frog jumps in
- Basho
------------------------------
Date: Wed, 17 Mar 1999 14:21:48 GMT
From: Eric Bohlman <ebohlman@netcom.com>
Subject: Re: Variable splitting
Message-Id: <ebohlmanF8qt8C.8ww@netcom.com>
Ruud Limbeck <ruud.limbeck@tip.nl> wrote:
: I need to split up a variable but is don't work .....
: The problemm $test contains : thisisatestandiwant
: All I want to have is test (actually 7 characters from
: the beginning and 4 caracters long .and drop it in a
: variable called $new .
You don't say what you've been trying to do that doesn't work, nor in
what way it doesn't work, but it sounds like
$new=substr($test,7,4);
is what you're looking for. perldoc -f substr if you're not familiar
with this extremely useful function.
------------------------------
Date: Wed, 17 Mar 1999 14:58:55 GMT
From: aml@world.std.com (Andrew M. Langmead)
Subject: Re: Variable splitting
Message-Id: <F8quy7.Ewz@world.std.com>
ruud.limbeck@tip.nl (Ruud Limbeck) writes:
>I need to split up a variable but is don't work .....
>The problemm $test contains : thisisatestandiwant
It doesn't work? What have you tried? Here are some solutions that I
can think of, some being better than others.
$new = substr($test, 7, 4);
$new = unpack 'x7a4', $test;
($new) = ($test =~ /.{7}(.{4});
$new = join '', (split //, $test)[7 .. 10];
--
Andrew Langmead
------------------------------
Date: Wed, 17 Mar 1999 03:06:19 -0500
From: tadmc@metronet.com (Tad McClellan)
Subject: Re: Variable splitting
Message-Id: <rpnnc7.149.ln@magna.metronet.com>
Ruud Limbeck (ruud.limbeck@tip.nl) wrote:
: The problemm $test contains : thisisatestandiwant
: All I want to have is test (actually 7 characters from
: the beginning and 4 caracters long .and drop it in a
: variable called $new .
$new = substr $test, 7, 4;
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Mar 1999 14:03:02 GMT
From: Zenin <zenin@bawdycaste.org>
Subject: Re: Which OS am I in
Message-Id: <921679664.481793@thrush.omix.com>
[posted & mailed]
Stephen Montgomery-Smith <stephen@math.missouri.edu> wrote:
: How can a perl program tell whether it is running under DOS
: or UNIX?
:
: I looked for a uname like function for perl, but I didn't find it.
perldoc -q 'which operating system'
--
-Zenin (zenin@archive.rhps.org) From The Blue Camel we learn:
BSD: A psychoactive drug, popular in the 80s, probably developed at UC
Berkeley or thereabouts. Similar in many ways to the prescription-only
medication called "System V", but infinitely more useful. (Or, at least,
more fun.) The full chemical name is "Berkeley Standard Distribution".
------------------------------
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 5156
**************************************