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!

Problem with a regexp

Status
Not open for further replies.

bytemania

Technical User
Mar 31, 2008
2
PT
i dont know what is wrong... Im a noob help me please

Code:
#!/usr/bin/perl

use strict;
use warnings;
 
sub bisplit {
	if(length($_)==2){
		my @lista = split($_[0],$_[1]);

		print (join(":",@lista)),"\n";
	}
}

bisplit(/\,/,"12,13,14,15,16");

 
The "warnings" pragma should be giving you some hints to problems in your code. Also, where is $_ defined in your code?

Code:
if(length([red]$_[/red])==2){

Maybe you mean to do something like this:

Code:
#!/usr/bin/perl

use strict;
use warnings;
 
sub bisplit {
    if ( @_== 2 ){
        my @lista = split(/$_[0]/,$_[1]);
        print join(":",@lista),"\n";
    }
}

bisplit(',',"12,13,14,15,16");



------------------------------------------
- Kevin, perl coder unexceptional! [wiggle]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top