[16319] in Perl-Users-Digest
Perl-Users Digest, Issue: 3731 Volume: 9
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue Jul 18 11:13:17 2000
Date: Tue, 18 Jul 2000 08:13:06 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)
Message-Id: <963933186-v9-i3731@ruby.oce.orst.edu>
Content-Type: text
Perl-Users Digest Tue, 18 Jul 2000 Volume: 9 Number: 3731
Today's topics:
String and Hash question...rather urgent (Vinod K. Menon)
Re: String and Hash question...rather urgent (Logan Shaw)
Re: String and Hash question...rather urgent (Jakob Schmidt)
Re: String and Hash question...rather urgent (Vinod K. Menon)
Re: String and Hash question...rather urgent (Stephen Kloder)
Re: String and Hash question...rather urgent (Godzilla!)
Re: String and Hash question...rather urgent (Craig Berry)
Re: String and Hash question...rather urgent (Cal Henderson)
Re: String length? (Tad McClellan)
Re: String length? (Jim Kauzlarich)
Re: String length? (Tad McClellan)
string to number? (David Li)
Re: string to number? (Tony Curtis)
Re: string to number? (David Li)
Re: string to number? (Bart Lateur)
Re: stupid perl question (EPROM)
Re: stupid perl question (Mark W. Schumann)
Re: sub selects (Jonathan Stowe)
Substitution with variables ()
Re: Substitution with variables (Keith Calvert Ivey)
Re: Substitution with variables ()
Re: Substitution with variables (Keith Calvert Ivey)
Digest Administrivia (Last modified: 16 Sep 99) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: 18 Jul 2000 00:00:01 GMT
From: anuragmenon@my-deja.com.bbs@openbazaar.net (Vinod K. Menon)
Subject: String and Hash question...rather urgent
Message-Id: <3bRU02$Tjd@openbazaar.net>
this is probably extremely elementary - but I am kinda new to perl and
am trying to get something done in a hurry and hopefully will get a
speedy reply - anyway, this is what I want to do.
1. Read in a string (String1)
2. Initialize a hash(Hash1) with a set of values
3. for every character in String1 in order from the first to the last,
extract the corresponding value from Hash1 using that character as
they key
4. concatenate the values extracted, in order,with a comma seperateing
the values, to form a new string.
For example if I have initialized the hash as
%hash1 = qw(a "10101"
b "20202");
and the input string is ab,
the output should be "10101,20202"
I am sure the code is very very short..but for some reason, I am really
having problems with it..
I appreciate all help..
Vinod.re
the result of the perl script should be "10101
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 00:00:01 GMT
From: logan@cs.utexas.edu.bbs@openbazaar.net (Logan Shaw)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRU06$TzZ@openbazaar.net>
In article <8l066h$js5$1@nnrp1.deja.com>,
Vinod K. Menon <anuragmenon@my-deja.com> wrote:
>this is probably extremely elementary - but I am kinda new to perl and
>am trying to get something done in a hurry and hopefully will get a
>speedy reply - anyway, this is what I want to do.
>
>1. Read in a string (String1)
>2. Initialize a hash(Hash1) with a set of values
>3. for every character in String1 in order from the first to the last,
> extract the corresponding value from Hash1 using that character as
> they key
>4. concatenate the values extracted, in order,with a comma seperateing
>the values, to form a new string.
>
>For example if I have initialized the hash as
>
>%hash1 = qw(a "10101"
> b "20202");
>
>and the input string is ab,
>the output should be "10101,20202"
Step 1:
$string = <>;
chomp $string;
Step 2:
%lookup_table = ( a => "10101", b => "20202" );
Step 3 and 4:
print join (",", @lookup_table{split (//, $string)}), "\n";
Note that my way of doing it uses a special perl feature, which is the
ability to use a list (instead of a single value) as the index to a
hash. I build the list by splitting with an empty pattern. I then
join the results of the array-indexed hash lookup using join() so that
I don't have to worry with appending commas to all but the last element
of a list or something.
- Logan
------------------------------
Date: 18 Jul 2000 00:10:00 GMT
From: sumus@aut.dk.bbs@openbazaar.net (Jakob Schmidt)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRUCO$UHW@openbazaar.net>
Vinod K. Menon <anuragmenon@my-deja.com> writes:
> %hash1 = qw(a "10101"
> b "20202");
using qw() you probably mean
%hash1 = qw( a 10101
b 20202 ); # no extra quotes...
>
> and the input string is ab,
> the output should be "10101,20202"
print join( ',', @hash1{ split( '', $string1 ) } ), "\n";
or
$output = join ',', @hash1{ split( '', $string1 ) };
--
Jakob
------------------------------
Date: 18 Jul 2000 01:30:02 GMT
From: anuragmenon@my-deja.com.bbs@openbazaar.net (Vinod K. Menon)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRWGQ$Wvu@openbazaar.net>
> using qw() you probably mean
>
> %hash1 = qw( a 10101
> b 20202 ); # no extra quotes...
the value that I plan to retrieve has spaces in the sense that the value
of the Key a is a string which is "1.0 2.0 3.0". If the extra quotes
cannot be used, then will
%hash1 = qw(a 1.0 2.0 3.0
b 2.0 3.0 4.0);
work or do I have to use individual assignment statements
like $hash1("a") = "1.0 2.0 3.0";
and so on for all keys?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 18 Jul 2000 02:10:02 GMT
From: stephenk@cc.gatech.edu.bbs@openbazaar.net (Stephen Kloder)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRXIT$VW4@openbazaar.net>
"Vinod K. Menon" wrote:
> > using qw() you probably mean
> >
> > %hash1 = qw( a 10101
> > b 20202 ); # no extra quotes...
>
> the value that I plan to retrieve has spaces in the sense that the value
> of the Key a is a string which is "1.0 2.0 3.0". If the extra quotes
> cannot be used, then will
>
> %hash1 = qw(a 1.0 2.0 3.0
> b 2.0 3.0 4.0);
> work or do I have to use individual assignment statements
>
> like $hash1("a") = "1.0 2.0 3.0";
>
> and so on for all keys?
>
qw() splits on a space, regardless of what other delimeters(e.g. ["'()])
appear. If you need to store strings with internal spaces, don't use qw().
Instead, use:
%hash1 = (a => "1.0 2.0 3.0",
b => "2.0 3.0 4.0");
--
Stephen Kloder | "I say what it occurs to me to say.
stephenk@cc.gatech.edu | More I cannot say."
Phone 404-874-6584 | -- The Man in the Shack
ICQ #65153895 | be :- think.
------------------------------
Date: 18 Jul 2000 04:20:05 GMT
From: godzilla@stomp.stomp.tokyo.bbs@openbazaar.net (Godzilla!)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRab5$X9g@openbazaar.net>
"Vinod K. Menon" wrote:
> this is probably extremely elementary - but I am kinda new to perl
> and am trying to get something done in a hurry and hopefully will
> get a speedy reply - anyway, this is what I want to do.
Well darn, yet another newbie to Perl. Amazing influx
rate of newbies to Perl. I am estimating somewhere in
the range of one-hundred to two-hundred fresh newbies
to Perl per month. Must be the free T-shirts.
(snipped)
> For example if I have initialized the hash as
> %hash1 = qw(a "10101"
> b "20202");
> and the input string is ab,
> the output should be "10101,20202"
(subsequent article)
> the value that I plan to retrieve has spaces in the
> sense that the value of the Key a is a string which
> is "1.0 2.0 3.0". If the extra quotes cannot be used,
> then will
> %hash1 = qw(a 1.0 2.0 3.0
> b 2.0 3.0 4.0);
> work or do I have to use individual assignment statements
> like $hash1("a") = "1.0 2.0 3.0";
> and so on for all keys?
> I appreciate all help..
Perhaps. My help is to suggest you make up your
mind what you want to do, stick with it, then
ask your question. You say you are in a hurry,
so formulate a question and, don't change your
parameters with each given answer. This would
save you precious time and annoy fewer people.
Godzilla!
--
$godzilla = "godzilla rocks!";
srand(time() ^ ($$ + ($$ << 15)));
sub randcase
{ rand(40) < 20 ? "\u$1" : "\l$1" ; }
$godzilla =~ s/([a-z])/randcase($1)/gie;
print $godzilla; exit;
------------------------------
Date: 18 Jul 2000 06:20:03 GMT
From: cberry@cinenet.net.bbs@openbazaar.net (Craig Berry)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRdh3$XXq@openbazaar.net>
Vinod K. Menon (anuragmenon@my-deja.com) wrote:
: this is what I want to do.
:
: 1. Read in a string (String1)
: 2. Initialize a hash(Hash1) with a set of values
: 3. for every character in String1 in order from the first to the last,
: extract the corresponding value from Hash1 using that character as
: they key
: 4. concatenate the values extracted, in order,with a comma seperateing
: the values, to form a new string.
:
: For example if I have initialized the hash as
:
: %hash1 = qw(a "10101"
: b "20202");
:
: and the input string is ab,
: the output should be "10101,20202"
Changing your mapping slightly for convenience, and adding some error
handling to deal with undefined chars:
#!/usr/bin/perl -w
# hashtrans - hash-based character translation, for clpm
# Craig Berry (20000717)
use strict;
my %trans;
@trans{'a'..'z'} = (1001..1026);
while (<>) {
chomp;
print join(',', map { $trans{$_} || '*' } split //), "\n";
}
(By the way, that || would be repalced with ?? if LR triumphs. :)
--
| Craig Berry - http://www.cinenet.net/users/cberry/home.html
--*-- "Beauty and strength, leaping laughter and delicious
| languor, force and fire, are of us." - Liber AL II:20
------------------------------
Date: 18 Jul 2000 07:30:15 GMT
From: cal@iamcal.com.bbs@openbazaar.net (Cal Henderson)
Subject: Re: String and Hash question...rather urgent
Message-Id: <3bRfYc$UP_@openbazaar.net>
"Vinod K. Menon" <anuragmenon@my-deja.com> wrote...
[snip]
:do I have to use individual assignment statements
:
: like $hash1("a") = "1.0 2.0 3.0";
:
: and so on for all keys?
[snip]
$hash1{"a"} = "1.0 2.0 3.0";
would be more sucessfull
--
Cal Henderson
sub a{my$a=reverse shift;$a=~y/b-z/a-y/;unshift@a,$a;}sub b{$c.=reverse
shift; while(length($c)>=$b[0]){a(substr($c,0,$b[0]));$c=substr($c,$b[0]);
shift@b;}}@b=(6,3,5,4,10,6,4,4,2,1);$a="l?jouipv"."ezvmxpbuxih";$a.=
",jofoqqibmzamsfsfxfjtuiIg";while($a ne ""){b(substr($a,0,2));$a=
substr($a,2);}print join(" ",@a);
------------------------------
Date: 13 Jul 2000 22:40:03 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: String length?
Message-Id: <3bOLi5$WH_@openbazaar.net>
On Thu, 13 Jul 2000 16:43:12 -0500, Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:
>
>"Craig Berry" <cberry@cinenet.net> wrote in message
>news:sms11e6qnd629@corp.supernews.com...
>> Jim Kauzlarich (o1technospam@skyenet.nospam.net) wrote:
>> : So, with a little last minute re-vamping, here is my creation: (though
>> : without the do loop, and the extra if/then evaluation it feels un-Perl.
>The
>> : little bit I know.)
>>
>> Nicely horrid. One tweak (unless the extra warning was intentional, of
>> course):
>
>Thank you!
>
>> : if ( @_[$count] ne "" ) {
>>
>> s/\@/\$/
>
>Regular expression I assume? I haven't really delved into them yet. Is
>that a substitution?
Yes.
But it is a substitution that _you_ (not perl) should make.
Instead of saying "change the @ to a $" in English, we tend
to say the same thing in Perl instead.
i.e. if ( $_[$count] ne "" ) {
^
^ scalar, not array slice as you have above
>I'm a bit surprised that no one snapped at my mis-attempt at using strict.
>"use strict();" I'd been up for about 20 hours, and when I attempted to add
>strict. It came back with the following err that I'm still not sure what
>means (mee tawk gud englush, eh?)
Are you sure?
use strict();
should turn on NO strictness (i.e. it is worthless when written that way).
>Global symbol "x" requires explicit package name at count3.cgi line 22.
All of the messages that perl might issue (and even some that are
NOT issued by perl) are documented in the perldiag.pod standard doc.
perldoc perldiag
---------------------
=item Global symbol "%s" requires explicit package name
(F) You've said "use strict vars", which indicates that all variables
must either be lexically scoped (using "my"), declared beforehand using
"our", or explicitly qualified to say which package the global variable
is in (using "::").
---------------------
>What is an "explicit package name"?
It is the name of the package that contains the 'x'.
I dunno what you did to get that message, so I'll make up
something else.
If it was complaining about $x, then strict wants you to
give the package name as well as the variable name:
$main::x; # the $x variable in the 'main' package
$MyPackage::x; # the $x variable in the 'MyPackage' package
type:
perldoc perlmod
and see the "Packages" section.
>I figured that I'd added in strict incorrectly, and changed it.
You figured correctly.
>I also
>don't understand why I didn't get an error when I put "use strict()" at the
>top of my program.
Probably because it is not a (syntax) error!
It is, however, a logic error :-)
perldoc -f use
perldoc strict
You can supply a LIST to "use".
It lists the things that you want to use.
If the list is empty, you are saying that you don't want to use
any of it.
>> --
>> | Craig Berry - http://www.cinenet.net/users/cberry/home.html
>> --*-- "Beauty and strength, leaping laughter and delicious
>> | languor, force and fire, are of us." - Liber AL II:20
Please do not quote .sigs. It is bad netiquette.
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 14 Jul 2000 06:40:02 GMT
From: o1technospam@skyenet.nospam.net.bbs@openbazaar.net (Jim Kauzlarich)
Subject: Re: String length?
Message-Id: <3bOYK3$WDt@openbazaar.net>
"Tad McClellan" <tadmc@metronet.com> wrote in message
news:slrn8mseeq.c0u.tadmc@magna.metronet.com...
> On Thu, 13 Jul 2000 16:43:12 -0500, Jim Kauzlarich
<o1technospam@skyenet.nospam.net> wrote:
> >"Craig Berry" <cberry@cinenet.net> wrote in message
> >news:sms11e6qnd629@corp.supernews.com...
> >> Jim Kauzlarich (o1technospam@skyenet.nospam.net) wrote:
> >> s/\@/\$/
> >
> >Regular expression I assume? I haven't really delved into them yet. Is
> >that a substitution?
>
>
> Yes.
>
> But it is a substitution that _you_ (not perl) should make.
>
> Instead of saying "change the @ to a $" in English, we tend
> to say the same thing in Perl instead.
>
>
> i.e. if ( $_[$count] ne "" ) {
> ^
> ^ scalar, not array slice as you have above
Sorry, don't know what you mean here. (I've really got to quit reading this
stuff at the end of the day. But I've convinced my ISP that I know enough
to try to troubleshoot dail-up connections over the phone =] , and after
work I stick around and enjoy the fast internet connection and the shell
access to my website.) I understand that regular expressions are a powerful
part of Perl, but I learn best (when studying on my own) by going where my
obsesion leads. I'm only just curious about regular expressions, but I'm
still pushing down other aveniues (sp). I'm going to have to look into them
soon though.
> >I'm a bit surprised that no one snapped at my mis-attempt at using
strict.
> >"use strict();" I'd been up for about 20 hours, and when I attempted to
add
> >strict. It came back with the following err that I'm still not sure what
> >means (mee tawk gud englush, eh?)
>
>
> Are you sure?
About which part?
And no, by the way. I'm not. :)
> All of the messages that perl might issue (and even some that are
> NOT issued by perl) are documented in the perldiag.pod standard doc.
>
> perldoc perldiag
Cool.
> ---------------------
> =item Global symbol "%s" requires explicit package name
>
> (F) You've said "use strict vars", which indicates that all variables
> must either be lexically scoped (using "my"), declared beforehand using
> "our", or explicitly qualified to say which package the global variable
> is in (using "::").
> ---------------------
I eventually did figure out the "my" stuff.
> >What is an "explicit package name"?
> It is the name of the package that contains the 'x'.
> If it was complaining about $x, then strict wants you to
> give the package name as well as the variable name:
>
> $main::x; # the $x variable in the 'main' package
>
> $MyPackage::x; # the $x variable in the 'MyPackage' package
Ahh. Cool beans. That looks right. Also that makes other stuff that I've
seen (mostly in "Perl in a Nutshell") make more sence now. Not
comprehension yet, but the fog is lightening.
> type:
>
> perldoc perlmod
>
> and see the "Packages" section.
Ok. Is a perldoc question off topic? I'm gonna admit it. Every time I try
to use perldoc I can't seem to scroll through it the way it seems I should.
And when I type in 'perldoc -h' I don't get a lot of help on the subject.
What do I type to get a list of the commands to scroll through and search
perldoc? And I have tried 'perldoc perldoc'. Sorry, I'm not familliar with
(the way things are done in) UNIX at all.
Well, ok. I'm more familliar than I was a month ago. ;)
> >I also
> >don't understand why I didn't get an error when I put "use strict()" at
the
> >top of my program.
> Probably because it is not a (syntax) error!
> You can supply a LIST to "use".
>
> It lists the things that you want to use.
>
> If the list is empty, you are saying that you don't want to use
> any of it.
dat splainz it.
> Please do not quote .sigs. It is bad netiquette.
No problemo.
Tanx, and l8r
JMK
[Please note the lack of a trailing quoted signature. ;-) ]
------------------------------
Date: 14 Jul 2000 16:50:01 GMT
From: tadmc@metronet.com.bbs@openbazaar.net (Tad McClellan)
Subject: Re: String length?
Message-Id: <3bP2EQ$XPe@openbazaar.net>
On Fri, 14 Jul 2000 01:45:56 -0500, Jim Kauzlarich <o1technospam@skyenet.nospam.net> wrote:
>
>"Tad McClellan" <tadmc@metronet.com> wrote in message
>news:slrn8mseeq.c0u.tadmc@magna.metronet.com...
>> On Thu, 13 Jul 2000 16:43:12 -0500, Jim Kauzlarich
><o1technospam@skyenet.nospam.net> wrote:
>> >"Craig Berry" <cberry@cinenet.net> wrote in message
>> >news:sms11e6qnd629@corp.supernews.com...
>> >> Jim Kauzlarich (o1technospam@skyenet.nospam.net) wrote:
>> >> s/\@/\$/
>> >
>> >Regular expression I assume? I haven't really delved into them yet. Is
>> >that a substitution?
>> i.e. if ( $_[$count] ne "" ) {
>> ^
>> ^ scalar, not array slice as you have above
>
>Sorry, don't know what you mean here.
The short version:
Do not write: if ( @_[$count] ne "" ) {
Write instead: if ( $_[$count] ne "" ) {
The long version:
Those two forms are a *different type* of data.
The difference does not make a difference with the operation
of _your_ code, but it is a bad habit to get into as there are
several places where the difference is profound and surprising.
(i.e. You will eventually debug until you curse and scream, only
to eventually find that you used a slice where you wanted
a scalar)
The one you had is an "array slice".
perldoc perldata
and see the "Slices" section.
The recommended alternative one is a "scalar", also described
in perldata.
>> >I'm a bit surprised that no one snapped at my mis-attempt at using
>strict.
>> >"use strict();" I'd been up for about 20 hours, and when I attempted to
>add
>> >strict. It came back with the following err that I'm still not sure what
>> >means (mee tawk gud englush, eh?)
>>
>>
>> Are you sure?
>
>About which part?
About the part where you say you did
use strict();
and got a strictness-related message.
>And no, by the way. I'm not. :)
heh.
>> type:
>>
>> perldoc perlmod
>>
>> and see the "Packages" section.
>
>Ok. Is a perldoc question off topic?
No.
All of the programs that form part of the perl distribution are
on-topic here.
'perldoc' is but one of those programs.
>I'm gonna admit it. Every time I try
>to use perldoc I can't seem to scroll through it the way it seems I should.
So don't use it then.
It is only a convenient way of looking up stuff in the docs.
If your idea of "convenient" differs from perldoc's operation on
your system, then just use some other method of viewing the docs :-)
You get the complete set of docs along with the perl distribution.
perldoc is just a way to view them.
Find out where they are on your system, and grep away using
any method you have available.
>Tanx, and l8r
Please avoid the IRC style of misspellings here.
We prefer the old fashioned form of misspelling on Usenet.
(i.e. the unintentional ones)
--
Tad McClellan SGML Consulting
tadmc@metronet.com Perl programming
Fort Worth, Texas
------------------------------
Date: 17 Jul 2000 02:00:00 GMT
From: w14357@email.mot.com.bbs@openbazaar.net (David Li)
Subject: string to number?
Message-Id: <3bQhU0$Tvo@openbazaar.net>
Hi,
Could you tell me what function in Perl can convert a string to number?
And the string is begin with "null" that asicc code is "0x20".
Thank you so much!
David
------------------------------
Date: 17 Jul 2000 02:20:01 GMT
From: tony_curtis32@yahoo.com.bbs@openbazaar.net (Tony Curtis)
Subject: Re: string to number?
Message-Id: <3bQi71$WDz@openbazaar.net>
>> On Mon, 17 Jul 2000 09:34:43 +0800,
>> "David Li" <w14357@email.mot.com> said:
> Hi, Could you tell me what function in Perl can convert
> a string to number?
There isn't one, perl does it for you:
$x = '123'; # numeral
++$x; # number
print "$x\n"; ==> 124
> And the string is begin with "null" that asicc code is "0x20".
NUL has ASCII code 0. I'm not sure what you are asking
here, if anything. SPACE has code 0x20 (32) but SPACE
isn't a number or a numeral.
hth t
--
"With $10,000, we'd be millionaires!"
Homer Simpson
------------------------------
Date: 17 Jul 2000 09:30:03 GMT
From: w14357@email.mot.com.bbs@openbazaar.net (David Li)
Subject: Re: string to number?
Message-Id: <3bR7GR$Wrv@openbazaar.net>
Thank you, Tony!
Tony Curtis <tony_curtis32@yahoo.com> wrote in message
news:87lmz1lcmi.fsf@limey.hpcc.uh.edu...
> >> On Mon, 17 Jul 2000 09:34:43 +0800,
> >> "David Li" <w14357@email.mot.com> said:
>
> > Hi, Could you tell me what function in Perl can convert
> > a string to number?
>
> There isn't one, perl does it for you:
>
> $x = '123'; # numeral
> ++$x; # number
> print "$x\n"; ==> 124
>
> > And the string is begin with "null" that asicc code is "0x20".
>
> NUL has ASCII code 0. I'm not sure what you are asking
> here, if anything. SPACE has code 0x20 (32) but SPACE
> isn't a number or a numeral.
>
> hth t
> --
> "With $10,000, we'd be millionaires!"
> Homer Simpson
------------------------------
Date: 17 Jul 2000 08:40:02 GMT
From: bart.lateur@skynet.be.bbs@openbazaar.net (Bart Lateur)
Subject: Re: string to number?
Message-Id: <3bR622$UqN@openbazaar.net>
Tony Curtis wrote:
>> And the string is begin with "null" that asicc code is "0x20".
It's not "ASICC" but "ASCII". Interesting typo, anyway.
>NUL has ASCII code 0. I'm not sure what you are asking
>here, if anything. SPACE has code 0x20 (32) but SPACE
>isn't a number or a numeral.
Hmmm... it sounds like he's looking for the ord() function.
--
Bart.
------------------------------
Date: 12 Jul 2000 01:00:00 GMT
From: eprom007@hotmail.com.bbs@openbazaar.net (EPROM)
Subject: Re: stupid perl question
Message-Id: <3bMkR1$XyV@openbazaar.net>
Uri Guttman wrote:
>
> and for work you won't learn perl?
No, not that I won't learn Perl, but it makes little sense to me to read for
hours
trying to figure something out, if there is a more simple way. Yesterday I
spent
4 hours trying to figure why a simple Perl script wasn't working, come to find
out,
I was using an outdated version, and the location switched from /usr/bin/perl
to
/usr/local/bin/perl.
> how little are they paying you?
not a whole lot to be honest, and this is a take-home-from-the-office
kind of project.
>
> if you are not a perl programmer then why are you hacking perl?
My job is to keep track of about a 1000+ handheld radios, each time
a radio keys up, its recorded in a plain text file.
My work project consists of searching about 3000+ one Meg files.
for certain strings. I wrote the original script in csh, but figured it may
run faster using Perl...
> i am not
> a brain surgeon and my boss (which happens to be myself) doesn't make me
> mess around in other people's skulls.
My supervisor doesn't bother me, as long as the job is done. So in a way
I am my own boss too. Its up to me to figure out *how* the job gets done.
> work. and his (typical) disdain for the docs and faq is annoying. what
> are they paying you for? posting questions on usenet and sitting around
> waiting for a spoonfed answer?
>
> sheesh yourself!
I find that most man pages are worse than the books (usually). Wouldn't you
agree?
But your right, docs and faq are the first place that one should look...I just
strongly doubted it would be in there.
Oh, and they are paying me for my job; my job certainly doesn't call for me to
put in overtime or work on projects on my off time. No one is going to fire me
if
I don't learn Perl, its just that im just trying to improve on the way I do
things. :)
oh well....back to square one..
I guess Perl isn't for everyone.
------------------------------
Date: 17 Jul 2000 23:50:01 GMT
From: catfood@apk.net.bbs@openbazaar.net (Mark W. Schumann)
Subject: Re: stupid perl question
Message-Id: <3bRTZP$Uv_@openbazaar.net>
In article <396B1C42.2F1B027B@hotmail.com>,
EPROM <eprom007@hotmail.com> wrote:
>I find that most man pages are worse than the books (usually). Wouldn't you
>agree?
Leaving aside the question of books being bad, the perl manpages are
extremely detailed and well written. The things you can't learn from
the manpages are, IMO, obscure features that a new Perl programmer is
unlikely to care about.
Start with "man perl" and work your way through the parts that look
interesting when you have a spare hour or two.
------------------------------
Date: 16 Jul 2000 18:10:08 GMT
From: gellyfish@gellyfish.com.bbs@openbazaar.net (Jonathan Stowe)
Subject: Re: sub selects
Message-Id: <3bQVIZ$VeC@openbazaar.net>
On Wed, 12 Jul 2000 13:12:20 GMT brainmuffin@excite.com wrote:
> Does anyone know if mySQL supports sub-selects, and if so, what the
> syntax is?
No MySQL does not support, sub-selects - this is one of the reasons why it
is crap. Why you didnt ask in a MySQl oriented goup beats me though...
/J\
--
yapc::Europe in assocation with the Institute Of Contemporary Arts
<http://www.yapc.org/Europe/> <http://www.ica.org.uk>
------------------------------
Date: 16 Jul 2000 17:20:01 GMT
From: fvision@my-deja.com.bbs@openbazaar.net ()
Subject: Substitution with variables
Message-Id: <3bQU41$VSF@openbazaar.net>
I have a script that searches through lines of text for commands and then
executes those commands and needs to put the result back in the line
where it found the command like this:
#Find all of the commands in the line
@commands = $line =~ /regularexpression/gi;
foreach $command (@commands) {
$result = &getresult($command);
$line =~ s/$command/$result/;
}
When I try to execute this I get the following error:
Can't modify constant item in substitution (s///) at ./mytest.pl line 30,
near "s/$commmand/"$result"/;"
Has anyone here attempted the same and could help me out?
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 16 Jul 2000 21:50:04 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: Substitution with variables
Message-Id: <3bQb5S$VHW@openbazaar.net>
fvision@my-deja.com wrote:
>@commands = $line =~ /regularexpression/gi;
>
>foreach $command (@commands) {
> $result = &getresult($command);
> $line =~ s/$command/$result/;
>}
Why not just
$line =~ s/(regularexpression)/getresult($1)/gie;
? The way you're doing it might make substitutions within the
results of previous commands rather than where you're expecting.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: 16 Jul 2000 23:10:01 GMT
From: fvision@my-deja.com.bbs@openbazaar.net ()
Subject: Re: Substitution with variables
Message-Id: <3bQd9Q$UOM@openbazaar.net>
In article <39751be2.4698795@news.newsguy.com>,
kcivey@cpcug.org (Keith Calvert Ivey) wrote:
> fvision@my-deja.com wrote:
>
> >@commands = $line =~ /regularexpression/gi;
> >
> >foreach $command (@commands) {
> > $result = &getresult($command);
> > $line =~ s/$command/$result/;
> >}
>
> Why not just
>
> $line =~ s/(regularexpression)/getresult($1)/gie;
>
> ? The way you're doing it might make substitutions within the
> results of previous commands rather than where you're expecting.
I see what you mean. This would work well. I did however find the
solution to the problem that I was having and feel really stupid. I had
actually left off the "$" on "$line" so I was looking for the error in
entirely the wrong place. When I retyped the snippit for the news post I
typed it correctly but did not on my code that is on the server. Go
figure.
Sent via Deja.com http://www.deja.com/
Before you buy.
------------------------------
Date: 17 Jul 2000 00:50:01 GMT
From: kcivey@cpcug.org.bbs@openbazaar.net (Keith Calvert Ivey)
Subject: Re: Substitution with variables
Message-Id: <3bQfcP$VOA@openbazaar.net>
fvision@my-deja.com wrote:
>I see what you mean. This would work well. I did however find the
>solution to the problem that I was having and feel really stupid. I had
>actually left off the "$" on "$line" so I was looking for the error in
>entirely the wrong place. When I retyped the snippit for the news post I
>typed it correctly but did not on my code that is on the server. Go
>figure.
If your program had "-w" and "use strict;" (as often recommended
on this group and elsewhere), then Perl would have told you
about the missing $. It was interpreting the bareword "line" as
a string constant, which can't be modified. Let Perl help you
catch errors.
Also, if you'd copied and pasted from your program into your
message, then we wouldn't have spent time looking at a program
that didn't contain the critical error. It's very easy to type
what you think is there rather than what's really there. Please
copy and paste in the future.
--
Keith C. Ivey <kcivey@cpcug.org>
Washington, DC
(Free at last from the forced spamsig of
Newsfeeds.com, cursed be their name)
------------------------------
Date: 16 Sep 99 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin)
Subject: Digest Administrivia (Last modified: 16 Sep 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.
| NOTE: The mail to news gateway, and thus the ability to submit articles
| through this service to the newsgroup, has been removed. I do not have
| time to individually vet each article to make sure that someone isn't
| abusing the service, and I no longer have any desire to waste my time
| dealing with the campus admins when some fool complains to them about an
| article that has come through the gateway instead of complaining
| to the source.
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.
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 3731
**************************************