472,790 Members | 1,445 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,790 software developers and data experts.

open(data,' variable problem

I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data>;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data>;
close data;
print @mailtext;
Jul 19 '05 #1
3 1593
MM
NoViagraHere wrote:
I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data>;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data>;
close data;
print @mailtext;


It works both ways on a Linux system using perl 5.8.1.

MM

Jul 19 '05 #2

"MM" <mm*********@comcast.net> wrote in message
news:65MAb.327887$9E1.1609413@attbi_s52...
NoViagraHere wrote:
I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data>;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data>;
close data;
print @mailtext;


I'd say try making it look like "open (data, '$ip');" or "open (data,
"$ip");" I doubt it'll work, but it's worth a shot
Jul 19 '05 #3
In article <3f***********************@newscene.com>, NoViagraHere
<No**********@flyingballs.com> wrote:
I am trying to open a text file in the same directory as the script is
located to retrieve stored info. The text file is simply named:
216.1.1.2
This code will NOT work:

$ip = '216.1.1.2';
open (data, $ip);
@mailtext=<data>;
close data;
print @mailtext;
however if I replace $ip as below, It DOES work. Any ideas?

open (data, '216.1.1.2');
@mailtext=<data>;
close data;
print @mailtext;


You don't say why it is not working. You should be checking if the open
succeeded:

open( data, $ip ) or die("Can't open $ip: $!");

FYI: this newsgroup is defunct. Use comp.lang.perl.misc in the future
for better response.
Jul 19 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: MostlyH2O | last post by:
Hi Folks, I've been cobbling together a rather complex web utility, and was wondering if there is a way to monitor the number of data connections and open recordsets currently being used by the...
0
by: melledge | last post by:
XTECH 2005 Program Available - Web Technologies, Browsers, Open Data, and XML Headline Event XTECH 2005 http://www.xtech.org takes place 24-27 May at the RAI Centre, Amsterdam, The Netherlands....
0
by: melledge | last post by:
Worldwide Debate on Open Data Highlighted at XTech 2005 Presentation Topics Include Web Services, RSS, FOAF, OAI, Open Access, and More;Special Focus on OpenOffice.org's Influence on Standards and...
5
by: Richard Trahan | last post by:
I have an inscrutable problem with window.open. Consider the following code: var graphwin = window.open("","graphWin","height=400,width=400,resizable=yes"); It works perfectly in one place in...
23
by: Markus | last post by:
Hi, i have this problem: Sometimes, i can't reproduce, if i click on an small image on the website, the popup _AND_ an other Tab in firefox open. Here are the linkcode: <div...
1
by: Melissa | last post by:
I have inherited an intranet ASP.NET (C#) page running on Windows 2000. The page populates a label control with some javascript to open a pop-up to a document (xls, doc, pdf, etc.). This is...
3
by: blackpuppy | last post by:
I am just beginner on PHP. I am reading "Spring Into PHP 5" but cannot make the ftp examples work. I am running PHP scripts on a Fedora Core 5 (VMWare virtual machine) on top of a Windows XP...
2
by: defabiisk | last post by:
Hello, I'm trying to open some data I've collected in my Perl DBI script - in excel. I'm using Javascript function to try and open the data in execl - without trying to do a SaveAs first. So I...
1
by: Laszlo Nagy | last post by:
Hi All, I'm using a simple program that uploads a file on a remote ftp server. This is an example (not the whole program): def store(self,hostname,username,password,destdir,srcpath):...
0
by: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
linyimin
by: linyimin | last post by:
Spring Startup Analyzer generates an interactive Spring application startup report that lets you understand what contributes to the application startup time and helps to optimize it. Support for...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
0
by: Mushico | last post by:
How to calculate date of retirement from date of birth
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.