[12835] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 245 Volume: 9

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sat Jul 24 18:07:19 1999

Date: Sat, 24 Jul 1999 15:05:09 -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           Sat, 24 Jul 1999     Volume: 9 Number: 245

Today's topics:
        Amateur (Jimtaylor5)
    Re: Amateur <jeffp@crusoe.net>
    Re: Amateur (Garth Sainio)
    Re: Amateur (Neko)
        Best Perl book? <unigni@zaynar.demon.co.uk>
    Re: Best Perl book? <JFedor@datacom-css.com>
    Re: Extracting plain text from email <hiller@email.com>
    Re: Extracting plain text from email <tchrist@mox.perl.com>
    Re: FAQ 9.13: How do I make sure users can't enter valu <cassell@mail.cor.epa.gov>
    Re: Finding duplicate elements in an array? <kejoki@netdoor.com>
    Re: Geekspeak Programming Contest <kejoki@netdoor.com>
    Re: Geekspeak Programming Contest (Neko)
    Re: Geekspeak Programming Contest <tchrist@mox.perl.com>
    Re: Geekspeak Programming Contest <tchrist@mox.perl.com>
        John F. Kennedy, Jr ()
    Re: Perl CGI vs VB ASP <cassell@mail.cor.epa.gov>
        Perl Cookbook 2nd Ed. ? <r28629@email.sps.mot.com>
    Re: Perl Cookbook 2nd Ed. ? <tchrist@mox.perl.com>
        printing array and `\n' - huh? (Eric Smith)
    Re: printing array and `\n' - huh? <jeffp@crusoe.net>
        Regex Problem - I think (r j huntington)
    Re: Regex Problem - I think <hiller@email.com>
        Scalar to Array Question <JFedor@datacom-css.com>
    Re: Scalar to Array Question <hiller@email.com>
    Re: Scalar to Array Question <JFedor@datacom-css.com>
    Re: Scalar to Array Question <JFedor@datacom-css.com>
    Re: Scalar to Array Question <aperrin@mcmahon.qal.berkeley.edu>
        Using FAQ in ActiveStates Perl <JFedor@datacom-css.com>
    Re: Variables in Regx? (Abigail)
        Waiting for system ?? <info@servicepool.de>
    Re: WinNT MD5|SHA Perl (Reini Urban)
        Digest Administrivia (Last modified: 1 Jul 99) (Perl-Users-Digest Admin)

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

Date: 24 Jul 1999 19:51:36 GMT
From: jimtaylor5@aol.com (Jimtaylor5)
Subject: Amateur
Message-Id: <19990724155136.25917.00001389@ng-cn1.aol.com>

I have this complicated and I'm quite sure amateurish was of reading the first
two lines of a 10 line file into two variables. Here's how I write it (don't
laugh). I know there is a better way to do this. Can anyone help?

 open(CONFI,"conf2.txt") || die "Error reading from configuration file $!\n";
   @lines = <CONFI>;
   close(CONFI);

foreach $line (@lines) {
  while ($counter < 2) {
       if ($counter < 1) {
	   $counter++;
	   $wordline = $line;
	
	   }
	   else {
	   $locks = $line;
	
	   $counter++;
       }
     }
   }


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

Date: Sat, 24 Jul 1999 16:30:10 -0400
From: japhy <jeffp@crusoe.net>
Subject: Re: Amateur
Message-Id: <Pine.GSO.4.10.9907241628520.6977-100000@crusoe.crusoe.net>

[posted & mailed]

On 24 Jul 1999, Jimtaylor5 wrote:
> I have this complicated and I'm quite sure amateurish was of reading the first
> two lines of a 10 line file into two variables. Here's how I write it (don't
> laugh). I know there is a better way to do this. Can anyone help?

[snipped his amateur ways...]

open FILE, "file" or die "can't open file: $!";
$line1 = <FILE>;
$line2 = <FILE>;
close FILE;

# you can chomp() if you wish


Read the perl docs.  If you have perl, you have the perl docs.  If you
don't have the perl docs, go to perl.com.

-- 
jeff pinyan    japhy@pobox.com
japhy's little hole in the (fire) wall:   http://www.pobox.com/~japhy
perl stuff     japhy+perl@pobox.com
japhy's perl supposit^Wrepository:        http://www.pobox.com/~japhy/perl



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

Date: Sat, 24 Jul 1999 16:34:16 -0400
From: modred@shore.net (Garth Sainio)
Subject: Re: Amateur
Message-Id: <modred-2407991634170001@gniqncy-s01-060.port.shore.net>

In article <19990724155136.25917.00001389@ng-cn1.aol.com>,
jimtaylor5@aol.com (Jimtaylor5) wrote:

!! I have this complicated and I'm quite sure amateurish was of reading
the first
!! two lines of a 10 line file into two variables. Here's how I write it (don't
!! laugh). I know there is a better way to do this. Can anyone help?
!! 
!!  open(CONFI,"conf2.txt") || die "Error reading from configuration file $!\n";
!!    @lines = <CONFI>;
!!    close(CONFI);
!! 
!! foreach $line (@lines) {
!!   while ($counter < 2) {
!!        if ($counter < 1) {
!!            $counter++;
!!            $wordline = $line;
!!         
!!            }
!!            else {
!!            $locks = $line;
!!         
!!            $counter++;
!!        }
!!      }
!!    }


You probably don't want to read the whole file into an array, for large
files you use a lot of memory you generally don't need to.

If you only care about the first two lines of the file, I'd use something
like the following after the open.

$wordline = <CONFI>;
$locks = <CONFI>;
close(CONFI);

Garth

-- 
Garth Sainio               "Finishing second just means you were the 
modred@shore.net            first to lose" - anonymous


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

Date: 24 Jul 1999 21:08:10 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Amateur
Message-Id: <7nd9vq$p5c$1@216.39.141.200>

On 24 Jul 1999 19:51:36 GMT, jimtaylor5@aol.com (Jimtaylor5) wrote:

>I have this complicated and I'm quite sure amateurish was of reading the first
>two lines of a 10 line file into two variables. Here's how I write it (don't
>laugh). I know there is a better way to do this. Can anyone help?
>
> open(CONFI,"conf2.txt") || die "Error reading from configuration file $!\n";
>   @lines = <CONFI>;
>   close(CONFI);

    ($wordline, $locks) = @lines;

One day, you're going to want to read the first two lines in a 10MB file, and
slurping the entire file into an array becomes unpractical.

    open CONFI, 'conf2.txt' or die "Couldn't open 'conf2.txt': $!";
    $wordline = <CONFI>;
    $locks    = <CONFI>;
    close CONFI;

Perhaps perl optimizes this to read only two lines and seek to the end of the
file (I do not know this to be true):

    ($wordline, $locks) = <CONFI>;

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: Sat, 24 Jul 1999 22:14:29 +0100
From: Unigni <unigni@zaynar.demon.co.uk>
Subject: Best Perl book?
Message-Id: <Gwvv+EA1yim3Ew2T@zaynar.demon.co.uk>

I have a little programming experience, and want to start learning Perl,
probably for CGI use on the Web... Can anybody suggest what would be the
best book(s) to get?
-- 
Philip Taylor
philip @ zaynar . demon . co . uk
http://www.ultrastore.com -- "The Shopping Experience of Tomorrow - NOW!"
     (an example of what can be done with *loads* of JavaScript and cookies!)


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

Date: Sat, 24 Jul 1999 18:06:01 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Best Perl book?
Message-Id: <7ndbdj$r9v$1@plonk.apk.net>


Unigni wrote in message ...
>I have a little programming experience, and want to start learning Perl,
>probably for CGI use on the Web... Can anybody suggest what would be the
>best book(s) to get?


I use mostly O'Reilly books:

Programming Perl (Camel Book) - Wall, Christiansen & Schwartz
Perl Cookbook (Ram Book) - Christiansen & Torkington
Learning Perl  (Llama Book) - Schwartz & Christiansen
Mastering Regular Expressions (Owl Book) - Friedl
Advanced Perl Programming (Panther Book) - Srinivasan

for Web/CGI/Perl

CGI/Perl Cookbook - Wiley - Patchett & Wright
Web Programming with Perl 5 - Sams.net - Middleton, Deng & Kemp

Jody




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

Date: Sat, 24 Jul 1999 21:50:58 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Re: Extracting plain text from email
Message-Id: <379A3548.1B0F446A@email.com>

If you are using Mail::POP3Client you can get the body of the message by
using $msg->Body($msgnum).

Modules and pre-written scripts also exist for stripping HTML tags. My
advice is just to not try to re-invent the wheel in that respect.

Jordan

Roger wrote:
> How can you get the plain text version of an email out of all the headers
> and if it been sent in html format loose all the formating below the main
> body of the message.

Jordan Hiller (hiller@email.com)

JavaScript and Perl programs for
 making online tests and quizzes:
http://web-shack.hypermart.net/quiz.html


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

Date: 24 Jul 1999 15:59:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Extracting plain text from email
Message-Id: <379a372f@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    "Roger" <rexcell@btinternet.com> writes:
:How can you get the plain text version of an email out of all the headers
:and if it been sent in html format loose all the formating below the main
:body of the message.

What is "loose"?  Did you mean to write "lose"?  Why didn't you?
After reading it a dozen times in one day, it gets to you.

Some of us autobounce all HTML or binary mailings sight unseen.
It's better that way.  If more people would do that, there'd be less
crap in our mailboxes.

Send text.

--tom
-- 
When in doubt, use brute force.
                --Ken Thompson


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

Date: Sat, 24 Jul 1999 14:49:54 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
To: Tom and Gnat <perlfaq-suggestions@perl.com>
Subject: Re: FAQ 9.13: How do I make sure users can't enter values into a form that cause my CGI script to do bad things?
Message-Id: <379A3502.549AE2B9@mail.cor.epa.gov>

[cc to perlfaq-suggestions]

Tom Christiansen wrote:
> [header snipped]
>   How do I make sure users can't enter values into a form that cause my CGI script to do bad things?
> 
>     Read the CGI security FAQ, at http://www-
>     genome.wi.mit.edu/WWW/faqs/www-security-faq.html, and the Perl/CGI
>     FAQ at http://www.perl.com/CPAN/doc/FAQs/cgi/perl-cgi-faq.html.
> [snip]

Nice, but...  The first URL gets truncated in a way which may
confuse the person who needs to read the FAQ in the first place.
Could this be re-formatted so that the URL is on only one line?

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 24 Jul 1999 14:39:48 -0500
From: Kevin Kinnell <kejoki@netdoor.com>
Subject: Re: Finding duplicate elements in an array?
Message-Id: <379A1684.16CE3D74@netdoor.com>

Pfash1 wrote:
[snip]
> I want to march thru this array and compare each element to
> every other one to find out if there are any duplicates ...
[snip]
> (ps. I eventually want to eliminate the duplicates so there is
> only one of each.)
> 
> Thanks much,
> Paul Fortier
> pfash@umich.edu

I'll try this one, and if I violate the group ettique... ettequ...
rules of propriety I will be suitably ashamed and do better next
time.

[On the other hand, I'll bet this is the wrong place to post this
question; if so you'll be enlightened and if not I will be. 'B)> ]

Something like

#
foreach $elem (sort @array) {
    ($prev eq $elem) && next;
     $prev = $elem;
     push @uniqary, $elem;
}    
#

should work, with whatever scoping changes you need to
make for the situation..

--
Kevin Kinnell <kejoki@netdoor.com>


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

Date: Sat, 24 Jul 1999 14:45:19 -0500
From: Kevin Kinnell <kejoki@netdoor.com>
Subject: Re: Geekspeak Programming Contest
Message-Id: <379A17CF.ED42851D@netdoor.com>

Larry Rosler wrote:
> 
> In article <3798AFC7.620DCF8F@netdoor.com> on Fri, 23 Jul 1999 13:09:11
> -0500, Kevin Kinnell <kejoki@netdoor.com> says...
> ...
> > Jan 1, 2001 = Jan 1, 2000
> 
> I don't get that.  ITYM:
> 
>   Jan 1, 2000 = Jan 1, 1900
> 
> or, even better,
> 
>   Jan 1, 2000 = Jan 1, 19100
> 
> --
> (Just Another Larry) Rosler

It's a reference to the off-by-one-bug that seems to be
prevalent -- but I like yours even better.
--
Kevin Kinnell <kejoki@netdoor.com>


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

Date: 24 Jul 1999 20:31:56 GMT
From: tgy@chocobo.org (Neko)
Subject: Re: Geekspeak Programming Contest
Message-Id: <7nd7rs$p5c$0@216.39.141.200>

On 24 Jul 1999 12:56:56 -0700, Tom Christiansen <tchrist@mox.perl.com> wrote:

>Users say "Microsoft design flaws".  Lusers say "virii".
>
>    one of them   = virus
>    two of them   = virii
>    three of them = viriii
>    four of them  = viriv
>    five of them  = virv 
>    six of them   = virvi

I actually like that.  Maybe not enough to use in public, but I will
certainly credit you if I do. :)

-- 
Neko | tgy@chocobo.org | Will hack Perl for a moogle stuffy! =^.^=


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

Date: 24 Jul 1999 15:31:01 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Geekspeak Programming Contest
Message-Id: <379a3095@cs.colorado.edu>

This is for inspiration.

--tom

#!/usr/bin/perl 
# 
# geekspeak correspondence lister
# tchrist@perl.com

while (<DATA>) {
    s/\s+$//;
    ($us, $them) = split(/\s*=\s*/, $_, 2);
    push @{ $us2them{$us} }, $them;
    push @{ $them2us{$them} }, $us;
}

for $word ( sort keys %us2them ) {
    next unless $them2us{$word};
    $ours = join " or ", sort @{ $us2them{$word} };
    $theirs = join " or ", sort @{ $them2us{$word} };
    wrapwrite("When I say $word, I mean what you would call $ours, "
	    . "but for you $word means what I would call $theirs.");
}

for $word ( sort keys %us2them ) {
    unless ($them2us{$word}) {  # already mentioned
	$theirs = join " or ", sort @{ $us2them{$word} };
	wrapwrite("Where I say $word, you would say $theirs.");
    }
}

for $word ( sort keys %them2us ) {
    unless ($us2them{$word}) {  # already mentioned
	$ours = join " or ", sort @{ $them2us{$word} };
	wrapwrite("Where you say $word, I would say $ours.");
    }
}
exit;

sub wrapwrite {
    my $msg = $_[0];
    write;

format STDOUT =
^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
$msg

 .

}

__DATA__
CD = CD-ROM
CD drive = CD
CGI scripts = CGIs
CORBA = ActiveX
DNS = domain name system
Evil Empire = AT&T
Evil Empire = Microsoft
Evil One = Bill Gates
FAQ = boring stuff
GUI = Windows
GUI annoyance = wizard
HTML = HTM
HTTP = web
IP = intellectual property
IP = internet protocol
IRC channel = chat room
IRC client = IRC browser
IT = tech-support
Internet Exploder = Internet Explorer
January 1, 2000 = next millennium
MS-ASCII = text
MS-HTML = HTML
Mordor = Redmond
Netscape = Internet
PC = home computer
PC = program counter
TCP/IP = IP
UBE = spam
Unix = UNIX
Unix programmer = elitist
WAN = Intranet
Web-based = Internet technology
Windoze = Windows
Wintel box = PC
a.out = EXE 
access the web = surf the net
alpha = beta
alpha = new technology
arithmetic = math
beggarware = shareware
beginner = newbie
beta = production
big business = enterprise
binaries = programs
binaries = shareware
binary = EXE
binary = eight-bit
binary edit = patch
bloatware = application
bloatware = apps
box = computer
break into = hack
brittle = optimized
browser = Internet
bug fix = upgrade
buggy = beta
buy = get
cat = type
challenging = impossible
check mail = logon to email
clean = simple
client = browser
code = software
coding = creating/making a file
command = system call
commercial network = Extranet
commonplace = ubiquitous
competence = elitism
compile = build
computer = server
computer scientist = engineer
computer scientist = mathematician
computer secretary = admin
condescending = elitist
configurable = confusing
configure = edit a file and rebuild
connect = logon
connect to http://www.foo.com/ = logon to foo.com
console = main monitor
control-C = interrupt 
controller = hard drive
copy = download
copy = upload
coredump = blue screen
couldn't care less = could care less
cracker = hacker
criminal = hacker
crippleware = shareware
customer = client
daemon = server
data = some data
data file = binary file
datum = a data 
delete = backspace
digital nervous system = DNS
directory = folder
disconnected from the Internet = offline
disk = CD-ROM
disk = hard drive
disk controller = hard drive
disk drive = hard drive
disk space = memory
diskette = disk
distracting = flashy
drive = hard drive
editor = text editor
elite = competent 
elite = professional 
elite = top-notch
enterprise = that spaceship from Star Trek
executable = program
executables = programs
expert-hostile = user-friendly
exploited design flaws = viruses
eye trash = banner ads
file = binary file
file = text file
file system = drive letter
file system = hard drive
fix = hire a consultant for
fleeceware = commercial software
fleeceware = software
flexible = difficult
floppy = disk
floppy disk = disk
folder = e-mail folder
function = command
functional = plain
garbage = attachment
get = download
grab = download
greatest common factor = least common denominator
grep = search
guru = god
hack = code up
hacker = coder
hard to read = encrypted
hide = protect
install = load
internal network = Intranet
interrupt = IRQ
kernel + libraries + daemons + tools + GUI = operating system
kernel = OS
kernel = kernal
keyword = command
kill = stop
launch a GUI = configure
legal extortion = per-seat licensing
limited = simple
load = build
log into = logon to
logical disk = drive letter
logical disk = hard drive
login = logon
login = shell account
ls = dir
luser = non-programmer
luser = surfer
luser = user
lying = marketing
mail = e-mail
mail messages = e-mails
mails = sends e-mails
manpage = documentation
mark-up language = programming language
math = advanced math
memory = RAM
message board = chat room
messages = e-mails
messy = good-looking
millennium = millenium
moderate = censor
monitor = computer
monolithic program = application
mount = load
mount point = drive letter
mount point = hard drive
net = web
netiquette = useless manners
network = web
newfs = format
newsgroup = chat room
newsreader = Usenet client
newsreader = news browser
next millennium = January 1, 2001
obscurity = security
obvious = subtle
offline = away from the computer
offline = in real life
on a web server = remote
online = cyberspace
open source = freeware
open source = shareware
open source = source code
operating system = kernel
paid bug fixes = updates
partition = drive letter
partition = hard drive
patch = source edit
physical disk = drive letter
physical disk = hard drive
pirate = copy
pirate = get
plonk = censor
professionalism = elitism
program = binary
program = command
program = script
program crash = program exited prematurely
program loader = DOS
programmer = scripter
programmer = software engineer
programming = scripting
put = upload
rc file = INI file
read the docs = help file
reboot the computer = program crash
remote = on a different computer
root = Administrator
run = double-click
screen = monitor
script kiddie = hacker
scripting = configuring
secretary = HTML programmer
security = authentication and authorization
shared library = DLL
shell command = system call
snob = elitist
snobs = elite 
spamvert = advert
stdin = console
stdout = console
stop = suspend
superuser = Administrator
symbolic link = shortcut
sysadmin = sysop
system call = operating system function
tarball = zip archive
transfer = download
transfer = upload
trojan = virus
unlink = delete
unmount = eject
unusual = unique
user = screen 
user = screen name
vi = notepad
video card = monitor
wizard = guru
worm = virus
www.foo.com = foo.com
-- 
I use `batshit' in an idiosyncratic fashion. --Andrew Hume


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

Date: 24 Jul 1999 15:36:43 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Geekspeak Programming Contest
Message-Id: <379a31eb@cs.colorado.edu>

A post I just read reminded me that I forgot to list

    separated = delimited

Sigh.

--tom
-- 
The most beautiful thing we can experience is the mysterious.  It is the
source of all art and science.                          --Albert Einstein


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

Date: 24 Jul 99 19:34:10 GMT
From: hakn@ecn.ab.ca ()
Subject: John F. Kennedy, Jr
Message-Id: <379a1532.0@ecn.ab.ca>

I'll never understand Americans.  John F. Kennedy wanted to be buried at
sea.  He arranged his funeral that way and they pull him out, dry him off,
burn him and toss his ashes back in the same spot.

--
Harold Knopke


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

Date: Sat, 24 Jul 1999 14:33:20 -0700
From: David Cassell <cassell@mail.cor.epa.gov>
Subject: Re: Perl CGI vs VB ASP
Message-Id: <379A3120.67655B6A@mail.cor.epa.gov>

Ronald J Kimball wrote:
> [snip]
> Language advocacy is pointless in a newsgroup that is dedicated to a
> single language.

It seems to be pretty pointless even in the advocacy groups.
Everyone there seems to be preaching to the choir, or else
blasting trolls like they're The Human Torch.

What more should one do besides point people to available
comparisons, like at perl.com ?  The benchmarks I see tend 
to be on very narrow topics, or else obviously slanted.

David
-- 
David Cassell, OAO                     cassell@mail.cor.epa.gov
Senior computing specialist
mathematical statistician


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

Date: Sat, 24 Jul 1999 13:11:08 -0500
From: TK Soh <r28629@email.sps.mot.com>
Subject: Perl Cookbook 2nd Ed. ?
Message-Id: <379A01BC.16772AFC@email.sps.mot.com>

I though I heard someone said the 2nd Ed. of Perl Cookbook is one its
way, is it real? Anybody?

-TK


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

Date: 24 Jul 1999 15:33:11 -0700
From: Tom Christiansen <tchrist@mox.perl.com>
Subject: Re: Perl Cookbook 2nd Ed. ?
Message-Id: <379a3117@cs.colorado.edu>

     [courtesy cc of this posting mailed to cited author]

In comp.lang.perl.misc, 
    TK Soh <r28629@email.sps.mot.com> writes:
:I though I heard someone said the 2nd Ed. of Perl Cookbook is one its
:way, is it real? Anybody?

Considering that it hasn't even been out for a year, that would
be pretty wicked.

--tom
-- 
Pointers are sharp tools, and like any such tool, used well they can
be delightfully productive, but used badly they can do great damage
(I sunk a wood chisel into my thumb a few days before writing this).
    --Rob Pike


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

Date: 24 Jul 1999 20:24:44 GMT
From: eric@fruitcom.com (Eric Smith)
Subject: printing array and `\n' - huh?
Message-Id: <slrn7pk88t.8hn.eric@plum.fruitcom.com>

Hi

I go

@wow=qw(bumble bee);

and any of these  ...
print "@wow \n";
print @wow;
print "@wow" . "\n";
gives ..
`bumble bee'

But when I go
print @wow . "\n";
I get ...
`2'

Yeah the number of elements in the array or the array in a scalar context.
How so?

-- 
Eric Smith
<eric@fruitcom.com> 
www.fruitcom.com
Tel. 021 423 6111


       We've had reports that on Linux (Redhat 5.1) on Intel,
       undef $scalar will return memory to the system, while on
       Solaris 2.6 it won't.  In general, try it yourself and
       see.
       --- from perlfaq3 ... makes u think



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

Date: Sat, 24 Jul 1999 17:07:06 -0400
From: japhy <jeffp@crusoe.net>
Subject: Re: printing array and `\n' - huh?
Message-Id: <Pine.GSO.4.10.9907241704430.6977-100000@crusoe.crusoe.net>

[posted & mailed]

On 24 Jul 1999, Eric Smith wrote:
> print "@wow \n";
> print @wow;
> print "@wow" . "\n";
> `bumble bee'

  print "@array"
is not interpolating @array in a scalar context.  Rather, it is the
equivelent of
  print join $", @array;
and in most cases, $" = " ".  That is, the $" variable is a space.

> print @wow . "\n";
> `2'

Now that concatenation operator... THAT treats its operands in scalar
context.  So @wow in scalar context is the number of elements in it.

-- 
jeff pinyan    japhy@pobox.com
japhy's little hole in the (fire) wall:   http://www.pobox.com/~japhy
perl stuff     japhy+perl@pobox.com
japhy's perl supposit^Wrepository:        http://www.pobox.com/~japhy/perl



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

Date: 24 Jul 1999 19:18:13 GMT
From: wolph@merlin.albany.net (r j huntington)
Subject: Regex Problem - I think
Message-Id: <7nd3hl$dkj$1@news.monmouth.com>
Keywords: regex

I'm just too inexperienced in perl to figure this out, I guess.
I've read the FAQs, but just haven't been able to find this.

How can I determine if a particular character exists in a 
line (easy) and then remove the char (also easy) AND everything
after it (that's where I have a problem).

Specifically, I need to turn something like

	www.somewebsite.com/something/whatever.html
into
	www.somewebsite.com

I thought of using split, but in fact, there may not be a '/'
char in the actual line, so there would be nothing to split.

What am I missing? Thanks in advance. Forgive me if this is
a bozo question.	-=rjh=-



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

Date: Sat, 24 Jul 1999 19:46:35 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Re: Regex Problem - I think
Message-Id: <379A1823.B7461006@email.com>

How about this:
# UNTESTED

$string =~ s#/.*##;
__END__

Good luck,
Jordan

r j huntington wrote:
> 
> How can I determine if a particular character exists in a
> line (easy) and then remove the char (also easy) AND everything
> after it (that's where I have a problem).

-- 
Jordan Hiller (hiller@email.com)

JavaScript and Perl programs for
 making online tests and quizzes:
http://web-shack.hypermart.net/quiz.html


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

Date: Sat, 24 Jul 1999 17:41:29 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Scalar to Array Question
Message-Id: <7nd9vl$qd4$1@plonk.apk.net>

Don't know where to look for information:

I have a Scalar variable called $items.

$items contains:

1090:2.5" 1.2GB Hard Drive:1:129.00 \n  <--- Carriage return or newline
1250:blah blah:5:5.50 \n

I'd like to turn this into an array so I can process the file using foreach.

If this is a FAQ, let me have it.

Jody




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

Date: Sat, 24 Jul 1999 21:41:22 GMT
From: Jordan Hiller <hiller@email.com>
Subject: Re: Scalar to Array Question
Message-Id: <379A3309.3D238E4A@email.com>

Split into an array of what? Each line? In that case:
my @array = split(/[\r\n]/, $items);

Jordan

Jody Fedor wrote:
> 
> Don't know where to look for information:
> 
> I have a Scalar variable called $items.
> 
> $items contains:
> 
> 1090:2.5" 1.2GB Hard Drive:1:129.00 \n  <--- Carriage return or newline
> 1250:blah blah:5:5.50 \n
> 
> I'd like to turn this into an array so I can process the file using foreach.
> 
> If this is a FAQ, let me have it.
> 
> Jody

-- 
Jordan Hiller (hiller@email.com)

JavaScript and Perl programs for
 making online tests and quizzes:
http://web-shack.hypermart.net/quiz.html


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

Date: Sat, 24 Jul 1999 18:26:05 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Scalar to Array Question
Message-Id: <7ndcja$rrq$1@plonk.apk.net>


Jody Fedor wrote in message <7nd9vl$qd4$1@plonk.apk.net>...
>Don't know where to look for information:
>
>I have a Scalar variable called $items.
>
>$items contains:
>
>1090:2.5" 1.2GB Hard Drive:1:129.00 \n  <--- Carriage return or newline
>1250:blah blah:5:5.50 \n
>
>I'd like to turn this into an array so I can process the file using
foreach.
>
>If this is a FAQ, let me have it.
>
>Jody

my @itema = ($items =~ /\n/g);

foreach $itema (@itema) {
  ($item, $desc, $qty, $price) = split /:/, $itema, 4;
  print "$item, $desc, $qty, $price<br>";
  }

This does not work, I only get a row of ,,, as the output, funny though, I
get the exact number of rows as there are items in the scalar.

help




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

Date: Sat, 24 Jul 1999 18:31:20 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Re: Scalar to Array Question
Message-Id: <7ndct7$s15$1@plonk.apk.net>


Jordan Hiller wrote in message <379A3309.3D238E4A@email.com>...
>Split into an array of what? Each line? In that case:
>my @array = split(/[\r\n]/, $items);
>
>Jordan
>
>Jody Fedor wrote:
>>
>> Don't know where to look for information:
>>
>> I have a Scalar variable called $items.
>>
>> $items contains:
>>
>> 1090:2.5" 1.2GB Hard Drive:1:129.00 \n  <--- Carriage return or newline
>> 1250:blah blah:5:5.50 \n
>>
>> I'd like to turn this into an array so I can process the file using
foreach.
>>
>> If this is a FAQ, let me have it.
>>
>> Jody
>
>--
>Jordan Hiller (hiller@email.com)


Thanks Jordan,  That did the trick.  All is well, thanks alot!

Jody

http://www.onlysupplies.com





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

Date: Sat, 24 Jul 1999 14:42:03 -0700
From: Andrew J Perrin <aperrin@mcmahon.qal.berkeley.edu>
Subject: Re: Scalar to Array Question
Message-Id: <379A332B.8CA97D2D@mcmahon.qal.berkeley.edu>

> If this is a FAQ, let me have it.
>
> Jody

 perldoc -f split

--
-------------------------------------------------------------
Andrew Perrin - NT/Unix/Access Consulting - aperrin@mcmahon.qal.berkeley.edu
            I'M LOOKING FOR ANOTHER EXPERIENCED ACCESS
               DEVELOPER - CONTACT ME IF INTERESTED.
        http://www.geocities.com/SiliconValley/Grid/7544/
-------------------------------------------------------------




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

Date: Sat, 24 Jul 1999 17:53:36 -0400
From: "Jody Fedor" <JFedor@datacom-css.com>
Subject: Using FAQ in ActiveStates Perl
Message-Id: <7ndamb$qpm$1@plonk.apk.net>

How can I get "More" to work at the command line for Active States Perl
Docs.

I've tried things like this without any success:

perldoc -q array > more
perldoc -q array | more

Any Suggestions?  My answers are just flying away.

Jody




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

Date: 24 Jul 1999 14:11:00 -0500
From: abigail@delanet.com (Abigail)
Subject: Re: Variables in Regx?
Message-Id: <slrn7pk3ss.3ja.abigail@alexandra.delanet.com>

Argouarch (argouarc@idiom.com) wrote on MMCLIII September MCMXCIII in
<URL:news:argouarc-2407991048240001@argouarc.dial.idiom.com>:
== Here's the problem, I have a dictionary flat file with 30 000 lines, I
== want to bold every instance of the defined word in each definition so my
== regular expresion has to change for each line (sure dont want to do this
== by hand, and was'nt PERL designed just for this crap :=)?. 
== I also want the html tags inserted in the file itself so I wrote a simple
== utility script to change the file.
== 
== I tried this:
== Open...
== While (<FILE>){
== ($key,$translation)=split(/:/);
== 
== s/(${$key})/<b>$1<\/b>/g;
== }
== 
== would not work... although I am forcing dereferencing of $key, (I also
== tried dereferencing on both side and naively a /$key/<b>$key<\/b>/). It
== seems that perl allows variables only on the left side like with the
== modifiers e and ee ?!?
== Am I missing something here? 


Why are you trying to dereference $key? What goes wrong with

    s{$key}{<b>$key</b>}g;

? And you are mistaken about /e.



Abigail
-- 
perl -wleprint -eqq-@{[ -eqw+ -eJust -eanother -ePerl -eHacker -e+]}-


  -----------== 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: Sat, 24 Jul 1999 21:53:00 +0700
From: Marco Ender <info@servicepool.de>
Subject: Waiting for system ??
Message-Id: <3799D34B.35FC4DB4@servicepool.de>

Hy ,

i have a small problem with a script, how can i force the script to wait
until a system proggy has done his work commpletly.

for (@filename){
    system wget $_ -0 filenamelocal.txt
    ----------> here i need WAIT ontil wget is finished.
    open (FILE, filelocal.txt)
    .....
    .....
    ....
    close (FILE)
system remove filelocal.txt;
}


Thx Marco




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

Date: Sat, 24 Jul 1999 21:18:27 GMT
From: rurban@xarch.tu-graz.ac.at (Reini Urban)
Subject: Re: WinNT MD5|SHA Perl
Message-Id: <379a2c8d.35805745@judy.x-ray.local>

hmm, just installed Digest-MD5-2.01 by myself
and it worked like a charm, 100% tests passed.

your perl installation seems to be broken, missing header file
somewhere.

i send you may blib win32-binary per email.

"John" <irishcream@iname.com> wrote:
>Hello All,
>I've been trying since the 5 hours to compile the CPAN MD5 Perl
>under WinNT, without success. After preparing the adequate
>environment (vcvars32.bat), perl Makefile.PL, nmake, I get
>the following errors
>----------
>MD5.c
>MD5.xs(54) : error C2065: 'MD5Init_perl' : undeclared identifier
>MD5.xs(88) : error C2065: 'MD5Update_perl' : undeclared identifier
>MD5.xs(99) : error C2065: 'MD5Final_perl' : undeclared identifier
>NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
>Stop.
>--------
>The problem is that in the MD5.xs, the following symbols are
>used wihout being defined anywhere !
>------------
>/*
>** The following macro re-definitions added to work around a problem on
>** Solaris where the original MD5 routines are already in /lib/libnsl.a.
>**/
>#define MD5Init  MD5Init_perl
>#define MD5Update MD5Update_perl
>#define MD5Final MD5Final_perl
>-----------
>If I remove them, I got other unrecoverable errors ....
>
>Did any body go through this before anf fix it? Or does anyone know
>a MD5 or SHA Perl implementation for WinNT ?

--
Reini Urban
http://xarch.tu-graz.ac.at/autocad/news/faq/autolisp.html


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

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 245
*************************************


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