Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

This is working fine for me.

#!/bin/Perl use warnings; if (@ARGV < 4) { print ("you need to provide 4 arguments\n\t4th argument is file to + parse"); exit; } openfile(@ARGV); sub openfile { print $_[3],"\n"; open FILE1,">$_[0]" || die "could not open $_[1]\n"; open FILE2,">$_[1]" || die "could not open $_[2]\n"; open FILE3,">$_[2]" || die "could not open $_[3]\n"; open FILE4,"<$_[3]" || die "could not open $_[4]\n"; while (<FILE4>) { print $_; } }

Result:

perl "E:\perl_TK\OpenFiles1.pl" a b c "e:\\territory20100713.sql" Process started >>> Name "main::FILE3" used only once: possible typo at E:\perl_TK\OpenFil +es1.pl line 16. Name "main::FILE1" used only once: possible typo at E:\perl_TK\OpenFil +es1.pl line 14. Name "main::FILE2" used only once: possible typo at E:\perl_TK\OpenFil +es1.pl line 15. e:\\territory20100713.sql -- MySQL dump 10.13 Distrib 5.1.37, for Win32 (ia32) -- -- Host: localhost Database: territory -- ------------------------------------------------------ -- Server version 5.1.37-community /*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; /*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; /*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; /*!40101 SET NAMES utf8 */; /*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; /*!40103 SET TIME_ZONE='+00:00' */; /*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; /*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY +_CHECKS=0 */; /*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO +' */; /*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; -- -- Table structure for table `address` -- DROP TABLE IF EXISTS `address`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `address` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Territory` varchar(45) NOT NULL, `Colonia` varchar(45) NOT NULL, `Street` varchar(60) NOT NULL, `Number` varchar(20) NOT NULL, `Lang` varchar(10) NOT NULL, `Notes` varchar(100) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=2302 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `address` -- LOCK TABLES `address` WRITE; /*!40000 ALTER TABLE `address` DISABLE KEYS */; INSERT INTO `address` VALUES (1,'','1-¦ de Mayo','Av. 1-¦ de Mayo','23 +9','Eng',''),(2,'','1-¦ de /*!40000 ALTER TABLE `address1` ENABLE KEY +S */; UNLOCK TABLES; -- -- Table structure for table `streets` -- DROP TABLE IF EXISTS `streets`; /*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET character_set_client = utf8 */; CREATE TABLE `streets` ( `ID` int(10) unsigned NOT NULL AUTO_INCREMENT, `Territory` varchar(45) NOT NULL, `Colonia` varchar(45) NOT NULL, `Street` varchar(60) NOT NULL, PRIMARY KEY (`ID`) ) ENGINE=InnoDB AUTO_INCREMENT=850 DEFAULT CHARSET=latin1; /*!40101 SET character_set_client = @saved_cs_client */; -- -- Dumping data for table `streets` -- LOCK TABLES `streets` WRITE; /*!40000 ALTER TABLE `streets` DISABLE KEYS */; /*!40000 ALTER TABLE `streets` ENABLE KEYS */; UNLOCK TABLES; -- -- Temporary table structure for view `territoy_list` -- DROP TABLE IF EXISTS `territoy_list`; /*!50001 DROP VIEW IF EXISTS `territoy_list`*/; SET @saved_cs_client = @@character_set_client; SET character_set_client = utf8; /*!50001 CREATE TABLE `territoy_list` ( `Territory` varchar(45), `Colonia` varchar(45), `Street` varchar(60), `Number` varchar(20), `Name` varchar(100), `Notes` varchar(100), `Lang` varchar(10), `Pub` varchar(5), `S_ID` varchar(45) ) ENGINE=MyISAM */; SET character_set_client = @saved_cs_client; -- -- Dumping routines for database 'territory' -- /*!50003 CREATE*/ /*!50020 DEFINER=`gene`@`%`*/ /*!50003 FUNCTION `act +uliza`(te CHAR(64), co CHAR -- Dump completed on 2010-07-13 16:17:07 <<< Process finished.

In reply to Re: opened file being overwritten by Generoso
in thread opened file being overwritten by perishowl

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (6)
As of 2024-03-28 19:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found