Re: substr help

2008-03-06 Thread John W. Krahn
Bobby wrote: "John W. Krahn" <[EMAIL PROTECTED]> wrote: Bobby wrote: Bobby wrote: open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excps

Re: substr help

2008-03-06 Thread Bobby
John, You are right, it's only reading the last record in my exclude_psc.txt file. %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); So how would i change the above code to have it read through all of my records in exclude_psc.txt file. I need to do the comparison below before printing to

Re: substr help

2008-03-06 Thread Bobby
That works, thanks Tom! Tom Phoenix <[EMAIL PROTECTED]> wrote: On Thu, Mar 6, 2008 at 8:31 AM, Bobby wrote: > Use of uninitialized value in concatenation (.) or string at generatePsc.pl > line 48, line 5. Is this what you seek? next unless defined $PSC; It can also be quite educational

Re: substr help

2008-03-06 Thread Tom Phoenix
On Thu, Mar 6, 2008 at 8:31 AM, Bobby <[EMAIL PROTECTED]> wrote: > Use of uninitialized value in concatenation (.) or string at generatePsc.pl > line 48, line 5. Is this what you seek? next unless defined $PSC; It can also be quite educational to use the Perl debugger to step through a pr

Re: substr help

2008-03-06 Thread Bobby
John, I don't understand, why would that only get me the last record in the text file? Is there a better way to do that? I'm still kinda new with Perl, don't use it enough. %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); "John W. Krahn" <[EMAIL PROTECTED]> wrote: Bobby wrote: > Could so

Re: substr help

2008-03-06 Thread Bobby
Below is what i get when i tried to print just the $PSC variable. So the $PSC column has the value of (PSC, FCSD2, ADEK1, ADEZ2). I did put in a check for alphanumeric in $PSC if ($PSC =~ /^[a-zA-Z0-9]+$/) before doing the substr but still have same issue. What i'm trying to do is to look for

Re: substr help

2008-03-06 Thread Chas. Owens
On Wed, Mar 5, 2008 at 11:57 PM, Richard Lee <[EMAIL PROTECTED]> wrote: snip > Also, can you explain why below is wrong? snip > func([EMAIL PROTECTED]); > sub func { > my $aref = shift; > my $oref = "$aref"; # WRONG <- why is it wrong? > }

Re: substr help

2008-03-05 Thread Richard Lee
*What not just like below? As long as you have unique key, it would retain all the information.* $ex_psc{"$excpsc"} = "$keyword"; $ex_psc{"$excpsc"} is superfluous because *all* hash keys are strings. perldoc -q quoting What’s wrong with always quoting "$vars"? John Thank you

Re: substr help

2008-03-05 Thread John W. Krahn
Richard Lee wrote: open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); *What not just like below? As lo

Re: substr help

2008-03-05 Thread Richard Lee
open EXCLUDE, '<', $exclude_psc or die "Could not open '$exclude_psc' $!"; while ( ) { next if $. == 1; # exclude header chomp; my ($excpsc,$keyword) = split /\|/; %ex_psc = (exclpsc=>$excpsc,exkeyword =>$keyword ); *What not just like below? As long as you have unique

Re: substr help

2008-03-05 Thread John W. Krahn
Bobby wrote: Could someone please tell me what's wrong with my use of the substr function below? I keep on getting "use of uninitialized value in substr". Thanks. $newpsc = substr($PSC,0,$count); Here's the complete code: #!/usr/bin/perl use strict; use warnings; my $exclude_psc = 'exclude_

Re: substr help

2008-03-05 Thread Nobody Imparticular
[..snip..] > > while () { > my ($base_no, $name, $description, $PSC) = split > /\|/; > Are you absolutely sure that $PSC is getting a value here? If you "print $PSC" do you get a value? It might also help to see the data stream... -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additio

Re: substr help

2008-03-05 Thread Bobby
Sorry, i've left out some details in my previous email. I've isolated the code and it works without the substr function. Thanks in advance for any suggestions. Bobby <[EMAIL PROTECTED]> wrote: Could someone please tell me what's wrong with my use of the substr function below? I keep on getting

Re: substr (help,help,help);

2001-06-28 Thread Craig S Monroe
[EMAIL PROTECTED]> To: "Craig S Monroe" <[EMAIL PROTECTED]>; "Beginners@Perl (E-mail)" <[EMAIL PROTECTED]> Sent: Wednesday, June 27, 2001 5:45 PM Subject: Re: substr (help,help,help); > > while (){ > > if (m/\/nic\/login/){ > > this just say

Re: substr (help,help,help);

2001-06-27 Thread Michael Fowler
On Wed, Jun 27, 2001 at 05:30:11PM -0400, Craig S Monroe wrote: > open (SOURCE, "< $filename"); > > while (){ > if (m/\/nic\/login/){ > substr ($_,28,4); > print; > } > } That substr is a no-op, meaning it does nothing. If warnings had been turned on, you would have seen something along the

Re: substr (help,help,help);

2001-06-27 Thread Me
> while (){ > if (m/\/nic\/login/){ this just says yes or no, you have a match or you don't. m// (and friends like s///) can do more than that for you. for one thing, they can grab a particular piece of what they match. > substr ($_,28,4); what substr normally does -- get or change a piece of