Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Dynamic Splice
I have the following line of code:

$MyPrtLine =3D join( ",", (split (/ *\t */, $_))[9,10,11,15,25,28,3=
1,32,34] );

Is there a way to build splice portion: [9,10,11,15,25,28,31,32,34] so I c=
ould place as a variable either like:

$MyPrtLine =3D join( ",", (split (/ *\t */, $_))[${MySplic}] );    =20
or
$MyPrtLine =3D join( ",", (split (/ *\t */, $_))${MySplice} );

Both generate errors and what I am after is the ability to make an externa=
l value which I have as part of an ini file which I read in. I then generat=
e the splice and no code changes.

I am taking a large line ( 50+ fields ) and cutting down to what another u=
ser actually needs.

Any way to accomplish?

Thanks.


Wags ;)

ps here is code that works with the first line(ie static splice). You shou=
ld be able to cut and paste unless your mailer changes tabs to spaces. I ra=
n it and it worked on xp, as 810 - 5.8.4.


#!perl

use strict;
use warnings;

while ( <DATA> ) {
chomp;
printf "%s\n",
join( ",", (split (/ *\t */, $_))[9,10,11,1=
5,25,28,31,32,34] );
}
=20
__DATA__
VPkr	dx  	 6694	    	V	3	E	o	vHbUNJq      	      	-75581.96	jZJy	Z	13421216=
sNvpbcSzF SVkecw djNTwqWj     	161123155 	H6	r	                           =
79416787	ULR ebJnUiTnYgP               	        	                 =
31638847	vbusYccDz FPEsDy srjiHhzs     	fcP 	        	*MQ Fsk=
P	cytKrr KAy soVdG              	    	          	        	          	6752-1=
7-39	AFn 	    	 	eZ	yvgu	+78789	 381595527
vnfi	FC  	 7617	3455	Q	5	C	P	pVQSdHYUuN   	      	+97317.36	cUds	f	94779484=
HIZXT tAGRyJwiZokJfo          	779586649 	X6	M	                           =
59613139	vWuQf fjykoJF                 	        	                 =
57762176	IwjeG CSMeynturIUEzk          	BvJ 	        	*oi gCt=
r	GxqzZg REI ZILUr              	    	          	        	          	1916-8=
8-42	Rwo 	    	 	TA	jhWg	+47967	 793474171
Tnkp	ZE  	 4697	    	r	4	j	y	IKGbYuA      	      	+28363.78	BhfJ	s	39813118=
CMEBGxJuZ ExCUxUn- krzx MfsbDp	616926757 	u8	f	                           =
59891125	nGFe iVWItm vBXF DtbnH        	        	                 =
51759434	WuzSdMPRk zkjFKrZ- sgeH WuQGnE	epp 	        	*em oXV=
U	cNCJfh seu xbIxH              	    	          	        	          	6374-7=
3-93	Tzm 	    	 	VZ	DbBk	+83234	 666885577



 ****************************************
***************
This message contains information that is confidential
and proprietary to FedEx Freight or its affiliates.
It is intended only for the recipient named and for
the express purpose(s) described therein.
Any other use is prohibited.
 ****************************************
***************


Report this thread to moderator Post Follow-up to this message
Old Post
Wagner, David --- Senior Programmer Analyst --- WG
12-18-04 08:55 PM


Re: Dynamic Splice
>         Is there a way to build splice portion: [9,10,11,15,25,28,31,32,34
] ...

Yes, put those in an array.  Like:

my @array = (9,10,11,15,25,28,31,32,34);

my $spliced = @array2[@array];

Jonathan Paton

--
#!perl
$J=' 'x25 ;for (qq< 1+10 9+14 5-10 50-9 7+13 2-18 6+13
17+6 02+1 2-10 00+4 00+8 3-13 3+12 01-5 2-10 01+1 03+4
00+4 00+8 1-21 01+1 00+5 01-7 >=~/ \S\S \S\S /gx) {m/(
\d+) (.+) /x,, vec$ J,$p +=$2 ,8,= $c+= +$1} warn $J,,

Report this thread to moderator Post Follow-up to this message
Old Post
Jonathan Paton
12-18-04 08:55 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

PERL Beginners archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 07:35 AM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.