On Mon, May 7, 2012 at 11:29 PM, John W. Krahn <jwkr...@shaw.ca> wrote:

> timothy adigun wrote:
>
>>
>> On Mon, May 7, 2012 at 8:36 AM, lina<lina.lastn...@gmail.com>  wrote:
>>
>>  I have two files, one with
>>>
>>> 3
>>> 2
>>> 1
>>>
>>> another is:
>>>
>>> 3 1
>>> 3 2
>>> 6 3
>>>
>>> How can I insert the first file into the middle of the second file,
>>>
>>
>>    This is one way to do it:
>>
>> #!/usr/bin/perl
>> use warnings;
>> use strict;
>>
>> my $part1 = get_data( $ARGV[0] );    # get f1.txt from CLI
>> my $part2 = get_data( $ARGV[1] );    # get f2.txt from CLI
>>
>> my $cot = () = @{$part1};
>>
>
> There is no need to copy the array to a list in order to get the number of
> elements in the array because an array in scalar context will return the
> number of elements.
>
>
>
>  foreach ( 0 .. ( $cot - 1 ) ) {
>>
>
> But you don't need the $cot variable anyways because you can just do this:
>
> foreach ( 0 .. $#$part1 ) {
>
>    thanks I know. I just felt like having fun! :-)

>
>

Reply via email to