Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default @_ array collection , is it readonly 2

Status
Not open for further replies.

1DMF

Programmer
Jan 18, 2005
8,795
GB
I understand that you cannot change CGI->param vars , but I thought the @_ collection was changeable ie
Code:
$_[0] = "My Value";

But I have found trying to do a text comparison wasn't working...
Code:
if($_[1] =~ /c/gi) { do whatever;}

it only works if I make a variable = the @_ value first like so
Code:
my $var = $_[1];
if($var =~ /c/gi) { do whatever;}

What am I missing here?

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Still not 100% sure what you just said, but appreciate the attempt to explain.

Code:
while( $string =~ s/c//g ) {
   print "Replaced a c\n";
}

In the above code, because of the "g" option, the s/// regexp does all the substitutions inside the (condition) part of the "while" loop . Remove the "g" and the behavior changes:

Code:
while( $string =~ s/c// ) {
   print "Replaced a c\n";
}


------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Thanks 1DMF, I think I understand but it seems an unusual way to do a validity check but what do I know, I don't even have an Ipod! I am sure it makes more sense when seen in the context of the rest of your code.

Keith
 
I think I understand but it seems an unusual way to do a validity check but what do I know

It's a members intranet site, and members have different levels of access.

Normally there is only two levels , Adviser or Principal

However Adviser can have principle status , but some companies have multiple advisers, but those who are 1 man bands don't need a principle login, but also don't need some functionality that admin gives them, while some have admin in the office which don't have a login.

For example on the screen where they submit business, while it's in 'pipeline', if you are a 1 man band, you don't need the table to list 'Adviser Name' in the display column (you're the only adviser) , so I have global vars/flags which idicates if they are ADMIN or not.

I'm probably making you even more confused but, if you saw the code and understood the way the membership numbering system works, it would make perfect sense, honest!

Kevin -> Gotcha , thanks!

"In complete darkness we are all the same, only our knowledge and wisdom separates us, don't let your eyes deceive you."

"If a shortcut was meant to be easy, it wouldn't be a shortcut, it would be the way!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top