Solved

can this code produce named files ?

Posted on 2013-12-04
3
200 Views
Last Modified: 2013-12-04
the code below does exactly what I need it to do

other than, I would like the files that it produces to be named with the extension .vim

Could you help with this please ?

#!/usr/bin/perl
use strict;
use warnings;
@ARGV=('master.vim') unless @ARGV; # read from master.vim if no file specified on command line
my $f='';
while( <> ){
    /(\d+)/ and $1 ne $f and $f=$1 , (open STDOUT,">>",$f or warn "$f $!");
    print;
}
0
Comment
Question by:MichaelGlancy
  • 2
3 Comments
 
LVL 84

Accepted Solution

by:
ozo earned 500 total points
Comment Utility
open STDOUT,">>$f.vim"
0
 

Author Comment

by:MichaelGlancy
Comment Utility
its not working - the error is flashing too fast for me to make out what it is

#!/usr/bin/perl
use strict;
use warnings;
@ARGV=('master.vim') unless @ARGV; # read from master.vim if no file specified on command line
my $f='';
while( <> ){
    /(\d+)/ and $1 ne $f and $f=$1 , (open STDOUT,">>",$f.vim or warn "$f.vim $!");
    print;
}
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
">>",$f.vim  is not the same as ">>$f.vim"
I said
open STDOUT,">>$f.vim"
although you can also say
open STDOUT,">>","$f.vim"
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now